:root {
  --bg: #07090d;
  --bg-elev: #12171f;
  --bg-elev-2: #181e28;
  --line: #232b36;
  --text: #f3f5f7;
  --muted: #8b95a1;
  --faint: #5d6670;
  --accent: #c8f542;
  --accent-dim: rgba(200, 245, 66, 0.16);
  --live: #ff3b30;
  --live-dim: rgba(255, 59, 48, 0.16);
  --pin: #f5c518;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max: 920px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
html { min-height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(24px + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#ptr {
  position: fixed;
  top: calc(8px + var(--safe-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.15s ease;
  z-index: 20;
}
#ptr.visible { opacity: 1; }
#ptr span {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  padding: calc(14px + var(--safe-top)) 16px 12px;
}
.top-row, .week-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max);
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { border-radius: 8px; }
.eyebrow {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.eyebrow.live { color: var(--live); }
.eyebrow.live::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  margin-bottom: 1px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live);
  animation: pulse 1.6s ease-out infinite;
}
h1 { margin: 0; font-size: 1.35rem; letter-spacing: -0.03em; font-weight: 750; line-height: 1.1; }

.icon-btn {
  appearance: none;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-btn:hover { border-color: #3a4554; background: var(--bg-elev-2); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.spin svg { animation: spin 0.7s linear; }

.week-bar { margin-top: 12px; gap: 10px; }
.week-label {
  flex: 1;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.92rem;
}
.week-label small {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}

.meta {
  max-width: var(--max);
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}
.meta .cached { color: var(--pin); }
.meta .error { color: #ff8a80; }

.board {
  max-width: var(--max);
  margin: 0 auto;
  padding: 16px 16px 0;
}

.banner {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.banner.error { border-color: #5a2a28; color: #ffc1bc; background: #1a1010; }
.banner.cached { border-color: #4a3d12; color: #f5d56a; }

.section { margin-bottom: 22px; }
.section-title {
  margin: 0 0 10px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.games { display: grid; gap: 10px; }
.games.pinned-grid { grid-template-columns: 1fr; }
@media (min-width: 800px) {
  .games { grid-template-columns: 1fr 1fr; }
  .games.pinned-grid { grid-template-columns: 1fr; max-width: calc(50% - 5px); }
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 12px 10px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--line);
}
.card.is-live::before { background: var(--live); }
.card.is-final::before { background: #3d4652; }
.card.is-sched::before { background: #3a6d9a; }
.card.is-favorite {
  border-color: color-mix(in srgb, var(--pin) 45%, var(--line));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pin) 18%, transparent);
}
.card.is-favorite::before { background: var(--pin); }

.teams { display: grid; gap: 8px; }
.team {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}
.logo-wrap {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.logo-wrap img { width: 32px; height: 32px; object-fit: contain; }
.logo-fallback {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--muted);
}
.team-id { min-width: 0; }
.abbr-row { display: flex; align-items: center; gap: 6px; }
.abbr {
  font-weight: 800;
  letter-spacing: 0.04em;
  font-size: 1rem;
}
.record { color: var(--muted); font-size: 0.75rem; margin-top: 1px; }
.score {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.04em;
  min-width: 1.6em;
  text-align: right;
  line-height: 1;
}
.team.is-loser .abbr, .team.is-loser .score { color: var(--faint); }
.team.is-winner .abbr { color: var(--text); }

.poss {
  width: 10px;
  height: 16px;
  display: grid;
  place-items: center;
}
.poss svg { display: none; }
.team.has-ball .poss svg { display: block; }

.abbr-row .pin { margin-left: 2px; }
.pin {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--faint);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}
.pin:hover, .pin[aria-pressed="true"] { color: var(--pin); }
.pin:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.7rem;
}
.badge.live { color: var(--live); }
.badge.live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.6s ease-out infinite;
}
.badge.final { color: var(--muted); }
.situation { color: var(--text); font-variant-numeric: tabular-nums; }

.bye {
  color: var(--muted);
  font-size: 0.85rem;
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.empty, .error-full {
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
}

.skeleton { display: grid; gap: 10px; }
.skel-day, .skel-card {
  background: linear-gradient(90deg, var(--bg-elev) 0%, var(--bg-elev-2) 50%, var(--bg-elev) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border-radius: 12px;
}
.skel-day { height: 14px; width: 40%; margin-bottom: 4px; }
.skel-card { height: 108px; border-radius: 16px; }

@keyframes shimmer {
  from { background-position: 0 0; }
  to { background-position: -200% 0; }
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.55); }
  100% { box-shadow: 0 0 0 8px rgba(255, 59, 48, 0); }
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .eyebrow.live::before, .badge.live::before, .skel-day, .skel-card { animation: none; }
  .icon-btn.spin svg { animation: none; }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.hidden { display: none !important; }

.seg, .conf-wrap {
  max-width: var(--max);
  margin: 10px auto 0;
}
.seg {
  display: flex;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}
.seg-sub { margin-top: 8px; }
.seg-btn {
  appearance: none;
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.seg-btn[aria-selected="true"] {
  background: var(--bg-elev-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.conf-wrap select {
  width: 100%;
  appearance: none;
  background: var(--bg-elev) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%238b95a1' d='M1 1l5 5 5-5'/></svg>") no-repeat right 12px center;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 36px 10px 12px;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
}
.conf-wrap select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.rank {
  display: inline-block;
  min-width: 1.2em;
  margin-right: 2px;
  color: var(--accent);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.rank::before { content: "#"; font-size: 0.62em; margin-right: 1px; opacity: 0.85; }

.rank-list { display: grid; gap: 0; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.rank-row {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.rank-row:first-child { border-top: 0; }
.rank-num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  text-align: center;
}
.rank-team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rank-team .logo-wrap { width: 32px; height: 32px; flex: none; }
.rank-name { font-weight: 700; line-height: 1.15; }
.rank-name small { display: block; color: var(--muted); font-weight: 600; font-size: 0.75rem; margin-top: 2px; }
.rank-move { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.82rem; min-width: 4.4rem; }
.rank-move .prev { display: block; color: var(--faint); font-weight: 600; font-size: 0.7rem; margin-bottom: 2px; }
.rank-move.up { color: #7dffa0; }
.rank-move.down { color: #ff8a80; }
.rank-move.same, .rank-move.new { color: var(--muted); }
.poll-head { margin: 0 0 8px; }
.poll-head .section-title { margin-bottom: 4px; }
.poll-date { margin: 0; color: var(--muted); font-size: 0.78rem; }
