:root {
  --bg: #0b0f17;
  --card: #151b26;
  --text: #eef2f8;
  --muted: #8a96a8;
  --accent: #34d399;
  --live: #ef4444;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --line: color-mix(in srgb, var(--text) 10%, transparent);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.brand { font-weight: 800; font-size: 22px; letter-spacing: -0.5px; }
.brand span { color: var(--accent); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 26px; line-height: 1;
  color: var(--muted);
}
.icon-btn:active { background: var(--card); }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.leagues {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 10px;
  scrollbar-width: none;
}
.leagues::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px;
  background: var(--card); color: var(--muted); font-weight: 600; font-size: 14px;
}
.chip.active { background: var(--accent); color: var(--bg); }

.datebar {
  display: grid; grid-template-columns: 52px 1fr 52px; align-items: center; gap: 8px;
  padding: 2px 16px 0;
}
.arrow {
  width: 52px; height: 52px; border-radius: 16px; background: var(--card);
  display: grid; place-items: center; color: var(--text);
}
.arrow:active { background: var(--accent); color: var(--bg); }
.date-label {
  position: relative; display: grid; justify-items: center; gap: 2px;
  padding: 6px 0; border-radius: 14px; cursor: pointer;
}
.date-main { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.date-sub { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.date-label input {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer;
}
.today-link { text-align: center; min-height: 6px; }
.today-link button {
  margin-top: 6px; padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700;
  color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
}

main { padding: 0 16px; }

.league-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 18px 2px 8px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.league-head:first-child { margin-top: 6px; }

.game {
  background: var(--card); border-radius: 16px; padding: 12px 14px;
  margin-bottom: 8px; display: grid; grid-template-columns: 1fr auto; gap: 10px;
  align-items: center;
}
.teams { display: grid; gap: 8px; min-width: 0; }
.team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.team img, .team .logo-fallback {
  width: 28px; height: 28px; flex: none; object-fit: contain;
}
.logo-fallback {
  border-radius: 50%; background: var(--line); display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: var(--muted);
}
.team-name {
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 600; font-size: 15px;
}
.team-record { color: var(--muted); font-size: 12px; font-weight: 500; margin-left: 6px; }
.team-score { font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.team.loser .team-name, .team.loser .team-score { color: var(--muted); }

.status {
  border-left: 1px solid var(--line); padding-left: 12px; min-width: 76px;
  text-align: center; font-size: 12px; font-weight: 600; color: var(--muted);
  display: grid; gap: 4px; justify-items: center;
}
.status.live { color: var(--live); }
.live-dot {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 800; letter-spacing: 0.05em;
}
.live-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--live);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.25; } }
.status .net { font-weight: 500; font-size: 11px; color: var(--muted); }

.empty, .error {
  background: var(--card); border-radius: 16px; padding: 14px; color: var(--muted);
  font-size: 14px; margin-bottom: 8px;
}
.error { color: var(--live); }
.skeleton { height: 86px; border-radius: 16px; background: var(--card); margin-bottom: 8px; opacity: 0.6; animation: pulse 1.4s infinite; }

.updated { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.tab { padding: 10px; font-weight: 700; font-size: 13px; color: var(--muted); border-radius: 12px; }
.tab.active { color: var(--accent); }
.tab:disabled { opacity: 0.4; cursor: default; }
.live-count { color: var(--live); }

.nearby { display: grid; gap: 8px; }
.nearby-note { color: var(--muted); font-size: 13px; text-align: center; padding: 6px; }
.nearby-btn {
  display: grid; justify-items: start; gap: 2px; text-align: left;
  padding: 14px 16px; border-radius: 16px; background: var(--card);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}
.nearby-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.nearby-day { font-size: 16px; font-weight: 700; }
.fatal { white-space: pre-wrap; font-size: 12px; }
.game.tappable { cursor: pointer; transition: transform .12s; }
.game.tappable:active { transform: scale(.985); }
