:root {
  color-scheme: dark;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
  color: #f3e8cb;
  background: #172322;
  --paper: #f5e8c9;
  --muted: #c5c1a7;
  --amber: #f2c777;
  --edge: #647269;
  --font-mono: "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; min-height: 100dvh; background: radial-gradient(ellipse at 66% 0, #354942, #172322 66%); }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .46; cursor: default; }
:focus-visible { outline: 2px solid #ffdc8f; outline-offset: 4px; }
.shell { width: min(1060px, 100%); margin: 0 auto; padding: 0 clamp(12px, 3vw, 34px) 16px; }
.topbar { min-height: 65px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.arcade-link { display: inline-flex; align-items: center; gap: 10px; color: var(--paper); font-weight: 820; text-decoration: none; white-space: nowrap; }
.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: #cdf66e; border-radius: 1px; }
.grid-icon i:nth-child(2) { opacity: .45; }
.utilities { display: flex; gap: 7px; }
.utility, .secondary { background: #2b3c37; border: 1px solid #6c7c6c; border-radius: 4px; color: var(--paper); font-size: .875rem; padding: 7px 10px; font-weight: 700; }
.utility:hover:not(:disabled), .secondary:hover { background: #3e5147; }
.cabinet { border: 1px solid var(--edge); border-radius: 8px; overflow: hidden; box-shadow: 0 20px 55px #0d1718a8; }
.hud { display: grid; grid-template-columns: 1.25fr 1fr 1fr .85fr; background: #1d302d; border-bottom: 1px solid #66766a; }
.hud-section { padding: 8px clamp(9px, 1.65vw, 20px) 9px; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 3px 10px; }
.hud-section + .hud-section { border-left: 1px solid #56655a; }
.hud-section > span { color: var(--muted); white-space: nowrap; font-size: .875rem; }
.hud-section strong { text-align: end; font-size: clamp(1rem, 2.1vw, 1.4rem); font-variant-numeric: tabular-nums; font-weight: 800; color: var(--paper); }
.hud-section small { grid-column: 1 / -1; overflow-wrap: anywhere; color: #dbbd82; font: .78rem var(--font-mono); }
.stage { position: relative; isolation: isolate; background: #819656; }
canvas { display: block; width: 100%; aspect-ratio: 448 / 268; object-fit: cover; image-rendering: pixelated; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; padding: clamp(16px, 4vw, 46px); background: linear-gradient(90deg, #18252265, transparent 85%); overflow: auto; }
.panel { max-width: min(455px, 85%); background: #233633f5; border: 1px solid #83927a; border-left: 4px solid var(--amber); border-radius: 3px; padding: clamp(15px, 3vw, 31px); box-shadow: 0 10px 38px #12262375; }
.edition { margin: 0 0 10px; color: var(--amber); font: 800 .88rem var(--font-mono); letter-spacing: .09em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-weight: 800; font-size: clamp(2.15rem, 7.2vw, 5.4rem); line-height: .86; letter-spacing: -.067em; }
h1 em { display: block; color: var(--amber); font-weight: inherit; }
.summary { max-width: 32ch; margin: 17px 0 18px; color: var(--paper); line-height: 1.45; font-size: 1rem; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.primary { padding: 11px 19px; border: 1px solid #ffde98; border-radius: 4px; color: #2c2624; background: var(--amber); font-weight: 850; }
.primary:hover { background: #ffda91; }
[data-mode="report"] .overlay, [data-mode="pause"] .overlay { justify-content: center; background: #172622b8; }
[data-mode="report"] .panel, [data-mode="pause"] .panel { width: min(100%, 560px); max-width: none; }
[data-mode="report"] h1, [data-mode="pause"] h1 { font-size: clamp(1.85rem, 5vw, 3.8rem); letter-spacing: -.05em; line-height: 1; }
.report { margin-bottom: 16px; }
.stops { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.stop { display: flex; justify-content: center; gap: 3px; border: 1px solid #626f63; padding: 5px 2px; background: #334540; color: #f3e8cb; font: .78rem var(--font-mono); }
.stop.kept { background: #3b5b53; border-color: #88ad8c; }
.stop.lost { background: #67493e; border-color: #a97c6a; }
.stop.new, .stop.retry { background: #55503a; border-color: #e2b968; }
.totals { margin: 10px 0 0; font-size: .875rem; color: var(--amber); line-height: 1.35; }
.notice { position: absolute; inset: 12px 12px auto auto; background: #203432eb; color: #ffe0a0; border: 1px solid #e3be7a; border-radius: 3px; padding: 7px 12px; font: bold .875rem var(--font-mono); pointer-events: none; }
.keyboard-guide { display: flex; align-items: center; justify-content: space-around; flex-wrap: wrap; gap: 8px 16px; padding: 12px 8px 0; font-size: .875rem; color: #dfd0a9; }
.keyboard-guide > div { display: flex; align-items: center; gap: 4px; }
.keyboard-guide span { margin-left: 3px; }
kbd { min-width: 21px; padding: 2px 4px; border: 1px solid #728174; border-bottom-width: 2px; border-radius: 3px; background: #263b37; color: #fae7b7; text-align: center; font: bold .84rem var(--font-mono); }
.touch-controls { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 700px) {
  .hud-section { grid-template-columns: 1fr; gap: 2px; }
  .hud-section strong { text-align: left; }
  .topbar { min-height: 53px; }
}
@media (max-width: 520px) {
  canvas { min-height: 244px; object-fit: cover; object-position: 50% 65%; }
  [data-mode="menu"] canvas { min-height: 274px; }
  [data-mode="report"] canvas { min-height: 390px; }
  .overlay { padding: 10px; }
  .panel { padding: 13px; max-width: 75%; }
  .edition { font-size: .78rem; margin-bottom: 6px; }
  .summary { margin: 10px 0 13px; font-size: .95rem; line-height: 1.35; }
  .hud-section { padding: 5px 6px; }
  .hud-section > span { font-size: .76rem; }
  .hud-section small { font-size: .67rem; }
}
@media (pointer: coarse), (max-width: 700px) {
  .touch-controls { display: flex; justify-content: space-between; gap: 7px; padding: 9px 0 0; touch-action: none; user-select: none; }
  .steering, .pedals { display: flex; gap: 5px; }
  .touch-controls button { min-height: 48px; min-width: 43px; border: 1px solid #6c7c6c; background: #2b3c37; color: #fcf0d1; border-radius: 4px; padding: 0 7px; font-weight: 800; font-size: .84rem; touch-action: none; }
  .steering button { font-size: 1.65rem; }
  .touch-controls [data-input="throw"] { background: var(--amber); color: #292721; border-color: #ffe098; }
  .touch-controls .active { filter: brightness(1.25); }
}
@media (pointer: coarse) { .keyboard-guide { display: none; } }
@media (orientation: landscape) and (max-height: 520px) {
  .shell { width: min(100%, calc((100dvh - 100px) * 1.67)); }
  .topbar { min-height: 43px; }
  .hud-section { grid-template-columns: auto 1fr; padding: 4px 8px; }
  .hud-section small { display: none; }
  .panel { margin: auto 0; }
  .keyboard-guide { padding-top: 5px; }
  .touch-controls { padding-top: 4px; }
  .touch-controls button { min-height: 40px; }
}
