/* ==========================================================================
   DESIGN SYSTEM & VARIABLES (Championship Dark Gold - Subtle Glow)
   ========================================================================== */
:root {
  --bg-primary: #08090d;
  --bg-secondary: #0f121a;
  --bg-card: rgba(20, 24, 36, 0.7);
  --bg-input: rgba(10, 12, 18, 0.8);
  
  --gold-primary: #e5c060;
  --gold-dark: #b3913b;
  --gold-glow: rgba(229, 192, 96, 0.25);
  
  --text-main: #f1f3f7;
  --text-muted: #8e9cae;
  --border-color: rgba(229, 192, 96, 0.15);
  --border-hover: rgba(229, 192, 96, 0.4);
  
  --success: #00b894;
  --success-glow: rgba(0, 184, 148, 0.15);
  --danger: #d63031;
  --danger-glow: rgba(214, 48, 49, 0.15);
  --info: #0984e3;

  --font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --shadow-subtle: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-gold: 0 0 12px var(--gold-glow);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(229, 192, 96, 0.05) 0%, transparent 60%),
    radial-gradient(circle at 10% 30%, rgba(9, 132, 227, 0.02) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-card);
  border-radius: 4px;
  border: 1px solid var(--border-color);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dark);
}

/* ==========================================================================
   LAYOUT & CONTAINER
   ========================================================================== */
header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
  position: relative;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 30%, var(--gold-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

header p {
  color: var(--text-muted);
  font-size: 1rem;
  letter-spacing: 1px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ==========================================================================
   NAVIGATION TABS
   ========================================================================== */
.nav-tabs {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-btn:hover {
  color: var(--gold-primary);
  border-color: rgba(229, 192, 96, 0.2);
  background: rgba(229, 192, 96, 0.02);
}

.tab-btn.active {
  color: var(--bg-primary);
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
  border-color: var(--gold-primary);
  box-shadow: var(--shadow-gold);
}

.tab-icon {
  font-size: 1.05rem;
  line-height: 1;
}
.tab-label {
  line-height: 1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

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

/* ==========================================================================
   GLOBAL COMPONENTS & GLASS CARDS
   ========================================================================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-subtle);
  margin-bottom: 2rem;
}

.card-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold-primary);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.75rem 1.5rem;
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn:hover:not(:disabled) {
  border-color: var(--gold-primary);
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-dark));
  color: var(--bg-primary);
  border: none;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffd778, var(--gold-primary));
  box-shadow: 0 0 15px rgba(229, 192, 96, 0.4);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-viva {
  background: var(--success-glow);
  color: var(--success);
  border: 1px solid rgba(0, 184, 148, 0.3);
}

.badge-rota {
  background: var(--danger-glow);
  color: var(--danger);
  border: 1px solid rgba(214, 48, 49, 0.3);
}

/* ==========================================================================
   TAB 1: LEADERBOARD (TABLA GENERAL)
   ========================================================================== */
.leaderboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* Podium section */
.podium-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1.5rem;
  margin: 1.5rem 0 3rem;
  padding-top: 1rem;
}

.podium-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: var(--transition);
}

.podium-spot:hover {
  transform: translateY(-5px);
}

.podium-spot.first { order: 2; }
.podium-spot.second { order: 1; }
.podium-spot.third { order: 3; }

.podium-pedestal {
  width: 120px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, rgba(10, 12, 18, 0.9) 100%);
  border: 1px solid var(--border-color);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  font-weight: 800;
  position: relative;
}

.first .podium-pedestal {
  height: 120px;
  border-color: rgba(229, 192, 96, 0.5);
  box-shadow: 0 0 15px rgba(229, 192, 96, 0.1);
}
.first .podium-pedestal::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--gold-primary);
}

.second .podium-pedestal {
  height: 90px;
  border-color: rgba(255, 255, 255, 0.2);
}
.second .podium-pedestal::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: #cbd5e1;
}

.third .podium-pedestal {
  height: 70px;
  border-color: rgba(184, 115, 51, 0.3);
}
.third .podium-pedestal::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: #b45309;
}

/* User avatar container with champion candidate flag */
.avatar-container {
  position: relative;
  margin-bottom: 0.75rem;
}

.avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-main);
  box-shadow: var(--shadow-subtle);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.podium-spot.first .avatar {
  width: 80px;
  height: 80px;
  border-color: var(--gold-primary);
  box-shadow: 0 0 10px rgba(229, 192, 96, 0.3);
  font-size: 1.8rem;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Champion flag floating under avatar */
.flag-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: #111420;
  border: 1.5px solid var(--border-color);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  cursor: help;
  z-index: 2;
}

/* RED X overlay for eliminated team flag */
.flag-badge.eliminated::after {
  content: '❌';
  position: absolute;
  font-size: 0.6rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.4);
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.podium-spot .podium-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  text-align: center;
  max-width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podium-spot .podium-score {
  font-weight: 800;
  color: var(--gold-primary);
  font-size: 1.1rem;
}

/* Leaderboard list table */
.leaderboard-table-container {
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.leaderboard-table th {
  padding: 1rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-color);
}

.leaderboard-table td {
  padding: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

.leaderboard-table tr:hover td {
  background: rgba(229, 192, 96, 0.02);
}

.row-rank {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-muted);
  width: 50px;
}

tr:nth-child(1) .row-rank { color: var(--gold-primary); }
tr:nth-child(2) .row-rank { color: #cbd5e1; }
tr:nth-child(3) .row-rank { color: #b45309; }

.row-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.row-user-name {
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.row-user-name:hover {
  color: var(--gold-primary);
  text-decoration: underline;
}

.row-points {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--gold-primary);
}

/* ==========================================================================
   TAB 2: REAL MATCHES (PARTIDOS REALES)
   ========================================================================== */
.matches-round-selector {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.round-btn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.round-btn:hover {
  color: var(--text-main);
  border-color: var(--border-hover);
}

.round-btn.active {
  background: var(--gold-glow);
  color: var(--gold-primary);
  border-color: var(--gold-primary);
}

.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* Match card layout */
.match-card {
  background: rgba(22, 26, 38, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: var(--transition);
}

.match-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
}

.match-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.match-team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.team-flag {
  font-size: 1.3rem;
  width: 24px;
  display: inline-block;
  text-align: center;
}

.team-score-display {
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-weight: 800;
  font-size: 1.1rem;
  min-width: 35px;
  text-align: center;
}

.match-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.match-advance-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.match-advance-info strong {
  color: var(--gold-primary);
}

/* Match predictions section inside details modal */
.user-predictions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.user-prediction-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 6px;
}

/* ==========================================================================
   TAB 3: BRACKET VISUAL (ÁRBOL DE LLAVES)
   ========================================================================== */
.bracket-scroll-container {
  overflow-x: auto;
  padding: 2rem 0;
  cursor: grab;
  position: relative;
}

.bracket-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  min-width: 1200px;
  padding: 0 1rem;
}

.bracket-round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: 520px;
  width: 220px;
  gap: 1rem;
}

/* Special round sizes to fit tree alignment */
.bracket-round.round-qf { height: 520px; }
.bracket-round.round-sf { height: 520px; }
.bracket-round.round-f { height: 520px; justify-content: center; gap: 3rem; }

.bracket-match {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  box-shadow: var(--shadow-subtle);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.bracket-match::after {
  /* Bracket lines placeholder - logic handles drawing connections or we use CSS pseudo classes */
}

.bracket-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  height: 28px;
  transition: var(--transition);
}

.bracket-team.winner {
  color: var(--gold-primary);
  background: rgba(229, 192, 96, 0.05);
}

.bracket-team.loser {
  opacity: 0.5;
}

.bracket-team-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bracket-score {
  font-weight: 800;
  font-size: 0.9rem;
}

/* Mini-avatars next to bracket teams showing supporters */
.bracket-supporters {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 0.25rem;
}

.mini-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5rem;
  font-weight: 800;
  color: white;
  cursor: pointer;
  position: relative;
}

.mini-avatar:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.95);
  color: var(--gold-primary);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  z-index: 10;
  border: 1px solid var(--border-color);
  pointer-events: none;
}

/* ==========================================================================
   TAB 4: PREDICTION WIZARD (ANOTAR MIS PREDICCIONES)
   ========================================================================== */
.wizard-welcome {
  text-align: center;
  padding: 2rem 0;
  max-width: 600px;
  margin: 0 auto;
}

.wizard-welcome h3 {
  font-size: 1.8rem;
  margin-bottom: 1rem;
  color: var(--gold-primary);
}

.wizard-welcome p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.wizard-form-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.wizard-form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
}

.wizard-input, .wizard-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 1rem;
  transition: var(--transition);
}

.wizard-input:focus, .wizard-select:focus {
  outline: none;
  border-color: var(--gold-primary);
  box-shadow: var(--shadow-gold);
}

/* Wizard Stepper layout */
.wizard-stepper {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 650px;
  margin: 0 auto;
}

.wizard-progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.wizard-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-primary));
  width: 0%;
  transition: width 0.3s ease;
}

.wizard-step-info {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
}

.wizard-match-editor {
  width: 100%;
  background: rgba(22, 26, 38, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  margin-bottom: 2rem;
}

.wizard-round-title {
  color: var(--gold-primary);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1.5rem;
}

.wizard-vs-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.wizard-team-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.wizard-team-flag {
  font-size: 3rem;
}

.wizard-team-name {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
}

.wizard-score-input {
  width: 70px;
  height: 60px;
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  color: var(--text-main);
  border-radius: 8px;
  transition: var(--transition);
}

.wizard-score-input:focus {
  outline: none;
  border-color: var(--gold-primary);
  box-shadow: var(--shadow-gold);
}

.wizard-vs-divider {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Tie breaker styling */
.wizard-tie-breaker {
  background: rgba(229, 192, 96, 0.03);
  border: 1.5px dashed var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  margin-top: 1rem;
  display: none;
}

.wizard-tie-breaker.visible {
  display: block;
  animation: fadeIn 0.3s ease;
}

.wizard-tie-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--gold-primary);
  margin-bottom: 0.75rem;
}

.tie-options-container {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.tie-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.tie-btn:hover {
  color: var(--text-main);
  border-color: var(--border-hover);
}

.tie-btn.selected {
  background: var(--gold-glow);
  color: var(--gold-primary);
  border-color: var(--gold-primary);
  box-shadow: var(--shadow-gold);
}

.wizard-controls {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 1rem;
}

/* Finished code display */
.code-display-box {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--gold-primary);
  word-break: break-all;
  min-height: 80px;
  margin: 1.5rem 0;
  text-align: left;
}

/* ==========================================================================
   TAB 5: ADMIN PANEL (PANEL DE CONTROL)
   ========================================================================== */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media(min-width: 900px) {
  .admin-grid {
    grid-template-columns: 1fr 1.2fr;
  }
}

.admin-match-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.admin-match-row {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-team-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-team-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  width: 130px;
}

.admin-score-input {
  width: 45px;
  height: 35px;
  text-align: center;
  font-weight: 800;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 4px;
}

.admin-vs {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.admin-text-area {
  width: 100%;
  height: 120px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-main);
  padding: 0.75rem;
  font-family: monospace;
  font-size: 16px;
  resize: vertical;
  margin-bottom: 1rem;
}

/* ==========================================================================
   MODAL WINDOW STYLES
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.visible {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold-primary);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.close-btn:hover {
  color: var(--gold-primary);
}

.modal-body {
  padding: 1.5rem;
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES
   ========================================================================== */
@media (max-width: 768px) {
  header h1 {
    font-size: 1.5rem;
  }
  header {
    padding: 1rem 0 0.5rem;
  }
  header p {
    font-size: 0.8rem;
  }

  /* Navegación: barra inferior fija estilo app */
  .nav-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    margin: 0;
    gap: 0;
    padding: 0.3rem 0.2rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
    background: rgba(8, 9, 13, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    justify-content: space-around;
  }

  .tab-btn {
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    padding: 0.4rem 0.15rem;
    font-size: 0.6rem;
    letter-spacing: 0.2px;
    border-radius: 10px;
    text-transform: none;
  }

  .tab-icon {
    font-size: 1.35rem;
  }

  .tab-btn.active {
    color: var(--gold-primary);
    background: rgba(229, 192, 96, 0.12);
    border-color: transparent;
    box-shadow: none;
  }

  /* Espacio para que el contenido no quede tapado por la barra inferior */
  .container {
    padding-bottom: 5.5rem;
  }

  #save-error-toast {
    bottom: 5.5rem;
  }

  /* Evita el desborde horizontal en mobile */
  html, body {
    overflow-x: hidden;
  }

  /* Tabla de posiciones -> tarjetas apiladas y legibles */
  .leaderboard-table thead {
    display: none;
  }
  .leaderboard-table,
  .leaderboard-table tbody,
  .leaderboard-table tr,
  .leaderboard-table td {
    display: block;
    width: 100%;
  }
  .leaderboard-table tr {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.85rem;
    position: relative;
  }
  .leaderboard-table td {
    border: none;
    padding: 0.3rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.92rem;
  }
  .leaderboard-table td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
  }
  .leaderboard-table .row-rank {
    position: absolute;
    top: 0.7rem;
    right: 1rem;
    width: auto;
    font-size: 1.15rem;
    padding: 0;
  }
  .leaderboard-table .row-user {
    justify-content: flex-start;
    gap: 0.6rem;
    padding-bottom: 0.55rem;
    margin-bottom: 0.45rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .leaderboard-table .row-points {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gold-primary);
  }

  /* Controles del wizard: apilados para que no se desborden */
  .wizard-controls {
    flex-direction: column;
    gap: 0.6rem;
  }
  .wizard-controls .btn {
    width: 100%;
  }
  #btn-wizard-next {
    order: -1; /* Siguiente arriba, como acción principal */
  }

  /* Podio: que entre completo en la pantalla */
  .podium-container {
    max-width: 100%;
    flex-wrap: nowrap;
  }
  .podium-pedestal {
    width: 100%;
    min-width: 0;
  }
  .podium-spot {
    flex: 1;
    min-width: 0;
  }

  .podium-container {
    gap: 0.75rem;
  }
  
  .podium-pedestal {
    width: 90px;
  }
  
  .first .podium-pedestal { height: 100px; }
  .second .podium-pedestal { height: 75px; }
  .third .podium-pedestal { height: 60px; }
  
  .avatar {
    width: 55px;
    height: 55px;
  }
  
  .podium-spot.first .avatar {
    width: 65px;
    height: 65px;
  }
  
  .wizard-vs-container {
    flex-direction: column;
    gap: 1rem;
  }
  
  .wizard-team-card {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 0.5rem;
  }
  
  .wizard-team-flag {
    font-size: 2rem;
  }
  
  .wizard-match-editor {
    padding: 1.5rem 1rem;
  }
}

/* ==========================================================================
   PANTALLA DE ACCESO (CLAVE ÚNICA) + AVISO DE GUARDADO
   ========================================================================== */
.gate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg-primary);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.gate-overlay.visible {
  display: flex;
}
.gate-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 2.5rem 2rem;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.gate-card h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  color: var(--gold-primary);
}
.gate-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.gate-input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  margin-bottom: 1rem;
  text-align: center;
}
.gate-input:focus {
  outline: none;
  border-color: var(--gold-primary);
}
.gate-btn {
  width: 100%;
}
.gate-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 1rem;
  min-height: 1.2em;
}

#save-error-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  background: var(--danger);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 1100;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}
#save-error-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   CIERRE DE PREDICCIONES POR RONDA + BLOQUEO ADMIN
   ========================================================================== */
.round-locks-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.round-lock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.round-lock-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.round-lock-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font-size: 16px;
  color-scheme: dark;
}
.round-lock-input:focus {
  outline: none;
  border-color: var(--gold-primary);
}
.lock-badge {
  background: var(--danger-glow);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 20px;
  padding: 0.1rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
}
.admin-lock-card {
  max-width: 480px;
  margin: 0 auto;
}

/* ==========================================================================
   PANEL ADMIN — TARJETAS DE PARTIDO CON STEPPERS +/-
   ========================================================================== */
.admin-match-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.85rem;
}
.admin-match-round {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gold-primary);
  margin-bottom: 0.75rem;
}
.admin-team-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
}
.admin-team-line + .admin-team-line {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.admin-team-name {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}
.admin-team-select {
  flex: 1;
  min-width: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 16px; /* evita el zoom automático en iOS */
}
.admin-team-select:focus {
  outline: none;
  border-color: var(--gold-primary);
}
.score-stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.step-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--gold-primary);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.step-btn:hover:not(:disabled) {
  border-color: var(--gold-primary);
  background: rgba(229, 192, 96, 0.1);
}
.step-btn:active:not(:disabled) {
  transform: scale(0.92);
}
.step-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.score-val {
  min-width: 30px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}
.admin-tie {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.admin-tie-label {
  font-size: 0.8rem;
  color: var(--gold-primary);
  font-weight: 600;
}
.admin-tie-select {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  font-size: 16px;
}
.admin-clear-btn {
  margin-top: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0.25rem 0;
}
.admin-clear-btn:hover {
  color: var(--danger);
}

/* ==========================================================================
   BANDERAS (imágenes reales de flagcdn) — ancla visual junto al nombre
   ========================================================================== */
.flag-img {
  height: 18px;
  width: auto;
  border-radius: 2px;
  object-fit: cover;
  vertical-align: middle;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}
.flag-xs { height: 14px; }
.flag-sm { height: 16px; }
.flag-lg {
  height: 42px;
  border-radius: 5px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}

/* Bandera en las tarjetas de Partidos (reemplaza el emoji del span .team-flag) */
img.team-flag {
  width: auto;
  height: 22px;
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

/* Bandera dentro del badge circular (candidato a campeón) */
.flag-badge-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Marcador cuando no hay equipo aún */
.flag-none {
  opacity: 0.5;
}
