/* ============================================================
   King of the Court – Turnier-App
   Palette: Sand & Netz + die fünf Farben des Zählbogens
   Typo: Anton (Display, Scoreboard) · Archivo (Text & Daten)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Anton&family=Archivo:wght@400;500;600;700;800&display=swap');

:root {
  --sand: #FBF7EE;        /* Hintergrund: heller Sand */
  --sand-2: #F1EADB;      /* Kartenränder, Zebra */
  --ink: #17233B;         /* Tiefblau wie eine nasse Feldlinie */
  --ink-soft: #5A6478;
  --line: #E3DCC9;
  --white: #FFFFFF;
  --live: #D6452C;        /* Signal für laufende Spiele */
  --ok: #1E9E56;

  --c-gruen: #1E9E56; --c-gruen-ink: #fff;
  --c-blau:  #1D70B8; --c-blau-ink: #fff;
  --c-rosa:  #F0629C; --c-rosa-ink: #fff;
  --c-gelb:  #F2CC0C; --c-gelb-ink: #3A3000;
  --c-lila:  #6A3FA0; --c-lila-ink: #fff;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 35, 59, .06), 0 6px 18px rgba(23, 35, 59, .07);
  --display: 'Anton', 'Arial Narrow', sans-serif; /* nur für große Zahlen */
  --head: 'Archivo', system-ui, sans-serif;      /* Überschriften: gut lesbar */
  --body: 'Archivo', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  background: var(--sand);
  color: var(--ink);
  line-height: 1.45;
}
button { font-family: inherit; }

/* Team-Farbklassen: setzen --tc / --tc-ink für alle Bausteine */
.c-gruen { --tc: var(--c-gruen); --tc-ink: var(--c-gruen-ink); }
.c-blau  { --tc: var(--c-blau);  --tc-ink: var(--c-blau-ink); }
.c-rosa  { --tc: var(--c-rosa);  --tc-ink: var(--c-rosa-ink); }
.c-gelb  { --tc: var(--c-gelb);  --tc-ink: var(--c-gelb-ink); }
.c-lila  { --tc: var(--c-lila);  --tc-ink: var(--c-lila-ink); }

/* ---------- Kopfbereich ---------- */
.site-head {
  background: var(--ink);
  color: var(--sand);
  padding: 14px 20px 12px;
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
}
.site-head .brand {
  font-family: var(--head);
  font-weight: 800;
  font-size: clamp(21px, 4.5vw, 30px);
  letter-spacing: .02em;
  text-transform: uppercase;
  margin: 0;
}
.site-head .brand .crown { color: var(--c-gelb); }
.site-head .sub { color: #B9C2D6; font-size: 14px; }
.site-head .spacer { flex: 1; }
.site-head nav a {
  color: #B9C2D6; text-decoration: none; font-weight: 600; font-size: 14px; margin-left: 14px;
}
.site-head nav a:hover, .site-head nav a:focus-visible { color: var(--sand); }

main { max-width: 1100px; margin: 0 auto; padding: 22px 16px 80px; }

h2.round-title {
  font-family: var(--head);
  font-weight: 800;
  font-size: clamp(19px, 3vw, 24px);
  text-transform: uppercase;
  letter-spacing: .02em;
  margin: 34px 0 6px;
  display: flex; align-items: baseline; gap: 12px;
}
h2.round-title .rtime {
  font-family: var(--body); font-weight: 700; font-size: 15px;
  color: var(--ink-soft); letter-spacing: 0;
}
.round-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

/* ---------- Spielkarten ---------- */
.game-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.game-card > header { padding: 12px 14px 8px; display: flex; justify-content: space-between; gap: 10px; align-items: start; flex-wrap: wrap; }
.game-card h3 { margin: 0; font-size: 17px; font-weight: 700; }
.game-card .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.game-card .hint { padding: 0 14px 14px; margin: 0; color: var(--ink-soft); font-size: 14px; }
.game-card.is-placeholder { border-style: dashed; background: transparent; box-shadow: none; }

.chip {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--sand-2); color: var(--ink-soft); white-space: nowrap;
}
.chip.live { background: var(--live); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
.chip.done { background: var(--ink); color: var(--sand); }
.chip.pause { background: #FFE9B8; color: #6b4e00; }
@keyframes pulse { 50% { opacity: .65; } }
@media (prefers-reduced-motion: reduce) { .chip.live { animation: none; } }

.teams { padding: 4px 10px 12px; display: grid; gap: 6px; }
.team-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--sand);
  border-left: 6px solid var(--tc);
}
.team-row .swatch, .pill .swatch, .sheet .swatch {
  width: 14px; height: 14px; border-radius: 4px; background: var(--tc); flex: none;
  display: inline-block;
}
.team-row .tname { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.team-row .pts { font-family: var(--display); font-size: 22px; min-width: 34px; text-align: right; }
.team-row .place { font-weight: 700; }
.team-row .out, .team-row.is-out .tname { color: var(--ink-soft); }
.team-row.is-out { opacity: .72; border-left-color: var(--ink-soft); }
.team-row .tb { cursor: help; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--white); border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 14px;
}

/* ---------- Zählbogen ---------- */
.sheet-wrap { overflow-x: auto; padding: 0 10px 12px; -webkit-overflow-scrolling: touch; }
.sheet { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.sheet th, .sheet td {
  border: 1px solid var(--line); min-width: 22px; height: 24px;
  text-align: center; padding: 0 2px;
}
.sheet thead th { background: var(--sand-2); font-weight: 600; color: var(--ink-soft); }
.sheet .tn { text-align: left; padding: 0 8px; white-space: nowrap; font-weight: 600; min-width: 90px; }
.sheet .tn .swatch { width: 10px; height: 10px; margin-right: 6px; }
.sheet .sum { font-weight: 700; background: var(--sand-2); min-width: 30px; }
.sheet .sum.capped { background: var(--c-gelb); }
.sheet td.x { background: var(--tc); color: var(--tc-ink); font-weight: 700; }
.sheet tbody tr { border-left: 4px solid var(--tc); }

/* ---------- Tabellen (Setzliste, Endstand) ---------- */
.table {
  width: 100%; border-collapse: collapse; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); font-size: 15px;
}
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { background: var(--sand-2); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  appearance: none; border: 0; border-radius: 12px; cursor: pointer;
  font-weight: 700; font-size: 15px; padding: 11px 18px;
  background: var(--ink); color: var(--sand);
  transition: transform .05s ease, opacity .15s;
}
.btn:hover { opacity: .92; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.secondary { background: var(--white); color: var(--ink); border: 1.5px solid var(--ink); }
.btn.danger { background: var(--live); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--c-blau); outline-offset: 2px;
}

input[type=text], input[type=number], input[type=password], input[type=time], select {
  font: inherit; padding: 9px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: var(--white); color: var(--ink); max-width: 100%;
}

.notice { padding: 10px 14px; border-radius: 10px; font-weight: 600; margin: 10px 0; }
.notice.err { background: #FDE5E0; color: #8C2413; }
.notice.ok { background: #DFF2E6; color: #14603A; }

/* ---------- Login ---------- */
.login-box {
  max-width: 360px; margin: 12vh auto; background: var(--white);
  padding: 26px; border-radius: var(--radius); box-shadow: var(--shadow);
  display: grid; gap: 12px; text-align: center;
}
.login-box h1 { font-family: var(--head); font-weight: 800; text-transform: uppercase; margin: 0; letter-spacing: .02em; }
.login-box input { font-size: 22px; text-align: center; letter-spacing: .3em; }

/* ============================================================
   Zähler-Seite (nur mobil im Einsatz)
   ============================================================ */
.zaehler main { max-width: 560px; padding-top: 12px; }

.court-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 16px; }
.court-picker .btn { padding: 16px 8px; font-size: 17px; }
.court-picker .btn[aria-pressed="true"] { background: var(--c-blau); color: #fff; }

.timer-block {
  background: var(--ink); color: var(--sand);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.timer-block .clock { font-family: var(--display); font-size: 56px; line-height: 1; font-variant-numeric: tabular-nums; }
.timer-block .clock.overtime { color: var(--c-gelb); }
.timer-block .phase-info { text-align: right; font-weight: 700; }
.timer-block .phase-info small { display: block; color: #B9C2D6; font-weight: 500; }

.score-btns { display: grid; gap: 10px; margin-bottom: 12px; }
.score-btn {
  display: flex; align-items: center; gap: 14px;
  width: 100%; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--tc); color: var(--tc-ink);
  padding: 18px 18px; font-size: 20px; font-weight: 700;
  box-shadow: var(--shadow);
  transition: transform .06s ease, filter .1s;
  touch-action: manipulation;
}
.score-btn:active { transform: scale(.97); filter: brightness(.92); }
.score-btn:disabled { opacity: .5; }
.score-btn .sc-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-btn .sc-pts { font-family: var(--display); font-size: 40px; line-height: 1; }
.score-btn .sc-plus { font-size: 26px; opacity: .8; }

.control-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.control-row .btn { padding: 15px 8px; }
.undo-label { text-align: center; color: var(--ink-soft); font-size: 14px; margin: -6px 0 12px; }

.cap-banner {
  background: var(--c-gelb); color: var(--c-gelb-ink);
  border-radius: 12px; padding: 12px 16px; font-weight: 700; margin-bottom: 12px; text-align: center;
}

/* Bestätigungs-Dialog Phasenende */
dialog {
  border: 0; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; max-width: 440px; width: calc(100vw - 40px);
}
dialog::backdrop { background: rgba(23, 35, 59, .55); }
dialog h3 { margin-top: 0; }
.rank-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 6px; }
.rank-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; background: var(--sand);
  border-left: 6px solid var(--tc); font-weight: 600;
}
.rank-list li .stat { margin-left: auto; color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.rank-list li.elim { outline: 2px solid var(--live); }
.dialog-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

.game-select { width: 100%; margin-bottom: 12px; }

/* ============================================================
   Spielleitung
   ============================================================ */
.admin section {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.admin section > h2 { margin: 0 0 12px; font-size: 19px; }
.admin .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.admin .grow { flex: 1; min-width: 160px; }

.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.team-list li {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--sand); border-radius: 10px; padding: 8px 12px;
}
.team-list .tname { font-weight: 600; flex: 1; min-width: 120px; }
.team-list label { font-size: 13px; display: flex; gap: 6px; align-items: center; color: var(--ink-soft); }

.flow-step { display: flex; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.flow-step:first-of-type { border-top: 0; }
.flow-step .num {
  font-family: var(--display); font-size: 22px; width: 34px; height: 34px; flex: none;
  display: grid; place-items: center; background: var(--ink); color: var(--sand); border-radius: 50%;
}
.flow-step .body { flex: 1; min-width: 240px; }
.flow-step h3 { margin: 2px 0 6px; font-size: 16px; }
.flow-step .desc { color: var(--ink-soft); font-size: 14px; margin: 0 0 8px; }

.seed-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.seed-list li {
  display: flex; align-items: center; gap: 10px; background: var(--sand);
  border-radius: 10px; padding: 6px 10px;
}
.seed-list .seed-no { font-family: var(--display); width: 30px; }
.seed-list .mv { display: flex; gap: 4px; margin-left: auto; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.settings-grid label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }

.danger-zone { border-color: var(--live) !important; }

/* ============================================================
   Anzeige (großer Bildschirm)
   ============================================================ */
.anzeige main { max-width: none; padding: 26px 30px; }
.anzeige .round-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; }
.anzeige .game-card h3 { font-size: 22px; }
.anzeige .team-row .tname { font-size: 20px; }
.anzeige .team-row .pts { font-size: 34px; }
.anzeige .big-timer { font-family: var(--display); font-size: 30px; color: var(--live); }

footer.credits { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 30px 0 20px; }

@media (max-width: 640px) {
  main { padding: 16px 10px 70px; }
  .site-head { padding: 10px 14px 9px; }
  .game-card > header { padding: 10px 12px 6px; }
}

/* ---------- Auslosung eintragen (Spielleitung) ---------- */
.assign-row {
  display: flex; align-items: center; gap: 10px;
  border-left: 5px solid var(--tc);
  background: var(--sand);
  border-radius: 8px; padding: 7px 10px;
}
.assign-row .swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--tc); flex: none; }
.assign-row .assign-color { font-weight: 700; font-size: 14px; min-width: 74px; }
.assign-row select { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--white); }
