:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5f6672;
  --border: #e1e4e9;
  --accent: #0b63ce;
  --live: #d6282f;
  --live-bg: #fdecec;
  --ready: #9a6700;
  --ready-bg: #fff4d6;
  --done-bg: #eceef2;
  --anomaly: #8a4b00;
  --anomaly-bg: #fff2e0;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2c3038;
    --accent: #5aa2ff;
    --live: #ff5c61;
    --live-bg: #3a1a1c;
    --ready: #e5b54a;
    --ready-bg: #372d14;
    --done-bg: #262a31;
    --anomaly: #f0a65a;
    --anomaly-bg: #36260f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

a { color: var(--accent); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Kopfzeile */

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.bar h1 { margin: 0; font-size: 1.15rem; }
.back { text-decoration: none; font-weight: 500; }

.connection {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.connection::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.connection[data-status="open"]::before { background: #1f9d55; }
.connection[data-status="closed"]::before { background: var(--live); }
.connection[data-status="connecting"]::before { background: var(--ready); }

/* Filter */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 16px 0 4px;
}

.day { display: flex; gap: 6px; }

button, select, input[type="date"] {
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 36px;
}

button { cursor: pointer; }
button:hover { border-color: var(--muted); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  cursor: pointer;
}

.check input { width: 18px; height: 18px; margin: 0; }

.day-title {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Liste */

.league h2 {
  margin: 24px 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.match-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.match-list li + li { border-top: 1px solid var(--border); }

.match {
  display: grid;
  grid-template-columns: 3.2rem 1fr auto;
  grid-template-areas:
    "kickoff teams score"
    "kickoff teams badge";
  align-items: center;
  gap: 2px 12px;
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
}

.match:hover { background: var(--bg); }

.kickoff { grid-area: kickoff; color: var(--muted); font-variant-numeric: tabular-nums; }
.teams { grid-area: teams; display: grid; gap: 4px; min-width: 0; }
.match .score { grid-area: score; justify-self: end; display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.match .badge { grid-area: badge; justify-self: end; }

.team {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.team img { width: 20px; height: 20px; object-fit: contain; flex: none; }
.team .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Aufschlag: Punkt hinter dem Teamnamen. */
.serving .name::after {
  content: " ●";
  color: var(--live);
  font-size: 0.7em;
  vertical-align: middle;
}

.sets { font-weight: 700; font-size: 1.1rem; }
.points { color: var(--muted); font-size: 0.9rem; }
.status-live .points { color: var(--live); font-weight: 600; }

.badge {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--done-bg);
  color: var(--muted);
}

.status-live .badge { background: var(--live-bg); color: var(--live); }
.status-ready .badge { background: var(--ready-bg); color: var(--ready); }
.status-planned .badge { background: transparent; border: 1px solid var(--border); }

.empty { margin: 32px 0; text-align: center; color: var(--muted); }
.error { color: var(--live); }

/* Detailseite */

.scoreboard { padding-top: 16px; }
.scoreboard .meta { margin: 0 0 12px; color: var(--muted); font-size: 0.9rem; text-align: center; }

.board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  font-weight: 600;
  min-width: 0;
}

.side img { width: 48px; height: 48px; object-fit: contain; }
.side .name { overflow-wrap: anywhere; }

.center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.center .sets { font-size: 2.2rem; line-height: 1; font-variant-numeric: tabular-nums; }

/* Satzergebnisse: dieselben Spalten wie das Scoreboard darüber. */
.set-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 4px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-variant-numeric: tabular-nums;
}

.set-list li {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.set-list li + li { border-top: 1px solid var(--border); }
.set-list .team1, .set-list .team2 { text-align: center; font-size: 1.05rem; color: var(--muted); }
.set-list .won { color: var(--text); font-weight: 700; }
.set-list .label { min-width: 5.5rem; text-align: center; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.set-list .running .team1, .set-list .running .team2 { color: var(--live); font-weight: 700; }
.set-list .running .label { color: var(--live); }

.section-title { margin: 28px 0 0; font-size: 1.1rem; }

.timeline-set h3 {
  margin: 20px 0 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.events {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.events li {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 7px 12px;
  font-size: 0.95rem;
}

.events li + li { border-top: 1px solid var(--border); }
.events time { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.events .score { font-weight: 700; font-variant-numeric: tabular-nums; }
.events .who { color: var(--muted); }
.events .hint { color: var(--muted); font-size: 0.85em; }
.events .serve { color: var(--live); font-size: 0.7rem; }

.events .milestone { background: var(--bg); font-weight: 500; }
.events .anomaly { background: var(--anomaly-bg); color: var(--anomaly); }

/* Punktendes Team: farbige Markierung je Team. */
.events .point .text::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 2px;
  vertical-align: middle;
}
.events .scorer-team1 .text::before { background: var(--accent); }
.events .scorer-team2 .text::before { background: var(--ready); }

@media (min-width: 560px) {
  .match { grid-template-columns: 3.5rem 1fr auto auto; grid-template-areas: "kickoff teams score badge"; }
  .match .badge { min-width: 5.5rem; text-align: center; }
}
