:root {
  --bg: #0b0e13;
  --card: rgba(16, 20, 27, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e9eef6;
  --muted: #98a4b4;
  --accent: #5ad1a0;
  --accent-2: #6ab6ff;
  --warn: #ff7a6b;
  --gold: #ffd24a;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

/* Our panels are laid out with `display: flex/grid` on an ID selector, which outranks the
   user-agent rule for [hidden]. Without this, toggling `hidden` does nothing. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .14s, border-color .14s, transform .08s;
}
button:hover { background: rgba(255, 255, 255, 0.14); border-color: rgba(255,255,255,.25); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }

button.primary {
  background: linear-gradient(180deg, var(--accent), #35a87c);
  color: #04110c;
  font-weight: 700;
  border-color: transparent;
}
button.primary:hover { filter: brightness(1.08); background: linear-gradient(180deg, var(--accent), #35a87c); }

input {
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  width: 100%;
  outline: none;
}
input:focus { border-color: var(--accent-2); }

kbd {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  margin-right: 3px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  font: 600 11px/1.5 ui-monospace, monospace;
}

.muted { color: var(--muted); }

/* --------------------------------------------------------------- boot */

#boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 700px at 70% -10%, rgba(90, 209, 160, .14), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(106, 182, 255, .14), transparent 60%),
    #070a0e;
  z-index: 50;
  overflow: auto;
}

.boot-card {
  width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.boot-card h1 {
  margin: 0 0 6px;
  font-size: 40px;
  letter-spacing: -1.4px;
  font-weight: 800;
}
.boot-card h1 span { color: var(--accent); }
.tag { margin: 0 0 22px; color: var(--muted); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .3px; text-transform: uppercase; }
.search-row { display: flex; gap: 8px; }
.search-row button { white-space: nowrap; }

.results { max-height: 168px; overflow: auto; margin-bottom: 14px; }
.results:empty { display: none; }
.results div {
  padding: 9px 11px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid transparent;
}
.results div:hover { background: rgba(255,255,255,.07); border-color: var(--line); }
.results div.on { background: rgba(90,209,160,.16); border-color: var(--accent); }

.map-wrap {
  position: relative;
  height: 280px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #10141a;
}
#boot-map { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
#boot-map:active { cursor: grabbing; }

.map-zoom {
  position: absolute; top: 8px; right: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.map-zoom button {
  width: 30px; height: 30px; padding: 0;
  font-size: 17px; line-height: 1;
  background: rgba(12, 15, 20, .85);
  backdrop-filter: blur(6px);
}

.map-hint {
  position: absolute; left: 8px; top: 8px;
  background: rgba(12, 15, 20, .82);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 11px;
  color: var(--muted);
  backdrop-filter: blur(6px);
  pointer-events: none;
  max-width: calc(100% - 60px);
}
.map-hint.picked { color: var(--accent); }

.boot-note {
  font-size: 12.5px;
  color: var(--muted);
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
}

#boot-play { width: 100%; padding: 13px; font-size: 16px; }

.boot-help { margin-top: 18px; }
.boot-help summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }

.credit { margin: 16px 0 0; font-size: 11px; color: #5f6b7a; line-height: 1.6; }

/* ---------------------------------------------------------------- HUD */

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }

.pill {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 15px;
  font-weight: 700;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
.pill.subtle { font-weight: 500; color: var(--muted); }
.pill.tiny { font-size: 11px; padding: 5px 11px; }

.top-left {
  position: absolute; top: 16px; left: 16px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  max-width: 44vw;
}
#hud-money { color: var(--accent); font-variant-numeric: tabular-nums; }
#hud-place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.top-right {
  position: absolute; top: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
#minimap {
  width: 190px; height: 190px;
  border-radius: 50%;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  background: #10141a;
}

#speedo {
  position: absolute; right: 22px; bottom: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 18px;
  text-align: right;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.kph b { font-size: 34px; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.kph span { font-size: 11px; color: var(--muted); margin-left: 4px; }
.gear { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.offroad { margin-top: 4px; font-size: 10px; font-weight: 800; color: var(--warn); letter-spacing: 1px; }

#job {
  position: absolute; left: 16px; top: 96px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 290px;
  backdrop-filter: blur(10px);
}
.job-head { font-size: 11px; font-weight: 800; letter-spacing: .8px; color: var(--gold); text-transform: uppercase; }
.job-body { margin-top: 3px; }
.job-dist { margin-top: 3px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

#prompt {
  position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 20px;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
#prompt kbd { background: var(--accent); color: #04110c; border-color: transparent; }

#emotes {
  position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%);
  display: flex; gap: 8px;
}
#emotes button { background: var(--card); backdrop-filter: blur(10px); }

#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: rgba(255,255,255,.75);
  box-shadow: 0 0 0 1.5px rgba(0,0,0,.5);
}

/* --------------------------------------------------------------- chat */

#chat { position: absolute; left: 16px; bottom: 16px; width: min(380px, 42vw); }
#chat-log {
  max-height: 190px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  margin-bottom: 8px;
  mask-image: linear-gradient(to bottom, transparent, #000 22%);
}
#chat-log div {
  background: rgba(10, 13, 18, .72);
  border-radius: 8px;
  padding: 4px 10px;
  width: fit-content;
  max-width: 100%;
  font-size: 13px;
  animation: fadein .18s ease-out;
  word-break: break-word;
}
#chat-log b { color: var(--accent-2); }
#chat-log .me b { color: var(--accent); }
#chat-log .sys { color: var(--muted); font-style: italic; font-size: 12px; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } }

/* ------------------------------------------------------------- toasts */

#toasts {
  position: absolute; left: 50%; top: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 9px 16px;
  box-shadow: var(--shadow);
  animation: pop .22s cubic-bezier(.2,1.4,.5,1);
  backdrop-filter: blur(10px);
}
.toast.bad { border-left-color: var(--warn); }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.96); } }

/* --------------------------------------------------------- scoreboard */

#scoreboard {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 24px;
  min-width: 280px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
#scoreboard h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
#scoreboard ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
#scoreboard li { display: flex; justify-content: space-between; gap: 18px; }
#scoreboard li span { color: var(--muted); font-size: 12px; }

/* -------------------------------------------------------------- panel */

#panel {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgba(4, 6, 10, .62);
  backdrop-filter: blur(5px);
  padding: 20px;
}
.panel-card {
  width: min(720px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-card header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 10px;
}
.panel-card h2 { margin: 0; font-size: 21px; letter-spacing: -.4px; }
#panel-close { padding: 4px 10px; border-radius: 8px; }
#panel-sub { padding: 0 22px 12px; color: var(--muted); font-size: 13px; }
#panel-sub:empty { display: none; }
#panel-body { padding: 0 22px 22px; overflow: auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 11px;
}
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  background: rgba(255,255,255,.03);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.card.owned { border-color: rgba(90,209,160,.45); }
.swatch { height: 42px; border-radius: 8px; border: 1px solid rgba(255,255,255,.14); }
.card .name { font-weight: 650; }
.card .meta { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.card .row { display: flex; gap: 7px; }
.card .row button { flex: 1; padding: 6px 8px; font-size: 13px; }
.price { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.price.free { color: var(--accent); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat { border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.section-title {
  margin: 20px 0 10px;
  font-size: 11px; font-weight: 800; letter-spacing: 1px;
  color: var(--muted); text-transform: uppercase;
}
.section-title:first-child { margin-top: 0; }

.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-row button { width: 34px; height: 34px; padding: 0; border-radius: 9px; }

.list { display: flex; flex-direction: column; gap: 7px; }
.list button { text-align: left; display: flex; justify-content: space-between; gap: 12px; }
.list button small { color: var(--muted); }

/* ------------------------------------------------------------- cinema */

#cinema {
  position: fixed; inset: 0; z-index: 40;
  background: #000;
  display: flex; flex-direction: column;
}
.cinema-stage { flex: 1; display: grid; place-items: center; min-height: 0; background: #000; }
.cinema-stage video { width: 100%; height: 100%; object-fit: contain; }
.cinema-bar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px;
  background: #0b0e13;
  border-top: 1px solid var(--line);
}
.cinema-bar > div:first-child { flex: 1; min-width: 0; }
.cinema-bar .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The <video> must stay in the DOM and keep playing to feed the in-world screen texture,
   so this is parked off-screen rather than hidden. */
#video-parking {
  position: fixed; left: -4px; top: -4px;
  width: 2px; height: 2px;
  overflow: hidden; opacity: 0.01; pointer-events: none;
}

/* ------------------------------------------------------------ loading */

#loading {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 16px 7px 10px;
  font-size: 12.5px;
  color: var(--muted);
  backdrop-filter: blur(10px);
}
.spin {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  #minimap { width: 128px; height: 128px; }
  #chat { width: 58vw; }
  .keys { grid-template-columns: 1fr; }
  #speedo { padding: 9px 13px; }
  .kph b { font-size: 26px; }
}

/* ------------------------------------------------------- touch controls -- */

#touch { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#touch > * { pointer-events: auto; }

#touch .stick {
  position: absolute; left: 18px; bottom: 18px;
  width: 132px; height: 132px;
  border-radius: 50%;
  background: rgba(12, 15, 20, .45);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  touch-action: none;
}
#touch .knob {
  width: 54px; height: 54px; border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  border: 1px solid rgba(255, 255, 255, .35);
  transition: transform .04s linear;
}

#touch .pedals {
  position: absolute; right: 18px; bottom: 18px;
  display: flex; gap: 12px;
}
#touch .pedal {
  width: 74px; height: 74px; border-radius: 50%;
  font-size: 22px; padding: 0;
  background: rgba(12, 15, 20, .55);
  backdrop-filter: blur(6px);
  touch-action: none;
}
#touch .pedal.down, #touch .switches button.down {
  background: var(--accent); color: #04110c; border-color: transparent;
}

#touch .switches {
  position: absolute; right: 18px; bottom: 108px;
  display: flex; flex-direction: column-reverse; gap: 8px;
}
#touch .switches button {
  width: 48px; height: 48px; border-radius: 50%;
  font-size: 15px; padding: 0;
  background: rgba(12, 15, 20, .55);
  backdrop-filter: blur(6px);
  touch-action: none;
}

@media (max-width: 720px) {
  #touch .stick { width: 112px; height: 112px; }
  #touch .pedal { width: 64px; height: 64px; }
}

/* ------------------------------------------------- chat channels + voice -- */

#chat-compose {
  background: rgba(10, 13, 18, .82);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px;
  backdrop-filter: blur(10px);
}
#chat-channels { display: flex; gap: 5px; margin-bottom: 6px; align-items: center; }
#chat-channels button {
  padding: 3px 10px; font-size: 11.5px; border-radius: 999px;
  background: rgba(255, 255, 255, .05);
}
#chat-channels button.on { background: var(--accent); color: #04110c; border-color: transparent; }
#chat-target {
  font: inherit; font-size: 11.5px; color: var(--text);
  background: rgba(0, 0, 0, .4); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 8px; max-width: 120px;
}
#chat-log .ch {
  font-size: 10px; font-weight: 800; letter-spacing: .5px;
  text-transform: uppercase; opacity: .75; margin-right: 5px;
}
#chat-log .nearby { border-left: 2px solid var(--accent); }
#chat-log .nearby .ch { color: var(--accent); }
#chat-log .private { border-left: 2px solid #d98ae0; }
#chat-log .private .ch { color: #d98ae0; }

#voice {
  position: absolute; left: 16px; bottom: 232px;
  display: flex; align-items: center; gap: 8px;
}
#voice-mic {
  width: 42px; height: 42px; border-radius: 50%; padding: 0; font-size: 17px;
  background: var(--card); backdrop-filter: blur(10px);
  filter: grayscale(1) opacity(.65);
}
#voice-mic.live { filter: none; background: var(--accent); border-color: transparent; }
#voice-mic.talking { box-shadow: 0 0 0 4px rgba(90, 209, 160, .35); }
#voice-meter {
  width: 54px; height: 5px; border-radius: 3px;
  background: rgba(255, 255, 255, .12); overflow: hidden;
}
#voice-meter span {
  display: block; height: 100%; width: 0%;
  background: var(--accent); transition: width .06s linear;
}
#voice-note { max-width: 230px; line-height: 1.35; }

/* ------------------------------------------------------------- shops ----- */

.product-art { display: grid; place-items: center; font-size: 26px; }
.card .blurb { font-size: 12px; color: var(--muted); line-height: 1.35; }

.cart { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.cart-line {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.06);
}
.cart-line > span:first-child { flex: 1; }
.tiny-btn { padding: 2px 9px; font-size: 13px; line-height: 1; }
.cart-total {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 0; font-weight: 700;
}

.shop-chat { display: flex; flex-direction: column; gap: 8px; }
.shop-log {
  max-height: 150px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 5px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  font-size: 13px; line-height: 1.4;
}
.shop-log .you { color: var(--accent); }
.shop-log .them { color: var(--text); }

/* ----------------------------------------------------------- theatre ----- */

.screen-bar {
  margin: 0 auto 16px;
  width: 78%;
  text-align: center;
  font: 800 10px/1 system-ui, sans-serif;
  letter-spacing: 4px;
  color: #0a0d12;
  background: linear-gradient(180deg, #e8eef6, #8e9bab);
  border-radius: 3px 3px 40px 40px / 3px 3px 14px 14px;
  padding: 7px 0 11px;
}
.seat-row { display: flex; gap: 5px; align-items: center; justify-content: center; margin-bottom: 5px; }
.seat-label { width: 16px; font: 700 11px system-ui, sans-serif; color: var(--muted); }
.seat {
  width: 26px; height: 24px; padding: 0;
  font: 600 10px system-ui, sans-serif;
  border-radius: 5px 5px 3px 3px;
}
.seat.free { background: rgba(200, 80, 80, .35); border-color: rgba(200, 80, 80, .5); }
.seat.free:hover { background: rgba(200, 80, 80, .6); }
.seat.taken { background: rgba(255, 255, 255, .07); color: var(--muted); cursor: not-allowed; }
.seat.mine { background: var(--accent); color: #04110c; border-color: transparent; }

.seat-legend { display: flex; gap: 14px; align-items: center; margin: 14px 0; font-size: 12px; }
.seat-tag::before {
  content: ''; display: inline-block; width: 10px; height: 10px;
  border-radius: 3px; margin-right: 6px; vertical-align: -1px;
}
.seat-tag.free::before { background: rgba(200, 80, 80, .55); }
.seat-tag.taken::before { background: rgba(255, 255, 255, .18); }
.seat-tag.mine::before { background: var(--accent); }
