/* ========== CORE VARS & RESET ========== */
:root {
  --glass-bg: rgba(30, 30, 30, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
  --accent-gold: #fbbf24;
  --accent-gold-glow: rgba(251, 191, 36, 0.3);
  --connector-color: #4a4a4a;
  --text-muted: #9ca3af;
}

.tournament-view-page {
  background: radial-gradient(
    circle at top center,
    #2a1a1a 0%,
    #0f0f0f 100%
  ) !important;
}

/* ========== STATS & HEADER ========== */
.tournament-stats-row {
  gap: 3rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  transition: transform 0.2s;
}

.stat-item:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.05);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-value i {
  color: var(--brand-pink);
}

.status-badge {
  padding: 0.35rem 1rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.ongoing {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.1);
}

.status-badge.finished {
  background: rgba(255, 255, 255, 0.1);
  color: #d1d5db;
}

/* ========== BRACKET LAYOUT ========== */
.bracket-wrapper {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  position: relative;
}

.playoff-column {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 1.5rem 2rem;
  overflow-x: auto;
}

/* Grid background effect */
.bracket-wrapper::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Ensure content is above grid */
.bracket-row,
.swiss-container,
.playoff-column {
  position: relative;
  z-index: 1;
}

.bracket-row {
  display: flex;
  gap: 50px;
  align-items: flex-start;
  min-width: max-content;
}

.bracket-section {
  flex-shrink: 0;
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: #fff;
}

.section-label i {
  font-size: 1.1em;
}

.section-label.winners i {
  color: #ec4899;
}
.section-label.losers i {
  color: #f59e0b;
}
.section-label.finals i {
  color: #fbbf24;
}
.section-label.swiss i {
  color: #60a5fa;
}

.bracket-row.losers-row {
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  padding-top: 2rem;
  margin-top: 0;
}

.rounds {
  display: flex;
  gap: 60px; /* Reduced gap between rounds */
}

.round {
  min-width: 200px; /* Reduced width */
  display: flex;
  flex-direction: column;
}

.round-title {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 20px; /* Reduced gap between matches */
  flex-grow: 1;
}

/* ========== MATCH CARD DESIGN (COMPACT) ========== */
.match-box {
  position: relative;
  width: 100%;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.9em; /* Scale down generally */
}

.match-box:hover {
  transform: translateY(-2px);
  z-index: 10;
}

.match-content {
  background: #222;
  border: 1px solid #333;
  border-radius: 8px; /* Slightly tighter radius */
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  position: relative;
}

/* Winning gradient border strip on left */
.match-content::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px; /* Thinner accent */
  background: #333;
  transition: background 0.3s;
}

/* If either team won, light up the strip */
.match-box:has(.winner) .match-content::before {
  background: var(--accent-gold);
  box-shadow: 0 0 10px var(--accent-gold-glow);
}

.team {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem; /* Reduced padding (Compact) */
  background: transparent;
  transition: background 0.2s;
}

.team:hover {
  background: rgba(255, 255, 255, 0.02);
}

.team.winner {
  background: linear-gradient(
    90deg,
    rgba(251, 191, 36, 0.05) 0%,
    transparent 100%
  );
}

.team.winner .name {
  color: #fff;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.team.winner .score {
  color: var(--accent-gold);
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.4);
}

.team-info {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* Tighter gap */
}

.team-logo-placeholder {
  width: 20px; /* Smaller icon */
  height: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.7rem;
}

.team.winner .team-logo-placeholder {
  color: var(--accent-gold);
  background: rgba(251, 191, 36, 0.1);
}

.name {
  font-size: 0.75rem; /* Smaller text */
  font-weight: 500;
  color: #9ca3af;
  transition: color 0.2s;
}

.score {
  font-size: 0.8rem; /* Smaller score */
  font-weight: 700;
  color: #555;
  width: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.team.played .score {
  color: #fff;
}

.vs-divider {
  height: 1px;
  background: #333;
  margin: 0;
}

/* ========== FINALS ROUND TITLE ========== */
.finals-round-title {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  text-transform: uppercase;
  margin-bottom: 1rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.finals-round-title i {
  font-size: 0.85rem;
}

[data-theme="light"] .finals-round-title {
  color: #ca8a04;
}

/* ========== FINALS BADGE ========== */
.finals-match .match-content {
  border: 1px solid var(--accent-gold);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.12);
}

.finals-badge {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-gold);
  color: #000;
  font-size: 0.5rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  z-index: 20;
  white-space: nowrap;
}

/* ========== CONNECTORS (Adjusted for Size) ========== */
.has-connector::after {
  content: "";
  position: absolute;
  right: -30px; /* Reduced reach */
  top: 50%;
  width: 30px;
  height: 1px;
  background: #444;
}

.has-connector.pair-top::before {
  content: "";
  position: absolute;
  right: -30px;
  top: 50%;
  width: 1px;
  height: calc(50% + 10px + 20px); /* Adjusted for new gaps */
  background: #444;
}

.has-connector.pair-bottom::before {
  content: "";
  position: absolute;
  right: -30px;
  bottom: 50%;
  width: 1px;
  height: calc(50% + 10px + 20px);
  background: #444;
}

/* ========== SWISS COMPACT STYLES ========== */
.swiss-container {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 1.5rem 2rem;
  overflow-x: auto;
}

.swiss-rounds {
  display: flex;
  gap: 20px;
  min-width: max-content;
}

.swiss-round-column {
  min-width: 180px;
  display: flex;
  flex-direction: column;
}

.swiss-groups-column {
  gap: 15px;
}

.swiss-subgroup {
  border: 1px solid #333;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px;
  border-radius: 8px;
}

.subgroup-label {
  font-size: 0.6rem;
  font-weight: 800;
  color: #666;
  margin-bottom: 6px;
  padding-left: 4px;
}

.swiss-subgroup .match-content {
  border: 1px solid #2a2a2a;
  background: #1e1e1e;
}

.swiss-subgroup .team {
  padding: 0.4rem 0.6rem;
}

.swiss-subgroup .name {
  font-size: 0.75rem;
}

.swiss-subgroup .team-logo-placeholder {
  width: 18px;
  height: 18px;
  font-size: 0.6rem;
}

/* ========== LIGHT MODE OVERRIDES ========== */
[data-theme="light"] .tournament-view-page {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
}

/* Stats & Header Light Mode */
[data-theme="light"] .stat-item {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

[data-theme="light"] .stat-item:hover {
  background: #ffffff;
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
}

[data-theme="light"] .stat-label {
  color: #6b7280;
}

[data-theme="light"] .stat-value {
  color: #1a1a1a;
}

[data-theme="light"] .status-badge.ongoing {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

[data-theme="light"] .status-badge.finished {
  background: rgba(0, 0, 0, 0.08);
  color: #6b7280;
  border: 1px solid rgba(0,0,0,0.12);
}

/* Bracket Wrapper Light Mode */
[data-theme="light"] .bracket-wrapper {
  background: #f3f4f6;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

[data-theme="light"] .swiss-container,
[data-theme="light"] .playoff-column {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

[data-theme="light"] .bracket-wrapper::before {
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
}

/* Section Labels Light Mode */
[data-theme="light"] .section-label {
  background: #f8f9fa;
  border: 1px solid rgba(0,0,0,0.12);
  color: #1a1a1a;
}

[data-theme="light"] .section-label.winners i { color: #db2777; }
[data-theme="light"] .section-label.losers i { color: #ea580c; }
[data-theme="light"] .section-label.finals i { color: #ca8a04; }
[data-theme="light"] .section-label.swiss i { color: #2563eb; }

[data-theme="light"] .bracket-row.losers-row {
  border-top: 1px dashed rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .round-title {
  color: #6b7280;
}

/* Match Cards Light Mode */
[data-theme="light"] .match-content {
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

[data-theme="light"] .match-box:hover .match-content {
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
  border-color: rgba(244, 169, 66, 0.4);
}

[data-theme="light"] .match-content::before {
  background: rgba(0,0,0,0.08);
}

[data-theme="light"] .match-box:has(.winner) .match-content::before {
  background: var(--accent-gold);
  box-shadow: 0 0 8px rgba(244, 169, 66, 0.4);
}

/* Team Styling Light Mode */
[data-theme="light"] .team:hover {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .team.winner {
  background: linear-gradient(
    90deg,
    rgba(234, 179, 8, 0.12) 0%,
    transparent 100%
  );
}

[data-theme="light"] .team.winner .name {
  color: #1a1a1a;
  font-weight: 700;
  text-shadow: none;
}

[data-theme="light"] .team.winner .score {
  color: #ca8a04;
  text-shadow: none;
}

[data-theme="light"] .team-logo-placeholder {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .team.winner .team-logo-placeholder {
  color: #ca8a04;
  background: rgba(234, 179, 8, 0.15);
}

[data-theme="light"] .name {
  color: #4b5563;
}

[data-theme="light"] .score {
  color: #9ca3af;
}

[data-theme="light"] .team.played .score {
  color: #1a1a1a;
}

[data-theme="light"] .vs-divider {
  background: rgba(0,0,0,0.1);
}

/* Finals Badge Light Mode */
[data-theme="light"] .finals-match .match-content {
  border: 2px solid var(--accent-gold);
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.15);
}

[data-theme="light"] .finals-badge {
  background: var(--accent-gold);
  color: #000;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.3);
}

/* Connectors Light Mode */
[data-theme="light"] .has-connector::after {
  background: rgba(0,0,0,0.15);
}

[data-theme="light"] .has-connector.pair-top::before,
[data-theme="light"] .has-connector.pair-bottom::before {
  background: rgba(0,0,0,0.15);
}

/* Swiss Container Light Mode - ya cubierto arriba */

[data-theme="light"] .swiss-subgroup {
  border: 1px solid rgba(0,0,0,0.12);
  background: #f8f9fa;
}

[data-theme="light"] .subgroup-label {
  color: #2563eb;
  font-weight: 800;
}

[data-theme="light"] .swiss-subgroup .match-content {
  border: 1px solid rgba(0,0,0,0.12);
  background: #ffffff;
}

/* Scrollbar Light Mode (if needed) */
[data-theme="light"] .bracket-wrapper::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.05);
}

[data-theme="light"] .bracket-wrapper::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.2);
}

/* ============================================
   SWISS STAGE – LoL Worlds
   ============================================ */

/* Fila de estado final (clasificados / eliminados) */
.ss-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 1.2rem;
  padding: 0 0.25rem;
}

.ss-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.ss-status-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.ss-team-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.5rem;
  align-items: center;
}

.ss-team {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  white-space: nowrap;
}

.ss-team::before {
  content: '·';
  opacity: 0.4;
  margin-right: 0.1rem;
}

.ss-team-list .ss-team:first-child::before {
  content: '';
  margin-right: 0;
}

.ss-status em {
  font-style: normal;
  opacity: 0.65;
  font-weight: 400;
}

.ss-status--qualified {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #10b981;
}

.ss-status--eliminated {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
}

/* Badge de record dentro de cada equipo */
.ss-record {
  display: inline-block;
  padding: 0px 5px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.45);
  margin-left: 5px;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}

.ss-record--qualified {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.ss-record--eliminated {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* Match en formato swiss_stage (sin conector) */
.ss-match {
  margin-bottom: 0.5rem;
}

/* Light theme */
[data-theme="light"] .ss-status--qualified {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.2);
}

[data-theme="light"] .ss-status--eliminated {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}

[data-theme="light"] .ss-record {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .ss-record--qualified { background: rgba(16, 185, 129, 0.12); color: #059669; }
[data-theme="light"] .ss-record--eliminated { background: rgba(239, 68, 68, 0.12); color: #dc2626; }

[data-theme="light"] .bracket-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.3);
}

/* ========== RESPONSIVE MÓVIL ========== */
@media (max-width: 768px) {
  /* Stats del header en móvil: 2 columnas */
  .tournament-stats-row {
    gap: 0.75rem;
  }

  .stat-item {
    padding: 0.75rem 1rem;
    flex: 1 1 calc(50% - 0.4rem);
    min-width: 0;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  /* Clasificados / Eliminados: apilar verticalmente en móvil */
  .ss-status-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .ss-status {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.6rem 0.8rem;
    width: 100%;
    box-sizing: border-box;
  }

  .ss-team-list {
    gap: 0.25rem 0.6rem;
  }

  /* Contenedor exterior del bracket: scroll horizontal */
  #publicBracketContainer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Escalar todo el bracket al 78% — el zoom afecta el layout
     por lo que el scroll sigue funcionando correctamente */
  .bracket-wrapper {
    zoom: 0.78;
    padding: 1.25rem;
    width: max-content;
    min-width: 100%;
  }
}

@media (max-width: 480px) {
  .bracket-wrapper {
    zoom: 0.62;
  }
}

