/* ══════════════════════════════════════════════════════════════════════════
   Flaggenkunde
   Farbwelt: heraldische Tinkturen (Or / Vert / Gules) auf Tiefengrau.
   Die Flagge ist das einzige gesättigte Element, alles andere hält sich raus.
   ══════════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('../fonts/archivo-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 800;
  font-stretch: 62% 125%;
  font-display: swap;
  src: url('../fonts/archivo-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/dmmono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/dmmono-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/dmmono-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/dmmono-500-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #10141a;
  --plate: #171d25;
  --raise: #212a35;
  --line: #2f3947;
  --line-soft: #232c37;
  --paper: #ecede8;
  --muted: #939fae;
  --or: #d9a441;      /* Messing: Ösen, Knäufe, Beschlag */
  --or-dim: #8a6a2c;
  --vert: #46997a;
  --gules: #cf4f45;

  --sans: 'Archivo', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SFMono-Regular', 'Cascadia Mono', monospace;

  --pad: clamp(1rem, 4vw, 2rem);
  --stage-h: min(46vh, 26rem);
  --radius: 3px;
  --dur: 200ms;
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

/* Klassen wie .screen--play setzen display und würden das UA-Stylesheet für
   [hidden] sonst überstimmen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
}

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

.mono {
  font-family: var(--mono);
  font-weight: 400;
  letter-spacing: 0.02em;
}

:where(button, input, a):focus-visible {
  outline: 2px solid var(--or);
  outline-offset: 2px;
}

/* ── Bildschirme ─────────────────────────────────────────────────────────── */

.screen {
  max-width: 46rem;
  margin: 0 auto;
  padding: max(var(--pad), env(safe-area-inset-top)) var(--pad)
           max(var(--pad), env(safe-area-inset-bottom));
}

.screen--scroll { min-height: 100%; }

.screen--play {
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 2.5vh, 1.5rem);
  height: 100%;
  height: 100dvh;
  padding-top: max(0.75rem, env(safe-area-inset-top));
}

/* ── Kopf ────────────────────────────────────────────────────────────────── */

.eyebrow {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--or);
}

.masthead { padding: clamp(1rem, 6vh, 3rem) 0 clamp(1.5rem, 4vh, 2.5rem); }

.masthead__title {
  margin: 0;
  font-size: clamp(3rem, 17vw, 6.5rem);
  font-stretch: 70%;
  font-weight: 800;
  line-height: 0.86;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  hyphens: manual;
}

.masthead__lead {
  max-width: 34ch;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.colophon {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
  color: #6d7887;
  font-size: 0.75rem;
}
.colophon p { margin: 0; }
.colophon .mono { color: #7f8b9a; }

/* ── Panels ──────────────────────────────────────────────────────────────── */

.panel {
  margin: 0 0 1rem;
  padding: 1.1rem 1.1rem 1.25rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--plate);
}

.panel__title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin: 0 0 0.9rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel__note { color: #6d7887; letter-spacing: 0.04em; text-transform: none; }

.panel--start {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: none;
  border: none;
  padding-inline: 0;
}

/* ── Kontinent-Chips ─────────────────────────────────────────────────────── */

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: color var(--dur), border-color var(--dur), background-color var(--dur);
}
.chip:hover { border-color: var(--or-dim); color: var(--paper); }
.chip__count { font-family: var(--mono); font-size: 0.78rem; opacity: 0.7; }
.chip[aria-pressed='true'] {
  background: var(--or);
  border-color: var(--or);
  color: var(--ink);
  font-weight: 600;
}
.chip[aria-pressed='true'] .chip__count { opacity: 0.75; }

/* ── Schalter ────────────────────────────────────────────────────────────── */

.switch {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  padding: 0.65rem 0;
  cursor: pointer;
}
.switch + .switch { border-top: 1px solid var(--line-soft); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__box {
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
  margin-top: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  position: relative;
  transition: background-color var(--dur), border-color var(--dur);
}
.switch__box::after {
  content: '';
  position: absolute;
  inset: 3px auto 3px 3px;
  width: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--dur) var(--ease), background-color var(--dur);
}
.switch input:checked + .switch__box { background: var(--or-dim); border-color: var(--or); }
.switch input:checked + .switch__box::after { transform: translateX(18px); background: var(--or); }
.switch input:focus-visible + .switch__box { outline: 2px solid var(--or); outline-offset: 2px; }
.switch input:disabled + .switch__box { opacity: 0.4; }

.switch__text { font-size: 0.95rem; }
.switch__text small {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  min-height: 52px;
  padding: 0.8rem 1.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color var(--dur), color var(--dur), border-color var(--dur);
}
.btn--primary { background: var(--or); color: var(--ink); }
.btn--primary:hover { background: #eab557; }
.btn--primary:disabled { background: var(--raise); color: #6d7887; cursor: not-allowed; }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--paper); }
.btn--ghost:hover { border-color: var(--or-dim); }
.btn--quiet {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.9rem;
  min-height: 44px;
}
.btn--quiet:hover { color: var(--paper); }

.hint { margin: 0; color: var(--muted); font-size: 0.8rem; min-height: 1.2em; }

.tally-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.tally-line__num {
  font-size: 2rem;
  font-stretch: 75%;
  font-weight: 700;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

/* ── HUD: Zählstreifen ───────────────────────────────────────────────────── */

.hud { flex: 0 0 auto; }

.hud__strip {
  display: flex;
  gap: 2px;
  height: 10px;
  margin-bottom: 0.55rem;
}
.hud__strip i {
  flex: 1 1 0;
  min-width: 1px;
  background: var(--line-soft);
  transition: background-color 180ms;
}
.hud__strip i[data-s='ok'] { background: var(--vert); }
.hud__strip i[data-s='no'] { background: var(--gules); }
.hud__strip i[data-s='now'] { background: var(--or); }

.hud__strip--meter { gap: 0; }
.hud__strip--meter i { min-width: 0; transition: flex-grow 240ms var(--ease); }

.hud__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.hud__quit {
  margin-left: auto;
  padding: 0.35rem 0;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.hud__quit:hover { color: var(--paper); }

/* ── Bühne: die Flagge ───────────────────────────────────────────────────── */

.stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(0.75rem, 2.5vh, 1.4rem);
  min-height: 0;
}

/* Feste Bühne, wechselnde Flaggen: jede behält ihr amtliches Seitenverhältnis
   (Schweiz 1:1, Katar 28:11, Nepal als Wimpel), ohne dass die Seite springt.
   --ratio setzt js/app.js je Flagge, --stage-h begrenzt die Höhe. */
.specimen {
  margin: 0;
  width: 100%;
  max-width: min(100%, 34rem);
  height: var(--stage-h);
  display: flex;
  align-items: center;
  justify-content: center;
}

.specimen__flag {
  display: block;
  width: min(100%, calc(var(--stage-h) * var(--ratio, 1.5)));
  height: auto;
  aspect-ratio: var(--ratio, 1.5);
  /* Kontur statt Rahmen: folgt der echten Silhouette, also auch dem
     nicht-rechteckigen Wimpel Nepals, und hält weiße Flaggen sichtbar. */
  filter:
    drop-shadow(1px 0 0 var(--line)) drop-shadow(-1px 0 0 var(--line))
    drop-shadow(0 1px 0 var(--line)) drop-shadow(0 -1px 0 var(--line))
    drop-shadow(0 14px 26px rgb(0 0 0 / 0.75));
}

.specimen--raise .specimen__flag { animation: hoist 260ms var(--ease) both; }

@keyframes hoist {
  from { clip-path: inset(100% 0 0 0); opacity: 0.4; }
  to   { clip-path: inset(0 0 0 0); opacity: 1; }
}

/* ── Auflösung ───────────────────────────────────────────────────────────── */

.verdict {
  width: 100%;
  max-width: min(100%, 34rem);
  padding: 0.85rem 1rem 0.9rem;
  border-left: 3px solid var(--line);
  background: var(--plate);
  animation: stamp 160ms var(--ease) both;
}
.verdict[data-ok='1'] { border-left-color: var(--vert); }
.verdict[data-ok='0'] { border-left-color: var(--gules); }

@keyframes stamp {
  from { opacity: 0; transform: translateY(6px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

.verdict__mark {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.verdict[data-ok='1'] .verdict__mark { color: var(--vert); }
.verdict[data-ok='0'] .verdict__mark { color: var(--gules); }

.verdict__country {
  margin: 0;
  font-size: clamp(1.5rem, 6.5vw, 2.4rem);
  font-stretch: 75%;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.verdict__capital {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  color: var(--paper);
}
.verdict__label {
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-right: 0.4rem;
}

.verdict__said { margin: 0.4rem 0 0; font-size: 0.8rem; color: var(--muted); }

.verdict__timer { height: 2px; margin-top: 0.7rem; background: var(--line-soft); }
.verdict__timer i {
  display: block;
  height: 100%;
  background: var(--or-dim);
  transform-origin: left;
  animation: countdown var(--advance, 1800ms) linear both;
}
@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ── Eingabe ─────────────────────────────────────────────────────────────── */

.controls {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.heard {
  margin: 0;
  min-height: 1.3em;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.answer { display: flex; gap: 0.5rem; }

.answer__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 56px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--plate);
  color: var(--paper);
  font: inherit;
  font-size: 1.15rem;
  font-stretch: 90%;
}
.answer__input::placeholder { color: #6d7887; }
.answer__input:focus { border-color: var(--or); outline: none; }
.answer__input:disabled { opacity: 0.5; }

.answer__mic {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 72px;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--plate);
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: border-color var(--dur), color var(--dur);
}
.answer__mic-text { font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; }
.answer__mic[hidden] { display: none; }
.mic-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
  border: 1px solid var(--muted);
}
.answer__mic[aria-pressed='true'] { border-color: var(--gules); color: var(--paper); }
.answer__mic[aria-pressed='true'] .mic-dot {
  background: var(--gules);
  border-color: var(--gules);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.controls__row { display: flex; gap: 0.5rem; }
.controls__row .btn { flex: 1 1 0; }

/* ── Ergebnis ────────────────────────────────────────────────────────────── */

.masthead--result { padding-bottom: 1.5rem; }

.score {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0;
  font-stretch: 70%;
  font-weight: 800;
  line-height: 0.9;
  text-transform: uppercase;
}
.score__num { font-size: clamp(3.5rem, 18vw, 7rem); font-variant-numeric: tabular-nums; }
.score__num--total { color: var(--muted); }
.score__of { font-size: 1rem; font-stretch: 100%; font-weight: 400; color: var(--muted); }
.score__pct { margin: 0.5rem 0 0; color: var(--or); font-size: 0.95rem; letter-spacing: 0.1em; }

.sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 4px;
}

.sheet__chip {
  position: relative;
  display: block;
  padding: 0;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  background: none;
  cursor: pointer;
  transition: transform 120ms var(--ease), border-color 120ms;
}
.sheet__chip img { display: block; width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.sheet__chip[data-ok='0'] { border-color: var(--gules); }
/* Fehler bleiben gut lesbar – sie sind der Lernstoff. Die Kennzeichnung
   übernimmt der rote Rand, nicht das Abdunkeln. */
.sheet__chip[data-ok='0'] img { filter: grayscale(1); }
.sheet__chip:hover, .sheet__chip[aria-current='true'] { transform: scale(1.12); z-index: 1; }
.sheet__chip[aria-current='true'] { border-color: var(--or); }

.sheet__detail {
  margin: 1rem 0 0;
  min-height: 3.2em;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.9rem;
  color: var(--muted);
}
.sheet__detail strong {
  display: block;
  font-size: 1.15rem;
  font-stretch: 80%;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--paper);
}
.sheet__detail .mono { font-size: 0.82rem; }

/* ── Breite Fenster ──────────────────────────────────────────────────────── */

@media (min-width: 56rem) and (min-height: 40rem) {
  .screen--play { max-width: 54rem; }
  .specimen { max-width: 40rem; }
  :root { --stage-h: min(50vh, 28rem); }
  .verdict { max-width: 40rem; }
  .answer { max-width: 40rem; margin: 0 auto; width: 100%; }
  .controls__row { max-width: 40rem; margin: 0 auto; width: 100%; }
  .heard { max-width: 40rem; margin: 0 auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
  .verdict__timer { display: none; }
}
