:root{
  --bg:#0a0e13; --panel:rgba(12,18,26,.92); --panel2:#131c27; --line:#243244; --text:#e8eef5; --muted:#8a9aab;
  --accent:#ffd23f; --good:#4ade80; --bad:#f87171; --ghost:#7fb2ff;
  color-scheme: dark;
}
*{ box-sizing:border-box; }
html,body{ margin:0; height:100%; background:var(--bg); color:var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; overflow:hidden; }
button{ font:inherit; color:inherit; }

.stage{ position:fixed; inset:0; background:#0f2418; user-select:none; -webkit-user-select:none; }
canvas{ position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; }

/* ===== HUD ===== */
.hud{ position:absolute; left:12px; top:12px; display:flex; flex-wrap:wrap; gap:6px; max-width:calc(100% - 260px); z-index:2; }
.hud[hidden]{ display:none; }
.pill{ padding:5px 10px; border:1px solid var(--line); border-radius:999px; background:rgba(10,14,19,.75);
  font-variant-numeric:tabular-nums; white-space:nowrap; font-size:13px; }
.pill b{ color:var(--muted); font-weight:500; margin-right:5px; }

/* ===== Menüs ===== */
.menue{ position:absolute; inset:0; z-index:3; display:flex; align-items:center; justify-content:center;
  background:radial-gradient(ellipse at center, rgba(5,8,12,.55), rgba(5,8,12,.85)); padding:16px; overflow:auto; }
.menue[hidden]{ display:none; }
.screen{ width:min(920px,100%); max-height:100%; margin:auto; }
.screen[hidden]{ display:none; }
.logo{ font-size:clamp(40px,8vw,78px); font-weight:900; letter-spacing:.08em; margin:0; text-align:center;
  text-shadow:0 4px 0 rgba(0,0,0,.4); }
.logo span{ color:var(--accent); }
.untertitel{ text-align:center; color:var(--muted); margin:4px 0 22px; }
.gross-titel{ text-align:center; font-size:48px; font-weight:900; margin:0 0 18px; }

.namensfeld{ display:block; width:min(420px,100%); margin:0 auto 18px; }
.namensfeld span{ display:block; font-size:13px; color:var(--muted); margin-bottom:5px; }
.namensfeld input{ width:100%; padding:11px 14px; font-size:17px; border-radius:10px; border:1px solid var(--line);
  background:var(--panel2); color:var(--text); outline:none; }
.namensfeld input:focus{ border-color:var(--accent); }
.namensfeld small{ display:block; margin-top:5px; font-size:12px; color:var(--muted); min-height:1.2em; }
.namensfeld small.fehler{ color:var(--bad); }
.namensfeld small.gut{ color:var(--good); }

.knoepfe{ display:flex; flex-direction:column; gap:10px; width:min(420px,100%); margin:0 auto; }
.knoepfe.reihe{ flex-direction:row; justify-content:center; width:auto; margin-top:14px; }
.knopf{ padding:12px 16px; border-radius:12px; border:1px solid var(--line); background:var(--panel2);
  cursor:pointer; font-size:16px; text-align:left; transition:transform .08s, border-color .15s, background .15s; }
.knopf:hover, .knopf:focus-visible{ border-color:var(--accent); background:#1a2533; outline:none; }
.knopf:active{ transform:scale(.98); }
.knopf:disabled{ opacity:.45; cursor:default; border-color:var(--line); background:var(--panel2); transform:none; }
.knopf.gross{ font-size:18px; font-weight:700; padding:14px 18px; }
.knopf small{ color:var(--muted); font-weight:400; margin-left:6px; }
.knopf-klein{ padding:6px 12px; border-radius:999px; border:1px solid var(--line); background:var(--panel2);
  cursor:pointer; font-size:13px; }
.knopf-klein:hover{ border-color:var(--accent); }
.fusszeile{ display:flex; gap:8px; justify-content:center; align-items:center; flex-wrap:wrap; margin-top:20px; }
.leise{ color:var(--muted); font-size:13px; }

.kopf{ display:flex; align-items:center; gap:14px; margin-bottom:14px; }
.kopf h2{ margin:0; font-size:24px; }

/* Karten (Strecken, Autos) */
.karten{ display:grid; grid-template-columns:repeat(auto-fill,minmax(210px,1fr)); gap:12px; }
.karte{ border:1px solid var(--line); border-radius:14px; background:var(--panel); overflow:hidden; cursor:pointer;
  display:flex; flex-direction:column; transition:border-color .15s, transform .08s; text-align:left; padding:0; }
.karte:hover, .karte:focus-visible{ border-color:var(--accent); outline:none; }
.karte:active{ transform:scale(.99); }
.karte.aktiv{ border-color:var(--accent); box-shadow:0 0 0 2px rgba(255,210,63,.35); }
.karte canvas{ position:static; width:100%; height:auto; aspect-ratio:16/10; background:#0f2418; }
.karte .inhalt{ padding:10px 12px 12px; display:flex; flex-direction:column; gap:3px; }
.karte h3{ margin:0 0 2px; font-size:17px; }
.karte .ideal{ margin:0 0 6px; font-size:12px; color:#d9b27a; font-weight:600; }
.karte .zeile{ display:flex; justify-content:space-between; gap:8px; font-size:13px; color:var(--muted);
  font-variant-numeric:tabular-nums; }
.karte .zeile b{ color:var(--text); font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.karte .zeile b.gold{ color:var(--accent); }
.karte .aktionen{ display:flex; gap:6px; margin-top:8px; }
.karte .text{ font-size:13px; color:var(--muted); margin:0 0 6px; }
.balken{ display:grid; grid-template-columns:90px 1fr; gap:4px 8px; align-items:center; font-size:12px; color:var(--muted); }
.balken i{ display:block; height:6px; border-radius:3px; background:#233042; overflow:hidden; }
.balken i::after{ content:""; display:block; height:100%; width:var(--w); background:var(--accent); border-radius:3px; }

.lack{ display:flex; align-items:center; gap:12px; margin-top:14px; flex-wrap:wrap; }
.farben{ display:flex; gap:8px; flex-wrap:wrap; }
.farben button{ width:30px; height:30px; border-radius:50%; border:2px solid rgba(255,255,255,.2); cursor:pointer; }
.farben button.aktiv{ border-color:#fff; box-shadow:0 0 0 2px var(--accent); }

/* Konto */
.logo{ color:var(--accent); letter-spacing:.22em; }
.kontofeld{ width:min(460px,100%); margin:0 auto 18px; padding:12px 14px; border:1px solid var(--line); border-radius:14px;
  background:var(--panel); text-align:center; }
.kontofeld p{ margin:0 0 10px; }
.kontofeld .knopf-zeile{ justify-content:center; flex-wrap:wrap; }
.kontofeld .knopf{ flex:1 1 auto; text-align:center; font-size:15px; padding:10px 12px; }
.fahrer-zeile{ font-size:16px; }
.fahrer-zeile b{ color:var(--accent); }
.screen.schmal{ width:min(520px,100%); }
.screen.schmal h2{ margin-top:0; }
.eingabe.breit{ width:100%; font-size:17px; }
.code-feld{ text-transform:uppercase; letter-spacing:.12em; font-family:ui-monospace, Consolas, monospace; text-align:center; }
.code-anzeige{ word-break:break-all; }
.haken{ display:flex; gap:8px; align-items:center; justify-content:center; margin:16px 0 4px; cursor:pointer; }
.haken input{ width:18px; height:18px; }
.knopf.rot{ border-color:#7f1d1d; color:var(--bad); }
a.knopf, a.knopf-klein{ text-decoration:none; display:inline-block; }

/* Name / Geräte */
.namens-link{ text-align:center; margin:-10px 0 16px; }
.knopf-link{ background:none; border:0; color:var(--muted); font-size:13px; cursor:pointer; text-decoration:underline; }
.knopf-link:hover{ color:var(--accent); }
.karten.zwei{ grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); }
.karte.ohne-klick{ cursor:default; }
.karte.ohne-klick:hover{ border-color:var(--line); }
.karte.ohne-klick .inhalt{ gap:10px; padding:16px; }
.eingabe.code.breit{ width:100%; }
.code-anzeige{ font:800 34px/1.2 ui-monospace, Consolas, monospace; letter-spacing:.25em; color:var(--accent);
  text-align:center; margin:4px 0 0; }

/* Online */
.mittig{ text-align:center; max-width:620px; margin-left:auto; margin-right:auto; }
.knopf-zeile{ display:flex; gap:8px; }
.knopf-zeile .knopf{ flex:1; }
.eingabe{ padding:10px 12px; border-radius:12px; border:1px solid var(--line); background:var(--panel2);
  color:var(--text); font-size:15px; min-width:0; }
.eingabe.code{ width:110px; text-transform:uppercase; letter-spacing:.2em; font-weight:700; text-align:center; }
.raum-code{ color:var(--accent); letter-spacing:.15em; font-family:ui-monospace, Consolas, monospace; }
.raum-status{ font-size:18px; font-weight:600; margin:0 0 12px; }
.knopf.an{ border-color:var(--good); background:rgba(74,222,128,.15); }
.bereit-ja{ color:var(--good); font-weight:600; }
.liste.raum-tabelle td:first-child{ width:auto; color:var(--text); }
.status-ungueltig{ color:var(--bad); }

/* Bestenliste */
.liste-rahmen{ border:1px solid var(--line); border-radius:14px; background:var(--panel); padding:6px 10px; max-height:60vh; overflow:auto; }
.liste{ width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums; }
.liste th{ text-align:left; font-size:12px; color:var(--muted); font-weight:500; padding:6px 8px; border-bottom:1px solid var(--line); }
.liste td{ padding:7px 8px; border-bottom:1px solid rgba(36,50,68,.5); font-size:14px; }
.liste tr.ich td{ background:rgba(255,210,63,.1); }
.liste tr.trenner td{ text-align:center; color:var(--muted); padding:2px; }
.liste td:first-child{ width:36px; color:var(--muted); }
.liste td.zeit{ font-weight:700; }
.liste .platz1{ color:var(--accent); font-weight:800; }
.auto-punkt{ display:inline-block; width:10px; height:10px; border-radius:50%; margin-right:6px; vertical-align:middle; }

.tasten{ border-collapse:collapse; margin-bottom:12px; }
.tasten td{ padding:6px 12px 6px 0; font-size:14px; }
kbd{ display:inline-block; min-width:1.6em; padding:0 5px; text-align:center; border:1px solid var(--line);
  border-bottom-width:2px; border-radius:5px; background:var(--panel2); font:12px/1.6 ui-monospace, Consolas, monospace; }

/* ===== Touch ===== */
.touch{ position:absolute; left:0; right:0; bottom:0; z-index:2; display:flex; justify-content:space-between;
  align-items:flex-end; padding:0 12px calc(12px + env(safe-area-inset-bottom)); pointer-events:none; }
.touch[hidden]{ display:none; }
.touch > div{ display:flex; gap:10px; align-items:flex-end; pointer-events:auto; }
.touch button{ width:72px; height:72px; border-radius:50%; border:2px solid rgba(255,255,255,.25);
  background:rgba(10,14,19,.45); font-size:26px; touch-action:none; }
.touch button.klein{ width:58px; height:58px; font-size:13px; }
.touch button.gas{ width:88px; height:88px; font-size:18px; font-weight:700; border-color:rgba(74,222,128,.6); }
.touch button.an{ background:rgba(255,210,63,.35); }

@media (max-width:640px){
  .hud{ max-width:calc(100% - 150px); }
  .pill{ font-size:11px; padding:4px 8px; }
  .karten{ grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); }
}
#code-anzeige{ font-size:clamp(20px,5vw,28px); letter-spacing:.1em; margin:14px 0; user-select:all; -webkit-user-select:all; }
.leise.fehler{ color:var(--bad); }
.leise.gut{ color:var(--good); }

/* kompakteres Hauptmenü (passt auch bei 720 px Höhe) */
.screen[data-screen="haupt"] .logo{ font-size:clamp(36px,7vw,64px); }
.screen[data-screen="haupt"] .untertitel{ margin:2px 0 14px; }
.screen[data-screen="haupt"] .kontofeld{ margin-bottom:12px; padding:10px 12px; }
.screen[data-screen="haupt"] .knoepfe{ gap:8px; }
.screen[data-screen="haupt"] .knopf.gross{ padding:11px 16px; }
.screen[data-screen="haupt"] .fusszeile{ margin-top:14px; }
a.knopf, a.knopf-klein{ color:var(--text); }

/* Garage: Geld, gesperrte Autos, Tuning */
.geld{ color:#facc15; font-weight:700; white-space:nowrap; }
.geld.gross{ margin-left:auto; font-size:18px; }
.karte.gesperrt canvas{ filter:grayscale(.85) brightness(.7); }
.karte.gesperrt{ cursor:default; }
.karte .aktionen{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.knopf-klein:disabled{ opacity:.45; cursor:not-allowed; }
.tuning{ max-width:760px; margin:14px auto 0; padding:12px 14px; background:var(--panel, #111a24); border:1px solid #233042; border-radius:12px; }
.tuning h3{ margin:0 0 8px; }
.tuning-teile{ display:grid; gap:8px; }
.tuning .teil{ display:flex; justify-content:space-between; align-items:center; gap:12px; padding:6px 0; border-bottom:1px solid #1b2634; font-size:14px; }
.tuning .stufen i{ display:inline-block; width:12px; height:12px; margin-right:3px; border-radius:3px; background:#233042; vertical-align:middle; }
.tuning .stufen i.an{ background:var(--accent); }
.haken{ display:flex; align-items:center; gap:8px; margin-top:10px; font-size:14px; cursor:pointer; }
.haken.mittig{ justify-content:center; }
small.tu{ color:#d9b27a; font-size:11px; margin-left:4px; }
/* Rangliste: Umschalter Serie / Getunt */
.umschalter{ display:flex; justify-content:center; gap:6px; margin:0 0 10px; }
.umschalter .knopf-klein.an{ border-color:var(--accent); background:rgba(255,210,63,.18); color:var(--text); }
@media (max-width:560px){ .tuning .teil{ flex-direction:column; align-items:flex-start; } }
