/* ───────────────────────────────────────────────────────────────────────────
   kk-gamehead.css · Gemeinsamer Spielkopf für alle Modi
   ───────────────────────────────────────────────────────────────────────────
   Varianten:
     .kk-gh.kk-gh--solo   → Blitz, Tagesreihe, Solo-Jahresschätzung
     .kk-gh.kk-gh--multi  → Einordnen!, Darts, Wer bin ich?, Karrierepfad,
                            Jahrgang! Multiplayer, Bestwert!, Mixed Mode
   Informationsrollen (gleich visuell in allen Modi):
     .kk-gh-close     · Austritt (links, 44×44)
     .kk-gh-title     · Modus + Fortschritt (zentriert, ein-Zeilig, Ellipse)
       .kk-gh-mode    · Modusname (fett)
       .kk-gh-progress· Fortschritt als tabulare X / Y
     .kk-gh-action    · Hilfe / Teilen / Ton (rechts, 44×44)
     .kk-gh-clock     · Echte Antwortfrist (Sekunden, tabular)
     .kk-gh-minute    · Fußball-Spielminute (bewusst unterschiedlich)
     .kk-gh-stat      · Statistik (±Jahre o.Ä.) – kein Zeitdruck
   Diese Datei ergänzt kk-flow.css. Mechanik-spezifisches Markup unterhalb
   des Kopfes bleibt unangetastet.
   ─────────────────────────────────────────────────────────────────────── */

:root {
  --gh-pad-x: 16px;
  --gh-pad-y: 12px;
  --gh-row-gap: 10px;
  --gh-tap: 44px;
  --gh-radius: 999px;
}

/* ── Basis für beide Varianten ────────────────────────────────────────── */
.kk-gh {
  box-sizing: border-box;
  padding:
    calc(env(safe-area-inset-top, 0px) + var(--gh-pad-y))
    max(var(--gh-pad-x), env(safe-area-inset-right, 0px))
    var(--gh-pad-y)
    max(var(--gh-pad-x), env(safe-area-inset-left, 0px));
  flex-shrink: 0;
  min-width: 0;
}
.kk-gh--solo {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kk-gh--multi {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--gh-row-gap);
}

.kk-gh-row {
  display: flex;
  align-items: center;
  gap: var(--gh-row-gap);
  min-height: var(--gh-tap);
  min-width: 0;
}

/* Austritt (links) und rechte Aktion: identische Geometrie, sichere Tap-Fläche
   und ein stabiler Abstand zueinander, damit sie sich nicht berühren. */
.kk-gh .kk-gh-close,
.kk-gh .kk-gh-action {
  flex: 0 0 auto;
  width: var(--gh-tap);
  height: var(--gh-tap);
  min-width: var(--gh-tap);
  min-height: var(--gh-tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--kk-dark-surf, rgba(255,255,255,.12));
  color: var(--kk-ink, #fff);
  cursor: pointer;
  padding: 0;
}
.kk-gh .kk-gh-close:focus-visible,
.kk-gh .kk-gh-action:focus-visible,
.kk-gh .icon-btn:focus-visible {
  outline: 2px solid var(--kk-accent, #C9FF35) !important;
  outline-offset: 2px !important;
}

/* Titel-Bereich: nimmt die verbleibende Breite, Ellipse bei langen Namen.
   mode (fett) steht links, progress (tabular) rechts – getrennt lesbar. */
.kk-gh-title {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--kk-ink, #fff);
  font: 700 14px/1.2 var(--kk-body, 'DM Sans', sans-serif);
  letter-spacing: 0;
  overflow: hidden;
  white-space: nowrap;
}
.kk-gh-mode {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}
.kk-gh-progress {
  flex: 0 0 auto;
  color: color-mix(in srgb, var(--kk-ink, #fff) 72%, transparent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
}

/* Modus-Pille für Multi-Varianten, die den Rundentag als Pille zeigen wollen.
   (Vorhandenes .round-tag wird weiter unten so angepasst, dass es in das
   Titel-Slot passt.) */
.kk-gh-title.is-pill {
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 4px 10px;
  gap: 6px;
  flex: 0 1 auto;
  font-size: 12px;
  font-weight: 700;
}

/* ── Zeitwerte: drei bewusst unterschiedliche Rollen ──────────────────── */
/* 1) Echte Antwortfrist — wird bei <10 s warnrot. */
.kk-gh .kk-gh-clock {
  flex: 0 0 auto;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--kk-dark-surf, rgba(255,255,255,.12));
  color: var(--kk-ink, #fff);
  font: 700 16px/1.2 var(--kk-body, 'DM Sans', sans-serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-align: center;
  transition: background .2s, color .2s;
}
.kk-gh .kk-gh-clock.is-low,
.kk-gh .kk-gh-clock.kk-timer-badge--danger {
  background: var(--kk-miss, #FF5B24);
  color: #fff;
  animation: none;
}
/* 2) Fußball-Spielminute: bewusst zarter Rahmen, kein Ablauf-Farbwechsel. */
.kk-gh .kk-gh-minute {
  flex: 0 0 auto;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 10px;
  background: transparent;
  color: color-mix(in srgb, var(--kk-ink, #fff) 80%, transparent);
  border: 1px solid rgba(255,255,255,.22);
  font: 700 14px/1.2 var(--kk-body, 'DM Sans', sans-serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-align: center;
}
/* 3) Statistik (z.B. ±Jahre bei Solo-Jahresschätzung): keine Zeit. */
.kk-gh .kk-gh-stat {
  flex: 0 0 auto;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 10px;
  background: var(--kk-dark-surf, rgba(255,255,255,.12));
  color: var(--kk-accent, #C9FF35);
  font: 700 14px/1.2 var(--kk-body, 'DM Sans', sans-serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-align: center;
}

/* Nach abgegebener Antwort kein eigener Entscheidungstimer mehr. */
.kk-gh[data-decision="submitted"] .kk-gh-clock,
.kk-gh[data-decision="handoff"] .kk-gh-clock,
.kk-gh[data-submit-state="success"] .kk-gh-clock {
  display: none;
}
/* Automatische Überleitungen: ruhiger Status, kein tickender Zähler. */
.kk-gh[data-decision="handoff"] .kk-gh-clock + .kk-gh-handoff,
.kk-gh .kk-gh-handoff {
  display: none;
  color: color-mix(in srgb, var(--kk-ink, #fff) 70%, transparent);
  font: 500 13px/1.3 var(--kk-body, 'DM Sans', sans-serif);
}
.kk-gh[data-decision="handoff"] .kk-gh-handoff { display: inline-flex; }

/* ── Solo-Variante ────────────────────────────────────────────────────── */
/* Baut auf die vorhandene Navy-Header-Hülle (.kk-blitz-header) auf,
   die Blitz/Tagesreihe/Schätzen bereits rendert. */
.kk-gh--solo {
  background: var(--kk-dark, #1B2D23);
  color: #fff;
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
}
.kk-gh--solo .kk-header-row { /* alte Zeile mit close/score/badge */
  display: flex;
  align-items: center;
  gap: var(--gh-row-gap);
  min-height: var(--gh-tap);
  min-width: 0;
}
.kk-gh--solo .kk-close-btn {
  flex: 0 0 auto;
  width: var(--gh-tap);
  height: var(--gh-tap);
  min-width: var(--gh-tap);
  min-height: var(--gh-tap);
}
.kk-gh--solo .kk-close-btn:focus-visible {
  outline: 2px solid var(--kk-accent);
  outline-offset: 2px;
}
.kk-gh--solo .kk-header-title {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  color: var(--kk-ink, #fff);
  font: 700 14px/1.2 var(--kk-body, 'DM Sans', sans-serif);
}
.kk-gh--solo .kk-header-title .kk-gh-mode {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kk-gh--solo .kk-header-title .kk-gh-progress {
  flex: 0 0 auto;
}

/* ── Multi-Variante (.match-top) ──────────────────────────────────────── */
.kk-gh--multi {
  position: relative;
}
/* Umsortierung: Close-Button links, Titel wächst, Aktion rechts.
   Bestehende Reihenfolge im DOM wird per order gelenkt, damit alt‑CSS
   mit Grid-Layouts (z.B. bestwert-reveal) nicht aus den Fugen gerät. */
.kk-gh--multi .kk-gh-close { order: 0; }
.kk-gh--multi .flow-clock,
.kk-gh--multi .turn-timer { order: 2; }
.kk-gh--multi .round-tag,
.kk-gh--multi .kk-gh-title { order: 1; flex: 1 1 auto; min-width: 0; }
.kk-gh--multi .kk-gh-clock,
.kk-gh--multi .kk-gh-minute,
.kk-gh--multi .kk-gh-stat { order: 2; }
.kk-gh--multi .kk-gh-action,
.kk-gh--multi #btn-show-question,
.kk-gh--multi #btn-share-result,
.kk-gh--multi [data-sound] { order: 3; }
.kk-gh--multi .kk-gh-close { order: 0; }

/* Round-Tag in Multi-Variante: füllt den Titel-Slot ohne Pill-Verengung.
   Bestehende !important-Overrides (z.B. aus kk-spieltag.css) werden mit
   gleich hoher Spezifität neutralisiert. */
.kk-gh--multi .round-tag {
  background: transparent !important;
  color: var(--kk-ink, #fff) !important;
  border-radius: 0 !important;
  padding: 0 !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.kk-gh--multi .round-tag b {
  font-weight: 700;
  flex: 0 0 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.kk-gh--multi .round-tag .kk-gh-progress {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: color-mix(in srgb, var(--kk-ink, #fff) 72%, transparent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.kk-gh--multi .round-tag .kk-gh-progress::before {
  content: '\00B7';
  margin-right: 6px;
  color: color-mix(in srgb, var(--kk-ink, #fff) 45%, transparent);
}
/* Kreis-Icon-Buttons (vorhandenes Legacy-Styling) bleiben, aber mit 44er
   Tap-Fläche und sicherem Abstand zum Nachbarn. Spezifität muss die
   schmaleren Media-Overrides in kk-spieltag.css (34 px) schlagen. */
body.in-match .match-top.kk-gh--multi .icon-btn,
body.in-playing .match .match-top.kk-gh--multi .icon-btn,
body #game-stage .panel.darts .match-top.kk-gh--multi .icon-btn,
body .panel.jahrgang.jg .match-top.kk-gh--multi .icon-btn,
body .panel.bestwert-play .match-top.kk-gh--multi .icon-btn {
  flex: 0 0 auto;
  width: var(--gh-tap) !important;
  height: var(--gh-tap) !important;
  min-width: var(--gh-tap) !important;
  min-height: var(--gh-tap) !important;
  border-radius: 50% !important;
}

/* Reveal-Kopf in Bestwert! behält sein eigenes Grid-Layout; wir setzen nur
   die gemeinsamen Farbrollen und Tap-Flächen durch. Kein Überschreiben. */
.panel.bestwert-reveal .kk-gh--multi { /* beibehaltenes Grid */ }

/* ── 320 px: Enge Phasen ohne Überlagerung ────────────────────────────── */
@media (max-width: 345px) {
  .kk-gh {
    --gh-pad-x: 12px;
    --gh-row-gap: 8px;
    gap: 8px;
  }
  .kk-gh-title,
  .kk-gh--multi .round-tag {
    font-size: 13px !important;
  }
  .kk-gh-progress { font-size: 12px; }
  .kk-gh .kk-gh-clock { min-width: 46px; font-size: 14px; padding: 4px 8px; }
  .kk-gh .kk-gh-minute,
  .kk-gh .kk-gh-stat { min-width: 46px; font-size: 12px; padding: 4px 8px; }
  .kk-gh--solo .kk-scoreboard-score { font-size: 36px; }
}

/* ── Reflow-Stresstest (halbe Breite) ─────────────────────────────────── */
@media (max-width: 260px) {
  .kk-gh {
    --gh-pad-x: 8px;
    --gh-row-gap: 6px;
  }
  .kk-gh-title,
  .kk-gh--multi .round-tag {
    font-size: 12px !important;
  }
  .kk-gh--solo .kk-scoreboard-score { font-size: 28px; }
  .kk-gh--solo .kk-timer-badge { font-size: 16px; min-width: 42px; }
}

/* ── Reduced Motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .kk-gh .kk-gh-clock,
  .kk-gh .kk-gh-clock.is-low,
  .kk-gh--solo .kk-timer-badge,
  .kk-gh--solo .kk-timer-bar-fill {
    animation: none !important;
    transition: none !important;
  }
}
