:root {
  color-scheme: dark;
  --ink: #f4f7fb;
  --muted: #93a3b8;
  --faint: rgba(147, 163, 184, 0.45);
  --amber: #ffc46b;
  --amber-soft: rgba(255, 196, 107, 0.16);
  --cyan: #51e2ff;
  --red: #ff5d6c;
  --green: #6ee7a8;
  --bg: #05070a;
  --panel: rgba(8, 12, 18, 0.82);
  --panel-solid: #0a0f16;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  --font: "Bahnschrift", "DIN Alternate", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { cursor: default; }
canvas { display: block; }
.hidden { display: none !important; }

#app { position: fixed; inset: 0; }

/* ---------------------------------------------------------------- atmosphere */
.grain, .vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.grain {
  opacity: 0.16;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.035) 0px,
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}
.vignette {
  background:
    radial-gradient(ellipse at 50% 42%, transparent 30%, rgba(0, 0, 0, 0.5) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.32), transparent 22%, transparent 75%, rgba(0, 0, 0, 0.42));
}

/* ---------------------------------------------------------------- primitives */
.mini-label {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.26em;
  color: var(--muted);
}
.kicker span {
  width: 26px;
  height: 2px;
  background: var(--amber);
  box-shadow: 0 0 12px rgba(255, 196, 107, 0.7);
}

.btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px 22px;
  min-width: 176px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: rgba(10, 14, 20, 0.6);
  color: var(--ink);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.btn span {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.1em;
}
.btn small {
  font-size: 10px;
  letter-spacing: 0.09em;
  color: var(--muted);
  text-transform: uppercase;
}
.btn:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.34); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(120deg, #ffc46b, #ff9d4d 65%, #f2763f);
  border-color: transparent;
  color: #171007;
  box-shadow: 0 12px 34px rgba(255, 157, 77, 0.26);
}
.btn.primary small { color: rgba(23, 16, 7, 0.68); }
.btn.primary:hover { box-shadow: 0 16px 44px rgba(255, 157, 77, 0.38); }
.btn.ghost:hover { background: rgba(20, 28, 38, 0.9); }
.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button { font-family: var(--font); }

/* ---------------------------------------------------------------- top bar */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 76px;
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 30;
  background: linear-gradient(180deg, rgba(4, 6, 9, 0.92), rgba(4, 6, 9, 0.4) 70%, transparent);
  animation: fadeDown 0.5s ease both;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 196, 107, 0.55);
  border-radius: 3px;
  background: rgba(255, 196, 107, 0.08);
  color: var(--amber);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.brand-text {
  display: flex;
  flex-direction: column;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.16em;
}
.brand-text small {
  margin-top: 2px;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--faint);
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.cash-chip, .name-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(10, 14, 20, 0.55);
}
.cash-chip span, .name-chip span {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.cash-chip small, .name-chip small {
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--faint);
}
.cash-chip span { color: var(--green); }
.name-chip { cursor: pointer; }
.name-chip:hover { border-color: var(--line-strong); }
.name-chip span { color: var(--ink); font-size: 12px; letter-spacing: 0.12em; }
.icon-btn {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(10, 14, 20, 0.55);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

/* ---------------------------------------------------------------- loading */
#loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 157, 77, 0.08), transparent 40%),
    #05070a;
  transition: opacity 0.5s ease, visibility 0.5s;
}
#loading.done { opacity: 0; visibility: hidden; }
.load-mark {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.08em;
}
.load-bar {
  width: 260px;
  height: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.load-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--amber), var(--cyan));
  transition: width 0.3s ease;
}
#load-text {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  padding: 104px 40px 40px;
  pointer-events: none;
  animation: fadeUp 0.45s ease both;
}
.screen > * { pointer-events: auto; }

/* menu */
#screen-menu {
  display: grid;
  grid-template-columns: minmax(520px, 1.1fr) minmax(300px, 0.9fr);
  align-items: end;
  gap: 40px;
  padding-bottom: 56px;
}
.menu-hero { max-width: 760px; }
.menu-hero h1 {
  margin: 0 0 20px;
  font-size: clamp(54px, 6.6vw, 102px);
  font-weight: 800;
  line-height: 0.82;
  letter-spacing: -0.035em;
  text-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.menu-hero h1 em {
  font-style: normal;
  color: var(--amber);
  text-shadow: 0 0 60px rgba(255, 196, 107, 0.28);
}
.lede {
  max-width: 470px;
  margin: 0 0 28px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.menu-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.menu-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--faint);
  text-transform: uppercase;
}
.menu-meta .sep { width: 1px; height: 12px; background: var(--line-strong); }
.dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(110, 231, 168, 0.9);
}
.dot.off::before { background: var(--red); box-shadow: 0 0 10px rgba(255, 93, 108, 0.8); }

.menu-car {
  justify-self: end;
  width: min(340px, 100%);
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-left: 2px solid var(--amber);
  background: linear-gradient(160deg, rgba(13, 18, 25, 0.86), rgba(7, 10, 14, 0.62));
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.menu-car h2 {
  margin: 6px 0 2px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.menu-car > p:not(.mini-label):not(.menu-tip) {
  margin: 0 0 16px;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--amber);
}
.menu-stats { display: grid; gap: 7px; margin-bottom: 18px; }
.menu-best {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.menu-best span { font-size: 9px; letter-spacing: 0.19em; color: var(--faint); }
.menu-best strong { font-family: var(--mono); font-size: 14px; color: var(--cyan); }
.menu-tip {
  margin: 18px 0 0;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--faint);
}

/* small stat bars reused by menu + garage */
.stat {
  display: grid;
  grid-template-columns: 52px 1fr 28px;
  align-items: center;
  gap: 8px;
}
.stat > span {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.stat > b {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}
.meter {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan), var(--amber));
  transition: width 0.35s ease;
}

/* ---------------------------------------------------------------- screen head */
.screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 26px;
  margin-bottom: 26px;
}
.screen-head.compact { margin-bottom: 18px; }
.screen-head h2 {
  margin: 0;
  font-size: clamp(28px, 3.2vw, 44px);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.screen-head .kicker { margin-bottom: 6px; }
.back {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(10, 14, 20, 0.6);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.back:hover { color: var(--ink); border-color: var(--line-strong); }
.head-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.head-right .hint {
  max-width: 260px;
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.06em;
  color: var(--faint);
  text-align: right;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- route select */
#screen-races {
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255, 196, 107, 0.06), transparent 55%),
    linear-gradient(180deg, rgba(3, 5, 8, 0.9), rgba(3, 5, 8, 0.72));
}
.race-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.race-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 16px;
  min-height: 330px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--accent, var(--amber));
  background:
    radial-gradient(ellipse at 80% 0%, rgba(255, 255, 255, 0.06), transparent 58%),
    linear-gradient(165deg, rgba(13, 18, 25, 0.86), rgba(6, 9, 13, 0.72));
  backdrop-filter: blur(10px);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.race-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.3);
  background:
    radial-gradient(ellipse at 80% 0%, rgba(255, 196, 107, 0.12), transparent 60%),
    linear-gradient(165deg, rgba(16, 22, 30, 0.92), rgba(7, 10, 14, 0.8));
}
.rc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--faint);
}
.rc-badge {
  padding: 3px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--accent);
  letter-spacing: 0.14em;
}
.rc-map {
  width: 100%;
  height: 116px;
  margin: 13px 0 10px;
  overflow: visible;
}
.rc-map polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent));
}
.rc-map circle { fill: var(--accent); opacity: 0.55; }
.rc-map .start { fill: #fff; opacity: 1; }
.race-card h3 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.005em;
}
.race-card > p {
  margin: 0 0 14px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted);
}
.rc-meta {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--faint);
}
.rc-meta b { color: var(--ink); font-family: var(--mono); font-weight: 600; }
.rc-actions { display: flex; gap: 8px; margin-top: 12px; }
.rc-actions button {
  flex: 1;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.rc-actions button:hover { background: var(--accent); color: #0b0d10; border-color: transparent; }
.rc-actions button.online { color: var(--cyan); border-color: rgba(81, 226, 255, 0.35); }
.rc-actions button.online:hover { background: var(--cyan); color: #04141a; }
.rc-record {
  margin-top: 9px;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--faint);
}
.rc-record b { color: var(--cyan); font-family: var(--mono); }

.free-roam {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  margin-top: 16px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  background: linear-gradient(100deg, rgba(12, 18, 24, 0.86), rgba(7, 10, 14, 0.6));
  backdrop-filter: blur(10px);
}
.free-roam h3 { margin: 4px 0 4px; font-size: 24px; font-weight: 800; }
.free-roam p:not(.mini-label) {
  margin: 0;
  max-width: 660px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
.free-roam .btn { min-width: 170px; }

/* ---------------------------------------------------------------- garage */
.garage-screen {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 20px;
  padding-top: 96px;
  padding-bottom: 30px;
}
.garage-col {
  width: 370px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  background: linear-gradient(170deg, rgba(10, 14, 20, 0.9), rgba(6, 9, 13, 0.72));
  backdrop-filter: blur(14px);
  padding: 18px;
  box-shadow: var(--shadow);
}
.garage-col.left { width: 390px; }
.garage-col.right { width: 390px; overflow-y: auto; }
.garage-col::-webkit-scrollbar { width: 4px; }
.garage-col::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); }
.seg {
  display: flex;
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.seg button {
  flex: 1;
  padding: 9px 8px;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  cursor: pointer;
}
.seg button.active { background: rgba(255, 196, 107, 0.12); color: var(--amber); }
.seg button:not(.active):hover { color: var(--ink); }

.garage-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  padding-right: 2px;
}
.garage-list::-webkit-scrollbar { width: 3px; }
.garage-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); }
.car-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.car-item:hover { background: rgba(255, 255, 255, 0.05); }
.car-item.selected { border-color: var(--amber); background: rgba(255, 196, 107, 0.07); }
.car-item .ci-dot {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.5);
}
.car-item > div { min-width: 0; }
.car-item b { display: block; font-size: 13px; font-weight: 700; letter-spacing: 0.01em; }
.car-item small {
  display: block;
  margin-top: 2px;
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--faint);
  text-transform: uppercase;
}
.car-item .ci-state {
  margin-left: auto;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--amber);
}
.car-item .ci-price {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--green);
}
.car-item .ci-price.locked { color: var(--red); }
.car-item.dealer { border-color: var(--line); }

.garage-cash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.garage-cash span { font-size: 9px; letter-spacing: 0.2em; color: var(--faint); }
.garage-cash strong { font-family: var(--mono); font-size: 18px; color: var(--green); }

/* right garage panel */
.car-title h2 { margin: 2px 0 3px; font-size: 30px; font-weight: 800; letter-spacing: -0.01em; }
.car-class {
  margin: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--amber);
}
.garage-blurb {
  margin: 12px 0 16px;
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--muted);
}
.stat-bars { display: grid; gap: 8px; margin-bottom: 18px; }
.swatch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}
.swatches { display: flex; gap: 7px; }
.swatches button {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.swatches button:hover { transform: scale(1.12); }
.swatches button.active { border-color: var(--ink); }
.upgrade-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.upgrades { display: grid; gap: 6px; margin-bottom: 16px; }
.upg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.upg > div { flex: 1; min-width: 0; }
.upg b { font-size: 11px; font-weight: 700; }
.upg small { display: block; margin-top: 2px; font-size: 8.5px; color: var(--faint); line-height: 1.35; }
.pips { display: flex; gap: 3px; margin-top: 5px; }
.pips i { width: 12px; height: 3px; background: rgba(255, 255, 255, 0.12); }
.pips i.on { background: var(--amber); box-shadow: 0 0 6px rgba(255, 196, 107, 0.5); }
.upg button {
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  white-space: nowrap;
}
.upg button:hover:not(:disabled) { background: var(--amber); color: #171007; border-color: transparent; }
.upg button:disabled { opacity: 0.35; cursor: default; }
.garage-actions { display: flex; gap: 8px; }
.garage-actions .btn { flex: 1; min-width: 0; padding: 12px 14px; }
.garage-actions .btn span { font-size: 14px; }
.garage-actions .btn small { font-size: 8.5px; }
.garage-note {
  min-height: 16px;
  margin: 10px 0 0;
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--amber);
}

/* ---------------------------------------------------------------- HUD */
#hud {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  animation: fadeIn 0.4s ease both;
}
#hud > * { pointer-events: none; }

.hud-route-box {
  position: absolute;
  top: 20px;
  left: 22px;
  min-width: 228px;
  padding: 12px 15px;
  border-left: 2px solid var(--amber);
  background: linear-gradient(120deg, rgba(7, 11, 16, 0.86), rgba(7, 11, 16, 0.38));
  backdrop-filter: blur(8px);
}
.hud-cp { display: flex; align-items: center; gap: 12px; margin: 9px 0 8px; }
.cp-arrow {
  display: block;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 20px;
  color: var(--amber);
  border: 1px solid rgba(255, 196, 107, 0.4);
  background: rgba(255, 196, 107, 0.08);
  transition: transform 0.08s linear;
}
.hud-cp b {
  display: block;
  font-size: 10px;
  letter-spacing: 0.13em;
  color: var(--ink);
}
.hud-cp span:not(.cp-arrow) {
  display: block;
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--amber);
}
.online-line { color: var(--faint); }

.hud-racebar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  background: rgba(7, 11, 16, 0.82);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.hud-racebar .cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 74px;
  padding: 9px 14px;
  border-right: 1px solid var(--line);
}
.hud-racebar .cell:last-child { border-right: 0; }
.hud-racebar .cell.wide { min-width: 118px; }
.hud-racebar span { font-size: 8px; letter-spacing: 0.18em; color: var(--faint); }
.hud-racebar b {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.hud-racebar .cell:nth-child(2) b { color: var(--amber); }
.hud-racebar .cell.wide b { color: var(--cyan); }

.standings {
  position: absolute;
  top: 92px;
  right: 22px;
  width: 220px;
  padding: 10px 12px;
  background: rgba(7, 11, 16, 0.78);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.standings ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.standings li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  color: var(--muted);
}
.standings li b {
  width: 15px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
}
.standings li span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.standings li em {
  font-family: var(--mono);
  font-style: normal;
  font-size: 8.5px;
  color: var(--faint);
}
.standings li.me { color: var(--ink); }
.standings li.me b { color: var(--amber); }
.standings li.me em { color: var(--amber); }

.wrong {
  position: absolute;
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 22px;
  border: 1px solid rgba(255, 93, 108, 0.55);
  background: rgba(255, 93, 108, 0.12);
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3em;
  animation: pulse 0.9s ease-in-out infinite;
}
.hud-warn {
  position: absolute;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 14px;
  background: rgba(7, 11, 16, 0.85);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.gauge {
  position: absolute;
  right: 22px;
  bottom: 26px;
  width: 236px;
  height: 236px;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.55));
}
.minimap {
  position: absolute;
  left: 22px;
  bottom: 26px;
  width: 188px;
  height: 188px;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.55));
}
.hud-keys {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8.5px;
  letter-spacing: 0.18em;
  color: rgba(147, 163, 184, 0.55);
  text-transform: uppercase;
  white-space: nowrap;
}

.countdown {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 40;
  font-family: var(--font);
  font-size: clamp(90px, 13vw, 180px);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-shadow: 0 0 70px rgba(255, 196, 107, 0.35);
  pointer-events: none;
}
.countdown[data-tone="go"] { color: var(--green); text-shadow: 0 0 80px rgba(110, 231, 168, 0.5); }
.countdown.pop { animation: pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both; }

.toast {
  position: fixed;
  bottom: 122px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  padding: 9px 18px;
  background: rgba(8, 13, 19, 0.92);
  border: 1px solid var(--line-strong);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink);
  animation: fadeUp 0.25s ease both;
}

/* ---------------------------------------------------------------- overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  background: rgba(3, 5, 8, 0.66);
  backdrop-filter: blur(9px);
  animation: fadeIn 0.25s ease both;
}
.overlay .panel {
  width: min(680px, 100%);
  padding: 34px 36px;
  border: 1px solid var(--line-strong);
  border-top: 2px solid var(--amber);
  background: linear-gradient(165deg, rgba(12, 17, 24, 0.97), rgba(6, 9, 13, 0.97));
  box-shadow: var(--shadow);
  max-height: 92vh;
  overflow-y: auto;
}
.overlay .panel.narrow { width: min(470px, 100%); }
.overlay h2 {
  margin: 0 0 18px;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}
.panel-copy {
  margin: 0 0 20px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.modal-input {
  width: 100%;
  margin: -6px 0 20px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: rgba(4, 7, 10, 0.9);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.06em;
  outline: none;
}
.modal-input:focus { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255, 196, 107, 0.25); }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.panel-actions .btn { flex: 1 1 150px; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.result-grid > div {
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}
.result-grid span {
  display: block;
  font-size: 8px;
  letter-spacing: 0.16em;
  color: var(--faint);
}
.result-grid b {
  display: block;
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink);
}
.result-grid b.reward { color: var(--green); }
.res-standings {
  display: grid;
  gap: 4px;
  margin-bottom: 18px;
}
.res-standings .row {
  display: flex;
  justify-content: space-between;
  padding: 7px 10px;
  border: 1px solid var(--line);
  font-size: 11px;
}
.res-standings .row.me { border-color: rgba(255, 196, 107, 0.45); color: var(--amber); }
.res-standings .row b { font-family: var(--mono); font-size: 11px; }
.res-standings .row em { font-style: normal; color: var(--faint); font-family: var(--mono); font-size: 10px; }

/* ---------------------------------------------------------------- animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(0.72); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes pulse { 0%, 100% { opacity: 0.65; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1250px) {
  .race-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .race-card { min-height: 290px; }
  .garage-col, .garage-col.left, .garage-col.right { width: 340px; }
}
@media (max-width: 980px) {
  .screen { padding: 92px 22px 22px; }
  #screen-menu { grid-template-columns: 1fr; align-items: end; }
  .menu-car { display: none; }
  .menu-hero h1 { font-size: clamp(52px, 13vw, 96px); }
  .garage-col.left { width: 45%; }
  .garage-col.right { width: 45%; }
  .garage-screen { gap: 10px; }
  .hud-racebar .cell:not(.wide) { min-width: 58px; padding: 8px 9px; }
  .hud-racebar .cell.wide { min-width: 96px; }
  .hud-racebar b { font-size: 12px; }
  .gauge { width: 190px; height: 190px; right: 14px; bottom: 18px; }
  .minimap { width: 150px; height: 150px; left: 14px; bottom: 18px; }
  .hud-keys { display: none; }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  #topbar { height: 64px; padding: 0 14px; }
  .brand-text small { display: none; }
  .cash-chip, .name-chip { padding: 5px 9px; }
  .icon-btn { display: none; }
  .screen { padding: 80px 14px 14px; }
  .race-grid { grid-template-columns: 1fr; }
  .free-roam { flex-direction: column; align-items: flex-start; }
  .garage-screen { flex-direction: column; padding-top: 76px; }
  .garage-col, .garage-col.left, .garage-col.right { width: 100%; max-height: 42vh; }
  .head-right { display: none; }
  .hud-route-box { min-width: 0; width: 172px; padding: 9px 11px; }
  .hud-cp b { font-size: 8px; }
  .hud-racebar { top: 150px; }
  .standings { display: none !important; }
  .gauge { width: 158px; height: 158px; }
  .minimap { width: 128px; height: 128px; }
}
