/* Shared by both pages: colours, type, buttons, panels and the test drive layout.
   Dark only: near-black, charcoal panels, silver and white type, thin hairlines. No gradients, no glow. */

:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --panel: #131316;
  --ink: #f3f3f1;
  --silver: #c4c6ca;
  --muted: #8d9096;
  --line: #26272c;
  --line-strong: #3b3c42;
  --track: #212227; /* canvas: asphalt */
  --corner: #303137; /* canvas: asphalt in the corners */
  --edge: #dcdcd8; /* canvas: edge lines and the light chequer squares */
  --chequer: #0b0b0c; /* canvas: dark chequer squares and badge rings */
  --accent: #f3f3f1; /* main buttons: white with black type */
  --accent-ink: #0a0a0b;
  --mine: #1f2025;
  --ok: #8fd0a6;
  --bad: #f0907e;
  --warn-bg: #2b1d1a;
  --meter: #d6d7db;
  --meter-track: #2a2b30;
  --split-1: #e4e5e8;
  --split-2: #9a9ca2;
  --split-3: #585a60;
  --class-muscle: #d9a81c; /* the four car classes: the same colours as CAR_CLASSES in scene.mjs */
  --class-gt: #babdc2;
  --class-super: #b9362c;
  --class-hyper: #3156b8;
  --head: "Michroma", "Inter", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* the hidden attribute wins over any display rule */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--ink); color: var(--bg); }

.page { max-width: 1240px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 40px; }

h1 { margin: 0; font: 400 1.45rem/1.2 var(--head); letter-spacing: 0.06em; text-transform: uppercase; }
h2 { margin: 0 0 14px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.lead { margin: 10px 0 20px; color: var(--muted); max-width: 62ch; }
.note { margin: 10px 0 0; color: var(--muted); font-size: 0.9rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 2px; padding: 18px 20px; min-width: 0; }
.setup, .stage { display: grid; gap: 16px; margin-bottom: 16px; }

button {
  min-height: 44px;
  padding: 12px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}
button:hover:not(:disabled) { border-color: var(--silver); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
button:disabled { opacity: 0.4; cursor: default; }
button.primary, .tracks button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { background: #fff; border-color: #fff; }
:lang(zh) button { letter-spacing: 0.06em; }

/* the share link after a race: looks like the primary button */
.share { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 16px; padding: 12px 20px; border: 1px solid var(--accent); border-radius: 2px; background: var(--accent); color: var(--accent-ink); font-size: 0.78rem; font-weight: 600; line-height: 1.2; letter-spacing: 0.14em; text-decoration: none; text-transform: uppercase; transition: background-color 0.2s, border-color 0.2s; }
.share:hover { background: #fff; border-color: #fff; }
:lang(zh) .share { letter-spacing: 0.06em; }

.tracks, .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions { margin-top: 16px; }
.tracks button { flex: 1 1 0; padding: 10px 12px; }

.legend { margin: 12px 0 0; font-size: 0.85rem; color: var(--muted); }
.swatch { display: inline-block; width: 22px; height: 12px; margin-right: 6px; vertical-align: -2px; background: var(--track); border-top: 1px solid var(--edge); border-bottom: 1px solid var(--edge); }
.swatch.corner { background: var(--corner); margin-left: 14px; }

.car-head { display: flex; align-items: center; gap: 10px; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 22px; margin: 16px 0 0; }
.stat { display: grid; grid-template-columns: 1fr auto; font-size: 0.9rem; color: var(--muted); }
.stat b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; height: 3px; margin-top: 6px; background: var(--line-strong); }
.bar i { display: block; height: 100%; background: var(--ink); }

.hud { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.hud strong { font: 400 0.92rem var(--head); letter-spacing: 0.08em; text-transform: uppercase; }
.hud span { color: var(--muted); font-size: 0.9rem; text-align: right; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 10 / 7; }

.board { list-style: none; margin: 0; padding: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.board li:last-child { border-bottom: 0; }
.board li.mine { background: var(--mine); font-weight: 600; }
.board .place { width: 1.4em; color: var(--muted); font-variant-numeric: tabular-nums; }
.board .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .time { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip { display: inline-block; min-width: 24px; padding: 0 6px; border-radius: 999px; color: #fff; font-size: 0.78rem; font-weight: 600; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }

.seed { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.seed span { color: var(--muted); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; }
.seed code { flex: 1; min-width: 19ch; color: var(--silver); font: 0.92rem var(--mono); overflow-wrap: anywhere; }

footer { margin-top: 24px; color: var(--muted); font-size: 0.85rem; text-align: center; }

/* language toggle (both pages) and the test drive header */
.lang { display: inline-flex; flex: none; border: 1px solid var(--line-strong); border-radius: 2px; overflow: hidden; }
.lang button { min-height: 34px; padding: 6px 11px; border: 0; border-radius: 0; color: var(--muted); font-size: 0.74rem; letter-spacing: 0.08em; }
.lang button + button { border-left: 1px solid var(--line-strong); }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.drive-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.drive-head .lead { margin-bottom: 0; }
.home-link { display: inline-flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.home-link img { width: 34px; height: auto; }
.home-link:hover span { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }

@media (min-width: 760px) {
  .setup { grid-template-columns: 1fr 1fr; }
  .stage { grid-template-columns: minmax(0, 1fr) 280px; }
}

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