/* =========================================================
   APEX RUSH — UI
   ========================================================= */
:root {
  --bg: #070908;
  --bg-soft: #0e1210;
  --ink: #f2f5ee;
  --muted: #98a49b;
  --dim: #5f6b62;
  --lime: #c9a36f;
  --orange: #b85f49;
  --line: rgba(236, 245, 230, 0.14);
  --panel: rgba(8, 11, 9, 0.72);
  --font-display: "Barlow Condensed", "Arial Narrow", Impact, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
body { position: fixed; inset: 0; touch-action: none; }
button, input { font: inherit; }
button { color: inherit; }

#app { position: relative; width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  touch-action: none;
}
.grade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 35%, rgba(0,0,0,0.34) 100%),
    linear-gradient(to top, rgba(0,0,0,0.46), transparent 28%);
  mix-blend-mode: multiply;
}
.is-hidden { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* =========================================================
   SHARED CONTROLS
   ========================================================= */
.eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lime);
}
.btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.035);
  color: var(--ink);
  padding: 13px 18px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-align: left;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .18s;
}
.btn:hover, .btn:focus-visible { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,.32); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--lime); border-color: var(--lime); color: #0a0d08; }
.btn-primary:hover, .btn-primary:focus-visible { background: #d8bf96; border-color: #d8bf96; }
.btn-quiet { color: var(--muted); font-size: 15px; }
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid rgba(255,255,255,.28);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: rgba(255,255,255,.06);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
}
:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }

/* =========================================================
   MAIN MENU
   ========================================================= */
.menu-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  pointer-events: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.menu-shade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5,7,6,0.92) 0%, rgba(5,7,6,0.55) 26%, transparent 60%),
    linear-gradient(0deg, rgba(5,7,6,0.78) 0%, transparent 40%);
}
.brand { position: relative; z-index: 1; flex: none; max-width: 720px; pointer-events: none; }
.brand-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
}
.brand-kicker span { width: 34px; height: 1px; background: var(--lime); }
.brand h1 {
  margin: 8px 0 4px;
  font-family: var(--font-display);
  font-size: clamp(64px, 8.6vw, 126px);
  line-height: 0.78;
  font-weight: 800;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  text-shadow: 0 12px 60px rgba(0,0,0,.5);
}
.brand h1 span { display: block; margin-left: 0.42em; color: var(--lime); }
.brand-sub { margin: 16px 0 0; color: rgba(242,245,238,.74); font-size: clamp(12px, 1.1vw, 15px); letter-spacing: 0.02em; }
.menu-panel {
  position: relative;
  z-index: 1;
  align-self: flex-start;
  width: min(430px, 100%);
  margin-top: auto;
  margin-bottom: 16px;
  padding: 20px 22px 18px;
  pointer-events: auto;
  background:
    linear-gradient(135deg, rgba(201,163,111,0.08), transparent 32%),
    linear-gradient(160deg, rgba(11,15,12,0.92), rgba(7,10,8,0.84));
  border: 1px solid var(--line);
  border-top-color: rgba(201,163,111,.55);
  box-shadow: 0 30px 80px rgba(0,0,0,.46);
  backdrop-filter: blur(14px);
}
.menu-panel::before { content: ""; position: absolute; top: -1px; left: -1px; width: 72px; height: 3px; background: var(--lime); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.track-badge { color: var(--dim); font-family: var(--font-display); font-size: 10px; letter-spacing: .13em; }
.setting { margin-bottom: 14px; }
.setting > label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.setting > label b { color: var(--ink); font-weight: 600; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; background: rgba(0,0,0,.38); border: 1px solid rgba(255,255,255,.07); }
.segmented.four { grid-template-columns: repeat(4, 1fr); }
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 34px;
  padding: 5px 4px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  transition: background .16s, color .16s;
}
.segmented button:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.segmented button.is-active { background: var(--lime); color: #0a0d08; }
.setting-note { margin: 6px 0 0; color: var(--dim); font-size: 10px; line-height: 1.4; }
.volume-setting { margin-bottom: 16px; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, var(--lime) 0 var(--fill, 60%), rgba(255,255,255,.18) var(--fill, 60%) 100%); }
input[type="range"]::-moz-range-track { height: 2px; background: rgba(255,255,255,.18); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--lime); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; margin-top: -4.5px; border: 0; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(201,163,111,.16); }
input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: var(--lime); }
.start-btn {
  pointer-events: auto;
  width: min(380px, calc(100vw - 40px));
  min-height: 61px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px 10px 20px;
  border: 0;
  background: var(--lime);
  color: #080b07;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  transition: background .18s, transform .18s;
}
.start-btn:hover { background: #d8bf96; }
.start-btn:active { transform: translateY(1px); }
.start-label { display: flex; flex-direction: column; align-items: flex-start; font-family: var(--font-display); font-size: 23px; font-weight: 800; line-height: .95; letter-spacing: .055em; }
.start-label small { font-size: 9px; font-weight: 700; letter-spacing: .23em; opacity: .58; margin-bottom: 3px; }
.start-arrow { display: grid; place-items: center; width: 37px; height: 37px; border: 1px solid rgba(8,11,7,.28); border-radius: 50%; }
.start-arrow svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.menu-foot { margin: 10px 0 0; color: var(--dim); font-size: 10px; letter-spacing: .02em; }
.menu-footer {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 22px;
  align-items: center;
  flex: none;
  padding-top: 10px;
  color: rgba(216,225,212,.55);
  font-size: 10px;
  letter-spacing: .02em;
  pointer-events: none;
}
.menu-footer b { color: rgba(242,245,238,.82); font-weight: 500; }
.footer-credit { margin-left: auto; color: rgba(216,225,212,.28); font-family: var(--font-display); letter-spacing: .12em; }

/* =========================================================
   HUD
   ========================================================= */
.hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  font-family: var(--font-display);
  text-transform: uppercase;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.45));
}
.hud-top {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.hud-stats {
  display: flex;
  align-items: stretch;
  background: linear-gradient(90deg, rgba(5,8,6,.82), rgba(5,8,6,.35));
  border-left: 2px solid var(--lime);
  border-top: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
}
.stat { min-width: 88px; padding: 9px 14px 8px; border-right: 1px solid rgba(255,255,255,.08); }
.stat:last-child { border-right: 0; }
.stat-label { display: block; margin-bottom: 1px; color: var(--muted); font-size: 9px; font-weight: 600; letter-spacing: .17em; }
.stat-value { display: block; color: var(--ink); font-size: 31px; line-height: 1; font-weight: 700; letter-spacing: .01em; }
.stat-value em { color: var(--dim); font-size: 15px; font-style: normal; margin-left: 1px; }
.stat-time { min-width: 148px; }
.stat-time .stat-value { font-size: 22px; padding-top: 6px; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.map-card {
  position: relative;
  width: 134px;
  height: 134px;
  padding: 5px;
  background: rgba(5,8,6,.66);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 50%;
  backdrop-filter: blur(6px);
  overflow: hidden;
}
#minimap { width: 100%; height: 100%; display: block; border-radius: 50%; }
.map-meta {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 9px;
  display: flex;
  justify-content: space-between;
  color: rgba(201,163,111,.75);
  font-size: 8px;
  letter-spacing: .16em;
  text-shadow: 0 1px 3px #000;
}
.hud-buttons { display: flex; gap: 5px; pointer-events: auto; }
.icon-btn {
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.13);
  background: rgba(5,8,6,.56);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .16s, color .16s;
}
.icon-btn:hover { background: rgba(201,163,111,.92); color: #080a07; }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#btn-hud-sound svg path:first-child { fill: currentColor; stroke: none; }
#btn-hud-sound.is-muted .sound-wave { display: none; }
.hud-bottom {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}
.lap-card {
  min-width: 208px;
  padding: 10px 13px;
  background: linear-gradient(90deg, rgba(5,8,6,.8), rgba(5,8,6,.3));
  border-left: 2px solid rgba(255,255,255,.35);
  border-top: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(7px);
}
.lap-card-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; letter-spacing: .14em; }
.live-dot { color: var(--lime); }
.live-dot::before {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 8px var(--lime);
  animation: blink 1.25s infinite;
}
.lap-card > strong { display: block; margin: 2px 0 5px; font-size: 30px; line-height: 1; letter-spacing: .01em; }
.lap-card-foot { display: flex; justify-content: space-between; gap: 20px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.08); color: var(--dim); font-size: 9px; letter-spacing: .1em; }
.lap-card-foot b { color: rgba(242,245,238,.8); font-weight: 500; font-size: 10px; }
.speedo { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.speedo-dial {
  --p: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: 166px;
  height: 166px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 62%, rgba(255,255,255,.06) 63%, transparent 64%),
    conic-gradient(from 225deg, var(--lime) 0deg, var(--lime) calc(var(--p) * 2.7deg), rgba(255,255,255,.10) calc(var(--p) * 2.7deg) 270deg, transparent 270deg);
  filter: drop-shadow(0 6px 22px rgba(0,0,0,.38));
}
.speedo-dial::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 62%, rgba(15,20,16,.94) 0 42%, rgba(5,8,6,.86) 70%, transparent 71%);
  border: 1px solid rgba(255,255,255,.08);
}
.speedo-dial::after { content: ""; position: absolute; width: 2px; height: 9px; top: 11px; left: calc(50% - 1px); background: var(--lime); opacity: .7; }
.speedo-dial { transition: filter .18s ease; }
.speedo-dial.is-boosting { filter: drop-shadow(0 0 20px rgba(201,163,111,.55)); }
.speedo-dial.is-boosting::before { border-color: rgba(201,163,111,.35); }
.speedo-dial.is-boosting #hud-speed { color: #ead7b8; text-shadow: 0 0 18px rgba(201,163,111,.6); }
.speedo-face { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; transform: translateY(4px); }
.gear { display: grid; place-items: center; width: 23px; height: 23px; margin-bottom: -3px; border: 1px solid rgba(255,255,255,.18); color: var(--lime); font-size: 12px; line-height: 1; }
#hud-speed { font-size: 65px; line-height: .9; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.speedo-face .unit { color: var(--muted); font-size: 9px; letter-spacing: .18em; }
.speedo-caption { display: flex; gap: 5px; color: var(--dim); font-size: 8px; letter-spacing: .15em; }
.control-hint {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(220,230,216,.45);
  font-family: var(--font-body);
  font-size: 9px;
  letter-spacing: .02em;
  text-transform: none;
}
.control-hint span { margin-right: 7px; }
.control-hint kbd { color: rgba(242,245,238,.7); }
.tilt-note {
  position: absolute;
  top: 82px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 10px;
  background: rgba(5,8,6,.55);
  color: rgba(201,163,111,.8);
  font-size: 9px;
  letter-spacing: .12em;
  opacity: 0;
  transition: opacity .3s;
}
.tilt-note.is-visible { opacity: 1; }

/* =========================================================
   TOUCH CONTROLS
   ========================================================= */
.touch-controls {
  position: absolute;
  inset: auto 0 max(14px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
  pointer-events: none;
  touch-action: none;
}
.touch-steer, .touch-pedals { display: flex; align-items: flex-end; gap: 8px; pointer-events: none; }
.touch-btn {
  pointer-events: auto;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(7,10,8,.42);
  color: rgba(255,255,255,.88);
  backdrop-filter: blur(5px);
  transition: background .08s, transform .08s, border-color .08s;
}
.touch-btn:active, .touch-btn.is-active { background: rgba(201,163,111,.82); border-color: rgba(201,163,111,.9); color: #080b07; transform: scale(.96); }
.touch-btn.steer { width: 66px; height: 66px; border-radius: 50%; }
.touch-btn.steer svg { width: 30px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.touch-btn.pedal { width: 76px; height: 76px; border-radius: 50%; font-family: var(--font-display); font-size: 13px; font-weight: 700; letter-spacing: .08em; }
.touch-btn.gas { border-color: rgba(201,163,111,.55); background: rgba(201,163,111,.18); }
.touch-btn.brake { border-color: rgba(184,95,73,.55); background: rgba(184,95,73,.14); }
.touch-btn.brake:active { background: var(--orange); border-color: var(--orange); }

/* =========================================================
   COUNTDOWN / TOAST
   ========================================================= */
.countdown { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-transform: uppercase; }
.countdown span {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(130px, 23vw, 280px);
  line-height: .74;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -.04em;
  text-shadow: 0 10px 60px rgba(0,0,0,.5);
  animation: count-pulse .82s var(--ease) both;
}
.countdown span.is-go { color: var(--lime); font-size: clamp(90px, 16vw, 210px); }
.countdown small { margin-top: 18px; color: var(--lime); font-family: var(--font-display); font-size: 11px; font-weight: 700; letter-spacing: .34em; }
.toast {
  position: absolute;
  left: 50%;
  bottom: 110px;
  z-index: 30;
  transform: translate(-50%, 10px);
  max-width: min(90vw, 420px);
  padding: 9px 14px;
  border: 1px solid rgba(201,163,111,.4);
  background: rgba(5,8,6,.86);
  color: var(--ink);
  font-size: 11px;
  letter-spacing: .02em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   OVERLAYS / DIALOGS
   ========================================================= */
.screen.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3,5,4,.66);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  touch-action: pan-y;
}
.dialog {
  width: min(430px, 100%);
  padding: 28px;
  background: linear-gradient(140deg, rgba(201,163,111,.08), transparent 36%), #0a0e0b;
  border: 1px solid var(--line);
  border-top-color: rgba(201,163,111,.55);
  box-shadow: 0 40px 100px rgba(0,0,0,.65);
}
.dialog-head h2 { margin: 4px 0 4px; font-family: var(--font-display); font-size: 62px; line-height: .9; letter-spacing: -.02em; }
.dialog-head p { margin: 0 0 22px; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; flex-direction: column; gap: 6px; }
.dialog-actions .btn { width: 100%; }
.dialog-foot { display: flex; justify-content: space-between; gap: 14px; margin-top: 20px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--dim); font-size: 10px; }

/* =========================================================
   RESULTS
   ========================================================= */
.results-card {
  width: min(800px, 100%);
  padding: clamp(20px, 3.2vw, 34px);
  background: linear-gradient(125deg, rgba(201,163,111,.07), transparent 32%), #0a0e0b;
  border: 1px solid var(--line);
  border-top-color: rgba(201,163,111,.55);
  box-shadow: 0 40px 110px rgba(0,0,0,.68);
}
.results-head { display: flex; justify-content: space-between; gap: 22px; align-items: flex-start; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.results-head h2 { margin: 5px 0 0; font-family: var(--font-display); font-size: clamp(36px, 5vw, 64px); line-height: .9; letter-spacing: -.02em; }
.placement-badge { flex: none; min-width: 122px; padding: 10px 12px; border-left: 2px solid var(--lime); background: rgba(255,255,255,.035); }
.placement-badge span { display: block; color: var(--muted); font-family: var(--font-display); font-size: 9px; letter-spacing: .14em; }
.placement-badge strong { font-family: var(--font-display); font-size: 50px; line-height: .9; font-weight: 700; color: var(--lime); }
.placement-badge small { color: var(--dim); font-size: 16px; }
.results-table-wrap { overflow-x: auto; margin: 12px 0 4px; }
.results-table { width: 100%; border-collapse: collapse; min-width: 540px; }
.results-table th { padding: 10px 9px 8px; text-align: left; color: var(--dim); font-family: var(--font-display); font-size: 10px; font-weight: 600; letter-spacing: .13em; border-bottom: 1px solid var(--line); }
.results-table td { padding: 12px 9px; border-bottom: 1px solid rgba(255,255,255,.06); color: rgba(242,245,238,.82); font-family: var(--font-display); font-size: 17px; letter-spacing: .02em; }
.results-table td:first-child { width: 42px; color: var(--dim); }
.results-table tr.is-player td { background: rgba(201,163,111,.08); color: var(--ink); }
.results-table tr.is-player td:first-child { color: var(--lime); }
.results-table .driver-dot { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; vertical-align: 1px; }
.results-table .proj { color: var(--dim); font-size: 11px; margin-left: 4px; font-family: var(--font-body); }
.results-table td.mono { font-size: 14px; }
.results-actions { display: flex; gap: 8px; margin-top: 20px; }
.results-actions .btn-primary { flex: 1.25; }
.results-actions .btn { flex: 1; text-align: center; }
.results-foot { margin-top: 14px; color: var(--dim); font-size: 11px; }

/* =========================================================
   LOADING / ROTATE / DEBUG
   ========================================================= */
.loading {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(80% 80% at 50% 40%, #121913, #060806 70%);
  transition: opacity .5s, visibility .5s;
}
.loading.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-mark { font-family: var(--font-display); font-size: clamp(42px, 6vw, 70px); font-weight: 800; letter-spacing: -.03em; line-height: .8; }
.loading-mark span { color: var(--lime); }
.loading-bar { width: min(240px, 60vw); height: 2px; margin: 24px 0 12px; background: rgba(255,255,255,.12); overflow: hidden; }
#loading-progress { display: block; width: 8%; height: 100%; background: var(--lime); transition: width .35s var(--ease); }
.loading p { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: .04em; }
.loading small { margin-top: 8px; color: var(--dim); font-family: var(--font-display); font-size: 9px; letter-spacing: .15em; }
.rotate-hint {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px;
  text-align: center;
  background: #070a08;
}
.phone-icon { width: 42px; height: 68px; border: 2px solid var(--lime); border-radius: 8px; margin-bottom: 12px; transform: rotate(90deg); animation: tilt-phone 1.6s infinite var(--ease); }
.rotate-hint strong { font-family: var(--font-display); font-size: 28px; letter-spacing: .04em; }
.rotate-hint span { max-width: 280px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.debug-panel {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 35;
  width: 330px;
  padding: 10px 12px;
  background: rgba(3,6,4,.85);
  border: 1px solid rgba(201,163,111,.24);
  color: rgba(230,240,225,.8);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.5;
  pointer-events: none;
}
.debug-head { display: flex; justify-content: space-between; margin-bottom: 5px; color: var(--lime); font-family: var(--font-display); font-size: 10px; letter-spacing: .1em; }
.debug-panel pre { margin: 0; white-space: pre-wrap; }
.debug-panel p { margin: 7px 0 0; color: var(--dim); font-family: var(--font-body); font-size: 9px; }

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes count-pulse {
  0% { opacity: 0; transform: scale(1.35); filter: blur(8px); }
  22% { opacity: 1; transform: scale(1); filter: blur(0); }
  100% { opacity: .92; transform: scale(.94); }
}
@keyframes tilt-phone {
  0%, 25% { transform: rotate(0deg); }
  65%, 100% { transform: rotate(90deg); }
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 900px) {
  .menu-screen { padding: 18px 20px; }
  .brand h1 { font-size: clamp(56px, 12vw, 88px); }
  .brand h1 span { margin-left: .28em; }
  .brand-sub { margin-top: 10px; font-size: 12px; }
  .menu-panel { width: min(400px, 100%); padding: 16px 17px 14px; }
  .panel-head { margin-bottom: 12px; }
  .setting { margin-bottom: 11px; }
  .segmented button { min-height: 31px; font-size: 12px; }
  .menu-footer { gap: 12px; flex-wrap: wrap; font-size: 9px; }
  .footer-credit { display: none; }
  .hud-stats .stat { min-width: 70px; padding: 7px 10px; }
  .stat-value { font-size: 25px; }
  .stat-time { min-width: 118px; }
  .stat-time .stat-value { font-size: 17px; padding-top: 5px; }
  .map-card { width: 108px; height: 108px; }
  .speedo-dial { width: 132px; height: 132px; }
  #hud-speed { font-size: 50px; }
  .lap-card { min-width: 175px; padding: 8px 10px; }
  .lap-card > strong { font-size: 25px; }
  .control-hint { display: none; }
  .results-card { padding: 20px; }
}

@media (max-width: 640px) {
  .menu-screen { padding: 10px 14px; }
  .brand-kicker { font-size: 9px; }
  .brand h1 { font-size: clamp(44px, 13vw, 70px); line-height: .76; }
  .brand-sub { display: none; }
 .menu-panel { padding: 12px 14px 12px; margin-bottom: 6px; }
 .panel-head { margin-bottom: 10px; }
 .setting { margin-bottom: 9px; }
   .menu-footer { display: none; }
  .menu-foot { font-size: 9px; }
  .hud-top { top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); }
  .hud-stats { gap: 0; }
  .hud-stats .stat { min-width: 58px; padding: 6px 7px; }
  .stat-label { font-size: 7px; letter-spacing: .1em; }
  .stat-value { font-size: 21px; }
  .stat-value em { font-size: 11px; }
  .stat-time { min-width: 92px; }
  .stat-time .stat-value { font-size: 14px; padding-top: 5px; }
  .map-card { width: 86px; height: 86px; }
  .map-meta { display: none; }
  .icon-btn { width: 28px; height: 28px; }
  .hud-bottom { left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); }
  .lap-card { min-width: 150px; }
  .lap-card > strong { font-size: 22px; }
  .speedo-dial { width: 108px; height: 108px; }
  #hud-speed { font-size: 41px; }
  .speedo-face .unit { font-size: 7px; }
  .gear { width: 18px; height: 18px; font-size: 9px; }
  .speedo-caption { display: none; }
  .results-head { flex-direction: column; }
  .placement-badge { align-self: stretch; display: flex; align-items: baseline; justify-content: space-between; }
  .placement-badge strong { font-size: 38px; }
  .results-actions { flex-direction: column-reverse; }
  .results-actions .btn { width: 100%; text-align: center; }
  .dialog { padding: 22px 18px; }
  .dialog-head h2 { font-size: 50px; }
  .touch-btn.steer { width: 60px; height: 60px; }
  .touch-btn.pedal { width: 68px; height: 68px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .menu-screen { padding: 12px 18px; }
  .brand-kicker { display: none; }
  .brand h1 { font-size: 48px; line-height: .78; margin-top: 0; }
  .brand h1 span { display: inline; margin-left: .18em; }
  .brand-sub { display: none; }
  .menu-panel { width: 380px; padding: 11px 13px; margin-bottom: 8px; }
  .panel-head { margin-bottom: 7px; }
  .track-badge { display: none; }
  .setting { margin-bottom: 7px; }
  .setting > label { margin-bottom: 4px; font-size: 10px; }
  .segmented button { min-height: 26px; font-size: 11px; }
  .setting-note { display: none; }
  .volume-setting { margin-bottom: 9px; }
  .start-btn { min-height: 47px; }
  .start-label { font-size: 19px; }
  .menu-foot { display: none; }
  .menu-footer { padding-top: 4px; }
  .hud-top { top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); }
  .hud-stats .stat { min-width: 62px; padding: 5px 8px; }
  .stat-label { font-size: 7px; }
  .stat-value { font-size: 22px; }
  .stat-time { min-width: 110px; }
  .stat-time .stat-value { font-size: 16px; padding-top: 4px; }
  .map-card { width: 84px; height: 84px; }
  .icon-btn { width: 26px; height: 26px; }
  .hud-bottom { bottom: max(8px, env(safe-area-inset-bottom)); }
  .lap-card { min-width: 165px; padding: 6px 9px; }
  .lap-card > strong { font-size: 22px; margin: 0 0 3px; }
  .lap-card-foot { padding-top: 3px; }
  .speedo-dial { width: 95px; height: 95px; }
  #hud-speed { font-size: 37px; }
  .speedo-face .unit { font-size: 7px; }
  .gear { display: none; }
  .speedo-caption { display: none; }
  .touch-btn.steer { width: 56px; height: 56px; }
  .touch-btn.pedal { width: 64px; height: 64px; font-size: 11px; }
  .touch-controls { bottom: max(8px, env(safe-area-inset-bottom)); }
  .dialog { padding: 18px 22px; }
  .dialog-head h2 { font-size: 42px; }
  .dialog-head p { margin-bottom: 14px; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .dialog-actions .btn-primary { grid-column: span 2; }
  .dialog-foot { margin-top: 12px; }
  .results-card { padding: 16px 20px; }
  .results-head { padding-bottom: 10px; }
  .results-head h2 { font-size: 37px; }
  .results-table td { padding: 7px 8px; font-size: 15px; }
  .results-table th { padding: 6px 8px; }
  .results-actions { margin-top: 10px; }
  .results-foot { margin-top: 8px; }
}

@media (hover: none) and (pointer: coarse) {
  .control-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}




/* =========================================================
MODERNES RENN-HUD · TACHO, BOOST, SEKTOREN
========================================================= */
#hud {
 --hud-scale: 1;
}
.hud-top, .hud-bottom {
 transform: scale(var(--hud-scale));
 transition: transform .22s var(--ease);
}
.hud-top { transform-origin: top left; }
.hud-bottom { transform-origin: bottom center; }

.timing-main { position: relative; }
.timing-main > strong {
 display: block;
 margin: 3px 0 6px;
 font-size: 32px;
 line-height: .96;
 letter-spacing: .01em;
 font-variant-numeric: tabular-nums;
}
.lap-card { min-width: 226px; }
.sector-row {
 display: grid;
 grid-template-columns: repeat(3, minmax(0, 1fr));
 gap: 6px;
 padding: 7px 0 5px;
 border-top: 1px solid rgba(255,255,255,.08);
}
.sector {
 display: flex;
 align-items: baseline;
 gap: 4px;
 color: var(--dim);
 font-size: 8px;
 letter-spacing: .12em;
}
.sector b { color: var(--muted); font-size: 9px; font-weight: 500; letter-spacing: .02em; }
.sector.is-best b { color: #789181; }
.sector.is-record b { color: #8b7182; }
.sector.is-slow b { color: #c9a36f; }
.sector.is-empty b { color: var(--dim); }
.gap-row {
 display: flex;
 align-items: center;
 justify-content: space-between;
 gap: 10px;
 padding-top: 4px;
 color: var(--dim);
 font-size: 8px;
 letter-spacing: .08em;
}
.gap-row b { color: rgba(242,245,238,.78); font-size: 9px; font-weight: 500; }
.gap-ahead { color: #b85f49; }
.gap-behind { color: #789181; }

.speedo { gap: 7px; }
.speedo-dial {
 --p: 0;
 --needle: 0;
 width: 176px;
 height: 176px;
 background:
  radial-gradient(circle at 50% 50%, transparent 58%, rgba(255,255,255,.045) 59%, transparent 60%),
  conic-gradient(from 225deg, var(--lime) 0deg, var(--lime) calc(var(--p) * 2.7deg), rgba(255,255,255,.09) calc(var(--p) * 2.7deg) 270deg, transparent 270deg);
 box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 18px 48px rgba(0,0,0,.5);
}
.speedo-dial::before { inset: 9px; background: radial-gradient(circle at 50% 58%, rgba(14,19,15,.97) 0 44%, rgba(4,7,5,.93) 72%, transparent 73%); }
.speedo-dial::after {
 width: 2px;
 height: 52px;
 top: 25px;
 left: calc(50% - 1px);
 background: linear-gradient(to bottom, var(--lime), rgba(201,163,111,.16));
 transform-origin: 50% 100%;
 transform: rotate(var(--needle));
 box-shadow: 0 0 10px rgba(201,163,111,.6);
 transition: transform .12s linear;
}
.redline-band {
 position: absolute;
 inset: 7px;
 border-radius: 50%;
 background: conic-gradient(from 225deg, transparent 0deg 226deg, rgba(184,95,73,.58) 226deg 270deg, transparent 270deg);
 -webkit-mask: radial-gradient(circle, transparent 0 63%, #000 64% 73%, transparent 74%);
 mask: radial-gradient(circle, transparent 0 63%, #000 64% 73%, transparent 74%);
 pointer-events: none;
 opacity: .9;
}
.speedo-face { transform: translateY(6px); }
.speedo-face .gear {
 width: 26px;
 height: 26px;
 margin-bottom: -1px;
 border-color: rgba(201,163,111,.3);
 background: rgba(201,163,111,.08);
 font-size: 13px;
}
#hud-speed { font-size: 68px; }
.rpm-row {
 display: flex;
 align-items: baseline;
 gap: 3px;
 margin-top: 3px;
 color: var(--dim);
 line-height: 1;
}
.rpm-row b { color: rgba(242,245,238,.78); font-size: 10px; font-weight: 500; }
.rpm-row em { font-style: normal; font-size: 7px; letter-spacing: .16em; }
.speedo-dial.is-redline { filter: drop-shadow(0 0 18px rgba(184,95,73,.3)); }
.speedo-dial.is-redline #hud-speed { color: #d4a08d; }
.speedo-dial.is-redline::after { background: linear-gradient(to bottom, #b85f49, rgba(184,95,73,.15)); box-shadow: 0 0 12px rgba(184,95,73,.7); }
.speedo-dial.is-shifting { filter: drop-shadow(0 0 14px rgba(201,163,111,.32)); }

.boost-meter {
 width: 176px;
 padding: 6px 8px 7px;
 background: rgba(5,8,6,.64);
 border: 1px solid rgba(255,255,255,.08);
 border-left: 2px solid color-mix(in srgb, var(--boost-color, #789181) 70%, transparent);
 backdrop-filter: blur(6px);
 transition: border-color .18s ease, box-shadow .18s ease;
}
.boost-meta {
 display: flex;
 align-items: center;
 justify-content: space-between;
 margin-bottom: 5px;
 color: var(--dim);
 font-size: 7px;
 letter-spacing: .14em;
}
.boost-meta b { color: var(--boost-color, #789181); font-size: 8px; font-weight: 600; letter-spacing: .08em; }
.boost-track {
 position: relative;
 height: 7px;
 overflow: hidden;
 background: rgba(255,255,255,.07);
}
.boost-track i {
 position: absolute;
 top: 0; bottom: 0;
 width: 1px;
 background: rgba(5,8,6,.86);
}
.boost-track i:nth-of-type(1) { left: 33.333%; }
.boost-track i:nth-of-type(2) { left: 66.666%; }
.boost-fill {
 width: 0%;
 height: 100%;
 background: linear-gradient(90deg, #547d92, #789181);
 box-shadow: 0 0 12px rgba(120,145,129,.55);
 transition: width .16s ease, background .2s ease;
}
.boost-meter[data-level="1"] { --boost-color: #547d92; }
.boost-meter[data-level="1"] .boost-fill { background: linear-gradient(90deg, #547d92, #89a9b5); box-shadow: 0 0 12px rgba(84,125,146,.6); }
.boost-meter[data-level="2"] { --boost-color: #b85f49; }
.boost-meter[data-level="2"] .boost-fill { background: linear-gradient(90deg, #b85f49, #c9a36f); box-shadow: 0 0 12px rgba(184,95,73,.65); }
.boost-meter[data-level="3"] { --boost-color: #8b7182; }
.boost-meter[data-level="3"] .boost-fill { background: linear-gradient(90deg, #75677e, #b6a5b4); box-shadow: 0 0 16px rgba(139,113,130,.7); }
.boost-meter.is-charging { box-shadow: 0 0 22px rgba(201,163,111,.16); }
.boost-meter.is-boosting .boost-fill { animation: boostPulse .32s infinite alternate; }
@keyframes boostPulse { from { filter: brightness(1); } to { filter: brightness(1.65); } }
.speedo-caption { color: rgba(152,164,155,.6); }

/* =========================================================
MENÜ · GLASS, PAINT, SETTINGS, ANIMATIONEN
========================================================= */
.menu-panel {
 background: linear-gradient(145deg, rgba(10,14,11,.76), rgba(7,10,8,.56));
 border: 1px solid rgba(255,255,255,.12);
 box-shadow: 0 28px 80px rgba(0,0,0,.52), inset 0 1px 0 rgba(255,255,255,.08);
 backdrop-filter: blur(18px) saturate(130%);
 -webkit-backdrop-filter: blur(18px) saturate(130%);
 animation: panelIn .7s var(--ease) both;
}
@keyframes panelIn {
 from { opacity: 0; transform: translateY(20px) scale(.985); }
 to { opacity: 1; transform: none; }
}
.menu-panel .setting { margin-top: 12px; }
.setting-grid {
 display: grid;
 grid-template-columns: 1.35fr .8fr;
 gap: 12px;
 align-items: end;
}
.setting-grid .setting { min-width: 0; }
.toggle-setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toggle-btn {
 min-width: 49px;
 border: 1px solid rgba(201,163,111,.35);
 background: rgba(201,163,111,.1);
 color: var(--lime);
 padding: 6px 9px;
 font-family: var(--font-mono);
 font-size: 10px;
 letter-spacing: .08em;
 cursor: pointer;
}
.toggle-btn[aria-pressed="false"] { border-color: rgba(255,255,255,.12); background: rgba(255,255,255,.03); color: var(--dim); }
.paint-setting { margin-top: 12px; }
.paint-row { display: flex; gap: 7px; flex-wrap: wrap; }
.paint-swatch {
 width: 25px;
 height: 25px;
 padding: 0;
 border: 2px solid rgba(255,255,255,.16);
 border-radius: 50%;
 background: var(--swatch);
 box-shadow: inset 0 0 0 2px rgba(4,7,5,.72);
 cursor: pointer;
 transition: transform .15s var(--ease), border-color .15s ease;
}
.paint-swatch:hover { transform: scale(1.12); }
.paint-swatch.is-active { border-color: #fff; box-shadow: 0 0 0 2px rgba(201,163,111,.62), inset 0 0 0 2px rgba(4,7,5,.72); }
.paint-setting label b { color: var(--ink); font-weight: 500; letter-spacing: .02em; }
.start-btn { transition: transform .18s var(--ease), background .18s ease, box-shadow .18s ease; }
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 42px rgba(201,163,111,.16); }
.start-btn:active { transform: translateY(0); }

.countdown span { animation: countPop .72s var(--ease) both; }
.countdown.is-pop span { animation: none; }
@keyframes countPop {
 0% { transform: scale(1.45); opacity: 0; filter: blur(6px); }
 45% { transform: scale(1); opacity: 1; filter: blur(0); }
 100% { transform: scale(.96); opacity: .92; }
}
#results:not(.is-hidden) .results-card { animation: resultsIn .55s var(--ease) both; }
@keyframes resultsIn {
 from { opacity: 0; transform: translateY(26px) scale(.97); }
 to { opacity: 1; transform: none; }
}
#results:not(.is-hidden) .placement-badge { animation: badgePop .7s .12s var(--ease) both; }
@keyframes badgePop {
 0% { transform: scale(.7) rotate(-4deg); opacity: 0; }
 65% { transform: scale(1.06) rotate(1deg); opacity: 1; }
 100% { transform: scale(1); }
}
#results:not(.is-hidden) .results-table tbody tr { animation: podiumIn .48s var(--ease) both; }
#results:not(.is-hidden) .results-table tbody tr:nth-child(1) { animation-delay: .16s; }
#results:not(.is-hidden) .results-table tbody tr:nth-child(2) { animation-delay: .24s; }
#results:not(.is-hidden) .results-table tbody tr:nth-child(3) { animation-delay: .32s; }
#results:not(.is-hidden) .results-table tbody tr:nth-child(4) { animation-delay: .40s; }
@keyframes podiumIn {
 from { opacity: 0; transform: translateX(-16px); }
 to { opacity: 1; transform: none; }
}

/* Touch: größere Extras */
.touch-extra {
 position: absolute;
 left: 50%;
 bottom: 22px;
 transform: translateX(-50%);
 display: flex;
 gap: 9px;
}
.touch-btn.extra {
 width: 66px;
 height: 46px;
 border-radius: 13px;
 font-size: 9px;
 letter-spacing: .08em;
}
.touch-btn.extra.boost { color: #111; background: rgba(201,163,111,.82); border-color: rgba(201,163,111,.94); }
.touch-btn.extra.is-active { transform: translateY(2px) scale(.97); }

@media (max-width: 700px) {
 .hud-top, .hud-bottom { transform-origin: top center; }
 .hud-bottom { transform-origin: bottom center; }
 .lap-card { min-width: 168px; padding: 7px 9px; }
 .timing-main > strong { font-size: 23px; }
 .sector-row { gap: 4px; padding: 5px 0 3px; }
 .gap-row { font-size: 7px; }
 .speedo-dial { width: 124px; height: 124px; }
 #hud-speed { font-size: 46px; }
 .speedo-face .gear { width: 20px; height: 20px; font-size: 10px; }
 .rpm-row b { font-size: 8px; }
 .rpm-row em { font-size: 6px; }
 .boost-meter { width: 124px; padding: 5px 6px; }
 .boost-meta { font-size: 6px; margin-bottom: 4px; }
 .speedo-caption { display: none; }
 .touch-btn.extra { width: 58px; height: 42px; }
 .touch-extra { bottom: max(10px, env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
 .lap-card { min-width: 145px; }
 .timing-main > strong { font-size: 20px; }
 .speedo-dial { width: 104px; height: 104px; }
 #hud-speed { font-size: 38px; }
 .speedo-dial::after { height: 34px; top: 18px; }
 .boost-meter { width: 108px; }
 .sector.is-empty { display: none; }
}

@media (prefers-reduced-motion: reduce) {
 .menu-panel, .countdown span, #results .results-card, #results .placement-badge, #results tbody tr, .hud-top, .hud-bottom {
  animation: none !important;
  transition: none !important;
 }
}

/* Kompaktes Setup auf niedrigen Desktop-/Tablet-Displays, damit Start immer sichtbar bleibt. */
@media (min-width: 901px) and (max-height: 980px) {
 .menu-screen { padding: 18px 28px; }
 .brand-sub { display: none; }
 .brand h1 { font-size: clamp(56px, 7.4vw, 88px); margin-bottom: 2px; }
 .menu-panel { width: min(424px, 100%); padding: 12px 16px 12px; margin-top: 12px; margin-bottom: 6px; }
 .panel-head { margin-bottom: 8px; }
 .menu-panel .setting { margin-top: 0; margin-bottom: 8px; }
 .setting > label { margin-bottom: 4px; font-size: 11px; }
 .segmented button { min-height: 29px; font-size: 12px; }
 .volume-setting { margin-bottom: 10px; }
 .paint-setting { margin-top: 8px; }
 .start-btn { min-height: 52px; margin-top: 12px; }
 .menu-foot { margin-top: 6px; }
 .menu-footer { padding-top: 6px; font-size: 9px; }
}

/* Touch-HUD: Lenkung/Pedale bleiben unten, Tacho rueckt darueber, Rundenkarte nach oben. */
#hud.is-touch .lap-card {
 position: fixed;
 top: calc(max(10px, env(safe-area-inset-top)) + 84px);
 left: max(10px, env(safe-area-inset-left));
 z-index: 1;
 min-width: 150px;
 padding: 6px 9px;
 background: linear-gradient(90deg, rgba(5,8,6,.86), rgba(5,8,6,.48));
 border-left: 2px solid var(--lime);
 border-top: 1px solid rgba(255,255,255,.08);
}
#hud.is-touch .hud-bottom {
 left: auto;
 right: max(14px, env(safe-area-inset-right));
 bottom: max(164px, calc(env(safe-area-inset-bottom) + 164px));
 width: auto;
 justify-content: flex-end;
 transform: none;
}
#hud.is-touch .speedo { transform: scale(var(--hud-scale)); transform-origin: bottom right; }
body.is-touch .touch-extra {
 flex-direction: column;
 gap: 6px;
 bottom: max(20px, env(safe-area-inset-bottom));
}
body.is-touch .touch-btn.extra { width: 64px; height: 42px; font-size: 8px; }

@media (orientation: landscape) and (max-height: 560px) {
 #hud.is-touch .lap-card { top: calc(max(8px, env(safe-area-inset-top)) + 64px); min-width: 136px; padding: 4px 7px; }
 #hud.is-touch .hud-bottom {
 left: 50%;
 right: auto;
 bottom: max(120px, calc(env(safe-area-inset-bottom) + 120px));
 transform: none;
 }
 #hud.is-touch .speedo { transform: translateX(-50%) scale(var(--hud-scale)); transform-origin: bottom center; }
 body.is-touch .touch-extra { flex-direction: row; gap: 8px; bottom: max(22px, env(safe-area-inset-bottom)); }
 body.is-touch .touch-btn.extra { width: 62px; height: 40px; }
}

@media (max-width: 400px) {
 body.is-touch .touch-extra { gap: 5px; }
 body.is-touch .touch-btn.extra { width: 56px; height: 40px; font-size: 7px; }
 #hud.is-touch .lap-card { min-width: 138px; }
}

@media (max-width: 360px) {
 .touch-controls { padding: 0 8px; }
 .touch-btn.steer { width: 50px; height: 50px; }
 .touch-btn.pedal { width: 58px; height: 58px; font-size: 10px; }
 #hud.is-touch .touch-btn.extra { width: 46px; height: 36px; font-size: 6px; }
 #hud.is-touch .touch-extra { gap: 4px; }
 #hud.is-touch .touch-steer, .touch-pedals { gap: 6px; }
}

/* =========================================================
KOMPAKTES RACE-HUD · nur Runde, Position, Karte, Tacho
========================================================= */
#hud .hud-top { gap: 12px; }
#hud .race-readout {
display: flex;
align-items: stretch;
background: linear-gradient(135deg, rgba(4,7,5,.34), rgba(4,7,5,.02));
border: 1px solid rgba(255,255,255,.07);
border-left: 2px solid var(--lime);
backdrop-filter: blur(10px);
clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 0 100%);
}
#hud .race-lap,
#hud .race-pos {
display: flex;
align-items: baseline;
padding: 8px 12px 7px;
font-family: var(--font-display);
line-height: .84;
}
#hud .race-lap { border-right: 1px solid rgba(255,255,255,.08); }
#hud .race-lap span,
#hud .race-pos span {
color: var(--ink);
font-size: 40px;
font-weight: 800;
letter-spacing: -.03em;
text-shadow: 0 3px 18px rgba(0,0,0,.55);
}
#hud .race-lap em {
margin-left: 1px;
color: var(--muted);
font-size: 21px;
font-style: normal;
font-weight: 700;
}
#hud .race-pos em {
margin-right: 3px;
color: var(--lime);
font-size: 14px;
font-style: normal;
font-weight: 700;
letter-spacing: .05em;
}
#hud .map-card {
width: 250px;
height: 250px;
padding: 0;
background: radial-gradient(circle at 50% 50%, rgba(4,7,5,.04), rgba(4,7,5,.2));
border: 1px solid rgba(255,255,255,.1);
box-shadow: inset 0 0 28px rgba(0,0,0,.16);
backdrop-filter: blur(4px);
}
#hud #minimap { opacity: .9; filter: drop-shadow(0 4px 8px rgba(0,0,0,.35)); }
#hud .hud-bottom { justify-content: center; align-items: flex-end; }
#hud .speedo { align-items: center; gap: 5px; }
#hud .speedo-dial { width: 188px; height: 188px; }
#hud .speedo-dial::before {
inset: 8px;
background: radial-gradient(circle at 50% 58%, rgba(10,15,11,.52) 0 44%, rgba(4,7,5,.2) 71%, transparent 72%);
border: 1px solid rgba(255,255,255,.08);
backdrop-filter: blur(11px) saturate(.85);
box-shadow: inset 0 0 38px rgba(0,0,0,.22);
}
#hud #hud-speed {
font-size: 76px;
text-shadow: 0 4px 26px rgba(0,0,0,.7), 0 1px 0 rgba(0,0,0,.45);
}
#hud .boost-meter {
width: 184px;
padding: 6px 9px 7px;
background: rgba(5,8,6,.24);
border-color: rgba(255,255,255,.09);
backdrop-filter: blur(10px);
}
#hud .boost-track { background: rgba(255,255,255,.12); }
#hud .speedo-caption { display: none; }

@media (max-width: 900px) {
#hud .map-card { width: 210px; height: 210px; }
#hud .speedo-dial { width: 164px; height: 164px; }
#hud #hud-speed { font-size: 64px; }
#hud .boost-meter { width: 160px; }
}

@media (max-width: 640px) {
#hud .hud-top { gap: 8px; }
#hud .race-lap, #hud .race-pos { padding: 7px 9px 6px; }
#hud .race-lap span, #hud .race-pos span { font-size: 30px; }
#hud .race-lap em { font-size: 16px; }
#hud .race-pos em { font-size: 11px; margin-right: 2px; }
#hud .map-card { width: 176px; height: 176px; }
#hud .hud-bottom { justify-content: center; }
#hud .speedo-dial { width: 132px; height: 132px; }
#hud #hud-speed { font-size: 50px; }
#hud .boost-meter { width: 128px; padding: 5px 6px; }
#hud.is-touch .hud-bottom {
left: 50%;
right: auto;
bottom: max(152px, calc(env(safe-area-inset-bottom) + 146px));
transform: translateX(-50%);
justify-content: center;
}
#hud.is-touch .speedo { transform: scale(var(--hud-scale)); transform-origin: center bottom; }
}

@media (max-width: 430px) {
#hud .map-card { width: 152px; height: 152px; }
#hud .speedo-dial { width: 116px; height: 116px; }
#hud #hud-speed { font-size: 43px; }
#hud .boost-meter { width: 114px; }
}

@media (orientation: landscape) and (max-height: 560px) {
#hud .map-card { width: 156px; height: 156px; }
#hud .race-lap span, #hud .race-pos span { font-size: 28px; }
#hud .speedo-dial { width: 106px; height: 106px; }
#hud #hud-speed { font-size: 40px; }
#hud .boost-meter { width: 116px; }
#hud.is-touch .hud-bottom {
left: 50%;
right: auto;
bottom: max(104px, calc(env(safe-area-inset-bottom) + 98px));
transform: translateX(-50%);
justify-content: center;
}
#hud.is-touch .speedo { transform: scale(var(--hud-scale)); transform-origin: center bottom; }
}

/* =========================================================
HUD FINAL · nackte Zahlen, transparente Karte, Tacho rechts
========================================================= */
#hud .race-readout {
gap: 18px;
padding: 0;
background: none;
border: 0;
box-shadow: none;
backdrop-filter: none;
clip-path: none;
filter: none;
}
#hud .race-lap,
#hud .race-pos {
padding: 0;
border: 0;
background: none;
}
#hud .race-lap { border-right: 0; }
#hud .race-pos em { display: none; }
#hud .map-card {
padding: 0;
background: none;
border: 0;
box-shadow: none;
backdrop-filter: none;
}
#hud #minimap { filter: none; }
#hud .hud-bottom {
left: auto;
right: max(18px, env(safe-area-inset-right));
bottom: max(18px, env(safe-area-inset-bottom));
transform: none;
justify-content: flex-end;
width: auto;
}
#hud .speedo { align-items: flex-end; }
#hud .boost-meter { display: none; }
#hud.is-touch .hud-bottom {
left: auto;
right: max(14px, env(safe-area-inset-right));
bottom: max(120px, calc(env(safe-area-inset-bottom) + 114px));
transform: none;
justify-content: flex-end;
}
#hud.is-touch .speedo { transform: scale(var(--hud-scale)); transform-origin: right bottom; }
