:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1a1a1a;
  --border: #242424;
  --border2: #303030;
  --text: #e2e2e2;
  --text2: #888;
  --text3: #fff;
  --gold: #c8a84b;
  --gold-dim: #7a6228;
  --green: #4a9e6a;
  --amber: #c9792a;
  --red: #c94a4a;
  --blue: #4a7ec9;
  --top-bg: #0e1e40;
  --fs-xs:   12px;
  --fs-sm:   13px;
  --fs-base: 14px;
  --fs-md:   15px;
  --fs-lg:   18px;
  --fs-xl:   22px;
}
[data-theme="light"] {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface2: #f8f9fb;
  --border: #e5e8ee;
  --border2: #d0d4dc;
  --text: #0e1e40;
  --text2: #6b7280;
  --text3: #374151;
  --gold: #f59e0b;
  --gold-dim: #d97706;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --blue: #1a5cff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; min-height: 100vh; font-size: var(--fs-base); }
a { color: var(--blue); }

/* Header */
.site-header {
  background: var(--top-bg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.header-title { font-size: var(--fs-lg); font-weight: 700; color: #fff; letter-spacing: -0.3px; }
.header-sub { font-size: var(--fs-xs); color: rgba(255,255,255,0.5); margin-top: 2px; }
.theme-row { display: flex; gap: 4px; }
.t-btn {
  font-size: var(--fs-xs);
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  background: transparent;
  transition: all 0.15s;
  user-select: none;
}
.t-btn.active { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.3); }
.t-btn:hover:not(.active) { color: rgba(255,255,255,0.8); }

/* Tabs */
.tabs-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 18px;
  font-size: var(--fs-sm);
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--gold); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* Tab panels */
.tab-panel { display: none; padding: 16px; max-width: 1100px; margin: 0 auto; }
.tab-panel.active { display: block; }
#tab-groups { max-width: 1800px; }

/* Section headings */
.section-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text3);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ── LEADERBOARD ── */
.lb-grid { display: flex; flex-direction: column; gap: 8px; }
.lb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.lb-rank { font-size: var(--fs-lg); font-weight: 700; min-width: 32px; text-align: center; flex-shrink: 0; }
.lb-rank.r1 { color: var(--gold); }
.lb-rank.r2 { color: #aaa; }
.lb-rank.r3 { color: #a0522d; }
.lb-body { flex: 1; min-width: 0; }
.lb-name { font-size: var(--fs-md); font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.lb-alive-count {
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text2);
}
.lb-alive-count.has-teams { background: rgba(74,158,106,0.2); color: var(--green); }
.lb-alive-count.no-teams  { background: rgba(201,74,74,0.15);  color: var(--red); }
.lb-teams { display: flex; flex-wrap: wrap; gap: 6px; }
.lb-team {
  font-size: var(--fs-xs);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  gap: 4px;
  align-items: center;
}
.lb-team.alive { border-color: var(--green); color: var(--text); }
.lb-team.alive .team-round { color: var(--green); font-weight: 600; }
.lb-team.out { color: var(--text2); text-decoration: line-through; opacity: 0.6; }
.lb-team.winner-team { border-color: var(--gold); background: rgba(200,168,75,0.12); }
.eliminated-banner {
  background: rgba(201,74,74,0.1);
  border: 1px solid rgba(201,74,74,0.3);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--red);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: center;
  margin-top: 4px;
}

/* ── GROUPS ── */
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.group-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.group-header { background: var(--surface2); padding: 8px 12px; font-weight: 700; font-size: var(--fs-sm); border-bottom: 1px solid var(--border); letter-spacing: 0.5px; }
.group-table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.group-table th {
  padding: 5px 6px;
  text-align: right;
  color: var(--text2);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.group-table th:nth-child(1),
.group-table th:nth-child(2),
.group-table th:nth-child(3) { text-align: left; }
.group-table th:last-child { padding-right: 10px; }
.group-table td { padding: 6px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
.group-table tr:last-child td { border-bottom: none; }
.group-table td:nth-child(1) { text-align: center; color: var(--text2); font-weight: 600; width: 20px; }
.group-table td:nth-child(2) { text-align: left; font-weight: 600; min-width: 110px; }
.group-table td:nth-child(3) { text-align: left; color: var(--text2); min-width: 75px; }
.group-table td:last-child { font-weight: 700; padding-right: 10px; }
.row-q1 { background: rgba(74,158,106,0.12); }
.row-q2 { background: rgba(74,158,106,0.06); }
.row-q3 { background: rgba(201,121,42,0.08); }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; flex-shrink: 0; }
.dot-r32  { background: var(--green); }
.dot-3rd  { background: var(--amber); }
.dot-out  { background: var(--red); }
.dot-out3 { background: #666; }
.groups-legend { margin-top: 10px; font-size: var(--fs-xs); color: var(--text2); display: flex; gap: 14px; flex-wrap: wrap; }

/* ── BRACKET ── */
.bracket-rounds { display: flex; flex-direction: column; gap: 20px; }
.bracket-round-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bracket-round-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.bracket-matches { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.bracket-matches.cols-2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.bracket-matches.cols-1 { grid-template-columns: 1fr; max-width: 400px; }
.b-match-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.b-match-id {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text2);
  padding: 4px 8px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.b-match-date { font-weight: 400; }
.b-team-row {
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
}
.b-team-row:last-child { border-bottom: none; }
.b-team-row.winner { background: rgba(74,158,106,0.12); font-weight: 700; }
.b-team-row.loser  { color: var(--text2); }
.b-team-row.tbd    { color: var(--text2); font-style: italic; }
.b-team-name        { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-team-participant { font-size: var(--fs-xs); color: var(--text2); white-space: nowrap; }
.b-score { font-size: var(--fs-sm); font-weight: 700; min-width: 20px; text-align: center; color: var(--text3); }
.b-seed  { font-size: var(--fs-xs); color: var(--text2); margin-right: 4px; }

/* ── SCHEDULE ── */
.schedule-days { display: flex; flex-direction: column; gap: 16px; }
.schedule-day-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.schedule-day-label.today  { color: var(--blue); }
.schedule-day-label.past   { opacity: 0.5; }
.schedule-no-matches {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text2);
  font-size: var(--fs-sm);
  font-style: italic;
}
.schedule-matches { display: flex; flex-direction: column; gap: 6px; }
.sched-match {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sched-time  { font-size: var(--fs-xs); color: var(--text2); font-weight: 600; min-width: 40px; flex-shrink: 0; }
.sched-stage { font-size: var(--fs-xs); font-weight: 700; color: var(--text2); background: var(--surface2); padding: 2px 5px; border-radius: 3px; flex-shrink: 0; }
.sched-teams { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.sched-team  { display: flex; flex-direction: column; min-width: 0; }
.sched-team-name { font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched-team-p    { font-size: var(--fs-xs); color: var(--text2); }
.sched-score { font-size: var(--fs-md); font-weight: 700; min-width: 44px; text-align: center; color: var(--text3); flex-shrink: 0; }
.sched-score.pending { color: var(--text2); font-size: var(--fs-xs); }

/* Utils */
.loading   { color: var(--text2); padding: 32px; text-align: center; }
.error-msg { color: var(--red); padding: 16px; background: rgba(201,74,74,0.1); border-radius: 6px; margin: 16px 0; }

@media (max-width: 600px) {
  .site-header     { padding: 10px 12px; }
  .tab-btn         { padding: 8px 12px; }
  .groups-grid     { grid-template-columns: 1fr; }
  .bracket-matches { grid-template-columns: 1fr; }
  .sched-match     { flex-wrap: wrap; }
}
