:root {
  --bg: #f3f5f9;
  --bg-card: #ffffff;
  --bg-soft: #e9edf5;
  --text: #111827;
  --text-muted: #5b6577;
  --border: #dfe4ef;
  --primary: #1d4ed8;
  --primary-600: #1e40af;
  --primary-soft: #dbe6ff;
  --accent: #22c55e;
  --danger: #dc2626;
  --rank-chip: #eef1f7;
  --shadow: 0 8px 24px rgba(20, 30, 60, 0.08);
  --radius: 16px;
  --radius-sm: 10px;
  --space: clamp(16px, 4vw, 28px);
  font-size: 16px;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --bg-card: #141a2e;
  --bg-soft: #1c233a;
  --text: #f1f4fb;
  --text-muted: #9aa5bb;
  --border: #28304a;
  --primary: #5b8bff;
  --primary-600: #7ba2ff;
  --primary-soft: #1c2747;
  --accent: #34d399;
  --danger: #f87171;
  --rank-chip: #1c233a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 var(--space); }

/* Skip link */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: 0 0 10px 0;
  z-index: 100;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { left: 0; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.25rem; }
.brand-mark { display: grid; place-items: center; color: var(--primary); }
.brand-accent { color: var(--primary); }
.main-nav { display: flex; gap: 20px; }
.nav-link { color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.nav-link:hover, .nav-link:focus-visible { color: var(--primary); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.theme-toggle:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.theme-toggle:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Hero */
.hero { padding: clamp(32px, 6vw, 64px) 0 clamp(24px, 4vw, 40px); }
.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 6px 14px;
  border-radius: 999px;
  margin: 0 0 14px;
}
h1 { margin: 0 0 10px; font-size: clamp(1.9rem, 5vw, 3rem); line-height: 1.1; letter-spacing: -0.02em; }
.hero-sub { margin: 0; color: var(--text-muted); font-size: clamp(1rem, 2.5vw, 1.15rem); max-width: 34em; }

/* League switcher */
.league-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}
.league-tab {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.league-tab:hover { border-color: var(--primary); color: var(--primary); }
.league-tab.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.league-tab:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Sections */
.section-block { margin-bottom: clamp(28px, 5vw, 44px); }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; }

.date-nav { display: inline-flex; align-items: center; gap: 10px; }
.date-label { font-weight: 600; color: var(--text-muted); min-width: 6em; text-align: center; }
.date-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  cursor: pointer;
}
.date-btn:hover { border-color: var(--primary); color: var(--primary); }
.date-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Match cards */
.matches { display: grid; gap: 12px; }
.match {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.team {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  min-width: 0;
}
.team.is-home { justify-content: flex-start; }
.team.is-away { justify-content: flex-end; text-align: right; }
.team-badge { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; flex-shrink: 0; }
.team-name { overflow-wrap: anywhere; }
.match-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 3.4em;
}
.match-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.match-date { font-size: 0.72rem; color: var(--text-muted); }
.score { font-weight: 800; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.status-chip {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-muted);
}
.status-live { background: var(--danger); color: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.empty { background: var(--bg-card); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 28px; text-align: center; color: var(--text-muted); }

/* Standings table */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; min-width: 560px; }
caption { text-align: left; padding: 14px 18px; font-weight: 700; }
th, td { padding: 11px 14px; text-align: center; white-space: nowrap; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); border-bottom: 1px solid var(--border); background: var(--bg-soft); }
td.team-cell { text-align: left; }
.team-line { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.team-line img { width: 24px; height: 24px; object-fit: contain; flex-shrink: 0; }
.rank-chip {
  display: inline-block;
  min-width: 2em;
  text-align: center;
  padding: 3px 0;
  border-radius: 6px;
  background: var(--rank-chip);
  font-weight: 700;
}

tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg) 45%, transparent); }
tbody tr:hover { background: var(--primary-soft); }
td.num { font-variant-numeric: tabular-nums; }

/* Status bar */
.status { min-height: 24px; padding: 6px 4px; color: var(--text-muted); font-size: 0.9rem; }
.status[hidden] { display: none; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  z-index: 50;
  max-width: min(92vw, 480px);
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 20px; padding: 28px 0; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; color: var(--text-muted); font-size: 0.9rem; }
.footer-inner a { color: var(--primary); }

/* Loading shimmer */
.skeleton { background: linear-gradient(90deg, var(--bg-soft) 25%, var(--bg-card) 50%, var(--bg-soft) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); height: 62px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Responsive */
@media (max-width: 620px) {
  .main-nav { display: none; }
  .header-inner { height: auto; padding: 10px 0; flex-wrap: wrap; }
  .team { gap: 8px; }
  .team-badge { width: 28px; height: 28px; }
  .match { padding: 12px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
  html { scroll-behavior: auto; }
}