:root {
  --bg: #1a0f2e; --surface: #241640; --surface-2: #2f1d52; --ink: #fff3e0; --ink-2: #cdb8ec; --line: #3a2560;
  --accent: #ff8a3d; --accent-ink: #1a0f2e; --ok: #7cfc9a; --warn: #ffd166; --bad: #ff5050; --info: #7df9ff;
  --coast-orange: #ff8a3d; --coast-pink: #ff5c8a; --coast-teal: #22d3c4; --coast-gold: #ffd166;
  --font-display: "Racing Sans One", "Barlow", system-ui, sans-serif; --font-ui: "Barlow", system-ui, sans-serif;
}
:root[data-theme="light"] {
  --bg: #fdf1e0; --surface: #ffffff; --surface-2: #ffe6c4; --ink: #2a1533; --ink-2: #6b5480; --line: #f0d3ae;
  --accent: #e8630f; --accent-ink: #ffffff; --ok: #2f8f4e; --warn: #b45309; --bad: #c81e3a; --info: #0e7490;
}
body { background: linear-gradient(180deg, #2a1350 0%, #4a1d4e 35%, #1a0f2e 100%); background-attachment: fixed; font-family: var(--font-ui); }
:root[data-theme="light"] body { background: linear-gradient(180deg, #ffe3b8 0%, #ffd0c2 40%, #fdf1e0 100%); background-attachment: fixed; }

/* Compact home so title + 4 modes + tier picker + radio + best-line + actions all fit
   a 360x640 phone without scrolling (mirrors serpent's compact-home approach). */
.logo { display: flex; justify-content: center; margin-bottom: -8px; } .logo canvas { width: 168px; height: 58px; }
.title { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.7rem, 8vw, 2.8rem); line-height: .95; letter-spacing: .02em; color: #fff5e0; text-shadow: 0 0 10px rgba(255,138,61,.85), 0 0 28px rgba(255,92,138,.5); }
:root[data-theme="light"] .title { color: #b3410f; text-shadow: 0 0 10px rgba(232,99,15,.25); }
.tagline { font-weight: 600; letter-spacing: .03em; font-size: .74rem; margin-top: 2px; }
.mode { background: color-mix(in oklab, var(--surface) 82%, transparent); border-color: color-mix(in oklab, var(--line) 70%, transparent); backdrop-filter: blur(6px); }
.mode b { font-family: var(--font-ui); font-weight: 700; font-size: .92rem; letter-spacing: .02em; }
.arcade-home { gap: var(--s-2); justify-content: flex-start; padding-top: var(--s-2); }
.modes { grid-template-columns: 1fr 1fr; gap: 6px; }
.mode { min-height: 46px; padding: 6px 10px; } .mode span { font-size: .68rem; }
.picker { margin: 0; }
.seg-line [role="radio"] { font-family: var(--font-ui); font-weight: 700; font-size: .8rem; height: 36px; }
.cta { font-family: var(--font-ui); font-weight: 700; height: 48px; }
.btn { font-family: var(--font-ui); font-weight: 700; letter-spacing: .02em; }
.btn-continue { grid-column: 1 / -1; background: color-mix(in oklab, var(--surface-2) 75%, var(--coast-pink) 25%); font-weight: 700; }
.best-line { font-weight: 600; font-size: .82rem; }

/* radio widget */
.radio { display: flex; align-items: center; gap: 6px; background: color-mix(in oklab, var(--surface) 80%, transparent); border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px 6px; }
.radio .btn-icon { width: 32px; height: 32px; min-height: 0; }
.radio-lcd { flex: 1; text-align: center; font-family: "Barlow", monospace; overflow: hidden; }
.radio-lcd small { display: block; font-size: .55rem; letter-spacing: .16em; color: var(--ink-2); }
.radio-lcd span { display: block; font-weight: 700; font-size: .8rem; color: var(--coast-teal); white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }

/* play */
.play { background: linear-gradient(180deg, #2a1350 0%, #1a0f2e 70%); }
:root[data-theme="light"] .play { background: linear-gradient(180deg, #ffe3b8 0%, #fdf1e0 70%); }
.play .stage { padding: calc(var(--hud-h) + 30px + env(safe-area-inset-top)) 6px calc(100px + env(safe-area-inset-bottom)); }
@media (pointer: fine) { .play .stage { padding-bottom: 12px; } }
:root[data-touch="swipe"] .play .stage { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.play .stage-canvas { border-radius: 10px; box-shadow: 0 0 0 1px rgba(255,138,61,.2), 0 0 60px rgba(255,92,138,.12); }
.hud-pill { font-family: var(--font-ui); font-weight: 700; font-size: .9rem; padding: 0 10px; gap: 5px; background: color-mix(in oklab, #1a0f2e 72%, transparent); }
:root[data-theme="light"] .hud-pill { background: color-mix(in oklab, #ffffff 78%, transparent); }
.hud-pill small { font-size: .6rem; letter-spacing: .12em; }
#hud-time-pill[data-danger="1"] { color: var(--bad); box-shadow: 0 0 0 1px var(--bad), 0 0 16px rgba(255,80,80,.6); animation: danger-pulse .9s ease-in-out infinite; }
@keyframes danger-pulse { 0%, 100% { box-shadow: 0 0 0 1px var(--bad), 0 0 10px rgba(255,80,80,.35); } 50% { box-shadow: 0 0 0 2px var(--bad), 0 0 22px rgba(255,80,80,.85); } }
:root[data-motion="reduced"] #hud-time-pill[data-danger="1"] { animation: none; }
.hud-fx { position: absolute; left: 0; right: 0; top: calc(var(--hud-h) + 26px + max(8px, env(safe-area-inset-top))); z-index: 3; display: flex; justify-content: center; gap: 6px; padding: 0 10px; pointer-events: none; min-height: 0; }
.fx-pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 999px; font-weight: 700; font-size: .68rem; letter-spacing: .08em; color: #1a0f2e; background: var(--c, var(--coast-orange)); }

.stage-line { position: absolute; left: 0; right: 0; top: calc(var(--hud-h) + max(6px, env(safe-area-inset-top))); z-index: 3; display: flex; justify-content: center; pointer-events: none; }
.stage-line span { background: color-mix(in oklab, #1a0f2e 55%, transparent); border-radius: var(--r-pill); padding: 3px 12px; font-weight: 700; font-size: .78rem; letter-spacing: .08em; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.6); }

.fork-banner { position: absolute; left: 0; right: 0; top: 60%; z-index: 4; display: flex; align-items: center; justify-content: center; gap: 10px; pointer-events: none; animation: fade var(--t-base); }
.fork-side { background: color-mix(in oklab, #1a0f2e 70%, transparent); border: 2px solid var(--coast-teal); color: #fff; font-weight: 800; letter-spacing: .06em; padding: 8px 14px; border-radius: var(--r-pill); text-shadow: 0 0 8px rgba(34,211,196,.7); }
.fork-vs { color: var(--ink-2); font-weight: 600; font-size: .75rem; text-transform: uppercase; }

.controls-row { position: relative; display: none; align-items: flex-end; justify-content: space-between; min-height: 58px; }
@media (pointer: coarse) { :root[data-touch="buttons"] .controls-row { display: flex; } }
#tc { --tc: 56px; width: 100%; }
#tc [data-action="a"] { font-weight: 700; font-size: .74rem; letter-spacing: .05em; background: color-mix(in oklab, var(--coast-teal) 45%, var(--surface)); border-color: var(--coast-teal); width: 68px; height: 68px; }
#tc [data-action="b"] { font-weight: 700; font-size: .7rem; letter-spacing: .05em; background: color-mix(in oklab, var(--bad) 45%, var(--surface)); border-color: var(--bad); }

#ready { pointer-events: none; backdrop-filter: none; background: transparent; align-content: center; padding-top: 22%; }
.overlay h2 { font-family: var(--font-display); font-weight: 400; color: #fff5e0; text-shadow: 0 0 12px rgba(255,138,61,.85), 0 0 30px rgba(255,92,138,.5); }
#ready h2 { font-size: clamp(1.4rem, 6.5vw, 2.1rem); letter-spacing: .03em; }
#ready p { font-size: .9rem; }
.overlay p { color: var(--ink); font-weight: 600; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
:root[data-theme="light"] .overlay h2 { color: #b3410f; text-shadow: none; } :root[data-theme="light"] .overlay p { text-shadow: none; }
.ready-progress { width: min(200px, 60vw); height: 6px; margin-top: 10px; border-radius: 999px; background: rgba(255,255,255,.18); overflow: hidden; }
.ready-progress-bar { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--coast-pink)); transition: width .15s ease; }
#paused { background: color-mix(in oklab, #1a0f2e 72%, transparent); backdrop-filter: blur(4px); }
:root[data-theme="light"] #paused { background: rgba(253,241,224,.82); }
.result-verdict { text-align: center; color: var(--ink-2); font-weight: 600; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: var(--s-2); }
.result-actions .btn-primary { grid-column: 1 / -1; }
.sheet-title { font-family: var(--font-display); font-weight: 400; letter-spacing: .03em; text-transform: uppercase; font-size: 1.25rem; }
.score-total { font-family: var(--font-display); font-weight: 400; color: var(--coast-orange); text-shadow: 0 0 18px rgba(255,138,61,.5); }
:root[data-theme="light"] .score-total { color: #b3410f; text-shadow: none; }
@container screen (min-width: 640px) { .arcade-home .modes { grid-template-columns: 1fr 1fr; } }
