:root {
  --night: #05070f;
  --navy: #0c1226;
  --gold: #e8b84a;
  --gold2: #ffe39a;
  --bolt: #a8ecff;
  --warn: #ffd23f;
  --danger: #ff4733;
  --ink: #eef2ff;
  --muted: #93a0c4;
  --f-display: 'Cinzel', 'Times New Roman', serif;
  --f-ui: 'Chakra Petch', system-ui, sans-serif;
  --dash-h: 92px;
}

* { box-sizing: border-box; margin: 0; }
html, body {
  height: 100%;
  background: #020308;
  color: var(--ink);
  font-family: var(--f-ui);
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 80% at 50% 0%, #131a36 0%, #020308 70%);
}

.stage {
  --sky1: #1a1440;
  --sky2: #3b2a63;
  --glow: #f0b45a;
  --ground: #0a0f20;
  --sp: 0;
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: min(100vw, 60vh);
  width: min(100vw, 60dvh);
  overflow: hidden;
  background: var(--night);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.stage[data-theme="temple"] { --sky1: #101a3c; --sky2: #2c4a78; --glow: #ffd98a; --ground: #0b1322; }
.stage[data-theme="valley"] { --sky1: #0b1030; --sky2: #26306e; --glow: #8fd8ff; --ground: #080d1c; }
.stage[data-theme="storm"]  { --sky1: #070a18; --sky2: #1c2440; --glow: #a8ecff; --ground: #070a14; }
.stage[data-theme="wrath"]  { --sky1: #14060c; --sky2: #4a1420; --glow: #ff7a4a; --ground: #0e070b; }

/* ---------- sky ---------- */
.sky {
  position: absolute; inset: 0 0 auto 0; height: 34%;
  background:
    radial-gradient(60% 70% at 50% 100%, color-mix(in srgb, var(--glow) 55%, transparent) 0%, transparent 70%),
    linear-gradient(var(--sky1), var(--sky2));
  transition: background .6s;
}
.stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 31% 9%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 68% 14%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 84% 26%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 6%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 38%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 8%, #fff 50%, transparent 51%);
  opacity: .6;
}
.cloud {
  position: absolute; height: 26%; border-radius: 999px;
  background: radial-gradient(closest-side, rgba(255,255,255,.22), transparent);
  filter: blur(6px);
}
.c1 { width: 70%; top: 12%; left: -20%; }
.c2 { width: 60%; top: 34%; left: 55%; }
.c3 { width: 80%; top: 58%; left: 10%; opacity: .7; }

.cloudbank {
  position: absolute; left: -10%; right: -10%; top: 20.5%; height: 9%;
  z-index: 4; pointer-events: none;
  background:
    radial-gradient(22% 80% at 12% 60%, rgba(214,222,255,.9), transparent 70%),
    radial-gradient(26% 90% at 34% 50%, rgba(235,238,255,.95), transparent 70%),
    radial-gradient(24% 85% at 58% 55%, rgba(220,226,255,.92), transparent 70%),
    radial-gradient(26% 95% at 82% 50%, rgba(235,238,255,.9), transparent 70%),
    radial-gradient(60% 60% at 50% 100%, rgba(160,170,220,.55), transparent 75%);
  filter: blur(5px);
  opacity: .82;
}

/* ---------- Zeus ---------- */
.zeus {
  position: absolute; z-index: 2; top: .5%; left: 50%; width: 50%;
  transform: translate(-50%, 14%) scale(.9);
  opacity: .78;
  transition: transform .35s cubic-bezier(.2,.9,.3,1.2), opacity .3s, filter .2s;
  pointer-events: none;
}
.zeus-svg { display: block; width: 100%; height: auto; overflow: visible; }
.zeus-aura {
  position: absolute; inset: -20% -25%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--bolt) 70%, transparent), transparent 70%);
  opacity: .12; transition: opacity .3s, transform .3s;
}
.zeus-hand { position: absolute; left: 86%; top: 12%; width: 1px; height: 1px; }
.z-arm { transform-origin: 146px 124px; transform: rotate(62deg); transition: transform .32s cubic-bezier(.3,.8,.3,1.3); }
.z-bolt { opacity: .25; transition: opacity .2s; }
.z-eyes { transition: fill .2s; }

/* ---------- world / road ---------- */
.world {
  position: absolute; z-index: 3; left: 0; right: 0; top: 24%; bottom: var(--dash-h);
  perspective: 620px; perspective-origin: 50% 0%;
  overflow: hidden;
  background: linear-gradient(color-mix(in srgb, var(--sky2) 60%, #000), var(--ground) 30%);
}
.road {
  position: absolute; left: -12%; right: -12%; bottom: 0; height: 170%;
  transform-origin: 50% 100%;
  transform: rotateX(48deg);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 2px, transparent 2px 26px),
    var(--ground);
}
.asphalt {
  --W: 300px;
  position: absolute; top: 0; bottom: 0; left: 21%; width: 58%;
  background:
    linear-gradient(90deg, rgba(0,0,0,.45), transparent 12%, transparent 88%, rgba(0,0,0,.45)),
    #171b29;
  box-shadow: 0 0 0 3px #d9dfef inset, 0 0 60px rgba(0,0,0,.8);
  overflow: hidden;
}
.lines {
  position: absolute; left: 0; right: 0; top: -180px; bottom: 0;
  transform-origin: 50% 100%;
  will-change: transform;
  background-image:
    linear-gradient(#e9edf7 0 55%, transparent 55%),
    linear-gradient(var(--gold) 0 55%, transparent 55%),
    linear-gradient(#e9edf7 0 55%, transparent 55%);
  background-size: 5px 180px;
  background-position: 25% 0, 50% 0, 75% 0;
  background-repeat: repeat-y;
}
.lines::before, .lines::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 3.2%;
  background: repeating-linear-gradient(var(--gold) 0 30px, #1b1408 30px 60px);
}
.lines::before { left: 0; }
.lines::after { right: 0; }

.props { position: absolute; inset: 0; }
.prop {
  position: absolute; top: 0; width: 7%; aspect-ratio: 1; will-change: transform;
  border-radius: 12%;
  background:
    radial-gradient(closest-side, #f4efe2 0 52%, #b9b3a3 53% 62%, transparent 63%),
    #8d8878;
  box-shadow: 0 18px 22px rgba(0,0,0,.6);
}
.prop.l { left: 9%; }
.prop.r { right: 9%; }
.prop.fire {
  border-radius: 50%;
  background: radial-gradient(closest-side, #fff6c8 0 22%, #ffb347 38%, #7a2a08 62%, #2a1a12 64%);
  box-shadow: 0 0 34px 12px rgba(255,150,50,.45);
}

.zones, .obstacles { position: absolute; inset: 0; }

.obstacle {
  position: absolute; top: 0; left: 50%;
  width: calc(var(--W) * .2); height: calc(var(--W) * .13);
  margin-left: calc(var(--W) * -.1);
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.18) 0 4px, transparent 4px 14px),
    linear-gradient(#f4efe2, #a39c8a);
  box-shadow: 0 10px 0 #5d5848, 0 22px 18px rgba(0,0,0,.6);
  will-change: transform;
}
.obstacle.hit { opacity: .35; filter: brightness(2); }

.car {
  position: absolute; left: 50%; bottom: 10%;
  width: calc(var(--W) * .15);
  margin-left: calc(var(--W) * -.075);
  will-change: transform;
  filter: drop-shadow(0 14px 10px rgba(0,0,0,.65));
}
.car img { display: block; width: 100%; height: auto; pointer-events: none; }
.car-trail {
  position: absolute; left: 12%; right: 12%; top: 92%; height: 160%;
  background: linear-gradient(rgba(168,236,255,.95), rgba(120,160,255,.35) 40%, transparent);
  filter: blur(5px); opacity: 0; transition: opacity .3s;
  clip-path: polygon(0 0, 100% 0, 78% 100%, 22% 100%);
}
.car-shock {
  position: absolute; inset: -18%; border-radius: 30%;
  border: 2px solid var(--bolt); opacity: 0;
  box-shadow: 0 0 18px var(--bolt), inset 0 0 18px var(--bolt);
}

.haze {
  position: absolute; inset: 0 0 auto 0; height: 26%; pointer-events: none;
  background: linear-gradient(color-mix(in srgb, var(--sky2) 80%, #000), transparent);
}

/* ---------- overlays ---------- */
.rain, .speedfx, .flash, .bolts { position: absolute; inset: 0; pointer-events: none; }
.rain { z-index: 5; display: none; }
.speedfx {
  z-index: 5;
  opacity: calc((var(--sp) - .7) * 3);
  background:
    linear-gradient(90deg, rgba(168,236,255,.16), transparent 16%, transparent 84%, rgba(168,236,255,.16)),
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(255,255,255,.05) 18px 19px);
  -webkit-mask-image: linear-gradient(90deg, #000, transparent 22%, transparent 78%, #000);
  mask-image: linear-gradient(90deg, #000, transparent 22%, transparent 78%, #000);
}
.bolts { z-index: 6; width: 100%; height: 100%; overflow: visible; }
.flash { z-index: 7; background: #dff6ff; opacity: 0; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.hud-top {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 12px 0;
}
.hud-box { display: flex; flex-direction: column; gap: 2px; text-shadow: 0 2px 6px #000; }
.hud-box.r { text-align: right; }
.lbl { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold2); opacity: .85; }
.val { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.hud-zeus {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-family: var(--f-display); font-weight: 900; font-size: 13px; letter-spacing: .14em; color: var(--gold2);
  text-shadow: 0 2px 6px #000;
}
.pips { display: flex; gap: 4px; }
.pips i { width: 16px; height: 5px; border-radius: 2px; background: var(--bolt); box-shadow: 0 0 8px var(--bolt); transition: .25s; }
.pips i.off { background: #3a2a2a; box-shadow: none; }

.hud-curve {
  position: absolute; top: 31%; left: 0; right: 0; text-align: center;
  font-weight: 700; font-size: 20px; letter-spacing: .3em; color: var(--warn);
  text-shadow: 0 0 12px rgba(255,210,63,.7); opacity: 0; transition: opacity .2s;
}
.hud-curve.on { opacity: 1; }

.toast {
  position: absolute; top: 40%; left: 0; right: 0; text-align: center;
  font-family: var(--f-display); font-weight: 900; font-size: clamp(22px, 7vw, 34px); letter-spacing: .06em;
  color: #fff; text-shadow: 0 0 18px var(--bolt), 0 3px 0 rgba(0,0,0,.6);
  opacity: 0;
}
.toast.gold { color: var(--gold2); text-shadow: 0 0 18px var(--gold), 0 3px 0 rgba(0,0,0,.6); }
.toast.red { color: #ffd7d0; text-shadow: 0 0 18px var(--danger), 0 3px 0 rgba(0,0,0,.6); }
.toast.count { font-size: 84px; }

.dash {
  position: absolute; z-index: 8; left: 0; right: 0; bottom: 0; height: var(--dash-h);
  display: grid; grid-template-columns: 52px 1fr 52px; align-items: center;
  padding: 0 10px env(safe-area-inset-bottom);
  background: linear-gradient(#0e1428, #05070f);
  border-top: 1px solid rgba(232,184,74,.45);
}
.dash-mid { text-align: center; position: relative; }
.speed { display: flex; align-items: baseline; justify-content: center; gap: 8px; line-height: 1; }
.speed b { font-size: 46px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2.1ch; text-align: right; }
.speed span { font-size: 12px; letter-spacing: .2em; color: var(--muted); }
.hud-state {
  height: 14px; font-size: 11px; font-weight: 700; letter-spacing: .2em; color: var(--gold2);
  text-transform: uppercase;
}
.bar { position: absolute; left: 0; right: 0; bottom: env(safe-area-inset-bottom); height: 5px; background: #1a2140; }
.bar i {
  display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, #4bd3ff, var(--gold) 75%, var(--danger));
}
.bar em {
  position: absolute; right: 6px; bottom: 8px; font-style: normal; font-size: 9px; letter-spacing: .2em; color: var(--danger);
}
.icon-btn {
  width: 42px; height: 42px; border-radius: 10px; font-weight: 700; font-size: 15px;
  border: 1px solid rgba(232,184,74,.4); background: rgba(232,184,74,.07); color: var(--gold2);
}
.icon-btn:active { transform: scale(.94); }
.icon-btn.off { opacity: .45; text-decoration: line-through; }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 10;
  display: none; flex-direction: column; align-items: center; justify-content: flex-start; gap: 14px;
  padding: 27dvh 22px 20px; text-align: center;
  background: linear-gradient(rgba(5,7,15,0) 0, rgba(5,7,15,.2) 20%, rgba(5,7,15,.93) 29%, rgba(5,7,15,.98) 60%);
  overflow-y: auto;
}
.stage[data-state="menu"] .screen-menu,
.stage[data-state="finish"] .screen-finish,
.stage[data-state="crash"] .screen-crash,
.stage[data-state="pause"] .screen-pause { display: flex; }
.stage[data-state="menu"] .hud,
.stage[data-state="finish"] .hud,
.stage[data-state="crash"] .hud { visibility: hidden; }
.stage[data-state="menu"] .dash,
.stage[data-state="finish"] .dash,
.stage[data-state="crash"] .dash { visibility: hidden; }

.title {
  font-family: var(--f-display); font-weight: 900; line-height: .9;
  font-size: clamp(54px, 19vw, 92px); letter-spacing: .06em;
  background: linear-gradient(#fff6d2, var(--gold) 55%, #9a6a14);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(232,184,74,.35));
}
.title span {
  display: block; margin-top: 8px; font-size: .27em; letter-spacing: .34em; text-indent: .34em;
  background: none; color: var(--bolt); -webkit-text-fill-color: var(--bolt);
}
.tagline { font-size: 12px; letter-spacing: .34em; text-transform: uppercase; color: var(--muted); }

.track-pick { display: grid; grid-template-columns: 44px 1fr 44px; gap: 8px; width: 100%; max-width: 380px; margin-top: 6px; }
.nav-btn { border: 1px solid rgba(255,255,255,.14); border-radius: 12px; font-size: 26px; color: var(--gold2); background: rgba(255,255,255,.03); }
.nav-btn:disabled { opacity: .25; cursor: default; }
.track-card {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; text-align: left;
  padding: 10px 14px; border-radius: 12px;
  border: 1px solid rgba(232,184,74,.35); background: rgba(232,184,74,.06);
}
.track-no { grid-row: span 2; font-family: var(--f-display); font-weight: 900; font-size: 28px; color: var(--gold); }
.track-card strong { font-size: 16px; letter-spacing: .08em; }
.track-card small { font-size: 12px; color: var(--muted); }
.track-card.locked { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.03); }
.track-card.locked strong, .track-card.locked .track-no { color: #6d7797; }

.btn-main {
  width: 100%; max-width: 380px; padding: 16px 18px; border-radius: 14px;
  font-weight: 700; font-size: 17px; letter-spacing: .2em; color: #1a1204;
  background: linear-gradient(#fff0b8, var(--gold) 60%, #c08a22);
  box-shadow: 0 6px 0 #6f4c0e, 0 14px 30px rgba(232,184,74,.3);
  transition: transform .08s, box-shadow .08s;
}
.btn-main:active { transform: translateY(4px); box-shadow: 0 2px 0 #6f4c0e, 0 8px 20px rgba(232,184,74,.3); }
.btn-main:disabled { filter: grayscale(1) brightness(.6); cursor: not-allowed; }
.btn-ghost {
  width: 100%; max-width: 380px; padding: 14px 18px; border-radius: 14px; font-weight: 700; letter-spacing: .16em; font-size: 14px;
  border: 1px solid rgba(232,184,74,.5); color: var(--gold2);
}
.btn-ghost:disabled { display: none; }
.btn-link { font-size: 13px; letter-spacing: .14em; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; padding: 8px; }
.row { display: grid; gap: 14px; width: 100%; justify-items: center; }

.stats, .result { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 380px; }
.stats div, .result div { padding: 9px 10px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.07); }
.stats dt, .result dt { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.stats dd, .result dd { margin-top: 3px; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result .wide { grid-column: 1 / -1; border-color: rgba(232,184,74,.4); }
.result .wide dd { font-size: 34px; color: var(--gold2); }
.result.compact { max-width: 320px; }

.hint { font-size: 12px; line-height: 1.6; color: var(--muted); }
.only-touch { display: none; }
.back { margin-top: auto; font-size: 12px; letter-spacing: .12em; color: var(--muted); text-decoration: none; padding: 6px; }
.back:hover { color: var(--gold2); }

.eyebrow { font-size: 12px; letter-spacing: .3em; color: var(--bolt); }
.big { font-family: var(--f-display); font-weight: 900; font-size: clamp(40px, 13vw, 60px); letter-spacing: .08em; color: var(--gold2); line-height: 1; }
.badge {
  padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .2em;
  color: #1a1204; background: var(--gold2); box-shadow: 0 0 24px var(--gold);
}
.quote { font-family: var(--f-display); font-weight: 700; font-size: 17px; letter-spacing: .08em; color: var(--bolt); min-height: 1.3em; }

.screen-crash { padding-top: 6dvh; background: radial-gradient(90% 60% at 50% 22%, #1b2a55, #03040a 70%); gap: 16px; }
.zeus-big { width: min(82%, 340px); filter: drop-shadow(0 0 40px rgba(168,236,255,.5)); }
.zeus-big svg { width: 100%; height: auto; display: block; overflow: visible; }
.zeus-big .z-arm { transform: rotate(-6deg); }
.zeus-big .z-bolt { opacity: 1; }
.zeus-big .z-eyes { fill: #fff; filter: drop-shadow(0 0 6px #a8ecff); }
.big-quote { font-size: clamp(22px, 7vw, 30px); color: #fff; text-shadow: 0 0 20px var(--bolt); line-height: 1.2; }

.screen-pause { justify-content: center; padding-top: 20px; background: rgba(3,4,10,.86); }
