:root {
  color-scheme: dark;
  --ink: #0a111a;
  --panel: #111c29;
  --stroke: #263748;
  --paper: #f3f5ee;
  --muted: #9aacba;
  --lime: #cdf66e;
  --amber: #ffca75;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  color: var(--paper);
  background: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 272px; min-height: 100dvh; background: radial-gradient(ellipse at 50% 0, #152331, #0a111a 72%); }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
.shell { width: min(1250px, 100%); margin: 0 auto; padding: 0 clamp(14px, 3.6vw, 46px) 20px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 69px; }
.arcade-link { display: inline-flex; gap: 10px; align-items: center; color: var(--paper); text-decoration: none; font-weight: 800; letter-spacing: .015em; white-space: nowrap; }
.arcade-link:hover { color: var(--lime); }
.grid-icon { display: grid; grid-template-columns: repeat(2, 5px); grid-template-rows: repeat(2, 5px); gap: 3px; transform: rotate(-8deg); }
.grid-icon i { background: var(--lime); border-radius: 1px; }
.grid-icon i:nth-child(2) { opacity: .45; }
.top-actions, .menu-actions { display: flex; align-items: center; gap: 9px; }
.utility { background: #111c29; border: 1px solid #334353; padding: 8px 13px; min-height: 40px; border-radius: 6px; color: #d8e0e6; white-space: nowrap; font-size: .87rem; font-weight: 700; }
.utility[aria-pressed="true"] { color: var(--lime); }
.utility:disabled { cursor: default; opacity: .47; }
.utility:not(:disabled):hover { border-color: #91a6a7; }
.stage { min-height: 440px; height: clamp(440px, calc(100dvh - 157px), 725px); position: relative; isolation: isolate; overflow: hidden; border: 1px solid #344759; border-radius: 12px; background: #172733; box-shadow: 0 21px 65px #070c14bd; }
#city { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; padding: clamp(24px, 6.4vw, 95px); background: linear-gradient(90deg, #0b1420f5, #0b1420ba 47%, #0a142254); }
[data-mode="menu"] .overlay { background: linear-gradient(90deg, #09131ced, #0b1522a6 43%, #0c192409 76%), linear-gradient(0deg, #091322b8, transparent 30%), url('./night-run.jpg') 57% center / cover no-repeat; }
.menu-content { max-width: min(100%, 530px); }
.overline { margin: 0 0 12px; text-transform: uppercase; letter-spacing: .18em; color: var(--lime); font-weight: 800; font-size: .84rem; }
.wordmark { margin: 0; font-family: Impact, "Arial Black", sans-serif; font-size: clamp(4.7rem, 10.4vw, 9.5rem); line-height: .78; letter-spacing: -.038em; font-weight: 900; font-style: italic; text-transform: uppercase; text-shadow: 0 4px 30px #070d15c9; }
.wordmark em { display: block; color: var(--lime); margin-left: -.015em; }
.overlay h1:not(.wordmark) { font-size: clamp(2.6rem, 7vw, 5.4rem); line-height: .94; letter-spacing: -.065em; margin: 0; }
.summary { color: #e0e7ec; line-height: 1.5; max-width: 33ch; font-size: clamp(1rem, 1.7vw, 1.18rem); margin: clamp(19px, 3vw, 29px) 0 25px; text-wrap: pretty; }
.primary, .secondary { border-radius: 6px; padding: 12px 22px; min-height: 47px; font-weight: 850; line-height: 1.2; }
.primary { color: #182319; background: var(--lime); border: 1px solid var(--lime); box-shadow: 0 5px 21px #0e170976; }
.primary:hover { background: #e1ff99; }
.secondary { border: 1px solid #acbac582; background: #101d2bcf; color: var(--paper); }
.secondary:hover { background: #233447; }
.record { text-transform: uppercase; color: #aebdca; font-size: .82rem; font-weight: 800; letter-spacing: .13em; margin: 20px 0 0; }
.record span { color: var(--paper); font-variant-numeric: tabular-nums; margin-left: 5px; }
.hud { position: absolute; top: clamp(10px, 2.3vw, 23px); left: clamp(10px, 2.3vw, 23px); right: clamp(10px, 2.3vw, 23px); display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.route, .run-score, .dash, .notice { background: #0b1520e3; border: 1px solid #667a895e; border-radius: 7px; box-shadow: 0 6px 18px #08111ca8; }
.route { align-self: start; padding: 10px 12px; width: min(240px, 63%); }
.district { display: flex; align-items: baseline; gap: 7px; font-weight: 800; }
#district-number { color: var(--lime); font-size: .7rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.track { height: 3px; background: #4f616c; overflow: hidden; margin-top: 8px; border-radius: 2px; }
.track span { display: block; height: 100%; width: 100%; background: var(--lime); transform: scaleX(0); transform-origin: left; }
.run-score { padding: 6px 11px; text-align: right; min-width: 91px; }
.run-score > span, .speed > span { color: var(--muted); font-size: .69rem; font-weight: 800; text-transform: uppercase; letter-spacing: .095em; }
.run-score strong { display: block; font-size: clamp(1.1rem, 3vw, 1.5rem); font-variant-numeric: tabular-nums; line-height: 1.05; }
.run-score small { display: block; color: var(--lime); font-size: .71rem; letter-spacing: .07em; margin-top: 4px; }
.notice { position: absolute; top: 19%; left: 50%; transform: translateX(-50%); width: max-content; max-width: 91%; padding: 7px 11px; border-color: #ffca7570; text-align: center; pointer-events: none; }
.notice strong { color: var(--amber); text-transform: uppercase; font-weight: 900; font-size: .88rem; letter-spacing: .09em; }
.notice span { margin-left: 7px; color: var(--paper); font-size: .85rem; white-space: nowrap; }
.notice[data-ready="true"] { border-color: var(--lime); }
.notice[data-ready="true"] strong { color: var(--lime); }
.fork-notice { top: auto; bottom: clamp(12px, 2vw, 19px); left: auto; right: clamp(10px, 2vw, 19px); max-width: min(91%, calc(100% - 136px)); transform: none; border-color: #ffc771b5; }
.fork-notice span { display: block; margin: 2px 0 0; font-weight: 850; }
.fork-notice[data-side="left"] span::before { content: '← '; }
.fork-notice[data-side="right"] span::after { content: ' →'; }
.dash { position: absolute; bottom: clamp(10px, 2vw, 19px); left: clamp(10px, 2vw, 19px); padding: 8px 12px; min-width: 116px; pointer-events: none; }
.speed { display: flex; gap: 5px; align-items: baseline; }
.speed b { font-size: clamp(1.62rem, 4.2vw, 2.1rem); line-height: 1; font-variant-numeric: tabular-nums; }
.jump-indicator { font-size: .82rem; color: #b9c6cf; margin-top: 3px; font-weight: 700; }
.jump-indicator[data-ready="true"] { color: var(--lime); }
.keyboard-guide { display: flex; gap: 14px 25px; flex-wrap: wrap; align-items: center; color: #b5c4ce; padding: 16px 1px; }
.keyboard-guide > div { display: flex; gap: 4px; align-items: center; }
.keyboard-guide span { margin-left: 5px; }
kbd { font-family: inherit; display: inline-grid; place-content: center; min-width: 26px; height: 25px; color: #e0e6e7; background: #1b2935; border: 1px solid #364556; border-bottom-width: 2px; border-radius: 4px; font-size: .79rem; font-weight: 800; }
kbd.space { padding: 0 8px; }
.keyboard-note { margin-left: auto; }
.keyboard-note b, .touch-tip b { color: var(--lime); }
.touch-controls, .touch-tip { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 650px) {
  .shell { padding: 0 9px 10px; }
  .topbar { min-height: 52px; padding: 0 2px; }
  .arcade-link { gap: 7px; font-size: .92rem; }
  .top-actions { gap: 5px; }
  .utility { min-height: 36px; padding: 6px 8px; font-size: .79rem; }
  .stage { height: clamp(375px, calc(100dvh - 132px), 670px); min-height: 0; border-radius: 8px; }
  .overlay { padding: 23px; }
  [data-mode="menu"] .overlay { align-items: end; padding-bottom: 32px; background: linear-gradient(0deg, #0a1320 3%, #0b1423dd 33%, #0b152270 57%, #0a152400 79%), url('./night-run.jpg') 64% top / auto 75% no-repeat, #0a1320; }
  .wordmark { font-size: clamp(3.9rem,14.8vw,7.2rem); }
  .wordmark em { display: inline; margin-left: 0; }
  .summary { margin: 15px 0 17px; }
  .record { margin-top: 15px; }
  .primary,.secondary { padding: 10px 14px; }
  .keyboard-guide { gap: 9px 13px; padding: 12px 0; font-size: .86rem; }
  .keyboard-note { margin: 0; }
}
@media (pointer: coarse), (max-width: 650px) {
  .touch-controls { display: flex; justify-content: space-between; gap: 6px; padding-top: 8px; touch-action: none; }
  .touch-controls > div { display: flex; gap: 5px; min-width: 0; }
  .touch-controls button { color: #e8eef1; background: #1b2b3a; border: 1px solid #405467; border-radius: 6px; font-size: .82rem; font-weight: 800; min-height: 48px; min-width: 46px; padding: 0 8px; touch-action: none; user-select: none; }
  .touch-controls [data-control="left"], .touch-controls [data-control="right"] { font-size: 1.9rem; line-height: .8; }
  .touch-controls [data-control="jump"] { color: #16221a; background: var(--lime); border-color: var(--lime); min-width: 57px; }
  .touch-controls button.active { filter: brightness(1.35); transform: translateY(1px); }
  [data-mode="menu"] .touch-tip { display: block; color: var(--muted); margin: 12px 2px; font-size: .9rem; }
}
@media (pointer: coarse) { .keyboard-guide { display: none; } }
@media (max-height: 480px) and (orientation: landscape) {
  .topbar { min-height: 44px; }
  .stage { min-height: 230px; height: calc(100dvh - 106px); }
  .overlay { align-items: center !important; padding: 14px 27px !important; }
  .wordmark { font-size: clamp(3.2rem, 8vw, 5.8rem); }
  .wordmark em { display: inline; }
  .summary { margin: 11px 0 10px; }
  .record { margin-top: 9px; }
  .overline { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { .touch-controls button.active { transform: none; } }
