/* ===========================================================================
   Spielplan – Layout und Farben
   Mobil zuerst; grosse Schrift und kraeftige Kontraste, weil die Seite am
   Beckenrand auf hellen Displays gelesen wird.
   ======================================================================== */

:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --line: #d9dde4;
  --line-strong: #c3c9d3;
  --text: #14171d;
  --muted: #626a78;
  --accent: #1a4fd6;
  --accent-soft: #e5ecfd;
  --blue-team: #1a4fd6;
  --white-team: #4a5260;
  --late: #b3401a;
  --late-soft: #fdeae2;
  --early: #1a7a45;
  --early-soft: #e2f4ea;
  --ontime: #4a5260;
  --ontime-soft: #eceef2;
  --live: #b3401a;
  --shadow: 0 1px 2px rgba(16, 20, 28, .07), 0 6px 18px rgba(16, 20, 28, .06);
  --radius: 14px;
  --cat-0: #0f6f78;
  --cat-1: #6b3fa0;
  --cat-2: #a3541a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015;
    --surface: #171a21;
    --surface-2: #1e222b;
    --line: #2a2f3a;
    --line-strong: #3a4150;
    --text: #e9ebf0;
    --muted: #9aa3b2;
    --accent: #7fa6ff;
    --accent-soft: #1c2740;
    --blue-team: #7fa6ff;
    --white-team: #c3cad6;
    --late: #ff9269;
    --late-soft: #3a2118;
    --early: #64d79b;
    --early-soft: #143026;
    --ontime: #aab2c0;
    --ontime-soft: #242a34;
    --live: #ff9269;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    --cat-0: #4fc3cd;
    --cat-1: #b79bec;
    --cat-2: #eaa76a;
  }
}

* { box-sizing: border-box; }

/* Das hidden-Attribut versteckt sonst nichts, sobald eine Klasse weiter unten
   ein eigenes display setzt (.adminbar, .now): Regeln dieser Datei haben
   Vorrang vor der eingebauten Regel des Browsers. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Platz fuer die eingeblendete Admin-Leiste; auf schmalen Displays bricht
   sie auf zwei Zeilen um und braucht mehr Hoehe. */
body.has-adminbar { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

@media (max-width: 639px) {
  body.has-adminbar { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
}

button { font: inherit; cursor: pointer; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* --- Kopfbereich ------------------------------------------------------- */

.site {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { flex: 1 1 260px; min-width: 0; }

.brand h1 {
  margin: 0;
  font-size: clamp(1.15rem, 4.2vw, 1.55rem);
  line-height: 1.2;
  letter-spacing: -.01em;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .87rem;
}

/* Verzugsanzeige */
.delay {
  flex: 0 0 auto;
  text-align: right;
  padding: 7px 14px;
  border-radius: 12px;
  background: var(--ontime-soft);
  color: var(--ontime);
  min-width: 132px;
}

@media (max-width: 639px) {
  .delay { text-align: left; }
}

.delay.is-late  { background: var(--late-soft);  color: var(--late); }
.delay.is-early { background: var(--early-soft); color: var(--early); }

.delay-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.delay-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .9;
  margin-top: 2px;
}

/* --- Hinweisbanner ----------------------------------------------------- */

.banner {
  max-width: 900px;
  margin: 12px auto 0;
  padding: 11px 16px;
  border-radius: 10px;
  background: var(--late-soft);
  color: var(--late);
  font-size: .9rem;
  border: 1px solid currentColor;
}

.banner.info { background: var(--accent-soft); color: var(--accent); }

main { max-width: 900px; margin: 0 auto; padding: 16px 16px 40px; }

/* --- Jetzt / Als naechstes --------------------------------------------- */

.now {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  margin-bottom: 20px;
}

@media (min-width: 640px) { .now { grid-template-columns: 1fr 1fr; } }

.now-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}

.now-card.is-live { border-color: var(--live); }

.now-kicker {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.now-card.is-live .now-kicker { color: var(--live); }

.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

.now-time {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 5px 0 1px;
}

.now-teams { font-size: 1rem; }
.now-meta { color: var(--muted); font-size: .84rem; margin-top: 3px; }

/* --- Filter ------------------------------------------------------------ */

.filters { display: grid; gap: 9px; margin-bottom: 16px; }

.filter-row { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: .89rem;
  font-weight: 500;
  line-height: 1.3;
}

.chip[aria-pressed="true"], .chip[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (prefers-color-scheme: dark) {
  .chip[aria-pressed="true"], .chip[aria-selected="true"] { color: #0e1015; }
}

.chip .chip-count { opacity: .65; font-weight: 400; margin-left: 5px; }

.search-row { gap: 10px; }
.search { flex: 1 1 200px; display: block; }

.search input {
  width: 100%;
  font: inherit;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.ghost {
  background: none;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: .86rem;
}

.ghost:hover { color: var(--text); border-color: var(--text); }

.primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 9px 20px;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) { .primary { color: #0e1015; } }

/* --- Spielliste -------------------------------------------------------- */

.list { display: grid; gap: 8px; }

.daybreak {
  margin: 18px 0 4px;
  flex-wrap: wrap;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.daybreak:first-child { margin-top: 0; }
.daybreak span:first-child { flex: 1 1 auto; }
.daybreak span:last-child { font-weight: 500; text-transform: none; letter-spacing: 0; }

.game {
  display: grid;
  grid-template-columns: 62px 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cat);
  border-radius: var(--radius);
  padding: 11px 13px;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}

.game.is-past { opacity: .5; }
.game.is-live { border-color: var(--live); border-left-color: var(--live); background: var(--surface); box-shadow: 0 0 0 2px var(--late-soft); }
.game.is-final { background: var(--surface-2); }

button.game { cursor: pointer; }
button.game:hover { border-color: var(--accent); }
button.game:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.g-time { min-width: 0; }

.g-clock {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
}

.g-clock.moved { color: var(--late); }
.g-clock.moved.early { color: var(--early); }

.g-orig {
  font-size: .74rem;
  color: var(--muted);
  text-decoration: line-through;
}

.g-main { min-width: 0; }

.g-teams {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
  min-width: 0;
}

.g-teams > span { overflow-wrap: anywhere; min-width: 0; }

@media (max-width: 560px) {
  .game { grid-template-columns: 54px 1fr; }
  .g-right { grid-column: 2; justify-content: flex-start; margin-top: 4px; }
}

.t-blue  { color: var(--blue-team); }
.t-white { color: var(--white-team); }
.vs { color: var(--muted); font-weight: 400; font-size: .85em; }

.g-sub {
  margin-top: 3px;
  font-size: .79rem;
  color: var(--muted);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.g-right { display: flex; align-items: center; gap: 9px; }

.cat-badge {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--cat);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.num { color: var(--muted); font-size: .78rem; white-space: nowrap; }

.tag-warn {
  font-size: .68rem;
  font-weight: 700;
  color: var(--late);
  background: var(--late-soft);
  border-radius: 999px;
  padding: 1px 8px;
}

.tag-final {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
}

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* --- Fussbereich ------------------------------------------------------- */

.site-footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 18px 16px 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
}

.foot-line { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.foot-line > span:first-child { flex: 1 1 auto; }
.fineprint { margin: 9px 0 0; font-size: .76rem; opacity: .75; }

/* --- Admin-Leiste ------------------------------------------------------ */

.adminbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  padding: 11px 16px calc(11px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 -4px 18px rgba(16, 20, 28, .1);
}

.adminbar-label { flex: 1 1 200px; font-size: .82rem; color: var(--muted); }
.adminbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Dialoge ----------------------------------------------------------- */

.dlg {
  border: none;
  border-radius: 16px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  max-width: 480px;
  width: calc(100% - 28px);
  box-shadow: 0 18px 50px rgba(10, 14, 22, .35);
}

.dlg::backdrop { background: rgba(10, 14, 22, .55); }
.dlg form { padding: 20px; }
.dlg h2 { margin: 0 0 4px; font-size: 1.15rem; }
.dlg-hint, .dlg-sub { margin: 0 0 16px; color: var(--muted); font-size: .87rem; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }

.field input[type="password"], .field input[type="time"] {
  font: inherit;
  font-size: 1.05rem;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 170px; margin-bottom: 14px; }

.nudges { display: flex; gap: 5px; flex-wrap: wrap; }

.nudges button {
  flex: 1 1 auto;
  min-width: 40px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 2px;
  font-size: .88rem;
  font-weight: 600;
}

.nudges button:hover { border-color: var(--accent); color: var(--accent); }

.preview {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: .87rem;
  line-height: 1.5;
  color: var(--muted);
  margin-bottom: 14px;
}

.preview strong { color: var(--text); }
.preview .big { display: block; font-size: 1.05rem; color: var(--text); margin-bottom: 3px; }

.error {
  color: var(--late);
  background: var(--late-soft);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: .86rem;
  margin: 0 0 14px;
}

.dlg menu {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.log { margin: 0 0 16px; padding-left: 20px; max-height: 50vh; overflow: auto; font-size: .87rem; }
.log li { margin-bottom: 7px; }
.log .ts { color: var(--muted); font-size: .8rem; display: block; }
.log-empty { color: var(--muted); list-style: none; margin-left: -20px; }

/* --- Menue ------------------------------------------------------------- */

.menu { position: relative; flex: 0 0 auto; }

.menu-button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 15px;
  font-size: .92rem;
  font-weight: 600;
}

.menu-button:hover { border-color: var(--accent); color: var(--accent); }
.menu-button .caret { width: 11px; height: 8px; opacity: .7; }
.menu-button[aria-expanded="true"] .caret { transform: rotate(180deg); }

.menu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  z-index: 40;
  min-width: 250px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  box-shadow: 0 12px 34px rgba(10, 14, 22, .22);
}

.menu-list a {
  display: block;
  padding: 11px 13px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--text);
  font-size: .95rem;
}

.menu-list a:hover { background: var(--surface-2); color: var(--accent); }
.menu-list .ext { color: var(--muted); margin-left: 4px; }

/* Auf dem Handy wird der Menueknopf zur eigenen Zeile direkt unter dem Titel. */
@media (max-width: 639px) {
  .menu { order: 2; flex: 1 1 100%; }
  .menu-button { width: 100%; justify-content: space-between; }
  .menu-list { left: 0; right: 0; }
  .delay { order: 3; }
}

/* --- Spielstand in der Liste ------------------------------------------- */

.score {
  font-weight: 800;
  font-size: 1.02em;
  white-space: nowrap;
  letter-spacing: -.01em;
}

.g-teams .is-win { font-weight: 800; }
.g-teams .is-loss { font-weight: 500; opacity: .62; }

/* Noch nicht feststehende Teams der Platzierungsspiele */
.g-teams .open, .now-teams .open {
  font-style: italic;
  font-weight: 500;
  color: var(--muted);
}

/* --- Punkteuebersicht --------------------------------------------------- */

.cat-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--cat);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.cat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.cat-head h2 { margin: 0; font-size: 1.15rem; color: var(--cat); }
.cat-meta { color: var(--muted); font-size: .82rem; }

.sub-head {
  margin: 16px 0 7px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-size: .72rem;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--ontime-soft);
  color: var(--ontime);
}

.pill.done { background: var(--early-soft); color: var(--early); }

.table-wrap { overflow-x: auto; }

.standings {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  font-variant-numeric: tabular-nums;
}

.standings th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 700;
  text-align: right;
  padding: 0 6px 6px;
  white-space: nowrap;
}

.standings td {
  padding: 8px 6px;
  text-align: right;
  border-top: 1px solid var(--line);
  white-space: nowrap;
}

.standings abbr { text-decoration: none; }
.standings .c-rank { width: 2em; text-align: left; color: var(--muted); }
.standings .c-team { text-align: left; width: 99%; font-weight: 600; white-space: normal; }
.standings .c-pts { font-weight: 800; }
.standings .c-wdl span { color: var(--muted); margin: 0 2px; }
.standings tbody tr:first-child .c-rank { color: var(--text); font-weight: 700; }
.standings tr.is-tied .c-team { color: var(--late); }

.tie-flag {
  margin-left: 7px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--late-soft);
  color: var(--late);
}

.tie-note {
  margin: 10px 0 0;
  font-size: .85rem;
  color: var(--late);
  background: var(--late-soft);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.tie-note.subtle { color: var(--muted); background: var(--surface-2); }
.tie-note .ghost { border-color: currentColor; color: inherit; }

.ranking { list-style: none; margin: 0; padding: 0; }

.ranking li {
  display: flex;
  align-items: baseline;
  gap: 11px;
  padding: 9px 2px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.ranking li.is-open { opacity: .55; }
.r-rank { width: 1.9em; font-weight: 800; font-size: 1.02rem; }
.r-team { flex: 1 1 140px; font-weight: 600; }
.r-note { color: var(--muted); font-size: .8rem; }

/* --- Dialog: Ergebnis eintragen ---------------------------------------- */

.dlg-wide { max-width: 560px; }
.dlg-body { padding: 20px; }
.dlg-body form { margin: 0; padding: 0; }

.section-head {
  margin: 18px 0 10px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.dlg-body form:first-of-type .section-head { border-top: none; padding-top: 0; margin-top: 4px; }

.score-entry {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.score-side {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
  text-align: center;
}

.score-side > span {
  font-size: .82rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.score-side input {
  width: 100%;
  max-width: 130px;
  font: inherit;
  font-size: 1.9rem;
  font-weight: 700;
  text-align: center;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.score-side input:disabled { opacity: .45; }
.score-colon { font-size: 1.5rem; font-weight: 700; padding-bottom: 11px; color: var(--muted); }

.section-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
}

.dlg-foot {
  display: flex;
  justify-content: flex-end;
  margin: 18px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

/* --- Dialog: weitere Aktionen und Losentscheid -------------------------- */

.action-list { display: grid; gap: 9px; margin-bottom: 16px; }

.action {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  padding: 12px 14px;
  color: var(--text);
}

.action:hover { border-color: var(--accent); }
.action strong { display: block; font-size: .95rem; }
.action span { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }

.draw-list { margin: 0 0 16px; padding: 0; list-style: none; counter-reset: pos; }

.draw-list li {
  counter-increment: pos;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 7px;
  background: var(--surface-2);
}

.draw-list li::before {
  content: counter(pos) ".";
  font-weight: 800;
  color: var(--muted);
  min-width: 1.5em;
}

.draw-list li > span:first-of-type { flex: 1 1 auto; font-weight: 600; }
.draw-actions { display: flex; gap: 5px; }

.draw-actions button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  width: 36px;
  height: 34px;
  font-size: 1rem;
}

.draw-actions button:disabled { opacity: .35; cursor: default; }
