:root {
  --ink: #f4f6f8;
  --ink-2: rgba(244, 246, 248, 0.7);
  --ink-3: rgba(244, 246, 248, 0.42);
  --glass: rgba(10, 12, 16, 0.42);
  --glass-2: rgba(10, 12, 16, 0.66);
  --line: rgba(255, 255, 255, 0.12);
  --accent: #5ff3ff;
  --glow: 0 0 6px var(--accent), 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent);
  --ok: #4fd18b;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #06080b; color: var(--ink);
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; user-select: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.38) 100%); }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 40; transition: opacity 0.35s ease; }
#fade.on { opacity: 1; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 5px; margin: 0 1px; border-radius: 5px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08); font: 500 11px/1.5 var(--mono); text-align: center; color: var(--ink); }
.brand { font-weight: 300; letter-spacing: 0.42em; font-size: 13px; color: var(--ink-2); }
.brand span { font-weight: 700; color: var(--ink); margin-left: 0.35em; }

/* ---------- intro (black, minimal, neon white) */
#intro { position: fixed; inset: 0; z-index: 20; overflow-y: auto; overflow-x: hidden; display: flex; justify-content: center;
  padding: clamp(24px, 6vh, 64px) 16px 190px;
  background: radial-gradient(ellipse 70% 60% at 50% 38%, rgba(26, 30, 36, 0.97) 0%, rgba(6, 7, 9, 0.99) 58%, #000 100%);
  transition: opacity 0.7s ease, visibility 0.7s; }
#intro.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.neon { color: #fff; text-shadow: 0 0 6px rgba(255, 255, 255, 0.55), 0 0 22px rgba(255, 255, 255, 0.22); }
.intro-inner { width: min(980px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; z-index: 2; }
.intro-inner > * { opacity: 0; transform: translateY(8px); transition: opacity 0.9s ease, transform 0.9s ease; }
body.ready .intro-inner > * { opacity: 1; transform: none; }
body.ready .intro-inner > *:nth-child(2) { transition-delay: 0.1s; } body.ready .intro-inner > *:nth-child(3) { transition-delay: 0.2s; }
body.ready .intro-inner > *:nth-child(4) { transition-delay: 0.3s; } body.ready .intro-inner > *:nth-child(5) { transition-delay: 0.4s; }
body.ready .intro-inner > *:nth-child(6) { transition-delay: 0.5s; } body.ready .intro-inner > *:nth-child(7) { transition-delay: 0.6s; }
#intro .brand { font-size: 15px; letter-spacing: 0.55em; margin-left: 0.55em; }
.tagline { font: 300 11px/1 var(--mono); letter-spacing: 0.4em; color: rgba(255, 255, 255, 0.45); margin-top: 14px; }
.sec-label { font: 200 34px/1 Inter, sans-serif; letter-spacing: 0.06em; margin: 44px 0 20px; }
.cards { display: grid; gap: 22px; width: 100%; }
.cards.three { grid-template-columns: repeat(3, 1fr); gap: clamp(14px, 3vw, 44px); }
.cards.four { grid-template-columns: repeat(4, 1fr); gap: clamp(12px, 2.4vw, 32px); width: min(860px, 100%); }
.card { position: relative; text-align: center; color: #fff; background: rgba(255, 255, 255, 0.012); cursor: pointer;
  border: 1.5px solid rgba(255, 255, 255, 0.5); border-radius: 26px; padding: 18px 14px;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.1), inset 0 0 10px rgba(255, 255, 255, 0.04);
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s, transform 0.25s; }
.cards.four .card { border-radius: 12px; padding: 26px 12px; }
.card:hover { border-color: rgba(255, 255, 255, 0.85); box-shadow: 0 0 16px rgba(255, 255, 255, 0.22), inset 0 0 14px rgba(255, 255, 255, 0.06); transform: translateY(-2px); }
.card.active { border-color: #fff; background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.45), 0 0 60px rgba(255, 255, 255, 0.12), inset 0 0 18px rgba(255, 255, 255, 0.12); }
.card .t { font-weight: 300; font-size: 17px; letter-spacing: 0.08em; text-transform: uppercase; }
.card.active .t { text-shadow: 0 0 6px rgba(255, 255, 255, 0.8), 0 0 18px rgba(255, 255, 255, 0.35); }
.card .s { font: 300 10.5px/1.4 var(--mono); color: rgba(255, 255, 255, 0.5); margin-top: 8px; letter-spacing: 0.08em; }
.card .d { display: none; }
.cta { margin-top: 46px; background: transparent; color: #fff; border: 1.5px solid #fff; padding: 14px 54px; border-radius: 999px;
  font: 400 14px/1 Inter, sans-serif; letter-spacing: 0.4em; text-indent: 0.4em;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.35), inset 0 0 12px rgba(255, 255, 255, 0.12); text-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
  transition: box-shadow 0.25s, background 0.25s, transform 0.2s; }
.cta:hover { background: rgba(255, 255, 255, 0.07); transform: translateY(-1px); box-shadow: 0 0 26px rgba(255, 255, 255, 0.6), 0 0 70px rgba(255, 255, 255, 0.18), inset 0 0 16px rgba(255, 255, 255, 0.2); }
.hint-keys { font-size: 11px; color: rgba(255, 255, 255, 0.35); margin-top: 14px; letter-spacing: 0.04em; }
#intro .fine { position: fixed; left: 18px; bottom: 12px; max-width: 360px; margin: 0; font-size: 10px; color: rgba(255, 255, 255, 0.28); line-height: 1.45; z-index: 2; text-align: left; }
#introFx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
#mascot { position: fixed; left: 50%; bottom: 8px; width: 150px; transform: translateX(-50%); z-index: 2; pointer-events: none;
  opacity: 0; transition: opacity 1.6s ease; }
body.ready #mascot.on { opacity: 1; animation: breathe 7s ease-in-out infinite 1.6s; }
@keyframes breathe { 0%, 100% { opacity: 0.88; } 50% { opacity: 0.5; } }
#mascot svg { width: 100%; overflow: visible; filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.75)) drop-shadow(0 0 12px rgba(255, 255, 255, 0.25)); }
#mascot .ln { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
#mascot .ln.thin { stroke-width: 1.6; opacity: 0.85; }
#mascot .pupil { fill: #fff; }
#mascot .eye { transform-box: fill-box; transform-origin: center; transition: transform 0.08s; }
#mascot .eye.blink { transform: scaleY(0.1); }

/* ---------- top bar */
#topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px; z-index: 10; pointer-events: none; opacity: 0; transition: opacity 0.6s; }
body.driving #topbar { opacity: 1; }
#topbar > * { pointer-events: auto; }
.tb-left { display: flex; align-items: center; gap: 14px; }
.world-tag { font: 400 10.5px/1 var(--mono); letter-spacing: 0.2em; color: var(--ink-3); text-transform: uppercase; }
.actions { display: flex; gap: 8px; align-items: center; }
.icon { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: grid; place-items: center; transition: background 0.2s; }
.icon:hover, .pill:hover { background: var(--glass-2); }
.icon svg { width: 19px; height: 19px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.pill { height: 38px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); transition: all 0.3s; }
.dot.on { background: var(--accent); box-shadow: var(--glow); }

/* ---------- HUD (Slow-Roads-style minimal + neon) */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; opacity: 0; transition: opacity 0.6s; font-family: var(--mono); }
body.driving #hud { opacity: 1; }
body.hud-off #hud, body.hud-off #topbar { opacity: 0 !important; }
.num { font-weight: 200; font-size: 44px; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.lbl { font-size: 9.5px; letter-spacing: 0.2em; color: var(--ink-2); margin-top: 6px; }
.sub { font-size: 10.5px; letter-spacing: 0.14em; color: var(--ink-3); margin-top: 6px; min-height: 1em; }
body.hud-neon .num { color: #fff; text-shadow: var(--glow); }
body.hud-neon .lbl { color: color-mix(in srgb, var(--accent) 70%, white); }
.h-odo { position: absolute; left: clamp(18px, 4vw, 48px); bottom: max(26px, env(safe-area-inset-bottom)); }
.h-speed { position: absolute; right: clamp(18px, 4vw, 48px); bottom: max(26px, env(safe-area-inset-bottom)); text-align: right; }
.h-speed .num { font-size: 64px; }
#steerViz { position: absolute; left: 50%; bottom: 0; width: 200px; height: 120px; transform: translateX(-50%); overflow: visible; }
#steerPath { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; opacity: 0.85; }
body.hud-neon #steerPath { stroke: var(--accent); filter: drop-shadow(0 0 4px var(--accent)); }
.h-right { position: absolute; right: clamp(18px, 4vw, 48px); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 12px; align-items: flex-end; }
.stat { display: grid; grid-template-columns: auto; justify-items: end; gap: 3px; }
.stat .k { font-size: 9px; letter-spacing: 0.24em; color: var(--ink-3); }
.stat .v { font-size: 12.5px; letter-spacing: 0.08em; color: var(--ink); font-variant-numeric: tabular-nums; }
body.hud-neon .stat .v { text-shadow: 0 0 6px color-mix(in srgb, var(--accent) 60%, transparent); }
.mini { width: 110px; height: 2px; background: rgba(255, 255, 255, 0.14); position: relative; overflow: hidden; border-radius: 2px; }
.mini i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.mini.dual i { left: 30%; }
.mini.dual i.regen { left: auto; right: 70%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
#airStat.empty .v { color: #ff5a5a; }
.lamps { display: flex; gap: 8px; font-size: 9.5px; letter-spacing: 0.12em; }
.lamps b { font-weight: 500; color: rgba(255, 255, 255, 0.16); transition: color 0.1s; }
.lamps b.on { color: #ffb02e; text-shadow: 0 0 8px #ffb02e; }
.lamps b#faLamp.on { color: var(--accent); text-shadow: var(--glow); }
#attitude { position: absolute; left: 50%; top: 50%; width: 320px; height: 320px; margin: -160px; opacity: 0; transition: opacity 0.25s; }
#attitude.on { opacity: 1; }
#timer { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); font-size: 22px; font-weight: 300; letter-spacing: 0.05em; text-align: center; }
#timer small { display: block; font-size: 10px; letter-spacing: 0.2em; color: var(--ink-3); margin-top: 4px; }
body.hud-neon #timer { text-shadow: var(--glow); }
#event { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%) scale(0.96); text-align: center; opacity: 0; transition: opacity 0.25s, transform 0.25s; }
#event.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#event .e1 { font: 700 34px/1.1 Inter, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }
#event .e2 { font-size: 11px; letter-spacing: 0.24em; color: var(--ink-2); margin-top: 8px; }
body.hud-neon #event .e1 { color: #fff; text-shadow: var(--glow); }
#keysHint { position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%); font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; text-align: center; transition: opacity 0.6s; white-space: nowrap; }

#toast { position: fixed; top: 64px; left: 50%; transform: translate(-50%, -8px); padding: 9px 16px; border-radius: 10px; background: var(--glass-2);
  border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-size: 13px; color: var(--ink-2);
  opacity: 0; transition: all 0.3s ease; z-index: 15; pointer-events: none; white-space: nowrap; }
#toast b { color: var(--ink); font-weight: 600; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- settings panel */
#panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100%); padding: 20px 20px 30px; z-index: 30; overflow-y: auto;
  background: rgba(10, 12, 16, 0.78); border-left: 1px solid var(--line); backdrop-filter: blur(24px) saturate(1.2); -webkit-backdrop-filter: blur(24px) saturate(1.2);
  transform: translateX(105%); transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
#panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.panel-head h2 { font-size: 19px; font-weight: 600; margin: 0; }
#panel h3 { font: 500 10px/1 var(--mono); letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); margin: 20px 0 9px; display: flex; justify-content: space-between; }
#panel h3 .val { color: var(--ink); letter-spacing: 0.04em; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 3px; border-radius: 11px; background: rgba(255, 255, 255, 0.06); }
.seg.two { grid-template-columns: repeat(2, 1fr); } .seg.three { grid-template-columns: repeat(3, 1fr); } .seg.five { grid-template-columns: repeat(5, 1fr); }
.seg button { border: 0; background: transparent; padding: 8px 2px; border-radius: 8px; font-size: 12px; font-weight: 500; color: var(--ink-2); transition: all 0.15s; }
.seg button:hover { color: var(--ink); }
.seg button.active { background: rgba(255, 255, 255, 0.92); color: #06080b; font-weight: 600; }
.hint { font-size: 12px; color: var(--ink-3); line-height: 1.5; margin: 8px 0 0; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.swatches { display: flex; gap: 9px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.45), transparent 45%), var(--c);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); transition: transform 0.15s; }
.swatches.small .swatch { width: 22px; height: 22px; background: var(--c); box-shadow: 0 0 10px var(--c); }
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--ink); }
.tog { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.tog input { appearance: none; flex: none; width: 34px; height: 20px; border-radius: 20px; background: rgba(255, 255, 255, 0.18); position: relative; cursor: pointer; transition: background 0.2s; margin: 0; }
.tog input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.tog input:checked { background: var(--accent); }
.tog input:checked::after { transform: translateX(14px); }
.selrow { display: flex; gap: 14px; margin-top: 8px; }
.selrow label { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
select { font: inherit; color: var(--ink); background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
select option { background: #15181d; }
.keys-table { margin-top: 18px; display: grid; gap: 7px; font-size: 11.5px; color: var(--ink-3); }

/* ---------- touch */
#touch { display: none; position: fixed; left: 0; right: 0; bottom: 0; padding: 0 16px max(18px, env(safe-area-inset-bottom)); z-index: 8; justify-content: space-between; align-items: flex-end; pointer-events: none; }
body.touch.driving #touch { display: flex; }
#touch .tl, #touch .tr { display: flex; gap: 10px; pointer-events: auto; align-items: flex-end; }
#touch button { width: 66px; height: 66px; border-radius: 18px; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 15px; font-weight: 600; touch-action: none; }
#touch button.on { background: rgba(255, 255, 255, 0.85); color: #06080b; }
#touch .gas { height: 104px; }
#touch .boost, #touch .lift { color: var(--accent); font-size: 12px; }
body.touch .h-odo, body.touch .h-speed { bottom: 130px; }
body.touch .h-right { display: none; }

@media (max-width: 760px) {
  .cards.three { grid-template-columns: 1fr; gap: 10px; } .cards.four { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .sec-label { font-size: 26px; margin: 28px 0 14px; }
  .card, .cards.four .card { padding: 14px 10px; }
  #mascot { width: 104px; } #intro .fine { display: none; }
  .h-speed .num { font-size: 46px; } .num { font-size: 34px; }
  #btnFull, #topbar .brand, .world-tag, #btnAP { display: none; }
  .h-right { display: none; }
}
