/* -------------------------------------------------------
   GLOBAL THEME VARIABLES
------------------------------------------------------- */
:root {
  --bg: #ffffff;
  --fg: #111111;
  --card-bg: #fafafa;
  --border: #cccccc;
  --muted: #666666;
  --accent: #f3f3f3;
  --link: #0057ff;
}

[data-theme="dark"] {
  --bg: #05060a;
  --fg: #f5f5f5;
  --card-bg: #11131a;
  --border: #33384a;
  --muted: #9ca3af;
  --accent: #1f2933;
  --link: #4da3ff;
}

/* -------------------------------------------------------
   BASE
------------------------------------------------------- */
body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, sans-serif;
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4 {
  color: var(--fg);
}

a {
  color: var(--link);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------
   HEADER + NAV
------------------------------------------------------- */
header {
  padding: 20px;
  text-align: center;
}

nav {
  margin-top: 10px;
}

nav a {
  margin: 0 10px;
  font-weight: 500;
}

#theme-toggle {
  margin-top: 10px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--fg);
  cursor: pointer;
}

/* -------------------------------------------------------
   SECTION TOGGLER BUTTONS
------------------------------------------------------- */
.section-toggle-buttons {
  text-align: center;
  margin-bottom: 20px;
}

.section-toggle-buttons button {
  padding: 8px 14px;
  margin: 4px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--fg);
  cursor: pointer;
}

/* -------------------------------------------------------
   GROUP TABLES
------------------------------------------------------- */
.group-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  justify-content: center;
  padding: 10px 0;
}

.group-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  width: 360px;
  background: var(--card-bg);
  page-break-inside: avoid;
  box-sizing: border-box;
}

.group-title {
  font-weight: 600;
  margin-bottom: 6px;
  text-align: center;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.standings-table th,
.standings-table td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  text-align: center;
}

.standings-table th {
  background: var(--accent);
}

.team-name {
  font-weight: 500;
  text-align: left;
}

.highlight-adv {
  background: rgba(0, 200, 0, 0.15);
}

/* -------------------------------------------------------
   ELIMINATION STYLES (ADDED)
------------------------------------------------------- */

.elim-badge {
  color: #d33;
  font-weight: 700;
}

.eliminated-row .team-name {
  opacity: 0.45;
  text-decoration: line-through;
  color: #b33;
}

[data-theme="dark"] .elim-badge {
  color: #e66;
}

[data-theme="dark"] .eliminated-row .team-name {
  color: #e66;
}

/* Knockout elimination (matches classifyTeam Option B) */
.fifa-match .team.team-eliminated span:first-child {
  opacity: 0.45;
  text-decoration: line-through;
  color: #b33;
}

[data-theme="dark"] .fifa-match .team.team-eliminated span:first-child {
  color: #e66;
}

/* -------------------------------------------------------
   KNOCKOUT BRACKET (FULL PAGE)
------------------------------------------------------- */
.bracket-container {
  display: flex;
  flex-direction: row;
  gap: 16px;
  overflow-x: auto;
}

.bracket-round {
  min-width: 180px;
  page-break-inside: avoid;
}

.bracket-round h4 {
  text-align: center;
  margin-bottom: 8px;
}

.match {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 10px;
  background: var(--card-bg);
  font-size: 0.8rem;
}

.team {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2px;
}

.team.winner {
  font-weight: 700;
  color: #0a0;
}

.connector.large {
  height: 20px;
}

/* -------------------------------------------------------
   PDF BUTTON
------------------------------------------------------- */
.pdf-button {
  display: inline-block;
  margin: 10px auto 20px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--fg);
  cursor: pointer;
  border-radius: 6px;
}

/* -------------------------------------------------------
   PRINT MODE
------------------------------------------------------- */
@media print {
  header,
  nav,
  .section-toggle-buttons,
  .pdf-button,
  footer {
    display: none !important;
  }

  body {
    margin: 10mm;
  }
}

/* -------------------------------------------------------
   UTILITIES
------------------------------------------------------- */
.hidden {
  display: none;
}

/* -------------------------------------------------------
   REMAINING SCHEDULE PAGE
------------------------------------------------------- */
.remaining-wrapper {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

.remaining-match {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.rm-date {
  font-weight: 600;
  margin-bottom: 4px;
}

.rm-teams {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.rm-meta {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* -------------------------------------------------------
   TODAY'S MATCHES
------------------------------------------------------- */
.todays-matches {
  margin: 20px auto;
  padding: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 900px;
}

.today-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 12px;
}

.today-match {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}

.tm-status {
  font-weight: 600;
  margin-bottom: 4px;
}

.tm-teams {
  font-size: 1.1rem;
  margin-bottom: 4px;
}

.tm-meta {
  font-size: 0.9rem;
  opacity: 0.8;
}

.no-matches {
  opacity: 0.7;
  padding: 8px 0;
}

.day-section {
  margin-bottom: 24px;
}

.day-section h3 {
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 1.2rem;
}

/* -------------------------------------------------------
   MINI KNOCKOUT BRACKET (HORIZONTAL LAYOUT)
------------------------------------------------------- */
.mini-bracket {
  display: flex;
  flex-direction: row;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  overflow-x: auto;
  max-width: 100%;
  margin: 0 auto;
  scroll-snap-type: x mandatory;
}

.mini-bracket .round {
  min-width: 220px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.mini-bracket .round-title {
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 0.95rem;
  text-align: center;
  color: var(--fg);
}

.mini-bracket .match {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  text-align: center;
  color: var(--muted);
}

.mini-bracket .match:last-child {
  border-bottom: none;
}

/* -------------------------------------------------------
   INDEX PAGE — TRUE KNOCKOUT BRACKET (SCALED)
------------------------------------------------------- */

.index-knockout {
  transform: scale(0.72);
  transform-origin: top left;
  width: 140%;
  overflow-x: auto;
  padding: 10px 0;
  margin: 0 auto;
}

.index-knockout .bracket-container {
  display: flex;
  flex-direction: row;
  gap: 20px;
  padding-bottom: 10px;
}

.index-knockout .bracket-round {
  min-width: 200px;
}

.index-knockout .match {
  font-size: 0.75rem;
  padding: 6px;
}

/* Knockout team state styling */
.fifa-match .team.locked span:first-child {
  font-weight: bold;
  color: #0a58ca;
}

.fifa-match .team.placeholder span:first-child {
  font-style: italic;
  opacity: 0.7;
}

.fifa-match .team.resolved span:first-child {
  font-weight: bold;
}

.tm-status {
  font-weight: 600;
}

.tm-status .broadcast {
  opacity: 0.85;
}

/* -------------------------------------------------------
   GROUP TABLE — SYMBOL COLUMN (Q / 🔒 / ❌)
------------------------------------------------------- */

.qual-col {
  width: 24px;
  text-align: center;
  font-weight: bold;
  padding: 0 4px;
}

.q-badge {
  color: #2a7;
  font-weight: 700;
  font-size: 0.95em;
}

.lock-badge {
  color: #06f;
  font-weight: 700;
  font-size: 1.05em;
}

/* Ensure team name spacing stays clean */
.standings-table td .team-name {
  display: inline-block;
  padding-left: 2px;
}

/* -------------------------------------------------------
   BRACKET TEAM STATE STYLING (matches classifyTeam)
------------------------------------------------------- */

.fifa-match .team.placeholder span:first-child {
  color: var(--muted);
  font-style: italic;
  opacity: 0.75;
}

.fifa-match .team.locked span:first-child {
  color: #0a58ca;
  font-weight: 700;
}

.fifa-match .team.resolved span:first-child {
  color: var(--fg);
  font-weight: 600;
}

/* -------------------------------------------------------
   FIXED, BALANCED COLUMN WIDTHS (FINAL)
------------------------------------------------------- */

.standings-table th:first-child,
.standings-table td:first-child {
  width: 26px;
  text-align: center;
}

.standings-table th:nth-child(2),
.standings-table td:nth-child(2) {
  width: 100px;
  text-align: left;
  white-space: wrap;
}

.standings-table th:not(:first-child):not(:nth-child(2)),
.standings-table td:not(:first-child):not(:nth-child(2)) {
  width: 32px;
}
