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

:root {
  --bg: #0d1117;
  --text: #c9d1d9;
  --text-heading: #f0f6fc;
  --text-muted: #484f58;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --border: #21262d;
  --border-light: #161b22;
  --current-bg: rgba(35, 134, 54, 0.15);
  --current-border: #238636;
  --upcoming-bg: rgba(210, 153, 34, 0.1);
  --upcoming-border: #d29922;
  --badge-live-bg: #238636;
  --badge-live-text: #fff;
  --badge-finished-bg: #21262d;
  --badge-finished-text: #484f58;
  --error: #da3633;
  --btn-bg: #21262d;
  --btn-text: #c9d1d9;
  --btn-hover: #30363d;
}

.light {
  --bg: #ffffff;
  --text: #1f2328;
  --text-heading: #1f2328;
  --text-muted: #656d76;
  --text-dim: #656d76;
  --accent: #0969da;
  --border: #d0d7de;
  --border-light: #f6f8fa;
  --current-bg: rgba(26, 127, 55, 0.1);
  --current-border: #1a7f37;
  --upcoming-bg: rgba(154, 103, 0, 0.08);
  --upcoming-border: #9a6700;
  --badge-live-bg: #1a7f37;
  --badge-live-text: #fff;
  --badge-finished-bg: #d0d7de;
  --badge-finished-text: #656d76;
  --error: #cf222e;
  --btn-bg: #d0d7de;
  --btn-text: #1f2328;
  --btn-hover: #afb8c1;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem;
  transition: background 0.3s, color 0.3s;
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.header-left {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.header-right {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
}

h1 {
  font-size: 3rem;
  font-weight: 300;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-heading);
  margin-bottom: 0.5rem;
  transition: color 0.3s;
}

#clock {
  font-size: 4rem;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  letter-spacing: 0.1em;
  transition: color 0.3s;
}

#theme-toggle {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

#theme-toggle:hover {
  background: var(--btn-hover);
}

.qr {
  width: 168px;
  height: 168px;
  border-radius: 6px;
  display: block;
}

body:not(.light) .qr {
  filter: invert(1);
}

#last-updated {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  transition: color 0.3s;
}

#schedule {
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  body { padding: 1rem; }
  h1 { font-size: 2rem; }
  #clock { font-size: 2.5rem; }
  .game-table { font-size: 1rem; }
  .game-table td.team1, .game-table td.team2 { min-width: 8rem; }
  .game-table td.ergebnis { font-size: 1.1rem; min-width: 3rem; }
  .qr { width: 96px; height: 96px; }
  .header-right { flex-direction: column; align-items: center; }
}

@media (max-width: 600px) {
  body { padding: 0.5rem; }
  h1 { font-size: 1.4rem; }
  #clock { font-size: 1.6rem; }
  .game-table { font-size: 0.8rem; }
  .game-table th { padding: 0.3rem 0.4rem; font-size: 0.7rem; }
  .game-table td { padding: 0.3rem 0.4rem; }
  .game-table td.team1, .game-table td.team2 { min-width: 5rem; }
  .game-table td.ergebnis { font-size: 0.9rem; min-width: 2.5rem; }
  .day-header { font-size: 1rem; }
  .group-table { font-size: 0.75rem; }
  .group-table th { padding: 0.2rem 0.3rem; font-size: 0.65rem; }
  .group-table td { padding: 0.2rem 0.3rem; }
  .qr { width: 64px; height: 64px; }
}

.day-group {
  margin-bottom: 2.5rem;
}

.day-header {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-heading);
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  transition: color 0.3s, border-color 0.3s;
}

.game-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.3rem;
}

.game-table th {
  text-align: left;
  padding: 0.6rem 1rem;
  font-weight: 500;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.3s, border-color 0.3s;
}

.game-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  transition: border-color 0.3s;
}

.game-table tr.past {
  opacity: 0.35;
}

.game-table tr.current {
  background: var(--current-bg);
  border-left: 4px solid var(--current-border);
}

.game-table tr.upcoming {
  background: var(--upcoming-bg);
  border-left: 4px solid var(--upcoming-border);
}

.game-table td.time {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 5rem;
}

.game-table td.nr {
  width: 3rem;
  text-align: center;
  color: var(--text-dim);
}

.game-table td.spielzeit {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 6rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.game-table td.klasse {
  width: 4rem;
  font-weight: 600;
  text-align: center;
}

.game-table td.gruppe {
  width: 8rem;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.game-table td.team1 {
  font-weight: 500;
  min-width: 12rem;
  text-align: right;
}

.game-table td.team2 {
  font-weight: 500;
  min-width: 12rem;
}

.game-table td.ergebnis {
  text-align: center;
  font-weight: 700;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  min-width: 5rem;
}

.game-table td.schiri {
  color: var(--text-dim);
  font-size: 0.95rem;
  min-width: 7rem;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.playing {
  background: var(--badge-live-bg);
  color: var(--badge-live-text);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-badge.finished {
  background: var(--badge-finished-bg);
  color: var(--badge-finished-text);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@media (max-width: 900px) {
  body { padding: 1rem; }
  h1 { font-size: 2rem; }
  #clock { font-size: 2.5rem; }
  .game-table { font-size: 1rem; }
  .game-table td.team1, .game-table td.team2 { min-width: 8rem; }
  .game-table td.ergebnis { font-size: 1.1rem; min-width: 3rem; }
  .qr { width: 96px; height: 96px; }
  .header-right { flex-direction: column; align-items: center; }
}

.loading {
  text-align: center;
  padding: 4rem;
  font-size: 1.5rem;
  color: var(--text-muted);
}

.error {
  text-align: center;
  padding: 4rem;
  font-size: 1.5rem;
  color: var(--error);
}

#groups {
  max-width: 1400px;
  margin: 2rem auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
}

.group-standings {
  flex: 1 1 400px;
}

.group-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.1rem;
}

.group-table th {
  text-align: left;
  padding: 0.4rem 0.6rem;
  font-weight: 500;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.group-table td {
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--border-light);
  text-align: center;
}

.group-table td.g-team {
  text-align: left;
  font-weight: 500;
}

.group-table td.g-rank {
  color: var(--text-dim);
  width: 2rem;
}

.group-table td.g-tore {
  font-variant-numeric: tabular-nums;
}

.group-table td.g-diff {
  font-variant-numeric: tabular-nums;
}

.group-table td.g-pts {
  font-weight: 700;
  font-size: 1.2rem;
}

.clickable {
  cursor: pointer;
}

.has-selection .game-table tr.dimmed,
.has-selection .group-table tr.dimmed {
  opacity: 0.2;
  transition: opacity 0.25s;
}


footer {
  text-align: center;
  padding: 3rem 0 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.5;
}
