/* DORFDRIFT — dark rally UI, warm amber accent (#ff8a1e) + asphalt greys. */
:root {
  --accent: #ff8a1e;
  --accent2: #ffb347;
  --bg: #0d0e12;
  --panel: #181a20;
  --panel2: #20232b;
  --ink: #f3f4f6;
  --dim: #9aa0ac;
  --line: #2c2f38;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: var(--bg); color: var(--ink); overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
canvas#game { display: block; position: fixed; inset: 0; width: 100%; height: 100%; background: #11331d; }

#attribution {
  position: fixed; right: 8px; bottom: 6px; z-index: 5;
  font-size: 10px; color: rgba(255,255,255,0.55);
  background: rgba(0,0,0,0.35); padding: 2px 7px; border-radius: 6px;
  pointer-events: none; letter-spacing: 0.2px;
}
/* hide attribution behind the speedo on tiny screens is fine; keep it readable */
@media (max-width: 520px) { #attribution { font-size: 9px; bottom: 2px; } }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 120% at 50% 0%, rgba(40,30,12,0.55), rgba(8,9,12,0.92));
  backdrop-filter: blur(3px);
  overflow-y: auto; padding: 20px;
}
.overlay.hidden { display: none; }

/* ---------- menu ---------- */
.menu-inner {
  width: min(680px, 100%); background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 22px 24px 26px; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.brand { text-align: center; margin-bottom: 14px; }
.logo {
  margin: 0; font-weight: 900; letter-spacing: 2px;
  font-size: clamp(40px, 9vw, 68px); line-height: 1;
  background: linear-gradient(180deg, #fff, #ffd9a8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 2px 0 rgba(0,0,0,0.2);
}
.logo span { color: var(--accent); -webkit-text-fill-color: var(--accent); }
.tagline { margin: 6px 0 0; color: var(--dim); font-size: 14px; }
.tagline strong { color: var(--accent2); }

.block { margin-top: 16px; }
.block > h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); }
.block .dim { color: var(--dim); font-weight: 500; text-transform: none; letter-spacing: 0; }
/* Die Reihe unter den Streckenkarten. Sie hielt urspruenglich ZWEI Abschnitte
   (Modus, Farbe) und haelt seit dem 2026-08-10 vier: dazu kamen Klasse und
   Satellitenbild.

   ⚠️ Als Flexbox brach sie damit auseinander, und zwar aus dem Grund, den man
   bei Flexbox genau einmal lernt: ein Flex-Kind schrumpft NICHT unter die
   Breite seines Inhalts, weil `min-width` bei Flex-Kindern auf `auto` steht.
   Die Klassenleiste ("Kleinwagen Sportwagen Rennwagen Unvernunft") ist breit,
   also wuchs die Reihe ueber den Kasten hinaus und die Auto-Farbe stand
   ausserhalb des Menues, mit umgebrochener Ueberschrift.

   Als Raster mit `auto-fit` legen sich vier Abschnitte von selbst in zwei
   Reihen, und `min-width: 0` erlaubt den Kindern endlich zu schrumpfen. */
.menu-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}
.menu-row .half { min-width: 0; }

/* track cards */
.track-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .track-cards { grid-template-columns: 1fr; } }
.track-card {
  background: var(--panel2); border: 2px solid var(--line); border-radius: 12px;
  padding: 10px; cursor: pointer; transition: border-color .12s, transform .12s;
  text-align: left;
}
.track-card:hover { transform: translateY(-2px); }
.track-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.track-card canvas { width: 100%; height: 88px; display: block; border-radius: 8px; background: #14241a; }
.track-card .tc-name { font-weight: 700; font-size: 14px; margin: 8px 0 2px; }
.track-card .tc-meta { font-size: 12px; color: var(--dim); }

/* segmented toggle */
/* Die Segmentleiste. `flex-wrap` und `min-width: 0` am Knopf, damit vier
   Klassennamen notfalls umbrechen statt die ganze Reihe aufzureissen. */
.seg { display: flex; flex-wrap: wrap; background: var(--panel2); border-radius: 10px; padding: 4px; gap: 4px; }
.seg-btn {
  flex: 1 1 auto; min-width: 0; border: none; background: transparent; color: var(--dim);
  padding: 9px 6px; border-radius: 7px; cursor: pointer; font-weight: 700; font-size: 12.5px;
  white-space: nowrap;
}
.seg-btn.active { background: var(--accent); color: #1a1206; }

/* colors */
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 3px solid transparent; transition: transform .1s;
}
.swatch.sel { border-color: #fff; transform: scale(1.12); }

/* scoreboard */
.board-body { font-size: 13px; color: var(--ink); }
.board-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--line); }
.board-row:last-child { border-bottom: none; }
.board-row .who { color: var(--dim); }
.board-section-h { color: var(--accent2); font-weight: 700; margin: 8px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

/* CTA buttons */
.cta {
  display: block; width: 100%; margin-top: 18px;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  color: #1a1206; border: none; border-radius: 12px;
  padding: 14px; font-size: 18px; font-weight: 900; letter-spacing: 1px;
  cursor: pointer; box-shadow: 0 6px 18px rgba(255,138,30,0.35);
}
.cta:active { transform: translateY(1px); }
.ghost {
  background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-weight: 700; cursor: pointer; font-size: 14px;
}
.legal { margin: 12px 0 0; text-align: center; font-size: 11px; color: var(--dim); }

/* ---------- modal (pause / results) ---------- */
.modal {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; text-align: center;
  box-shadow: 0 16px 50px rgba(0,0,0,0.55);
}
.modal.wide { width: min(520px, 100%); }
.modal h2 { margin: 0 0 14px; font-size: 26px; }
.modal .cta { margin-top: 10px; }
.modal-row { display: flex; gap: 8px; margin-top: 14px; }
.modal-row .cta { flex: 1.4; margin-top: 0; }
.modal-row .ghost { flex: 1; }
@media (max-width: 420px) { .modal-row { flex-wrap: wrap; } }

/* standings */
.standings { text-align: left; }
.stand-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; margin-bottom: 6px; background: var(--panel2);
}
.stand-row.you { box-shadow: 0 0 0 2px var(--accent) inset; }
.stand-pos { font-weight: 900; font-size: 18px; width: 28px; color: var(--accent2); }
.stand-dot { width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.stand-name { flex: 1; font-weight: 700; }
.stand-time { color: var(--dim); font-variant-numeric: tabular-nums; }
.results-meta { margin-top: 12px; color: var(--dim); font-size: 13px; }
.results-meta b { color: var(--ink); }

/* ---------- touch controls ---------- */
#touch { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#touch.hidden { display: none; }
.touch-left { position: absolute; left: 14px; bottom: 20px; display: flex; gap: 12px; }
.touch-right { position: absolute; right: 14px; bottom: 20px; display: flex; gap: 12px; align-items: flex-end; }
.tbtn {
  pointer-events: auto; width: 74px; height: 74px; border-radius: 50%;
  background: rgba(30,32,40,0.7); color: #fff; border: 2px solid rgba(255,255,255,0.18);
  font-size: 26px; font-weight: 800; backdrop-filter: blur(2px);
}
.tbtn.gas { background: rgba(255,138,30,0.78); color: #1a1206; width: 88px; height: 88px; font-size: 18px; }
.tbtn.small { width: 60px; height: 60px; font-size: 12px; }
.tbtn:active { filter: brightness(1.25); }

/* utility */
.hidden { display: none !important; }
