
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #101522; font-family: system-ui, Arial, sans-serif; color: white; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.hud { position: absolute; top: env(safe-area-inset-top, 0px); left: 0; right: 0; padding: 15px 18px; display: flex; justify-content: space-between; pointer-events: none; text-shadow: 0 2px 5px #000; font-weight: 800; }
.hud small { display: block; color: #b6c4d6; font-size: 11px; letter-spacing: 1px; }
.hud span { font-size: 23px; }
.center { text-align: center; }
.right { text-align: right; }
.toolbar { position: absolute; top: calc(86px + env(safe-area-inset-top, 0px)); left: 15px; right: 15px; display: flex; align-items: center; justify-content: space-between; }
#toolsHud { font-size: 22px; text-shadow: 0 2px 5px #000; }
#pause { padding: 7px 12px; color: white; border: 1px solid #ffffff55; border-radius: 10px; background: #182538cc; }
#pause:disabled { opacity: .5; cursor: default; }
.controls { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 7px; padding: 0 22px; pointer-events: none; }
.ctrl { pointer-events: auto; border: 2px solid #ffffff55; border-radius: 24px; width: min(105px, 29vw); height: 83px; background: #182538bb; color: white; font-size: 43px; font-weight: bold; touch-action: none; user-select: none; box-shadow: 0 5px 20px #0006; }
.ctrl.pressed { background: #3d77b0dd; transform: scale(.97); }
.brake-group { display: grid; justify-items: center; gap: 4px; }
.ctrl.brake { width: 76px; height: 76px; border-radius: 50%; font-size: 27px; background: #9b2832cc; border-color: #ff7777; }
.ctrl.brake.pressed { background: #e33a44; }
.ctrl.brake.spent { background: #4b3b40; border-color: #a99b9e; }
#brakeStatus { font-size: 9px; font-weight: 800; text-shadow: 0 1px 4px black; }
.overlay { position: absolute; inset: 0; background: #0a1020bb; display: flex; align-items: center; justify-content: center; padding: 20px; }
.panel { width: min(390px, 95vw); max-height: 100%; overflow-y: auto; padding: 26px 22px; text-align: center; border: 1px solid #ffffff30; border-radius: 24px; background: #172236ee; box-shadow: 0 20px 65px #0009; }
.panel h1 { font-size: 34px; margin: 0 0 8px; color: #7bd8ff; }
.panel p { line-height: 1.55; color: #d3dfed; }
.start { border: 0; border-radius: 16px; background: #5cd3ff; color: #102136; padding: 15px 24px; font-size: 18px; font-weight: 900; margin-top: 10px; }
#repair { background: #ffca54; }
.hidden { display: none; }
@media (max-height: 500px) {
  .hud { padding-top: 5px; }
  .toolbar { top: calc(69px + env(safe-area-inset-top, 0px)); }
  .controls { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .ctrl { height: 56px; font-size: 30px; }
  .ctrl.brake { width: 52px; height: 52px; }
  .panel { padding: 16px; }
}

/* Main menu and sound options */
.overlay.main-menu { background: radial-gradient(ellipse at top, #123047e8, #080e1cf5 75%); }
.main-menu .panel { padding: 34px 26px; border-color: #70d9ff33; background: #121f30f5; }
.main-menu h1 { font-size: clamp(27px, 7vw, 35px); font-style: italic; letter-spacing: -1px; margin-bottom: 26px; }
.score-card { display: grid; gap: 5px; padding: 20px; margin-bottom: 20px; border-radius: 18px; background: #091421; border: 1px solid #ffffff12; }
.eyebrow { font-size: 11px; letter-spacing: 2px; color: #9ab3c7; }
.score-card strong { font-size: 48px; line-height: 1.15; color: #ffda83; font-variant-numeric: tabular-nums; }
.score-unit { font-size: 10px; letter-spacing: 3px; color: #9ab3c7; }
.sound-options { text-align: left; border: 1px solid #ffffff24; border-radius: 14px; margin: 16px 0; background: #ffffff04; }
.sound-options summary { cursor: pointer; list-style: none; padding: 15px 16px; display: flex; justify-content: space-between; font-weight: 600; }
.sound-options summary::-webkit-details-marker { display: none; }
.sound-options[open] summary span { transform: rotate(45deg); }
.sound-settings { padding: 0 16px 16px; }
.sound-settings label { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin: 13px 0 7px; color: #d3dfed; }
.sound-settings output { color: #7bd8ff; font-variant-numeric: tabular-nums; }
.sound-settings input[type=range] { width: 100%; accent-color: #5cd3ff; cursor: pointer; }
.sound-settings input[type=checkbox] { width: 20px; height: 20px; accent-color: #5cd3ff; }
.panel .start { width: 100%; }
.menu-return { margin-top: 18px; padding: 8px; border: 0; background: transparent; color: #a9bfd0; font-size: 12px; letter-spacing: 1px; }
summary:focus-visible, input:focus-visible { outline: 2px solid #7bd8ff; outline-offset: 4px; }
.score-card.hidden { display: none; }
@media (max-height: 500px) { .main-menu .panel { padding: 20px; } .main-menu h1 { margin-bottom: 14px; } .score-card { padding: 12px; margin-bottom: 12px; } .score-card strong { font-size: 34px; } }

.menu-logo { display: block; width: 100%; height: auto; margin: 0 auto 26px; }
.menu-logo.hidden { display: none; }
.main-menu #title { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-height: 500px) { .menu-logo { margin-bottom: 16px; } }

/* Dashboard and tactile controls */
button, summary { -webkit-tap-highlight-color: transparent; }
.ctrl { outline: none; -webkit-touch-callout: none; }
.ctrl:focus { outline: none; }
.ctrl:focus-visible { outline: 2px solid #ffe0a0; outline-offset: 5px; }
.speedometer { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 144px; height: 132px; filter: drop-shadow(0 5px 8px #0008); }
.speedometer svg { width: 100%; height: 100%; overflow: visible; }
.digital-speed { position: absolute; top: 84px; left: 50%; transform: translateX(-50%); text-align: center; min-width: 49px; padding: 1px 5px; border-radius: 4px; background: #0b1421; box-shadow: inset 0 1px 4px #000; }
.hud .digital-speed span { font-size: 20px; line-height: 22px; font-variant-numeric: tabular-nums; }
.hud .digital-speed small { font-size: 8px; line-height: 10px; letter-spacing: 0; }
.controls .ctrl.brake { width: 78px; height: 94px; border: 0; border-radius: 15px; background: linear-gradient(100deg,#0b0e13,#34404c 45%,#080c11); padding: 5px 5px 10px; box-shadow: 0 7px 0 #05090e, 0 11px 18px #0008; transform: perspective(230px) rotateX(12deg); }
.pedal-face { display: flex; flex-direction: column; justify-content: center; gap: 6px; height: 100%; border: 2px solid #8e9daa; border-bottom-color: #303b45; border-radius: 10px; padding: 9px 10px 5px; background: linear-gradient(110deg,#d3dce3,#6c7c89 26%,#afbdc8 48%,#52616e 80%,#97a5b0); box-shadow: inset 1px 2px 2px #ffffffa0, inset -2px -3px 3px #172431; }
.pedal-face i { display: block; height: 5px; flex-shrink: 0; border-radius: 2px; background: #17202a; box-shadow: inset 0 1px 2px #000, 0 1px 0 #d0dce5; }
.pedal-face b { color: #15222e; font-size: 8px; letter-spacing: 1px; text-shadow: 0 1px #d1dce5; }
.controls .ctrl.brake.pressed { background: #18222c; transform: perspective(230px) rotateX(21deg) translateY(5px); box-shadow: 0 2px 0 #05090e,0 4px 9px #0008; }
.controls .ctrl.brake.spent { background: #202a33; border: 0; }
.record-details { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px solid #ffffff16; margin-top: 14px; padding-top: 14px; }
.record-details strong { display: block; font-size: 23px; color: #c7edff; }
.record-details small { display: block; font-size: 8px; color: #99afc0; letter-spacing: .7px; margin-top: 5px; }
@media (max-height: 500px) { .speedometer { width: 112px; height: 103px; } .digital-speed { top: 65px; } .hud .digital-speed span { font-size: 15px; line-height: 17px; } .hud .digital-speed small { font-size: 7px; line-height: 8px; } .controls .ctrl.brake { width: 64px; height: 64px; padding: 4px 4px 7px; } .pedal-face { gap: 3px; padding: 5px 7px; } .pedal-face i { height: 3px; } }

.brake-group { gap: 12px; }

/* Constant transparency keeps the center lane visible without flicker. */
.speedometer { filter: none; }
.dial-shell { opacity: .08; }
.speedometer .digital-speed { background: #0b142118; box-shadow: none; text-shadow: 0 1px 3px #000; }
.speedometer svg > line, .speedometer svg > text { opacity: .45; }
  
.help-content { padding: 0 16px 16px; font-size: 13px; line-height: 1.6; color: #d3dfed; }
.help-content p { margin: 10px 0; }
.countdown { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 4px; background: #07132138; pointer-events: none; text-shadow: 0 3px 16px #000; }
.countdown strong { font-size: 100px; color: #8ee7ff; line-height: 1.1; }
.countdown span { font-size: 13px; letter-spacing: 2px; font-weight: 700; }
.countdown.hidden { display: none; }
.pwa-actions { margin-top: 14px; font-size: 11px; color: #9ab3c7; }
.pwa-actions button { width: 100%; border: 1px solid #ffffff30; border-radius: 10px; padding: 10px; margin-top: 8px; background: #193447; color: #e4f4ff; }
.pwa-actions p { font-size: 11px; margin: 8px 0 0; }
button:disabled { cursor: wait; opacity: .65; }
