:root {
  --bg: #0e1016;
  --panel: #171a24;
  --panel2: #1e2231;
  --line: #272c3c;
  --text: #e6e9f2;
  --dim: #8c93a8;
  --accent: #5ee6a8;
  --accent2: #6f8cff;
  --red: #ff566e;
  --amber: #ffc35c;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", system-ui, sans-serif;
  min-height: 100vh;
}
body.center { display: grid; place-items: center; padding: 24px; }

h1 { font-size: 26px; }
h2 { font-size: 17px; margin-bottom: 14px; font-weight: 600; }
b { font-weight: 600; }
small { font-size: 12px; }
.hint { color: var(--dim); font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; font-family: "Consolas", monospace; }
.ok { color: var(--accent); font-size: 13px; }
.err { color: var(--red); font-size: 13px; margin-bottom: 10px; }
.good { color: var(--accent); }
.bad { color: var(--red); }

/* --- Topbar --- */
#topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 22px; height: 58px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 17px; white-space: nowrap; }
#nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
#nav button {
  background: none; border: 0; color: var(--dim);
  padding: 8px 14px; border-radius: 8px;
  font-size: 14px; cursor: pointer; white-space: nowrap;
}
#nav button:hover { color: var(--text); background: var(--panel2); }
#nav button.active { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--accent); }
.me { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.chip {
  background: var(--panel2); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 20px; font-size: 12px;
}
.net { font-size: 11px; }
.net.on { color: var(--accent); }
.net.off { color: var(--amber); }
.queued { color: var(--amber); font-size: 12px; }

main { max-width: 1120px; margin: 0 auto; padding: 24px 22px 60px; }

/* --- Karten & Grids --- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.grid { display: grid; gap: 14px; margin-bottom: 18px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .grid.two { grid-template-columns: 1fr; } }

.stat { margin: 0; display: flex; flex-direction: column; gap: 3px; }
.stat .lab { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.stat b { font-size: 24px; font-variant-numeric: tabular-nums; }
.stat small { color: var(--dim); }
.bar { height: 5px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin: 6px 0 2px; }
.bar i { display: block; height: 100%; background: var(--accent); }

/* --- Buttons & Felder --- */
button.primary {
  background: var(--accent); color: #08120d; border: 0;
  padding: 9px 16px; border-radius: 8px;
  font-weight: 600; font-size: 14px; cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }
button.primary:disabled { opacity: .5; cursor: default; }
button.big { padding: 12px 22px; font-size: 15px; width: 100%; margin-top: 12px; }
button.ghost {
  background: none; border: 1px solid var(--line); color: var(--dim);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: var(--dim); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 5px; }
input, select {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 8px; font-size: 14px; width: 100%;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent2); }
input[type=range] { padding: 0; }
.field small { display: block; color: var(--dim); margin-top: 5px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.row > * { width: auto; flex: 1; min-width: 120px; }
.row button { flex: 0; }

.warn {
  background: rgba(255, 195, 92, .08);
  border: 1px solid rgba(255, 195, 92, .3);
  color: #ffd99a;
  padding: 12px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}

/* --- Auth --- */
.auth { width: 380px; max-width: 100%; }
.auth h1 { margin-bottom: 6px; }
.auth .hint { margin-bottom: 18px; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; }
.tabs button {
  flex: 1; background: var(--panel2); border: 1px solid var(--line);
  color: var(--dim); padding: 8px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tabs button.active { color: var(--text); border-color: var(--accent); }

/* --- Charts --- */
.chart { width: 100%; min-height: 200px; display: grid; place-items: center; }
.chart svg { width: 100%; height: auto; }
.chart .empty { text-align: center; }
.linechart .grid, .radar .grid { stroke: var(--line); stroke-width: 1; fill: none; }
.linechart .line { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-linejoin: round; }
.linechart .line.inv { stroke: var(--accent2); }
.linechart .area { fill: rgba(94, 230, 168, .1); stroke: none; }
.linechart .area.inv { fill: rgba(111, 140, 255, .1); }
.dot { fill: var(--accent); }
.dot.inv { fill: var(--accent2); }
.axis { fill: var(--dim); font-size: 10px; font-family: inherit; }
.axis.label { fill: var(--dim); font-size: 11px; }
.radar-fill { fill: rgba(94, 230, 168, .18); stroke: var(--accent); stroke-width: 2; }

/* --- Empfehlungen --- */
.recs { display: grid; gap: 12px; }
.rec {
  background: var(--panel2); border: 1px solid var(--line);
  border-left: 3px solid var(--dim);
  border-radius: 8px; padding: 13px 15px;
}
.rec.high { border-left-color: var(--red); }
.rec.mid { border-left-color: var(--amber); }
.rec.low { border-left-color: var(--accent2); }
.rec-h { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.rec p { color: var(--dim); font-size: 13px; margin-bottom: 8px; }
.pill {
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 20px; color: var(--dim);
}

/* --- Lektionen --- */
.lesson.locked { opacity: .55; }
.lock { font-size: 12px; color: var(--amber); font-weight: 400; }
.scen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.scen {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 13px;
  display: flex; flex-direction: column; gap: 6px;
}
.scen.locked { opacity: .5; }
.scen p { color: var(--dim); font-size: 12.5px; flex: 1; }
.scen-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.scen-foot small { color: var(--dim); }

/* --- Kalibrierung --- */
.calib-progress { display: flex; gap: 6px; margin: 16px 0; }
.calib-progress i {
  flex: 1; height: 5px; border-radius: 3px; background: var(--panel2);
}
.calib-progress i.done { background: var(--accent); }
.calib-progress i.now { background: var(--accent2); }
.calib-now {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  background: var(--panel2); border-radius: 8px; padding: 14px; margin-bottom: 10px;
}
.calib-now .lab { display: block; color: var(--dim); font-size: 11px; text-transform: uppercase; }
.calib-now b { font-size: 20px; }
.result-hero {
  text-align: center; padding: 22px; background: var(--panel2);
  border-radius: 10px; margin-bottom: 14px;
}
.result-hero .lab { display: block; color: var(--dim); font-size: 12px; text-transform: uppercase; }
.result-hero b { display: block; font-size: 40px; color: var(--accent); margin: 4px 0; }
.conf { color: var(--dim); font-size: 13px; }
.reasons { list-style: none; margin-bottom: 16px; }
.reasons li {
  color: var(--dim); font-size: 13.5px; padding: 7px 0 7px 20px;
  position: relative; border-bottom: 1px solid var(--line);
}
.reasons li:before { content: "→"; position: absolute; left: 0; color: var(--accent2); }

/* --- Tabellen --- */
.table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--dim); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table tr.you { background: rgba(94, 230, 168, .07); }
.big-n { font-size: 17px; color: var(--accent); font-weight: 600; }
.minibar {
  display: inline-block; width: 60px; height: 5px; background: var(--panel2);
  border-radius: 3px; overflow: hidden; vertical-align: middle; margin-right: 6px;
}
.minibar i { display: block; height: 100%; background: var(--accent2); }
.conv-out { background: var(--panel2); border-radius: 8px; padding: 12px; font-size: 13px; color: var(--dim); }
.conv-out b { color: var(--text); }

/* --- Spiel-Overlay --- */
#game { position: fixed; inset: 0; z-index: 100; background: #11131a; }
#canvas { display: block; width: 100%; height: 100%; cursor: none; }
/* Fadenkreuz: liegt fix in der Bildschirmmitte. Der Rueckstoss verschiebt die
   Kamera, nicht das Crosshair - genau wie in einem echten Shooter. */
#crosshair {
  position: absolute; top: 50%; left: 50%;
  width: 26px; height: 26px; transform: translate(-50%, -50%);
  pointer-events: none;
}
#crosshair i {
  position: absolute; background: var(--accent);
  box-shadow: 0 0 3px rgba(0, 0, 0, .9);
}
#crosshair i:nth-child(1) { left: 0; top: 12px; width: 8px; height: 2px; }
#crosshair i:nth-child(2) { right: 0; top: 12px; width: 8px; height: 2px; }
#crosshair i:nth-child(3) { top: 0; left: 12px; width: 2px; height: 8px; }
#crosshair i:nth-child(4) { bottom: 0; left: 12px; width: 2px; height: 8px; }

#hud {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 28px; background: rgba(14, 16, 22, .82);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 22px;
}
#hud .lab { display: block; color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
#hud b { font-size: 19px; font-variant-numeric: tabular-nums; }
#drift-flash {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -140px);
  color: var(--amber); font-size: 14px; font-weight: 600;
  background: rgba(14, 16, 22, .9); padding: 6px 14px; border-radius: 20px;
  border: 1px solid rgba(255, 195, 92, .4);
}
#startprompt, #endcard {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; width: 480px; max-width: 92vw;
  text-align: center;
}
#startprompt p, #endcard p { color: var(--dim); font-size: 14px; margin: 8px 0; }
#endcard .grid.stats { grid-template-columns: 1fr 1fr; margin: 16px 0; }
#endcard .stat { background: var(--panel2); text-align: left; }
#endcard .stat b { font-size: 20px; }
.xpline { color: var(--accent); font-size: 15px; font-weight: 600; margin-bottom: 14px; min-height: 22px; }
#endcard button { margin: 4px; width: auto; display: inline-block; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--accent);
  padding: 12px 20px; border-radius: 10px; z-index: 200; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5);
}
