:root {
  color-scheme: dark;
  --ink: #0c1117;
  --text: #f3f4f3;
  --muted: #b7bdc0;
  --lime: #d9f56b;
  --line: #ffffff26;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  --safe-left: max(25px, env(safe-area-inset-left));
  --safe-right: max(25px, env(safe-area-inset-right));
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--ink); color: var(--text); }
body { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
#game, #world, .vignette, .menu, .hud, .steer-pad { position: absolute; inset: 0; width: 100%; height: 100%; }
#game { isolation: isolate; touch-action: none; overflow: hidden; }
#world { display: block; }
.vignette { background: radial-gradient(ellipse at 50% 48%, transparent 51%, #0a110f39 83%, #060a0e79 100%); pointer-events:none; }
button, select, input { font: inherit; }
button { cursor: pointer; color: inherit; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .42; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
.menu { display: grid; grid-template-rows: auto 1fr auto; gap: 12px; padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); background: linear-gradient(90deg,#070d14ef 0%,#080e18ab 28%,#0a131927 59%,transparent 77%), linear-gradient(0deg,#060b12e8 0%, transparent 28%, transparent 87%, #0b10186c 100%); }
.menu-top { display:flex; align-items:center; justify-content:space-between; gap: 12px; }
.wordmark { display:flex; align-items:center; gap: 6px; font-weight:800; font-size: .93rem; letter-spacing:.135em; white-space:nowrap; }
.wordmark b { color:#c5c9cb; font-weight:450; }
.wordmark i { width: 17px; height: 13px; display: inline-block; background: var(--lime); transform: skew(-18deg); clip-path: polygon(39% 0, 100% 0, 61% 100%, 0 100%); margin-right: 6px; }
.menu-copy { align-self:center; margin-left: clamp(0px, 3.1vw, 70px); margin-top: 1vh; width:max-content; max-width:100%; }
.eyebrow { color:#d9f56b; font-size: clamp(.69rem, 1.18vw, .94rem); font-weight:800; letter-spacing:.17em; margin:0 0 .82em; }
h1 { font-size: clamp(3.65rem, min(10.4vw, 15vh), 11rem); font-weight:900; letter-spacing:-.083em; line-height:.78; margin:0 0 .25em -.065em; text-shadow:0 4px 35px #060a103b; }
h1 span { color: var(--lime); }
.menu-subtitle { margin: 0 0 1.25em; color:#dbe2e2; font-size: clamp(.86rem, 1.44vw, 1.33rem); line-height:1.3; }
.primary, .secondary, .icon-button { font-weight:750; border:1px solid transparent; min-height:44px; border-radius:6px; display:inline-flex; justify-content:center; align-items:center; gap:8px; padding:8px 15px; white-space:normal; }
.primary { background:var(--lime); color:#142008; box-shadow:0 7px 25px #090d1a41; }
.primary:hover:not(:disabled) { background:#e8fa9c; }
.secondary, .icon-button { background:#101921eb; border-color:#e0ecf238; }
.secondary:hover:not(:disabled), .icon-button:hover { background:#28343b; border-color:#e0ecf277; }
.start { min-width: 162px; min-height: 50px; padding-inline: 20px; }
.active-location { display:flex; gap:9px; align-items:center; margin: .9rem 0 0; color:#e1e6e5; font-size:.8rem; font-weight:700; }
.active-location span { width:6px; height:6px; border-radius:50%; background:var(--lime); }
.map-list { display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap: 8px; align-self:end; }
.map { position:relative; display:flex; justify-content:end; flex-direction:column; align-items:flex-start; isolation:isolate; overflow:hidden; min-height:clamp(63px, 12vh, 106px); padding:10px 14px; border:1px solid #ffffff43; border-radius:6px; text-align:left; background: linear-gradient(0deg,#090f1be0,#131e2f30), var(--map-image, linear-gradient(152deg, transparent 52%, #fff1 53%, transparent 70%)), var(--map-color); background-size:cover; background-position:center; box-shadow:0 5px 28px #0002; }
.map::before { content:""; position:absolute; inset:0; border-radius:5px; pointer-events:none; box-shadow:inset 0 0 0 1px #0002; }
.map:hover, .map.selected { border-color:var(--lime); }
.map.selected::after { content:""; position:absolute; top:10px; right:10px; width:7px; height:7px; border-radius:50%; background:var(--lime); }
.map span { font-size:.68rem; text-transform:uppercase; letter-spacing:.1em; color:#f2f5f2c9; font-weight:650; }
.map b { font-size:clamp(.83rem,1.6vw,1.23rem); text-shadow:0 3px 10px #000; }
.coastal { --map-color:linear-gradient(115deg,#2b495c,#8c594b); }
.urban { --map-color:linear-gradient(115deg,#12152e,#56375e); }
.alpine { --map-color:linear-gradient(115deg,#2e4a55,#5b766d); }
.arid { --map-color:linear-gradient(115deg,#613a28,#9c6346); }
.hud { pointer-events:none; padding:var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); }
.hud-top { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.hud-world { display:grid; gap:5px; padding:6px 0; color:white; font-weight:760; font-size:clamp(.87rem, 1.72vw, 1.42rem); text-shadow:0 2px 13px #000, 0 1px 3px #000; }
.hud-world small { color:#eef7c6; font-size:.66rem; font-weight:850; letter-spacing:.13em; }
.hud-actions { display:flex; gap:8px; pointer-events:auto; }
.hud-actions b { color:var(--lime); font-size:.82em; }
#reverse { touch-action:none; }
#reverse.held { background:#475623; border-color:#d9f568; }
.instrument { width:clamp(155px, 23vw, 300px); position:absolute; bottom:var(--safe-bottom); left:50%; transform:translateX(-50%); border-radius:8px; padding:9px 13px 7px; background:linear-gradient(160deg,#0b1521e5,#081016da); border:1px solid #e3ecff31; box-shadow:0 7px 30px #0005; }
.readout, .rpm-caption, .speed-group, .gear-group { display:flex; align-items:baseline; }
.readout { justify-content:space-between; align-items:end; gap:10px; margin-bottom:6px; }
.speed-group { gap:5px; }
.speed-group strong { font-size:clamp(2rem, 5.75vw, 5.7rem); line-height:.82; font-weight:850; letter-spacing:-.055em; font-variant-numeric:tabular-nums; }
#unit { border:0; padding:6px 0; background:none; color:#e8eddf; pointer-events:auto; font-size:clamp(.58rem, 1.05vw, .92rem); font-weight:850; }
.gear-group { flex-direction:column; align-items:center; gap:1px; }
.gear-group small, .rpm-caption { font-size:clamp(.55rem, 1vw, .76rem); color:#c5d0d4; font-weight:750; letter-spacing:.06em; }
.gear-group strong { font-size:clamp(1.15rem, 2.9vw, 2.6rem); color:var(--lime); line-height:1; }
.rpm-track { height:5px; background:#ffffff25; border-radius:2px; overflow:hidden; }
#rpm-bar { width:100%; height:100%; transform:scaleX(.15); transform-origin:left; background:linear-gradient(90deg,#c3ec67,#e5f16a,#ffd258,#fc796a); }
.rpm-caption { justify-content:space-between; margin-top:4px; }
.telemetry { position:absolute; right:var(--safe-right); bottom:calc(var(--safe-bottom) + 56px); color:#f5ffecda; font:.67rem ui-monospace,monospace; text-shadow:0 2px 4px #000; }
.steer-pad { z-index:1; touch-action:none; }
.hud { z-index:2; }
.pedals { position:absolute; inset:0; pointer-events:none; z-index:3; }
.pedal { pointer-events:auto; touch-action:none; position:absolute; bottom:var(--safe-bottom); width:clamp(96px, 25vw, 280px); height:clamp(55px, 27vh, 145px); display:flex; align-items:end; gap:8px; font-size:.81rem; font-weight:800; border:1px solid #ffffff4a; border-top-color:#ffffff0c; border-radius:10px; background:linear-gradient(0deg,#0b1722a6,#0c192517); padding:12px; }
.pedal.left { left:var(--safe-left); }
.pedal.right { right:var(--safe-right); justify-content:end; }
.pedal:active, .pedal.held { background:linear-gradient(0deg,#bdde5968,#aac74613); border-color:#ddf77885; }
.pedal-bars { width:13px; height:15px; background:repeating-linear-gradient(0deg,#e1edee 0 1px,transparent 1px 4px); opacity:.8; }
.hud-hidden .instrument, .hud-hidden .hud-world, .hud-hidden .hud-actions, .hud-hidden .telemetry { visibility:hidden; }
.hud-hidden .pedal:not(.held) { border-color:transparent; background:transparent; color:transparent; }
.hud-hidden .pedal:not(.held) .pedal-bars { opacity:0; }
.restore-hud { position:absolute; z-index:4; top:var(--safe-top); right:var(--safe-right); opacity:.78; }
.toast { position:absolute; z-index:5; top:calc(var(--safe-top) + 55px); left:50%; transform:translateX(-50%); background:#0b151fee; border:1px solid #d5ec842e; border-radius:6px; padding:8px 13px; color:#edffc2; font-size:.87rem; font-weight:650; text-align:center; max-width:80%; pointer-events:none; }
.dialog-wrap, .rotate, .loading { position:absolute; z-index:7; inset:0; display:grid; place-items:center; padding:var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left); background:#080e15b5; }
.dialog { width:min(100%, 670px); max-height:100%; overflow:auto; overscroll-behavior:contain; touch-action:pan-y; border:1px solid #dce8ee38; border-radius:10px; background:#121b23; padding:clamp(14px, 3.1vw, 28px); box-shadow:0px 20px 65px #0009; }
.dialog-head { display:flex; justify-content:space-between; align-items:center; gap:12px; }
h2 { margin:0; font-size:clamp(1.28rem, 3.05vw, 2rem); letter-spacing:-.035em; line-height:1.1; }
.close { font-size:1.5rem; width:44px; padding:0; }
.dialog p { margin:11px 0; color:#c7d2d6; font-size:.95rem; line-height:1.42; }
.dialog-actions, .setup-drive { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.tilt-demo { display:flex; align-items:center; justify-content:center; gap:19px; color:#d2ef88; margin:4px 0; font-size:.72rem; font-weight:820; letter-spacing:.1em; }
.tilt-demo i { position:relative; display:block; width:38px; height:38px; border-radius:50%; border:3px solid #d9f56b; transform:rotate(0); }
.tilt-demo i::before { content:""; position:absolute; inset:13px 2px 0; border-top:2px solid #d9f56b; }
.tilt-demo i::after { content:""; position:absolute; width:2px; height:13px; background:#d9f56b; top:14px; left:15px; }
.dialog .motion-status { color:#e0fda2; min-height: 1.3em; margin:5px 0; text-align:center; }
.dialog .control-note { color:#aabac2; font-size:.8rem; margin-bottom:0; }
.settings-grid { display:grid; grid-template-columns:1fr 1fr; gap:9px 16px; margin-top:14px; }
.settings-grid label { min-height:42px; display:flex; justify-content:space-between; align-items:center; border-bottom:1px solid #ffffff16; padding:3px 0; gap:8px; color:#dbe4e7; font-size:.84rem; }
select { background:#26333e; color:#f1f3f5; border:1px solid #b9c7cc3b; border-radius:4px; min-height:33px; padding:3px; min-width:86px; max-width:64%; }
.range { display:inline-flex; align-items:center; gap:4px; }
.range input { width: min(12vw,100px); }
.range output { min-width:31px; text-align:right; color:#dbf772; font-variant-numeric:tabular-nums; }
input { accent-color:var(--lime); }
input[type=checkbox] { width:21px; height:21px; }
.loading { z-index:9; background:radial-gradient(ellipse at 65% 30%,#253641,#0b141c 70%); }
.loading > div, .rotate > div { width:min(390px, 100%); text-align:center; }
.loading .wordmark { justify-content:center; margin-bottom:18px; }
progress { display:block; width:100%; height:8px; margin:20px 0 12px; appearance:none; border:0; overflow:hidden; border-radius:4px; background:#ffffff26; }
progress::-webkit-progress-bar { background:#ffffff26; }
progress::-webkit-progress-value { background:var(--lime); }
progress::-moz-progress-bar { background:var(--lime); }
.loading p, .rotate p { color:#c4d0d4; line-height:1.4; }
.rotate { z-index:8; background:#0d1925f5; }
.rotation-icon { width:35px; height:23px; border:2px solid var(--lime); border-radius:5px; margin:0 auto 18px; transform:rotate(-23deg); }
@media (pointer:fine) {
  .pedal { height:70px; width:155px; }
  .telemetry { bottom:calc(var(--safe-bottom) + 80px); }
}
@media (max-height:480px) {
  :root { --safe-top:max(9px, env(safe-area-inset-top)); --safe-bottom:max(10px, env(safe-area-inset-bottom)); }
  .menu { gap:5px; }
  .menu-copy { margin-top:0; }
  .menu-subtitle { margin-bottom:8px; }
  .active-location { margin-top:8px; }
  .start { min-height:42px; }
  .map { min-height:51px; padding:6px 9px; }
  .map span { font-size:.59rem; }
  .dialog-head .close { min-height:35px; width:37px; }
  .dialog { padding-top:10px; padding-bottom:12px; }
  .dialog p { margin:6px 0; font-size:.84rem; }
  .dialog-actions, .setup-drive { margin-top:7px; }
  .settings-grid { gap:3px 12px; margin-top:7px; }
  .settings-grid label { min-height:32px; }
  .pedal { height: clamp(54px,22vh,100px); }
}
@media (max-width:620px) {
  .map-list { grid-template-columns:repeat(2,minmax(0, 1fr)); }
  .map { min-height:48px; }
  .settings-grid { grid-template-columns:1fr; }
  .range input { width:88px; }
  .hud-world { font-size:.81rem; }
  .hud-actions { gap:4px; }
  .label-button { padding-inline:8px; }
}
@media (max-width:430px) {
  .hud-world { max-width:27vw; }
  .hud-actions { gap:3px; }
  .hud-actions button { font-size:.75rem; }
  #camera-label { display:none; }
}
