/* ------------------------------
   THEME VARIABLES
------------------------------ */
:root {
  --bg: #050816;
  --bg-elevated: #0b1020;
  --card: #0a0f1f; /* slightly brighter for contrast */
  --text: #ffffff; /* brighter text */
  --muted: #cbd5e1; /* brighter table headers */
  --accent: #38bdf8;
  --border: #334155; /* brighter border */
}

:root[data-theme="light"] {
  --bg: #f9fafb;
  --bg-elevated: #ffffff;
  --card: #f3f4f6;
  --text: #020617;
  --muted: #6b7280;
  --accent: #0ea5e9;
  --border: #e5e7eb;
}

/* ------------------------------
   GLOBAL
------------------------------ */
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header, footer {
  text-align: center;
  padding: 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

#theme-toggle {
  margin-top: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}

/* ------------------------------
   GROUPS — NO SCROLL, HIGH CONTRAST
------------------------------ */
#groups-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
}

.group-card {
  background: var(--card);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 0 0 1px var(--border);
}

.group-title {
  font-weight: 600;
  margin-bottom: 1rem;
}

.standings-table {
  width: 100%;
  min-width: 480px; /* ensures no squishing */
  border-collapse: collapse;
  font-size: 1rem;
  table-layout: auto;
}

.standings-table th,
.standings-table td {
  padding: 0.6rem 0.9rem;
  text-align: center;
  white-space: nowrap;
}

.standings-table td:first-child,
.standings-table th:first-child {
  text-align: left;
}

.standings-table th {
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.highlight-adv {
  background: rgba(34, 197, 94, 0.18); /* brighter for dark mode */
}

/* Flags */
.team-flag {
  width: 18px;
  height: 12px;
  margin-right: 0.4rem;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.4);
}

/* ------------------------------
   BRACKET
------------------------------ */
#bracket-container {
  display: flex;
  justify-content: center;
  gap: 3rem;
  padding: 2rem 0;
  overflow-x: auto;
}

.bracket-round {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 220px;
}

.bracket-round h4 {
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: var(--accent);
  cursor: pointer;
}

.match {
  background: var(--card);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  box-shadow: 0 0 0 1px var(--border);
  position: relative;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.team {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.15rem 0;
}

.team-name {
  display: inline-flex;
  align-items: center;
}

.team.winner {
  font-weight: 600;
  color: #22c55e;
}

.match::after {
  content: "";
  position: absolute;
  right: -1.5rem;
  top: 50%;
  width: 1.5rem;
  height: 2px;
  background: #334155;
}

.bracket-round:last-child .match::after {
  display: none;
}

.connector {
  width: 2px;
  background: #334155;
  margin: 0 auto;
}

.connector.large {
  height: 60px;
}

.final-match {
  border: 1px solid var(--accent);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* ------------------------------
   MOBILE COLLAPSE
------------------------------ */
@media (max-width: 768px) {
  #groups-container {
    grid-template-columns: 1fr;
  }

  .standings-table {
    min-width: 100%;
  }

  #bracket-container {
    flex-direction: column;
    gap: 1rem;
  }

  .bracket-round.collapsed .match,
  .bracket-round.collapsed .connector {
    display: none;
  }
}
