/* Leitstellen-Bingo. Tokens und Schriften wie saniakte.de (website/styles.css). */

@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/schriften/Barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/schriften/Barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 700; font-display: swap; src: url("/schriften/Barlow-700.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-display: swap; src: url("/schriften/IBMPlexMono-600.woff2") format("woff2"); }

:root {
  --bg: #0B1017; --surface: #131B24; --surface2: #1B2632; --border: #26333F; --line: #1F2A35;
  --text: #E9EFF5; --muted: #93A3B3; --dim: #808F9B;
  --brand: #4D92FF; --brand-ink: #08111F; --brand-weich: #16243A;
  --signal: #FAF329; --signal-ink: #1B242D; --alarm: #FF4D4D; --ok: #3FCF8E; --ok-weich: #0F2A22;
  --rand: 16px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: dark;
}

[data-theme="hell"] {
  --bg: #F4F6F9; --surface: #FFFFFF; --surface2: #EDF1F6; --border: #D3DCE6; --line: #E4EAF1;
  --text: #1B242D; --muted: #5A6875; --dim: #616E7A;
  --brand: #014DC7; --brand-ink: #FFFFFF; --brand-weich: #E5EDFB;
  --signal: #F5EC3B; --signal-ink: #1B242D; --alarm: #E60000; --ok: #1F9D63; --ok-weich: #E3F5EC;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dunkel"]) {
    --bg: #F4F6F9; --surface: #FFFFFF; --surface2: #EDF1F6; --border: #D3DCE6; --line: #E4EAF1;
    --text: #1B242D; --muted: #5A6875; --dim: #616E7A;
    --brand: #014DC7; --brand-ink: #FFFFFF; --brand-weich: #E5EDFB;
    --signal: #F5EC3B; --signal-ink: #1B242D; --alarm: #E60000; --ok: #1F9D63; --ok-weich: #E3F5EC;
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: "Barlow", "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: break-word;
}

a { color: var(--brand); }
h1, h2 { overflow-wrap: break-word; hyphens: auto; }
button, input { font: inherit; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.zum-inhalt {
  position: absolute; left: 12px; top: -80px; z-index: 100;
  padding: 12px 18px; border-radius: 9px;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; text-decoration: none;
}
.zum-inhalt:focus { top: 12px; }

/* Kopf: flach, damit die Karte auf dem Telefon in den ersten Bildschirm passt. */

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(var(--rand), env(safe-area-inset-right)) 10px max(var(--rand), env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.wortmarke { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; min-height: 44px; }

.wortmarke-zeichen {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  width: 34px; height: 34px; border-radius: 8px; background: #0b1017; flex-shrink: 0;
}
.wortmarke-buchstabe { font-size: 17px; font-weight: 700; color: #fff; line-height: 0.85; }
.wortmarke-name { display: flex; align-items: flex-start; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.wortmarke-i { display: flex; flex-direction: column; align-items: center; width: 0.3em; color: var(--brand); }
.wortmarke-i svg { margin-bottom: 2px; flex-shrink: 0; }
.wortmarke-i span { line-height: 0.74; color: var(--text); }

.kopf-konto {
  display: inline-flex; align-items: center; min-height: 44px; max-width: 50%;
  padding: 0 14px; border-radius: 9px; border: 1.5px solid var(--border);
  color: var(--text); font-size: 15px; font-weight: 600; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Seite */

.seite {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px max(var(--rand), env(safe-area-inset-right)) 32px max(var(--rand), env(safe-area-inset-left));
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1fr);
}

.spiel { min-width: 0; }

.spiel-kopf { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; margin-bottom: 10px; }
.titel { margin: 0; font-size: clamp(24px, 6.4vw, 34px); line-height: 1.1; font-weight: 700; letter-spacing: -0.015em; }
.runde-stand { margin: 0; font-size: 15px; color: var(--muted); }
.runde-stand .zahl { color: var(--text); }

.zahl { font-family: "IBM Plex Mono", ui-monospace, monospace; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Die Karte. Quadratische Felder; die Schrift richtet sich nach der Breite der
   Karte (Container-Einheiten), lange Sprüche bekommen eine kleinere Stufe. */

.karte {
  container-type: inline-size;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(4px, 1.4vw, 8px);
  width: 100%;
  max-width: min(640px, calc(100dvh - 220px));
  min-width: 0;
}

.feld {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(3px, 1.2cqi, 10px);
  border-radius: clamp(6px, 1.6cqi, 12px);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: clamp(11px, 4.4cqi, 20px);
  line-height: 1.12;
  text-align: center;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
  cursor: pointer;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 140ms var(--ease-out), border-color 160ms ease, background-color 160ms ease;
}

.feld[data-laenge="mittel"] { font-size: clamp(10.5px, 3.9cqi, 18px); }
.feld[data-laenge="lang"] { font-size: clamp(10px, 3.45cqi, 16px); line-height: 1.08; }

.feld-text { display: block; max-width: 100%; }

/* Markiert wie mit dem Textmarker auf dem Notizzettel. */
.feld:not(.feld-frei)[aria-pressed="true"] { border-color: var(--text); background: var(--surface2); }
.feld:not(.feld-frei)[aria-pressed="true"] .feld-marker {
  background: linear-gradient(transparent 12%, var(--signal) 12%, var(--signal) 90%, transparent 90%);
  color: var(--signal-ink);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding: 0 0.12em;
}

.feld-frei { cursor: default; background: var(--brand-weich); border-color: var(--brand); color: var(--brand); flex-direction: column; gap: 4px; }
.feld-frei svg { width: 56%; height: auto; }
.feld-frei .feld-text { font-size: clamp(11px, 3.9cqi, 18px); font-weight: 700; }

.feld.in-linie { border-color: var(--ok); box-shadow: inset 0 0 0 1.5px var(--ok); }

@media (hover: hover) and (pointer: fine) {
  .feld:not(.feld-frei):hover { border-color: var(--muted); }
}
.feld:not(.feld-frei):active { transform: scale(0.96); }

.spiel-leiste { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 14px; }
.spiel-hinweis { margin: 0; font-size: 15px; color: var(--muted); flex: 1 1 220px; }

/* Knöpfe */

.knopf, .knopf-still, .knopf-gefahr {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: 10px;
  font-weight: 700; font-size: 17px; cursor: pointer;
  transition: transform 150ms ease-out;
}
.knopf { border: 0; background: var(--brand); color: var(--brand-ink); }
.knopf-still { border: 1.5px solid var(--border); background: transparent; color: var(--text); font-weight: 600; }
.knopf-gefahr { border: 1.5px solid var(--alarm); background: transparent; color: var(--alarm); font-weight: 600; }
.knopf:active, .knopf-still:active, .knopf-gefahr:active { transform: scale(0.97); }
.knopf[disabled], .knopf-still[disabled] { opacity: 0.6; cursor: progress; }
.knopf-reihe { display: flex; flex-wrap: wrap; gap: 10px; }

/* Konto und Bestenliste: einklappbar, damit auf dem Telefon die Karte vorn steht. */

.neben { display: grid; gap: 0; align-content: start; min-width: 0; border-top: 1px solid var(--border); }

.klappe { border-bottom: 1px solid var(--border); }
.klappe-titel {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; cursor: pointer; list-style: none;
}
.klappe-titel::-webkit-details-marker { display: none; }
.klappe-titel h2 { margin: 0; font-size: 20px; font-weight: 700; }
.klappe-titel::after {
  content: ""; width: 10px; height: 10px; flex-shrink: 0; margin-right: 4px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-3px);
  transition: transform 200ms var(--ease-out);
}
.klappe[open] > .klappe-titel::after { transform: rotate(225deg) translateY(-3px); }
.klappe-inhalt { padding-bottom: 20px; }

.formular { display: grid; gap: 6px; }
.formular-hilfe { margin: 0 0 8px; color: var(--muted); font-size: 15px; }
.feld-beschriftung { font-weight: 600; font-size: 15px; margin-top: 6px; }
.feld-hilfe { margin: 0; font-size: 14px; color: var(--dim); }
.eingabe {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 17px;
}
.eingabe:focus-visible { border-color: var(--brand); outline-offset: 0; }
.eingabe-pin { max-width: 9em; letter-spacing: 0.3em; font-family: "IBM Plex Mono", ui-monospace, monospace; }
.formular-fehler { margin: 4px 0; min-height: 1.4em; color: var(--alarm); font-size: 15px; font-weight: 600; }
.formular-fehler:empty { min-height: 0; margin: 0; }

.konto { display: grid; gap: 10px; }
.konto-name, .konto-zahl { margin: 0; }
.konto-zahl .zahl { font-size: 22px; }
.loeschen { margin-top: 8px; }
.loeschen > summary { min-height: 44px; display: inline-flex; align-items: center; cursor: pointer; color: var(--muted); font-size: 15px; }
.loeschen .formular { margin-top: 6px; }

.bestenliste { margin: 0; padding: 0; list-style: none; display: grid; }
.bestenliste li {
  display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; gap: 10px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.bestenliste li:last-child { border-bottom: 0; }
.bestenliste .platz { color: var(--dim); }
.bestenliste .name { overflow-wrap: anywhere; }
.bestenliste .eigen .name { font-weight: 700; }
.bestenliste .eigen .platz { color: var(--brand); }
.bestenliste-leer { margin: 0; color: var(--muted); }

.datenschutz { max-width: 68ch; font-size: 15px; color: var(--muted); }
.datenschutz h2 { font-size: 17px; color: var(--text); margin: 0 0 6px; }
.datenschutz p { margin: 0 0 10px; }

.fuss {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
  padding: 20px max(var(--rand), env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(var(--rand), env(safe-area-inset-left));
  background: var(--surface); border-top: 1px solid var(--border);
  font-size: 15px; color: var(--muted);
}
.fuss-verweise { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.fuss-verweise a { display: inline-flex; align-items: center; min-height: 44px; }
.darstellung-schalter {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border-radius: 9px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 15px; font-weight: 600; cursor: pointer;
}

/* Bingo-Meldung: erscheint unten über der Karte. */

.meldung {
  position: fixed; z-index: 50;
  left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  width: min(420px, calc(100% - 2 * var(--rand)));
  padding: 16px 20px 18px;
  border-radius: 14px;
  background: var(--ok-weich); color: var(--text);
  border: 2px solid var(--ok);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.35);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out);
  pointer-events: none;
}
.meldung[hidden] { display: block !important; visibility: hidden; }
.meldung.zeigen { opacity: 1; transform: translate(-50%, 0); visibility: visible; }
.meldung-puls { color: var(--ok); display: block; margin-bottom: 4px; clip-path: inset(0 100% 0 0); }
.meldung.zeigen .meldung-puls { clip-path: inset(0 0 0 0); transition: clip-path 640ms var(--ease-out) 80ms; }
.meldung-titel { margin: 0; font-size: 30px; font-weight: 700; line-height: 1.1; }
.meldung-text { margin: 4px 0 0; font-size: 16px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .feld, .knopf, .knopf-still, .knopf-gefahr, .klappe-titel::after { transition: none; }
  .feld:not(.feld-frei):active, .knopf:active, .knopf-still:active, .knopf-gefahr:active { transform: none; }
  .meldung { transform: translate(-50%, 0); transition: opacity 200ms ease; }
  .meldung-puls, .meldung.zeigen .meldung-puls { clip-path: none; transition: none; }
}

/* Breite Bildschirme: Karte links, Konto und Bestenliste rechts. */

@media (min-width: 900px) {
  :root { --rand: 32px; }
  .seite { grid-template-columns: minmax(0, 640px) minmax(280px, 1fr); column-gap: 48px; padding-top: 28px; }
  .karte { max-width: min(640px, calc(100dvh - 240px)); }
  .datenschutz { grid-column: 1 / -1; }
  .neben { border-top: 0; }
  .klappe:first-child { border-top: 1px solid var(--border); }
}

/* Querformat am Telefon: Karte so groß, wie die Höhe erlaubt. */
@media (orientation: landscape) and (max-height: 520px) {
  .kopf { padding-block: 4px; }
  .seite { padding-top: 10px; }
  .spiel {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "karte kopf" "karte leiste";
    align-content: start;
    column-gap: 20px;
  }
  .spiel-kopf { grid-area: kopf; flex-direction: column; align-items: flex-start; }
  .spiel-leiste { grid-area: leiste; align-self: start; flex-direction: column; align-items: flex-start; }
  .karte { grid-area: karte; align-self: start; width: calc(100dvh - 90px); max-width: none; }
}
