/* ============================================================
   DAMIETTA RUSH — interface
   ============================================================ */
:root {
  --ink: #08090d;
  --paper: #f5efe3;
  --muted: #a9a397;
  --gold: #f5b53f;
  --gold-bright: #ffd278;
  --cyan: #75f5e7;
  --red: #ff594d;
  --panel: rgba(11, 12, 17, .58);
  --panel-strong: rgba(9, 10, 14, .82);
  --display: "Bahnschrift Condensed", "Bahnschrift", "Arial Narrow", "Haettenschweiler", Impact, sans-serif;
  --sans: Bahnschrift, "Segoe UI", Tahoma, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; margin: 0; padding: 0;
  background: #07080c;
  color: var(--paper);
  overflow: hidden;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}
button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
::selection { background: var(--gold); color: #17110a; }

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #13101a;
}
#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.grade {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background:
    linear-gradient(180deg, rgba(13, 12, 31, .2), transparent 32%, transparent 72%, rgba(9, 7, 12, .2)),
    radial-gradient(ellipse at 72% 44%, rgba(255, 170, 89, .06), transparent 42%);
  mix-blend-mode: normal;
}
.vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background:
    radial-gradient(ellipse at 50% 46%, transparent 47%, rgba(5, 5, 9, .22) 78%, rgba(3, 4, 8, .62) 110%),
    linear-gradient(90deg, rgba(4, 5, 9, .32), transparent 20%, transparent 80%, rgba(4, 5, 9, .3));
}
.impact-flash {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 70%, rgba(255, 64, 35, .38), transparent 56%);
  mix-blend-mode: screen;
}
.impact-flash.hit { animation: impact .45s ease-out; }
@keyframes impact {
  0% { opacity: .95; }
  100% { opacity: 0; }
}
.credit-mark {
  position: absolute; right: 22px; top: 50%; transform: rotate(90deg) translateY(-100%);
  transform-origin: right top; z-index: 3; pointer-events: none;
  font: 500 9px/1 var(--sans); letter-spacing: .34em; color: rgba(248, 239, 224, .28);
}
.credit-mark span { color: var(--gold); }

/* ============================================================
   HUD
   ============================================================ */
.hud {
  position: absolute; inset: 0; z-index: 10;
  pointer-events: none;
  opacity: 1;
  transition: opacity .45s ease;
}
.hud.is-hidden { opacity: 0; }
.hud-left {
  position: absolute; left: clamp(14px, 1.8vw, 30px); top: clamp(14px, 2.2vh, 26px);
  display: flex; flex-direction: column; gap: 10px;
}
.position-card {
  width: clamp(154px, 12.2vw, 194px);
  padding: 12px 34px 13px 17px;
  background:
    linear-gradient(125deg, rgba(10, 12, 17, .84), rgba(14, 16, 23, .35) 72%, rgba(14, 16, 23, 0));
  border-left: 3px solid var(--gold);
  clip-path: polygon(0 0, 100% 0, 88% 100%, 0 100%);
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, .28));
  backdrop-filter: blur(5px);
}
.position-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hud-label {
  display: block;
  font: 600 9px/1 var(--sans);
  letter-spacing: .23em;
  color: rgba(245, 239, 227, .62);
  text-transform: uppercase;
}
.position-number {
  display: flex; align-items: baseline; gap: 3px; margin-top: 1px;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(39px, 3.3vw, 53px);
  line-height: .86;
  letter-spacing: -.035em;
  color: #fffdf6;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .5);
}
.position-number i { font-style: normal; font-size: .45em; color: rgba(255,255,255,.35); margin: 0 1px; }
.position-number em { font-style: normal; font-size: .54em; color: var(--gold); font-weight: 500; letter-spacing: 0; }
.card-divider {
  height: 1px; margin: 7px 22px 6px 0;
  background: linear-gradient(90deg, rgba(255,255,255,.18), transparent);
}
.lap-row .position-number { font-size: clamp(27px, 2.35vw, 37px); margin-top: 3px; }
.lap-number em { color: rgba(255,255,255,.5); }
.location-chip {
  align-self: flex-start;
  display: flex; align-items: center; gap: 7px;
  padding: 6px 11px;
  background: rgba(8, 10, 14, .38);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(244, 238, 227, .68);
  font: 600 8px/1 var(--sans); letter-spacing: .17em;
  backdrop-filter: blur(4px);
}
.location-chip b { color: var(--gold); margin: 0 2px; }
.live-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 9px var(--red);
  animation: pulse 1.8s infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

.hud-timer {
  position: absolute; right: clamp(14px, 1.8vw, 30px); top: clamp(14px, 2.2vh, 26px);
  display: flex; align-items: center; gap: 12px;
  min-width: clamp(190px, 15vw, 242px);
  padding: 9px 38px 10px 14px;
  background: linear-gradient(105deg, rgba(11, 13, 18, .76), rgba(11, 13, 18, .4));
  border-top: 1px solid rgba(255,255,255,.16);
  clip-path: polygon(0 0, 100% 0, 92% 100%, 8% 100%);
  backdrop-filter: blur(6px);
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.24));
}
.timer-icon { width: 27px; height: 27px; color: var(--gold); flex: none; }
.timer-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.timer-copy { display: flex; flex-direction: column; gap: 3px; }
.timer-value {
  font: 500 clamp(17px, 1.35vw, 22px)/1 var(--mono);
  letter-spacing: .015em;
  color: #fffaf0;
  font-variant-numeric: tabular-nums;
}
.hud-top-actions {
  position: absolute; top: clamp(62px, 8.5vh, 91px); right: clamp(20px, 2.3vw, 38px);
  display: flex; gap: 6px; pointer-events: auto;
}
.icon-btn {
  width: 30px; height: 30px; padding: 6px;
  display: grid; place-items: center;
  color: rgba(255,255,255,.68);
  background: rgba(8, 10, 14, .38);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 2px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
  backdrop-filter: blur(5px);
}
.icon-btn:hover { color: var(--gold); border-color: rgba(245,181,63,.55); background: rgba(8,10,14,.62); }
.icon-btn svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .sound-off { display: none; }
.is-muted .icon-btn .sound-on { display: none; }
.is-muted .icon-btn .sound-off { display: block; }
#muteBtn .sound-on path:first-child, #muteBtn .sound-off path:first-child { fill: currentColor; stroke-linejoin: round; }

.toast {
  position: absolute; left: 50%; top: 17.5%;
  transform: translate(-50%, -8px);
  padding: 8px 17px;
  color: #fff8ec;
  background: rgba(9, 10, 15, .66);
  border: 1px solid rgba(245, 181, 63, .45);
  border-left: 3px solid var(--gold);
  font: 600 10px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase;
  opacity: 0; transition: opacity .25s, transform .25s;
  white-space: nowrap; backdrop-filter: blur(7px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.cyan { border-left-color: var(--cyan); border-color: rgba(117,245,231,.38); }
.toast.red { border-left-color: var(--red); border-color: rgba(255,89,77,.45); }

.hud-minimap {
  position: absolute; left: clamp(14px, 1.8vw, 30px); bottom: clamp(14px, 2.4vh, 28px);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  filter: drop-shadow(0 12px 24px rgba(0,0,0,.34));
}
.map-shell {
  position: relative;
  width: clamp(136px, 10.9vw, 178px); height: clamp(136px, 10.9vw, 178px);
  border-radius: 50%;
  padding: 7px;
  background: rgba(7, 9, 14, .52);
  border: 1px solid rgba(245, 238, 225, .26);
  box-shadow: inset 0 0 0 3px rgba(0,0,0,.28), inset 0 0 28px rgba(0,0,0,.45);
  backdrop-filter: blur(6px);
}
.map-shell::before {
  content: ""; position: absolute; inset: 3px; border-radius: 50%;
  border: 1px dashed rgba(255,255,255,.09); pointer-events: none;
}
#minimap { display: block; width: 100%; height: 100%; border-radius: 50%; }
.map-north {
  position: absolute; top: -1px; left: 50%; transform: translateX(-50%);
  font: 700 8px/1 var(--sans); letter-spacing: .12em; color: var(--gold);
  background: #11121a; padding: 2px 5px; border: 1px solid rgba(245,181,63,.4);
}
.map-start {
  position: absolute; right: 2px; bottom: 19px; transform: rotate(-37deg);
  font: 600 6px/1 var(--sans); letter-spacing: .12em; color: rgba(255,255,255,.46);
}
.map-caption { display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,.45); }
.map-caption span { font: 600 11px/1 Tahoma, sans-serif; color: var(--gold); }
.map-caption b { font: 600 7px/1 var(--sans); letter-spacing: .21em; }

.speed-cluster {
  position: absolute; right: clamp(10px, 1.7vw, 30px); bottom: clamp(4px, 1.3vh, 18px);
  width: clamp(268px, 21vw, 345px);
  display: flex; flex-direction: column; align-items: flex-end;
  filter: drop-shadow(0 18px 26px rgba(0,0,0,.35));
}
.nitro-wrap {
  width: 60%; min-width: 178px; padding: 8px 12px 10px;
  background: linear-gradient(100deg, rgba(8,10,15,.16), rgba(8,10,15,.7));
  border-top: 1px solid rgba(117,245,231,.26);
  margin-right: 8px; margin-bottom: -4px;
}
.nitro-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.nitro-title span { font: 600 8px/1 var(--sans); letter-spacing: .19em; color: rgba(230,251,248,.7); }
.nitro-title span:last-child { color: var(--cyan); font-family: var(--mono); letter-spacing: .04em; font-size: 8px; }
.nitro-row { display: flex; align-items: center; gap: 9px; }
.nitro-bottle { width: 20px; height: 31px; opacity: .95; flex: none; }
.nitro-bottle svg { width: 100%; height: 100%; overflow: visible; }
.bottle-fill { fill: rgba(117,245,231,.18); stroke: rgba(117,245,231,.6); stroke-width: 1.2; }
.bottle-line { fill: none; stroke: rgba(117,245,231,.85); stroke-width: 1.5; stroke-linecap: round; }
.nitro-track {
  position: relative; flex: 1; height: 7px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(117,245,231,.22);
  overflow: hidden;
}
#nitroFill {
  position: absolute; inset: 0; transform-origin: left center; transform: scaleX(.68);
  background: linear-gradient(90deg, #28bfd0, var(--cyan) 62%, #ddfffa);
  box-shadow: 0 0 13px rgba(117,245,231,.58);
  transition: transform .1s linear;
}
.nitro-seg { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(5,10,12,.5); z-index: 1; }
.nitro-seg:nth-of-type(1) { left: 25%; }
.nitro-seg:nth-of-type(2) { left: 50%; }
.nitro-seg:nth-of-type(3) { left: 75%; }
.nitro-wrap.is-low .nitro-title span:last-child { color: var(--red); animation: blink .6s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }

.speedometer {
  position: relative;
  width: clamp(268px, 21vw, 345px); height: clamp(268px, 21vw, 345px);
}
.gauge { width: 100%; height: 100%; overflow: visible; }
#gaugeTicks line { stroke: rgba(255, 247, 231, .58); stroke-width: 1.4; }
#gaugeTicks line.major { stroke: rgba(255, 250, 240, .95); stroke-width: 2.5; }
#gaugeTicks line.red { stroke: rgba(255, 88, 70, .9); stroke-width: 2.5; }
#gaugeTicks text {
  fill: rgba(255, 248, 236, .8);
  font-family: var(--display); font-size: 16px; font-weight: 600; text-anchor: middle;
}
.gauge-redline { fill: none; stroke: rgba(255, 89, 77, .7); stroke-width: 2; stroke-linecap: round; }
.needle { stroke: #ff654f; stroke-width: 3.2; stroke-linecap: round; filter: drop-shadow(0 0 5px rgba(255,101,79,.7)); }
.needle-hub { fill: #f4d7b0; stroke: #a04e35; stroke-width: 3; }
#needleGroup { transform-box: view-box; transform-origin: 160px 160px; }
.speed-readout {
  position: absolute; left: 49.2%; top: 63.5%; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; pointer-events: none;
}
.speed-number {
  font: 700 clamp(48px, 4.25vw, 68px)/.78 var(--display);
  letter-spacing: -.04em; color: #fffdf6;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 18px rgba(0,0,0,.62);
}
.speed-unit { margin-top: 7px; font: 600 8px/1 var(--sans); letter-spacing: .23em; color: rgba(255,255,255,.58); }
.gear-card {
  position: absolute; right: 18.5%; bottom: 13.5%;
  width: 46px; height: 54px; padding-top: 6px;
  display: flex; flex-direction: column; align-items: center;
  border: 1px solid rgba(255,255,255,.34);
  background: rgba(16,17,22,.54);
  clip-path: polygon(8% 0, 100% 0, 100% 100%, 0 100%, 0 14%);
}
.gear-card span { font: 600 6px/1 var(--sans); letter-spacing: .17em; color: rgba(255,255,255,.5); }
.gear-card b { margin-top: 3px; font: 700 28px/.9 var(--display); color: var(--gold-bright); }
.speed-brand {
  position: absolute; left: 50%; bottom: 11%;
  transform: translateX(-50%);
  font: 600 6px/1 var(--sans); letter-spacing: .29em; color: rgba(255,255,255,.24);
}

/* ============================================================
   COUNTDOWN / OVERLAY SCREENS
   ============================================================ */
.countdown {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  font: 700 clamp(120px, 20vw, 260px)/.8 var(--display);
  color: #fffaf0; letter-spacing: -.055em;
  text-shadow: 0 5px 0 rgba(17,14,12,.25), 0 24px 70px rgba(0,0,0,.45), 0 0 80px rgba(245,181,63,.22);
  opacity: 0;
}
.countdown.show { animation: countPop .7s cubic-bezier(.17,.84,.3,1) both; }
.countdown.go { color: var(--gold-bright); font-size: clamp(95px, 15vw, 210px); }
@keyframes countPop {
  0% { opacity: 0; transform: scale(1.6); filter: blur(12px); }
  18% { opacity: 1; filter: blur(0); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.88); }
}

.screen {
  position: absolute; inset: 0; z-index: 30;
  transition: opacity .45s ease, visibility .45s;
}
.screen.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.start-screen {
  background:
    linear-gradient(90deg, rgba(6, 7, 11, .92) 0%, rgba(7, 8, 12, .78) 32%, rgba(7,8,12,.22) 58%, rgba(7,8,12,.1) 100%),
    linear-gradient(0deg, rgba(6,7,11,.74), transparent 28%, transparent 80%, rgba(6,7,11,.2));
  display: flex; align-items: center;
  padding: clamp(26px, 5.5vh, 58px) clamp(25px, 6vw, 96px);
}
.start-screen.leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.start-grid {
  width: 100%; max-width: 1600px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 42px;
}
.title-stack { max-width: min(700px, 60vw); position: relative; animation: riseIn .9s .1s both ease-out; }
@keyframes riseIn { from { opacity: 0; transform: translateY(18px); } }
.series-pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 11px;
  color: rgba(247, 239, 225, .76);
  border: 1px solid rgba(245,181,63,.36);
  background: rgba(10,11,16,.42);
  font: 600 8px/1 var(--sans); letter-spacing: .21em;
  backdrop-filter: blur(8px);
}
.series-pill i { width: 6px; height: 6px; background: var(--gold); border-radius: 50%; box-shadow: 0 0 10px rgba(245,181,63,.6); }
.series-pill span { color: rgba(255,255,255,.27); margin: 0 3px; }
.arabic-mark {
  margin-top: clamp(20px, 4.4vh, 44px);
  color: var(--gold);
  font: 600 clamp(14px, 1.35vw, 20px)/1 Tahoma, "Segoe UI", sans-serif;
  letter-spacing: .05em;
  direction: rtl; text-align: left;
  opacity: .93;
}
.arabic-mark span { opacity: .5; margin: 0 9px; }
.game-title { margin: 8px 0 0; font-family: var(--display); font-weight: 700; text-transform: uppercase; }
.title-line { display: block; line-height: .75; letter-spacing: -.035em; }
.title-line-top {
  font-size: clamp(72px, 9.2vw, 156px);
  color: #f7f1e7;
  text-shadow: 0 4px 30px rgba(0,0,0,.4);
}
.title-line-bottom {
  margin-left: -.035em; margin-top: .13em;
  font-size: clamp(106px, 14.5vw, 242px);
  color: transparent;
  -webkit-text-stroke: clamp(1px, .13vw, 2.5px) rgba(245,181,63,.92);
  line-height: .68;
  letter-spacing: -.028em;
  filter: drop-shadow(0 0 26px rgba(245,181,63,.14));
}
.title-period { -webkit-text-stroke: 0; color: var(--gold); font-size: .72em; }
.title-deck {
  max-width: 490px; margin: clamp(18px, 3.2vh, 30px) 0 0;
  color: rgba(241, 235, 224, .65);
  font: 400 clamp(11px, .88vw, 14px)/1.65 var(--sans);
  letter-spacing: .015em;
}
.start-btn {
  position: relative;
  margin-top: clamp(20px, 3.2vh, 32px);
  min-width: 248px; height: 54px;
  display: inline-flex; align-items: center; justify-content: space-between; gap: 26px;
  padding: 0 17px 0 22px;
  border: 0; background: var(--gold);
  color: #17120b;
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, 94% 100%, 0 100%);
  font: 700 12px/1 var(--sans); letter-spacing: .16em;
  transition: background .2s, transform .2s, box-shadow .2s;
  box-shadow: 0 14px 34px rgba(245,181,63,.15);
}
.start-btn::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-101%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.38), transparent);
  transition: transform .55s;
}
.start-btn:hover { background: var(--gold-bright); transform: translateY(-2px); }
.start-btn:hover::after { transform: translateX(101%); }
.start-btn:active { transform: translateY(0); }
.start-btn-key { display: grid; place-items: center; width: 27px; height: 27px; background: rgba(20,14,8,.16); font-size: 16px; }
.race-facts {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  margin-top: 24px; color: rgba(245,239,227,.43);
  font: 500 8px/1 var(--sans); letter-spacing: .14em;
}
.race-facts b { color: rgba(245,239,227,.86); font-weight: 600; }
.race-facts i { display: block; width: 2px; height: 2px; border-radius: 50%; background: rgba(245,181,63,.6); }
.controls-hint { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 16px; color: rgba(245,239,227,.37); font: 500 8px/1 var(--sans); letter-spacing: .09em; }
.controls-hint span { display: inline-flex; align-items: center; gap: 4px; }
kbd {
  display: inline-grid; place-items: center; min-width: 19px; height: 18px; padding: 0 4px;
  font: 500 8px/1 var(--mono); color: rgba(255,247,234,.7);
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.16); border-bottom-color: rgba(255,255,255,.28);
}
.start-aside {
  width: min(280px, 24vw); align-self: flex-end; margin-bottom: 0;
  display: flex; flex-direction: column; gap: 14px;
  animation: riseIn 1s .32s both ease-out;
}
.best-card {
  padding: 16px 16px 14px;
  background: rgba(9,10,15,.48);
  border-top: 1px solid rgba(245,181,63,.4);
  border-left: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
}
.best-card strong { display: block; margin-top: 9px; font: 500 clamp(25px, 2.2vw, 34px)/1 var(--mono); letter-spacing: -.04em; color: var(--paper); }
.best-card small { display: block; margin-top: 7px; color: rgba(255,255,255,.34); font: 500 7px/1 var(--sans); letter-spacing: .16em; }
.route-card { padding: 15px 16px 12px; background: rgba(9,10,15,.32); border: 1px solid rgba(255,255,255,.09); backdrop-filter: blur(8px); }
.route-head, .route-foot { display: flex; justify-content: space-between; color: rgba(255,255,255,.44); font: 600 7px/1 var(--sans); letter-spacing: .12em; }
.route-head b { color: rgba(245,181,63,.8); font-weight: 500; }
.route-map { width: 100%; height: auto; margin: 10px 0 5px; overflow: visible; }
.route-glow { fill: none; stroke: rgba(245,181,63,.14); stroke-width: 11; stroke-linecap: round; }
.route-line { fill: none; stroke: rgba(245,181,63,.78); stroke-width: 1.8; stroke-dasharray: 2 6; }
.route-map circle { fill: var(--gold); }
.route-map text { fill: rgba(255,255,255,.35); font: 600 6px var(--sans); letter-spacing: .18em; }
.route-foot { padding-top: 9px; border-top: 1px solid rgba(255,255,255,.08); font-size: 6px; color: rgba(255,255,255,.28); }
.aside-note { margin: 0; color: rgba(245,239,227,.3); font: 400 9px/1.65 var(--sans); text-align: right; }
.menu-footer {
  position: absolute; left: clamp(25px, 6vw, 96px); right: clamp(25px, 6vw, 96px); bottom: 17px;
  display: flex; justify-content: space-between; align-items: center;
  color: rgba(255,255,255,.22); font: 500 6px/1 var(--sans); letter-spacing: .19em;
}
.footer-center { color: rgba(245,181,63,.48); }

/* ============================================================
   MODALS
   ============================================================ */
.overlay-screen {
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(5, 6, 10, .56);
  backdrop-filter: blur(10px) saturate(.8);
}
.modal-card {
  width: min(540px, 92vw);
  padding: clamp(24px, 3.2vw, 38px);
  background:
    linear-gradient(135deg, rgba(25,25,29,.96), rgba(11,12,16,.96)),
    radial-gradient(circle at 90% 0, rgba(245,181,63,.1), transparent 45%);
  border: 1px solid rgba(255,255,255,.13);
  border-top: 2px solid var(--gold);
  box-shadow: 0 35px 100px rgba(0,0,0,.65);
  position: relative;
  overflow: hidden;
}
.modal-card::before {
  content: ""; position: absolute; width: 300px; height: 300px; right: -160px; top: -180px;
  border: 1px solid rgba(245,181,63,.14); border-radius: 50%;
  box-shadow: 0 0 0 35px rgba(245,181,63,.025), 0 0 0 70px rgba(245,181,63,.02);
  pointer-events: none;
}
.modal-kicker { color: var(--gold); font: 600 8px/1 var(--sans); letter-spacing: .26em; }
.modal-card h2 {
  margin: 10px 0 0;
  font: 700 clamp(44px, 5vw, 67px)/.85 var(--display);
  letter-spacing: -.035em; text-transform: uppercase; color: #f8f2e6;
}
.modal-card h2 span { color: var(--gold); }
.modal-card p { margin: 13px 0 0; color: rgba(255,255,255,.45); font: 400 11px/1.6 var(--sans); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 25px; }
.primary-btn, .ghost-btn {
  min-height: 44px; padding: 0 20px;
  border: 1px solid transparent; cursor: pointer;
  font: 600 9px/1 var(--sans); letter-spacing: .17em;
  transition: background .2s, color .2s, border-color .2s, transform .2s;
}
.primary-btn { background: var(--gold); color: #16110a; border-color: var(--gold); }
.primary-btn:hover { background: var(--gold-bright); border-color: var(--gold-bright); transform: translateY(-1px); }
.ghost-btn { color: rgba(255,255,255,.62); background: rgba(255,255,255,.035); border-color: rgba(255,255,255,.14); }
.ghost-btn:hover { color: var(--paper); border-color: rgba(255,255,255,.34); background: rgba(255,255,255,.07); }
.pause-card { width: min(450px, 91vw); }

.finish-card { width: min(760px, 94vw); max-height: 94vh; overflow: auto; scrollbar-width: thin; }
.finish-headline { display: flex; align-items: center; gap: 22px; }
.finish-place {
  flex: none; width: 82px; height: 88px;
  display: flex; align-items: baseline; justify-content: center;
  padding-top: 17px;
  border: 1px solid rgba(245,181,63,.4);
  background: rgba(245,181,63,.055);
}
.finish-place span { color: rgba(245,181,63,.6); font: 700 17px var(--display); align-self: flex-start; }
.finish-place strong { font: 700 60px/.8 var(--display); color: var(--gold-bright); letter-spacing: -.05em; }
.finish-headline h2 { font-size: clamp(37px, 4.4vw, 57px); }
.finish-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 24px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.1); }
.finish-stats > div { background: #111217; padding: 13px 14px; }
.finish-stats strong { display: block; margin-top: 8px; font: 500 21px/1 var(--mono); color: var(--paper); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.finish-stats small { font-size: 8px; color: rgba(255,255,255,.35); letter-spacing: .08em; }
.result-table { margin-top: 19px; }
.result-row {
  display: grid; grid-template-columns: 44px 1fr auto;
  align-items: center; gap: 10px;
  padding: 8px 11px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  color: rgba(255,255,255,.62); font: 500 10px/1.2 var(--sans); letter-spacing: .025em;
}
.result-row.result-head { padding-top: 0; border-bottom-color: rgba(255,255,255,.12); color: rgba(255,255,255,.28); font-size: 7px; letter-spacing: .15em; }
.result-row .pos { font-family: var(--display); font-size: 17px; color: rgba(255,255,255,.4); }
.result-row .rider { display: flex; align-items: center; gap: 9px; }
.result-row .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--rider-color, #666); }
.result-row .rider b { font-weight: 600; color: rgba(255,255,255,.78); letter-spacing: .08em; }
.result-row .time { font-family: var(--mono); font-size: 10px; color: rgba(255,255,255,.48); }
.result-row.is-player { background: rgba(245,181,63,.09); border-left: 2px solid var(--gold); padding-left: 9px; }
.result-row.is-player .rider b { color: var(--gold-bright); }
.result-row.is-player .time { color: var(--paper); }
.finish-actions { align-items: center; }
.screenshot-btn { margin-left: auto; }

.rotate-hint { display: none; }
.loading {
  position: absolute; inset: 0; z-index: 80;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  background: #0b0c11;
  transition: opacity .55s ease, visibility .55s;
}
.loading.is-hidden { opacity: 0; visibility: hidden; }
.loading-mark {
  width: 66px; height: 66px; display: grid; place-items: center;
  border: 1px solid rgba(245,181,63,.55);
  color: var(--gold); font: 700 25px/1 var(--display); letter-spacing: -.06em;
  transform: rotate(45deg);
}
.loading-mark::first-letter { color: var(--paper); }
.loading-copy { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.loading-copy span { color: rgba(255,255,255,.44); font: 600 8px/1 var(--sans); letter-spacing: .25em; }
.loading-copy b { display: block; width: 120px; height: 1px; background: rgba(255,255,255,.12); overflow: hidden; }
.loading-copy b::after { content: ""; display: block; width: 40%; height: 100%; background: var(--gold); animation: loadBar 1s infinite ease-in-out; }
@keyframes loadBar { from { transform: translateX(-110%); } to { transform: translateX(350%); } }

/* ============================================================
   TOUCH
   ============================================================ */
.touch-controls { display: none; position: absolute; inset: 0; z-index: 15; pointer-events: none; }
.touch-controls.is-hidden { opacity: 0; visibility: hidden; }
.touch-controls button { pointer-events: auto; user-select: none; -webkit-user-select: none; }
.touch-steer { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.touch-pedals { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 10px; }
.touch-btn {
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(9,11,16,.5);
  color: rgba(255,255,255,.8);
  backdrop-filter: blur(8px);
  touch-action: none;
}
.steer-btn { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; }
.steer-btn svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.steer-btn:active, .steer-btn.pressed { background: rgba(245,181,63,.75); color: #17110a; border-color: var(--gold); }
.pedal-stack { display: flex; flex-direction: column; gap: 8px; }
.pedal { width: 62px; height: 48px; border-radius: 4px; font: 700 8px/1 var(--sans); letter-spacing: .09em; }
.pedal.gas { background: rgba(28,122,101,.62); border-color: rgba(117,245,231,.4); }
.pedal:active, .pedal.pressed { background: rgba(245,181,63,.8); color: #17110a; border-color: var(--gold); }
.nitro-btn {
  width: 66px; height: 66px; border-radius: 50%; border-color: rgba(117,245,231,.5);
  color: var(--cyan); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.nitro-btn span { font: 700 14px/1 var(--display); }
.nitro-btn small { font: 600 5px/1 var(--sans); letter-spacing: .1em; color: rgba(255,255,255,.45); }
.nitro-btn:active, .nitro-btn.pressed { background: rgba(117,245,231,.8); color: #081214; border-color: var(--cyan); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .start-aside { width: 240px; }
  .title-stack { max-width: 63vw; }
  .title-deck { max-width: 410px; }
  .hud-minimap .map-caption { display: none; }
}
@media (max-width: 850px) {
  .start-screen { align-items: flex-start; padding-top: 8vh; overflow-y: auto; }
  .start-grid { display: block; }
  .title-stack { max-width: 100%; }
  .title-line-top { font-size: clamp(61px, 15vw, 106px); }
  .title-line-bottom { font-size: clamp(98px, 24vw, 180px); }
  .title-deck { max-width: 490px; }
  .start-aside { width: 100%; max-width: 380px; margin-top: 26px; align-self: auto; flex-direction: row; align-items: stretch; }
  .best-card, .route-card { flex: 1; }
  .aside-note { display: none; }
  .menu-footer { display: none; }
  .hud-minimap { transform: scale(.8); transform-origin: left bottom; }
  .speed-cluster { transform: scale(.82); transform-origin: right bottom; }
  .hud-timer { transform: scale(.86); transform-origin: right top; }
  .position-card { transform: scale(.88); transform-origin: left top; }
  .hud-top-actions { right: 16px; top: 70px; }
}
@media (pointer: coarse) {
  .touch-controls { display: block; }
  .controls-hint { display: none; }
  .hud-minimap { display: none; }
  .speed-cluster { opacity: .9; }
  .hud-top-actions { opacity: .8; }
  .start-btn { height: 52px; }
}
@media (max-width: 650px) {
  .start-screen { padding: 26px 20px; }
  .series-pill { font-size: 7px; letter-spacing: .14em; }
  .arabic-mark { margin-top: 24px; font-size: 13px; }
  .title-line-top { font-size: clamp(53px, 14.4vw, 85px); }
  .title-line-bottom { font-size: clamp(84px, 24vw, 135px); }
  .title-deck { font-size: 11px; max-width: 90%; }
  .race-facts { gap: 8px; font-size: 7px; }
  .start-aside { display: none; }
  .start-btn { width: 100%; max-width: 330px; }
  .hud-timer { min-width: 156px; padding-right: 25px; gap: 8px; }
  .timer-icon { width: 20px; height: 20px; }
  .timer-value { font-size: 15px; }
  .position-card { width: 126px; }
  .position-number { font-size: 37px; }
  .lap-row .position-number { font-size: 25px; }
  .location-chip { font-size: 6px; letter-spacing: .1em; }
  .speed-cluster { transform: scale(.65); transform-origin: right bottom; bottom: 0; }
  .hud-top-actions { top: 59px; right: 12px; }
  .touch-steer { left: 12px; bottom: 14px; }
  .touch-pedals { right: 12px; bottom: 14px; }
  .steer-btn { width: 53px; height: 53px; }
  .pedal { width: 55px; height: 44px; }
  .nitro-btn { width: 57px; height: 57px; }
  .modal-card { padding: 22px 19px; }
  .finish-headline { gap: 14px; }
  .finish-place { width: 64px; height: 70px; }
  .finish-place strong { font-size: 48px; }
  .finish-stats strong { font-size: 16px; }
  .result-row { grid-template-columns: 31px 1fr auto; padding: 7px 8px; font-size: 9px; }
  .result-row .time { font-size: 8px; }
  .modal-actions { gap: 7px; }
  .primary-btn, .ghost-btn { min-height: 40px; padding: 0 14px; font-size: 8px; }
  .credit-mark { display: none; }
}
@media (max-width: 420px) {
  .start-screen { padding-top: 20px; }
  .series-pill { font-size: 6px; }
  .title-line-top { font-size: 46px; }
  .title-line-bottom { font-size: 78px; }
  .title-deck { line-height: 1.5; margin-top: 15px; }
  .race-facts { margin-top: 16px; }
  .start-btn { margin-top: 17px; }
  .hud-left { top: 10px; left: 10px; }
  .hud-timer { top: 10px; right: 10px; }
  .hud-top-actions { display: none; }
  .finish-card { width: 96vw; }
  .finish-stats { grid-template-columns: 1fr; }
  .finish-stats > div { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px; }
  .finish-stats strong { margin-top: 0; }
}
@media (pointer: coarse) and (max-height: 560px) {
  .start-screen { align-items: center; padding: 16px 26px; overflow: hidden; }
  .start-grid { display: flex; align-items: center; }
  .title-stack { max-width: 60vw; }
  .series-pill { font-size: 6px; padding: 5px 8px; letter-spacing: .14em; }
  .arabic-mark { margin-top: 9px; font-size: 12px; }
  .title-line-top { font-size: clamp(42px, 7vw, 58px); }
  .title-line-bottom { font-size: clamp(64px, 11vw, 94px); margin-top: .08em; }
  .title-deck { display: none; }
  .start-btn { margin-top: 12px; height: 42px; min-width: 214px; }
  .race-facts { margin-top: 10px; font-size: 7px; }
  .controls-hint, .start-aside, .menu-footer, .aside-note { display: none; }
  .hud-left { transform: scale(.76); transform-origin: left top; top: 10px; left: 10px; }
  .hud-timer { transform: scale(.72); transform-origin: right top; top: 8px; right: 8px; }
  .hud-top-actions { top: 55px; right: 10px; transform: scale(.82); transform-origin: right top; }
  .speed-cluster { transform: scale(.55); transform-origin: right bottom; bottom: 116px; right: 5px; }
  .nitro-wrap { margin-bottom: 0; }
  .touch-steer { left: 14px; bottom: 16px; }
  .touch-pedals { right: 12px; bottom: 14px; }
  .steer-btn { width: 57px; height: 57px; }
  .pedal { width: 58px; height: 45px; }
  .nitro-btn { width: 61px; height: 61px; }
  .countdown { font-size: clamp(76px, 18vh, 120px); }
  .countdown.go { font-size: clamp(60px, 14vh, 96px); }
  .toast { top: 13% !important; }
}
@media (orientation: portrait) and (pointer: coarse) and (max-width: 700px) {
  .rotate-hint {
    display: flex; position: absolute; z-index: 40; left: 50%; bottom: 47%;
    transform: translateX(-50%);
    flex-direction: column; align-items: center; gap: 5px;
    padding: 10px 16px; background: rgba(8,9,13,.82);
    border: 1px solid rgba(245,181,63,.28);
    color: rgba(255,255,255,.72); font: 500 9px/1 var(--sans); letter-spacing: .16em;
    pointer-events: none; white-space: nowrap;
    box-shadow: 0 14px 40px rgba(0,0,0,.35);
  }
  .rotate-hint small { color: rgba(255,255,255,.38); font-size: 7px; letter-spacing: .05em; }
  .speed-cluster { opacity: .18; }
  .touch-controls { opacity: .3; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
