:root {
  --bg: #070b12;
  --bg2: #0c121c;
  --panel: #0e1622ee;
  --line: #1e3a4a;
  --cyan: #5eead4;
  --gold: #fbbf24;
  --mute: #94a3b8;
  --text: #e8eef5;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Source Sans 3", system-ui, sans-serif; overflow: hidden; }
.hidden { display: none !important; }
.boot {
  height: 100%; display: grid; place-content: center; text-align: center; gap: .45rem;
  background: radial-gradient(ellipse at 50% 18%, #ff6b4a 0%, #3a2060 42%, #070b12 78%);
}
.boot h1, .brand { font-family: Syne, sans-serif; }
.boot h1 { font-size: clamp(2rem, 6vw, 3.2rem); margin: 0; letter-spacing: .04em; }
.kicker { letter-spacing: .22em; text-transform: uppercase; color: var(--cyan); font-size: .72rem; }
.boot-msg { color: var(--mute); }

.app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.top {
  display: flex; align-items: center; gap: .7rem; padding: .45rem .8rem;
  border-bottom: 1px solid var(--line); background: #080e16; flex-wrap: wrap;
}
.brand { color: var(--text); text-decoration: none; font-weight: 800; font-size: .95rem; }
.games-mini {
  color: var(--gold); text-decoration: none; font-size: .72rem; letter-spacing: .12em;
  text-transform: uppercase; font-weight: 700;
}
.phase-pill {
  font-family: "IBM Plex Mono", monospace; font-size: .72rem; letter-spacing: .14em;
  padding: .28rem .7rem; border: 1px solid var(--cyan); color: var(--cyan); border-radius: 999px;
}
.hud-meta { display: flex; flex-wrap: wrap; gap: .65rem; font-size: .82rem; color: var(--mute); }
.hud-meta b { color: var(--gold); }
.grow { flex: 1; }
.paypal-mini {
  color: #fff; background: #0070ba; text-decoration: none; font-size: .72rem;
  padding: .28rem .55rem; border-radius: 7px; font-weight: 700;
}

.stage { display: grid; grid-template-columns: 1fr 300px; min-height: 0; }
.viewport { position: relative; min-width: 0; min-height: 0; background: #05080e; }
#circuit { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; background: #05080e; }
.hint {
  position: absolute; left: 12px; bottom: 72px; max-width: 72%;
  font-size: .82rem; color: #d8f3e0; text-shadow: 0 1px 4px #000; pointer-events: none;
}
.pilot-plate {
  position: absolute; left: 10px; bottom: 10px; z-index: 6;
  display: flex; align-items: flex-end; gap: .55rem;
  pointer-events: none;
  filter: drop-shadow(0 6px 14px #000a);
}
.pilot-plate img {
  width: 108px; height: 148px; object-fit: cover; object-position: 50% 18%;
  border: 1px solid var(--gold); border-radius: 8px; display: block; background: #0b121c;
}
.pilot-meta {
  background: #070b12e8; border: 1px solid var(--line); border-radius: 8px;
  padding: .35rem .55rem .4rem; min-width: 7.5rem;
}
.pilot-meta b { display: block; font-family: Syne, sans-serif; font-size: .88rem; color: var(--gold); }
.pilot-meta span { display: block; font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); }
.speedo {
  position: absolute; right: 14px; bottom: 54px; z-index: 6;
  font-family: Syne, sans-serif; font-size: 2.4rem; color: var(--gold);
  text-shadow: 0 2px 12px #000; pointer-events: none; letter-spacing: .04em;
}
.speedo small { display: block; font-size: .72rem; color: var(--cyan); letter-spacing: .16em; }
.boost-hud {
  position: absolute; right: 14px; bottom: 18px; width: 160px; height: 8px;
  background: #122; border: 1px solid var(--line); border-radius: 99px; overflow: hidden;
  pointer-events: none;
}
.boost-fill { height: 100%; width: 40%; background: linear-gradient(90deg, #5eead4, #fbbf24); }
.count-flash {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 800 5rem Syne, sans-serif; color: #fff4e6; pointer-events: none;
  text-shadow: 0 0 28px #ff4d6d, 0 0 60px #fbbf24aa; letter-spacing: .12em;
}
.keys {
  position: absolute; right: 10px; top: 10px; font-size: .68rem; color: #64748b;
  font-family: "IBM Plex Mono", monospace; pointer-events: none; text-align: right;
}
.race-hud {
  position: absolute; inset: 0; z-index: 7; pointer-events: none;
  display: flex; flex-direction: column; justify-content: flex-start;
  padding: 10px 12px 8px;
}
.rh-top {
  display: grid; grid-template-columns: auto 1fr auto; gap: .55rem; align-items: stretch;
}
.rh-block {
  background: #070b12d8; border: 1px solid var(--line); border-radius: 12px;
  padding: .4rem .65rem .45rem; backdrop-filter: blur(8px);
}
.rh-block span, .rh-row span {
  display: block; font: 700 .62rem "IBM Plex Mono", monospace;
  letter-spacing: .14em; text-transform: uppercase; color: var(--mute);
}
.rh-lapbox b {
  display: block; font: 800 1.7rem Syne, sans-serif; color: var(--gold); line-height: 1.05;
}
.rh-lapbox em {
  font: 700 .78rem "IBM Plex Mono", monospace; color: var(--cyan); letter-spacing: .08em;
}
.rh-live { text-align: center; }
.rh-live b {
  display: block; font: 800 clamp(1.6rem, 4vw, 2.35rem) "IBM Plex Mono", monospace;
  color: #e8eef5; letter-spacing: .04em; line-height: 1.05;
}
.rh-live span i { color: var(--gold); font-style: normal; }
.rh-board { min-width: 9.5rem; }
.rh-row { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.rh-row b { font: 650 .86rem "IBM Plex Mono", monospace; color: var(--text); }
.rh-delta {
  margin-top: .28rem; font: 800 .95rem "IBM Plex Mono", monospace; letter-spacing: .04em;
  color: var(--mute);
}
.rh-delta.up { color: #4ade80; }
.rh-delta.down { color: #f87171; }
.rh-sectors {
  align-self: center; margin-top: .35rem;
  font: 650 .72rem "IBM Plex Mono", monospace; color: var(--mute);
  background: #070b12cc; border: 1px solid var(--line); border-radius: 8px;
  padding: .2rem .55rem;
}
.rh-dash {
  position: absolute; right: 14px; bottom: 20px;
  display: flex; gap: 1rem; align-items: flex-end;
  background: linear-gradient(180deg, #0c1622ee, #070b12f5);
  border: 1px solid var(--line); border-radius: 16px;
  padding: .55rem 1.05rem .6rem;
  box-shadow: 0 12px 32px #000a;
}
.rh-tacho-wrap { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.rh-tacho { width: 200px; height: 124px; display: block; }
.rh-needle { transform-origin: 120px 128px; transition: transform 50ms linear; }
.rh-shift { display: flex; gap: 4px; justify-content: center; }
.rh-shift i {
  width: 10px; height: 8px; border-radius: 2px; background: #1a2830; display: block;
}
.rh-shift i.on:nth-child(-n+3) { background: #5eead4; box-shadow: 0 0 8px #5eead4; }
.rh-shift i.on:nth-child(n+4):nth-child(-n+5) { background: #fbbf24; box-shadow: 0 0 8px #fbbf24; }
.rh-shift i.on:nth-child(n+6) { background: #ef4444; box-shadow: 0 0 10px #ef4444; }
.rh-shift.flash i.on { opacity: .35; }
.rh-core { text-align: center; min-width: 8.2rem; }
.rh-gear {
  font: 800 2.55rem Syne, sans-serif; color: var(--gold); line-height: 1;
  text-shadow: 0 0 18px #fbbf2466;
}
.rh-gear.shift { color: #5eead4; }
.rh-spd b {
  font: 800 2.55rem "IBM Plex Mono", monospace; color: #e8eef5; letter-spacing: .04em;
}
.rh-spd small { display: block; font: 700 .62rem "IBM Plex Mono", monospace; color: var(--cyan); letter-spacing: .16em; }
.rh-rpm { font: 500 .68rem "IBM Plex Mono", monospace; color: var(--mute); margin-top: .1rem; }
.rh-side { display: grid; gap: .22rem; min-width: 5.2rem; }
.rh-pedal { display: grid; grid-template-columns: 2rem 1fr; gap: .28rem; align-items: center; }
.rh-pedal span { font: 700 .58rem "IBM Plex Mono", monospace; color: var(--mute); letter-spacing: .08em; }
.rh-pedal div { height: 7px; background: #122; border-radius: 99px; overflow: hidden; }
.rh-pedal i { display: block; height: 100%; width: 0; background: #5eead4; }
.rh-pedal.brk i { background: #f87171; }
.rh-pedal.bst i { background: linear-gradient(90deg, #5eead4, #fbbf24); }
.rh-prog {
  position: absolute; left: 12px; right: 12px; bottom: 6px;
  height: 4px; background: #122; border-radius: 99px; overflow: hidden; margin-top: 0;
}
.rh-prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #5eead4, #fbbf24); }
@media (max-width: 900px) {
  .rh-top { grid-template-columns: 1fr 1fr; }
  .rh-live { grid-column: 1 / -1; order: -1; }
  .rh-tacho { width: 156px; height: 96px; }
  .rh-dash { right: 8px; bottom: 16px; gap: .7rem; padding: .4rem .7rem .45rem; }
  .rh-gear { font-size: 2.1rem; }
  .rh-spd b { font-size: 2.1rem; }
  .rh-side { width: 100%; grid-template-columns: 1fr 1fr 1fr; display: grid; }
}
.rail {
  background: var(--bg2); border-left: 1px solid var(--line); overflow: auto;
  padding: .6rem; display: flex; flex-direction: column; gap: .5rem;
}
.panel { background: #0b121c; border: 1px solid var(--line); border-radius: 10px; padding: .65rem; }
.panel h3 {
  margin: 0 0 .4rem; font-family: Syne, sans-serif; font-size: .78rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--cyan);
}
.card { font-size: .84rem; color: var(--mute); }
.card b { color: var(--gold); }
.log { font: 400 .72rem "IBM Plex Mono", monospace; color: var(--mute); max-height: 8rem; overflow: auto; }
.dock {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  padding: .4rem .7rem; border-top: 1px solid var(--line); background: #080e16;
}
.btn {
  font: 650 .78rem "IBM Plex Mono", monospace; background: #102018; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: .4rem .65rem; cursor: pointer;
}
.btn:hover { border-color: var(--cyan); }
.btn.gold { background: #3a2a08; border-color: var(--gold); color: var(--gold); }
.btn.ghost { background: transparent; }
.radio-inline { display: flex; align-items: center; gap: .35rem; }
.radio-inline button {
  font: 650 .68rem "IBM Plex Mono", monospace; background: #102018; color: var(--cyan);
  border: 1px solid var(--line); border-radius: 7px; padding: .28rem .45rem; cursor: pointer;
}
.radio-title-inline {
  font-family: "IBM Plex Mono", monospace; font-size: .68rem; color: var(--mute);
  max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.overlay {
  position: fixed; inset: 0; background: #070b12e8; display: grid; place-items: center;
  padding: 1rem; z-index: 20; overflow: auto;
}
.overlay.studio { padding: 0; display: block; background: #05080e; overflow: auto; }
.title-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.2fr minmax(320px, 480px);
}
.title-art { position: relative; min-height: 100vh; background: #05080e; }
.title-art img { width: 100%; height: 100%; object-fit: cover; object-position: 42% center; display: block; }
.title-art-fade {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 70%, #070b12 100%);
  pointer-events: none;
}
.title-panel {
  background: linear-gradient(180deg, #2a1830, #070b12);
  border-left: 1px solid var(--line);
  padding: clamp(1.1rem, 3vw, 2rem);
  overflow: auto;
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
}
.title-panel h1 {
  font-family: Syne, sans-serif; font-size: clamp(1.7rem, 3.4vw, 2.6rem);
  letter-spacing: .06em; margin: .15rem 0 .35rem; line-height: .98;
}
.title-tag { color: var(--text); font-size: 1.02rem; margin: 0 0 .7rem; }
.lore { color: var(--mute); font-size: .88rem; }
.name {
  width: 100%; background: #0b121c; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .5rem .6rem; font: inherit; margin-top: .25rem;
}
.donate-row { display: flex; flex-wrap: wrap; gap: .45rem; margin: .85rem 0 0; }
.donate-row a {
  display: inline-flex; align-items: center;
  text-decoration: none; font: 700 .78rem Syne, sans-serif;
  padding: .5rem .75rem; border-radius: 8px;
}
.donate-paypal { background: #0070ba; color: #fff !important; }
.donate-patreon { background: #f96854; color: #111 !important; }
.mode-grid { display: grid; gap: .45rem; margin-top: .7rem; }
.mode-card {
  text-align: left; width: 100%;
  background: #102028cc; border: 1px solid var(--line); border-radius: 12px;
  padding: .7rem .8rem; cursor: pointer; color: var(--text); font-family: inherit;
}
.mode-card:hover { border-color: var(--gold); }
.mode-card b { display: block; font-family: Syne, sans-serif; font-size: 1rem; }
.mode-card span { display: block; color: var(--mute); font-size: .78rem; margin-top: .15rem; }
.cast-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: .45rem 0 .75rem; }
.cast {
  background: #102028; border: 1px solid var(--line); border-radius: 10px;
  padding: .3rem; cursor: pointer; color: var(--text); text-align: center; font-family: inherit;
}
.cast img { width: 100%; height: 128px; object-fit: cover; object-position: 50% 16%; border-radius: 7px; display: block; }
.cast b { display: block; font-size: .72rem; margin-top: .28rem; font-family: Syne, sans-serif; }
.cast span { display: block; font-size: .62rem; color: var(--mute); }
.cast.on { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.cast.locked { opacity: .45; cursor: not-allowed; min-height: 10rem; display: flex; flex-direction: column; justify-content: flex-end; }
.cast-soon { display: block; font: 700 .68rem "IBM Plex Mono", monospace; letter-spacing: .16em; text-transform: uppercase; color: var(--mute); margin: auto 0 .4rem; }
.garage-chip {
  display: grid; grid-template-columns: 72px 1fr auto; gap: .65rem; align-items: center;
  margin: .45rem 0 .75rem; padding: .45rem; border: 1px solid var(--line); border-radius: 12px; background: #102028cc;
}
.garage-chip img { width: 72px; height: 96px; object-fit: cover; object-position: 50% 40%; border-radius: 8px; display: block; }
.garage-chip b { display: block; font-family: Syne, sans-serif; }
.garage-chip span { display: block; font-size: .72rem; color: var(--mute); }
.garage-screen { min-height: 100vh; }
.garage-stage { position: relative; height: 100vh; min-height: 100vh; background: #05070c; overflow: hidden; }
#garageCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; cursor: grab; touch-action: none; z-index: 1;
}
.garage-fallback {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: 40% center; z-index: 0;
}
.garage-stage-fade {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: linear-gradient(90deg, transparent 62%, #070b12 100%);
}
.garage-hint {
  position: absolute; left: 1rem; bottom: 1rem; z-index: 3; margin: 0;
  font: 500 .72rem "IBM Plex Mono", monospace; color: #94a3b8; text-shadow: 0 1px 8px #000;
}
.stat-block { margin-top: .7rem; display: grid; gap: .35rem; }
.stat-row { display: grid; grid-template-columns: 4.4rem 1fr 2.4rem; gap: .4rem; align-items: center; font-size: .78rem; color: var(--mute); }
.stat-row b { color: var(--gold); font: 600 .72rem "IBM Plex Mono", monospace; text-align: right; }
.stat-bar { height: 6px; background: #122; border-radius: 99px; overflow: hidden; }
.stat-bar i { display: block; height: 100%; background: linear-gradient(90deg, #5eead4, #fbbf24); }
.sheet {
  width: min(720px, 100%); background: #0c1622; border: 1px solid var(--line);
  border-radius: 16px; padding: 1.2rem 1.25rem;
}
.sheet h2 { font-family: Syne, sans-serif; margin: 0 0 .4rem; }
.opt-group { margin: .85rem 0 .35rem; font: 700 .72rem Syne, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); }
.opt-row {
  display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; align-items: center;
  padding: .5rem 0; border-bottom: 1px solid var(--line);
}
.opt-row .lore { margin: .15rem 0 0; font-size: .75rem; }
.opt-row input[type="range"] { width: 9rem; accent-color: var(--gold); }
.opt-toggle {
  font: 650 .72rem "IBM Plex Mono", monospace; min-width: 3.6rem;
  background: #102028; color: var(--mute); border: 1px solid var(--line);
  border-radius: 8px; padding: .32rem .5rem; cursor: pointer;
}
.opt-toggle.on { color: var(--gold); border-color: var(--gold); }
.opt-soon { color: var(--mute); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.opt-range { display: flex; flex-direction: column; align-items: flex-end; gap: .12rem; }
.opt-range span { font: 500 .68rem "IBM Plex Mono", monospace; color: var(--gold); }
.sheet.sheet-opts { width: min(640px, 100%); max-height: min(88vh, 760px); overflow: auto; }
.drag-tree {
  position: absolute; left: 50%; top: 8.6rem; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 8; pointer-events: none;
  background: #0b1220f0; border: 1px solid var(--line); border-radius: 14px;
  padding: .4rem .6rem .5rem;
}
.tree-banner {
  display: none; margin: 0;
  font: 800 .68rem "IBM Plex Mono", monospace;
  letter-spacing: .22em; text-transform: uppercase; color: var(--gold);
}
.drag-tree.is-ready .tree-banner { display: block; }
.tree-cols { display: flex; gap: 12px; }
.tree-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tree-bulb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #151b24; border: 1px solid #2a3544;
  box-shadow: inset 0 0 6px #000;
}
.tree-bulb.sm { width: 11px; height: 11px; }
.tree-bulb.yellow.on { background: #fde68a; box-shadow: 0 0 12px #fbbf24; }
.tree-bulb.amber.on { background: #f59e0b; box-shadow: 0 0 14px #f59e0b; }
.tree-bulb.green.on { background: #22c55e; box-shadow: 0 0 16px #4ade80; }
.tree-bulb.red.on { background: #ef4444; box-shadow: 0 0 16px #f87171; }
.drag-hud {
  position: absolute; left: 50%; bottom: 64px; transform: translateX(-50%);
  z-index: 8; pointer-events: none;
  font: 600 .8rem "IBM Plex Mono", monospace; color: var(--gold);
  text-shadow: 0 1px 8px #000; letter-spacing: .04em;
  background: #070b12cc; border: 1px solid var(--line); border-radius: 8px;
  padding: .28rem .65rem;
}
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .8rem 0; }
@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { border-left: 0; border-top: 1px solid var(--line); max-height: 38vh; }
  .modes { grid-template-columns: 1fr; }
  .title-screen { grid-template-columns: 1fr; }
  .title-art { min-height: 34vh; }
  .title-art-fade { background: linear-gradient(180deg, transparent 35%, #070b12 100%); }
  .title-panel { border-left: 0; border-top: 1px solid var(--line); min-height: auto; }
  .drag-tree { top: 11.2rem; }
  .garage-stage { height: 42vh; min-height: 42vh; }
  .garage-stage-fade { background: linear-gradient(180deg, transparent 40%, #070b12 100%); }
  .garage-chip { grid-template-columns: 64px 1fr; }
  .garage-chip .btn { grid-column: 1 / -1; }
  .pilot-plate img { width: 80px; height: 110px; }
  .speedo { font-size: 1.7rem; }
}
