:root {
  --bg: #07091a;
  --surface: #0f1630;
  --surface-2: #182045;
  --border: rgba(255 255 255 / 0.07);
  --gold: #f5a623;
  --gold-light: #ffd97d;
  --text: #e8edf8;
  --text-muted: #6272a0;
  --green: #22c55e;
  --red: #f87171;
  --blue: #60a5fa;
  --radius: 14px;
  --radius-sm: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────── */

header {
  background: linear-gradient(160deg, #0c1435 0%, #1a0e3a 60%, #0c1435 100%);
  border-bottom: 1px solid var(--border);
  padding: 40px 20px 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% -20%, rgba(245 166 35 / 0.15) 0%, transparent 65%);
  pointer-events: none;
}

.header-inner { position: relative; }

.trophy-wrap {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 24px rgba(245 166 35 / 0.5));
}

h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.2rem, 7vw, 4rem);
  letter-spacing: 0.04em;
  color: var(--gold-light);
  line-height: 1;
}

.subtitle {
  font-size: 0.9rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Main layout ─────────────────────────────────── */

main {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin: 20px 0 4px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

#refresh-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: color 0.15s, border-color 0.15s;
}
#refresh-btn:hover { color: var(--text); border-color: var(--gold); }

.error-banner {
  background: rgba(248 113 113 / 0.08);
  border: 1px solid rgba(248 113 113 / 0.25);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.error-banner.hidden { display: none; }

.section { margin-top: 36px; }

.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 16px;
}

/* ── Leaderboard ─────────────────────────────────── */

#leaderboard { display: flex; flex-direction: column; gap: 10px; }

.lb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.lb-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--rank-color, transparent);
  border-radius: 3px 0 0 3px;
}

.lb-card.rank-1 { --rank-color: #f5c842; border-color: rgba(245 200 66 / 0.2); }
.lb-card.rank-2 { --rank-color: #b0b8c8; border-color: rgba(176 184 200 / 0.2); }
.lb-card.rank-3 { --rank-color: #cd7f32; border-color: rgba(205 127 50 / 0.2); }

.lb-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.lb-rank {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  min-width: 28px;
  color: var(--rank-color, var(--text-muted));
}

.lb-name {
  font-weight: 600;
  font-size: 1rem;
  flex: 1;
}

.lb-total {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.6rem;
  color: var(--gold-light);
  letter-spacing: 0.03em;
}

.lb-total-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lb-teams {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.lb-team-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
}

.lb-team-row.eliminated .team-name,
.lb-team-row.eliminated .team-flag { opacity: 0.35; }

.team-flag { font-size: 1.1em; }

.team-name { font-weight: 500; }

.team-pts {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  min-width: 48px;
  text-align: right;
}
.lb-team-row:not(.eliminated) .team-pts { color: var(--gold-light); }

/* ── Status badges ───────────────────────────────── */

.badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  text-transform: uppercase;
}
.badge-active   { background: rgba(34 197 94 / 0.12); color: #4ade80; border: 1px solid rgba(34 197 94 / 0.25); }
.badge-elim     { background: rgba(255 255 255 / 0.05); color: var(--text-muted); border: 1px solid var(--border); }
.badge-champion { background: rgba(245 166 35 / 0.18); color: var(--gold); border: 1px solid rgba(245 166 35 / 0.35); }
.badge-runner   { background: rgba(176 184 200 / 0.1); color: #b0b8c8; border: 1px solid rgba(176 184 200 / 0.2); }

/* ── Allocations grid ────────────────────────────── */

.allocations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.alloc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.alloc-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.alloc-teams {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.alloc-team {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.alloc-team .team-flag { opacity: 0.9; }
.alloc-team span { flex: 1; }

/* ── Scoring section ─────────────────────────────── */

.scoring-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  max-width: 480px;
}

@media (max-width: 420px) { .scoring-grid { grid-template-columns: 1fr; } }

.score-rule {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.82rem;
  gap: 12px;
}
.score-rule.highlight {
  border-color: rgba(245 166 35 / 0.3);
  background: rgba(245 166 35 / 0.06);
}
.pts { font-weight: 700; color: var(--gold); white-space: nowrap; }

/* ── Footer ──────────────────────────────────────── */

footer {
  text-align: center;
  padding: 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
footer a { color: var(--text-muted); text-decoration: underline; }
footer a:hover { color: var(--gold); }

/* ── Skeleton loading ────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
  height: 72px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
