/* Spielfläche: 16:9, skaliert proportional; alle Größen in cqw (relativ zur Bühne) */
.game { min-height: 100%; display: grid; place-items: center; }
.stage {
  position: relative; overflow: hidden; container-type: inline-size;
  width: min(100vw, calc(100vh * 16 / 9)); aspect-ratio: 16 / 9; background: #14151b;
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* HUD: bewusst klein, die Szene bleibt dominant */
.hud { position: absolute; inset: 0; pointer-events: none; font-family: var(--font-display); }
.hud small { display: block; font: 600 1cqw var(--font-body); letter-spacing: .12em; color: var(--muted); }
.hud__time, .hud__panel {
  position: absolute; background: rgba(14,15,19,.72); border-radius: .8cqw;
  font-variant-numeric: tabular-nums; text-align: center; contain: layout paint style; /* kein Backdrop-Filter: wäre bei bewegter Szene dauerhaft teuer */
}
.hud__time { top: 1.6cqw; left: 50%; transform: translateX(-50%); padding: .5cqw 2.6cqw; font-size: 4.6cqw; color: var(--amber); }
.hud__panel { top: 1.6cqw; padding: .6cqw 1.6cqw; font-size: 2.6cqw; min-width: 11cqw; }
.hud__panel--left { left: 1.6cqw; }
.hud__panel--right { right: 1.6cqw; }

/* Overlays: Karte mit zwei Rennstreifen am linken Rand (Anspielung auf das Fahrzeug) */
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,11,16,.55); }
.overlay--lost { background: rgba(40,6,8,.6); }
.card {
  position: relative; width: 46cqw; padding: 2.2cqw 3cqw 2.2cqw 4.6cqw; border-radius: 1.2cqw;
  background: rgba(20,22,28,.92); box-shadow: 0 1.5cqw 5cqw rgba(0,0,0,.5);
}
.card::before, .card::after { content: ""; position: absolute; top: 1.2cqw; bottom: 1.2cqw; background: var(--paper); border-radius: .3cqw; }
.card::before { left: 1.3cqw; width: .7cqw; }
.card::after { left: 2.3cqw; width: .7cqw; }
.card--center { text-align: center; padding-left: 3.4cqw; }
.card--center::before, .card--center::after { display: none; }
.card h1, .card h2 { margin: 0 0 .9cqw; font: 400 4cqw/1 var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.card h2 { font-size: 3.4cqw; }
.lead { margin: 0 0 1.2cqw; font-size: 1.5cqw; color: var(--amber); font-weight: 600; }
.hint { margin: 1.2cqw 0 1.4cqw; font-size: 1.1cqw; line-height: 1.5; color: var(--muted); max-width: 62ch; }

.controls { list-style: none; margin: 0; padding: 0; display: grid; gap: .5cqw; font-size: 1.4cqw; }
.controls li { display: flex; align-items: center; gap: 1.2cqw; }
kbd {
  display: inline-grid; place-items: center; min-width: 3cqw; height: 2.6cqw; padding: 0 1cqw;
  border-radius: .6cqw; background: var(--asphalt-soft); border: .12cqw solid #4a4e59;
  border-bottom-width: .35cqw; font: 600 1.3cqw var(--font-body);
}
.keys { display: inline-flex; gap: .5cqw; }

.btn {
  display: inline-block; cursor: pointer; border: 0; border-radius: .8cqw; padding: .8cqw 2.6cqw;
  background: var(--amber); color: #1a1200; font: 400 2.2cqw var(--font-display); letter-spacing: .06em; text-transform: uppercase;
}
.btn:hover { background: #ffc24d; }
.btn:focus-visible { outline: .3cqw solid var(--paper); outline-offset: .3cqw; }

.result-time { white-space: nowrap; margin: .6cqw 0 1.6cqw; font: 400 6.4cqw/1 var(--font-display); color: var(--amber); font-variant-numeric: tabular-nums; }
.result-time span { font: inherit; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2cqw; margin: 0 0 2cqw; }
.stats div { padding: 1cqw; border-radius: .8cqw; background: rgba(255,255,255,.06); }
.stats dt { font-size: 1cqw; letter-spacing: .1em; color: var(--muted); }
.stats dd { margin: .4cqw 0 0; font-size: 1.5cqw; font-weight: 700; }
.rating[data-rating="fast"] { color: var(--go); }
.rating[data-rating="medium"] { color: var(--amber); }
.rating[data-rating="slow"] { color: var(--stop); }
.overlay--lost h2 { color: var(--stop); }

.notice { margin: 0 0 1.2cqw; padding: .8cqw 1.2cqw; border-radius: .6cqw; font-size: 1.2cqw; background: rgba(229,38,43,.18); color: #ffb3b5; }
.load-error { position: absolute; inset: auto 2cqw 2cqw; margin: 0; padding: 1.2cqw; border-radius: .8cqw; background: rgba(229,38,43,.92); font-size: 1.4cqw; }

/* Kleine Bildschirme: Karten füllen die Breite, der lange Hinweistext entfällt, Mindestschriftgrößen sichern die Lesbarkeit */
@container (max-width: 700px) {
  .card { width: 92cqw; padding: 2.6cqw 3cqw 2.6cqw 7.4cqw; }
  .card--center { padding-left: 3cqw; }
  .card h1 { font-size: max(15px, 4.6cqw); margin-bottom: 1.2cqw; }
  .card h1 br { display: none; }
  .card h2 { font-size: max(14px, 4cqw); margin-bottom: 1cqw; }
  .lead { font-size: max(11px, 2.7cqw); margin-bottom: 1.4cqw; }
  .controls { font-size: max(11px, 2.6cqw); gap: 1cqw; }
  kbd { font-size: max(10px, 2.4cqw); height: max(18px, 4cqw); min-width: max(20px, 4.6cqw); }
  .keys { gap: 1cqw; }
  .hint { display: none; }
  .notice { font-size: max(10px, 2.2cqw); padding: 1.2cqw 1.8cqw; margin: 1.4cqw 0; }
  .btn { font-size: max(13px, 3.2cqw); padding: 1.4cqw 4cqw; }
  .card::before, .card::after { width: max(3px, .9cqw); top: 2cqw; bottom: 2cqw; }
  .card::before { left: 2cqw; } .card::after { left: 3.7cqw; }
  .result-time { font-size: max(24px, 8cqw); margin: .8cqw 0 1.6cqw; }
  .stats { gap: 1.4cqw; margin-bottom: 1.6cqw; } .stats div { padding: 1.2cqw; }
  .stats dt { font-size: max(9px, 2cqw); } .stats dd { font-size: max(11px, 2.5cqw); margin-top: .4cqw; }
  .hud small { font-size: max(8px, 1.6cqw); }
  .hud__time { top: 1.2cqw; font-size: max(18px, 6cqw); padding: .4cqw 3cqw; }
  .hud__panel { top: 1.2cqw; left: auto; font-size: max(14px, 4cqw); min-width: max(64px, 15cqw); padding: .6cqw 1.4cqw; }
  .hud__panel--left { left: 1.2cqw; } .hud__panel--right { right: 1.2cqw; }
  .tacho { width: max(92px, 24cqw); right: 1.2cqw; bottom: 1.2cqw; } .tacho__keys { display: none; }
  .mode-tag { top: max(54px, 12.8cqw); font-size: max(8px, 1.6cqw); }
  .sound-btn { left: 1.2cqw; bottom: 1.2cqw; width: max(28px, 5.4cqw); height: max(28px, 5.4cqw); }
}
/* Sehr schmale Darstellung (Smartphone im Hochformat): nur das Nötigste auf dem Startbildschirm */
@container (max-width: 480px) {
  .lead { display: none; }
  .stats { grid-template-columns: 1fr; } .stats div:nth-child(-n+2) { display: none; } /* Distanz und Fahrzeit stehen schon oben */
  .overlay--lost .lead { display: block; }
  .card h1 { font-size: max(14px, 4.2cqw); }
}

/* Grip-Anzeige: Balken ist bei voller Haftung gefüllt und leert sich bei Wheelspin */
.slip { height: .7cqw; margin-top: .5cqw; border-radius: .2cqw; background: #3a3d46; overflow: hidden; }
.slip i { display: block; height: 100%; width: calc(var(--grip, 1) * 100%); background: var(--go); }
.slip[data-level="mid"] i { background: var(--amber); }
.slip[data-level="high"] i { background: var(--stop); }
/* Warnung in der Toleranzzone: roter Rand pulsiert */
.stage[data-warning]::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 6cqw rgba(229,38,43,.85); animation: warn .35s ease-in-out infinite alternate; }
@keyframes warn { from { opacity: .35; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stage[data-warning]::after { animation: none; } }

.pause-note { position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); margin: 0; padding: 1.4cqw 2.6cqw; border-radius: .8cqw; background: rgba(14,15,19,.88); font-size: 1.8cqw; }

/* Drehzahlmesser unten rechts */
.tacho { position: absolute; right: 1.6cqw; bottom: 1.6cqw; width: 15cqw; text-align: center; }
.tacho svg { display: block; width: 100%; height: auto; font-family: var(--font-body); }
.tacho__keys { margin: .4cqw 0 0; font-size: 1cqw; color: var(--muted); }
.tacho__keys kbd { min-width: 1.8cqw; height: 1.6cqw; padding: 0 .4cqw; margin-right: .3cqw; font-size: 1cqw; border-bottom-width: .2cqw; }

/* Trainingsmodus */
.notice--success { background: rgba(61,220,132,.16); color: #b9f5d2; }
.notice--info { background: rgba(90,200,250,.14); color: #bfe8fb; }
.mode-tag { position: absolute; top: 9.6cqw; left: 50%; transform: translateX(-50%); margin: 0; padding: .3cqw 1.2cqw; border-radius: 99cqw; background: rgba(14,15,19,.72); border: .15cqw solid #5ac8fa; color: #bfe8fb; font: 700 1cqw var(--font-body); letter-spacing: .14em; text-transform: uppercase; pointer-events: none; }
.stage[data-state="READY"] .mode-tag { display: none; }

/* Ton-Taste unten links */
.sound-btn { position: absolute; left: 1.6cqw; bottom: 1.6cqw; width: 3.6cqw; height: 3.6cqw; min-width: 28px; min-height: 28px; padding: .7cqw; border: .12cqw solid #4a4e59; border-radius: 50%; background: rgba(14,15,19,.8); color: var(--paper); cursor: pointer; z-index: 5; }
.sound-btn svg { display: block; width: 100%; height: 100%; }
.sound-btn:hover { background: rgba(42,45,52,.95); }
.sound-btn:focus-visible { outline: .3cqw solid var(--paper); outline-offset: .3cqw; }
.sound-btn__slash { display: none; }
.sound-btn[aria-pressed="true"] .sound-btn__slash { display: inline; }
.sound-btn[aria-pressed="true"] .sound-btn__waves { opacity: .35; }

/* Ergebnis im Vergleich mit dem Computer */
.opponent-result { margin: 0 0 1.4cqw; font-size: 1.5cqw; font-weight: 700; }
.opponent-result[data-outcome="win"] { color: var(--go); }
.opponent-result[data-outcome="lose"] { color: var(--amber); }
@container (max-width: 700px) { .opponent-result { font-size: max(11px, 2.5cqw); margin-bottom: 1.4cqw; } }
