:root {
  --bg: #0a0c14;
  --surface: #111420;
  --surface2: #181c2e;
  --surface3: #1e2338;
  --border: #2a2f4a;
  --accent: #e8312a;
  --accent2: #f5a623;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --text: #e8eaf2;
  --text2: #8890b0;
  --green: #27ae60;
  --blue: #2980b9;
  --white: #ffffff;
  --radius: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

header {
  background: linear-gradient(135deg, #0d0f1a 0%, #1a1f35 50%, #0d0f1a 100%);
  border-bottom: 2px solid var(--accent);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo { display: flex; align-items: center; gap: 16px; }
.logo-trophy { font-size: 32px; }

.logo-text h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 28px;
  letter-spacing: 3px;
  line-height: 1;
  color: var(--white);
}

.logo-text span {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  color: var(--accent2);
  letter-spacing: 4px;
  text-transform: uppercase;
}

.nav-tabs { display: flex; gap: 4px; }

.nav-tab {
  padding: 8px 18px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.nav-tab:hover { border-color: var(--accent); color: var(--text); }
.nav-tab.active { background: var(--accent); border-color: var(--accent); color: white; }

.header-actions { display: flex; gap: 8px; }

.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: #c0241d; }
.btn-outline { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--accent2); color: var(--accent2); }
.btn-gold { background: var(--gold); color: #1a1200; }
.btn-gold:hover { background: #e6c200; }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #1e8c4a; }

main { padding: 24px; max-width: 1400px; margin: 0 auto; }

.tab-content { display: none; }
.tab-content.active { display: block; }

.groups-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.group-header {
  background: linear-gradient(135deg, var(--surface2), var(--surface3));
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.group-letter {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  color: var(--accent2);
  line-height: 1;
}

.group-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  color: var(--text2);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.standings-table { width: 100%; border-collapse: collapse; }

.standings-table th {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.standings-table th:first-child { text-align: left; padding-left: 12px; }

.standings-table td {
  padding: 7px 8px;
  text-align: center;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.standings-table td:first-child { text-align: left; padding-left: 10px; font-weight: 500; }
.standings-table tr:last-child td { border-bottom: none; }
.team-row { transition: background 0.15s; }
.team-row:hover { background: rgba(255, 255, 255, 0.03); }

.team-rank {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-right: 4px;
}

.rank-1 { background: var(--gold); color: #1a1200; }
.rank-2 { background: var(--silver); color: #1a1a1a; }
.rank-3, .rank-4 { background: var(--surface3); color: var(--text2); }

.team-name-cell { display: flex; align-items: center; gap: 6px; }
.flag { display: inline-flex; align-items: center; vertical-align: middle; }

.matches-grid { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px; }

.match-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.match-date {
  font-size: 10px;
  color: var(--text2);
  width: 32px;
  text-align: center;
  flex-shrink: 0;
  font-family: 'Barlow Condensed', sans-serif;
}

.match-teams { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; }

.match-team {
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  width: 50px;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.5px;
}

.match-team.winner { color: var(--accent2); font-weight: 700; }
.match-score { display: flex; gap: 2px; align-items: center; }
.score-separator { color: var(--text2); font-weight: 700; font-size: 12px; }

.group-matches-btn {
  width: 100%;
  padding: 6px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: color 0.2s;
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.group-matches-btn:hover { color: var(--accent2); }
.group-matches-section { display: none; border-top: 1px solid var(--border); }
.group-matches-section.open { display: block; }

.bracket-container { position: relative; overflow-x: auto; padding: 20px 0; }

.bracket {
  display: flex;
  position: relative;
  gap: 40px;
  min-width: 1300px;
  height: 1550px;
}

.bracket-round {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 200px;
  height: 100%;
}

.bracket-round-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px;
  letter-spacing: 2px;
  text-align: center;
  color: var(--accent2);
  padding: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.bracket-matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex: 1;
  height: calc(100% - 50px);
  padding: 10px 0;
  box-sizing: border-box;
  position: relative;
}

.bracket-match {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  max-height: 85px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.bracket-match:hover { border-color: var(--accent); box-shadow: 0 0 10px rgba(232, 49, 42, 0.2); }

.bracket-team {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  min-height: 32px;
}

.bracket-team:last-child { border-bottom: none; }
.bracket-team:hover { background: rgba(255, 255, 255, 0.04); }
.bracket-team.winner { background: rgba(232, 49, 42, 0.12); }
.bracket-team.winner .bracket-team-name { color: var(--accent2); font-weight: 700; }
.bracket-team-flag { display: inline-flex; align-items: center; min-width: 24px; }

.bracket-team-name {
  flex: 1;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bracket-team-score {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px;
  color: var(--text);
  min-width: 20px;
  text-align: center;
}

.bracket-match-meta {
  padding: 3px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 9px;
  color: var(--text2);
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
}

.bracket-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.bracket-path {
  fill: none;
  stroke: var(--border);
  stroke-width: 2px;
  transition: stroke 0.3s, stroke-width 0.3s, filter 0.3s;
}

.bracket-path.highlighted {
  stroke: var(--accent2);
  stroke-width: 3px;
  filter: drop-shadow(0 0 4px rgba(245, 166, 35, 0.6));
}

.champion-display {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  animation: fadeIn 0.5s ease;
}

.champion-display.visible { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.champion-trophy { font-size: 64px; animation: bounce 1s ease infinite alternate; }

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.6); }
}

.champion-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 48px;
  letter-spacing: 4px;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
}

.champion-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text2);
}

.section-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 22px;
  letter-spacing: 3px;
  color: var(--white);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  padding: 12px 20px;
  font-size: 13px;
  color: var(--green);
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 1px;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }

.sim-banner {
  background: linear-gradient(135deg, #1a0f00, #2a1800);
  border: 1px solid var(--accent2);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sim-banner-text { font-family: 'Barlow Condensed', sans-serif; font-size: 13px; color: var(--accent2); letter-spacing: 1px; }
.sim-banner-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 20px;
  letter-spacing: 2px;
  margin-bottom: 16px;
  color: var(--accent2);
}

.modal-match {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.modal-team { flex: 1; font-family: 'Barlow Condensed', sans-serif; font-size: 15px; font-weight: 600; }
.modal-team:last-child { text-align: right; }

.modal-input {
  width: 40px;
  height: 36px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  font-family: 'Bebas Neue', sans-serif;
  outline: none;
}

.modal-input:focus { border-color: var(--accent2); }
.modal-sep { font-family: 'Bebas Neue', sans-serif; font-size: 20px; color: var(--text2); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

tr.qualified-1st td:first-child { border-left: 3px solid var(--gold); }
tr.qualified-2nd td:first-child { border-left: 3px solid var(--silver); }
tr.third-place td:first-child { border-left: 3px solid #4a9eff; }

@media (max-width: 1200px) {
  .groups-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 800px) {
  .groups-grid { grid-template-columns: repeat(2, 1fr); }
  header { flex-wrap: wrap; gap: 10px; }
  .nav-tabs { flex-wrap: wrap; }
}
