/* ===== Leaderboard Page ===== */

.leaderboard-page {
  min-height: 100vh;
  padding: 30px 20px 60px;
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 30px;
}

/* ===== Header ===== */
.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: "Rajdhani", sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 1px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.back-link:hover {
  color: var(--human-primary);
  border-color: var(--human-primary);
  background: rgba(0, 255, 200, 0.05);
}

.back-arrow {
  font-size: 1.2rem;
}

.leaderboard-title {
  font-family: "Orbitron", monospace;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--accent-gold), #ff9500);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.trophy {
  font-size: 1.4em;
  -webkit-text-fill-color: initial;
}

.header-spacer {
  width: 120px;
}

.bench-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ai-primary);
  text-decoration: none;
  font-family: "Orbitron", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--ai-primary);
  transition: all 0.3s ease;
}

.bench-link:hover {
  background: rgba(255, 0, 255, 0.1);
  box-shadow: 0 0 20px rgba(255, 0, 255, 0.3);
}

/* ===== Model Filter ===== */
.model-filter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: 16px;
  border: 1px solid var(--border-color);
}

.filter-label {
  font-family: "Orbitron", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 2px;
}

.model-filter .model-select {
  min-width: 220px;
}

/* ===== Undefeated AI Banner ===== */
.undefeated-banner {
  position: relative;
  background: linear-gradient(135deg, rgba(255, 50, 50, 0.12), rgba(255, 120, 50, 0.08));
  border: 2px solid rgba(255, 100, 100, 0.4);
  border-radius: 20px;
  padding: 24px 28px;
  overflow: hidden;
}

.undefeated-banner.hidden {
  display: none;
}

.banner-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(255, 80, 80, 0.15) 0%, transparent 50%);
  animation: pulse-glow 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.1); }
}

.banner-content {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 1;
}

.banner-icon {
  font-size: 3rem;
  animation: robot-bounce 2s ease-in-out infinite;
}

@keyframes robot-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.banner-text {
  flex: 1;
}

.banner-text h3 {
  font-family: "Orbitron", monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: #ff6b6b;
  letter-spacing: 3px;
  margin: 0 0 6px 0;
  text-shadow: 0 0 20px rgba(255, 100, 100, 0.5);
}

.banner-text p {
  font-family: "Rajdhani", sans-serif;
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
  letter-spacing: 0.5px;
}

.banner-text p span {
  color: var(--ai-primary);
  font-weight: 600;
}

.challenge-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #ff6b6b, #ff8e53);
  color: #fff;
  font-family: "Orbitron", monospace;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(255, 100, 100, 0.3);
  white-space: nowrap;
}

.challenge-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 30px rgba(255, 100, 100, 0.5);
}

/* ===== Model vs Model Comparison ===== */
.model-comparison-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 28px;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: "Orbitron", monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 3px;
  margin: 0 0 24px 0;
  text-align: center;
}

.section-icon {
  font-size: 1.4rem;
}

.model-comparison-grid {
  overflow-x: auto;
  padding-bottom: 8px;
}

.loading-comparison {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.comparison-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--accent-red);
  font-size: 0.95rem;
}

/* Model Matrix Table */
.model-matrix {
  width: 100%;
  border-collapse: collapse;
  font-family: "Rajdhani", sans-serif;
  min-width: 700px;
}

.model-matrix th,
.model-matrix td {
  padding: 14px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.model-matrix thead th {
  background: var(--bg-tertiary);
  font-family: "Orbitron", monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 1px;
  white-space: nowrap;
}

.matrix-corner {
  width: 140px;
}

.matrix-header {
  min-width: 100px;
}

.matrix-header .header-icon {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.human-header {
  color: var(--human-primary) !important;
}

.model-header {
  color: var(--ai-primary) !important;
}

.total-header {
  color: var(--accent-gold) !important;
}

/* Matrix Rows */
.matrix-row {
  transition: all 0.2s ease;
}

.matrix-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.matrix-row:last-child td {
  border-bottom: none;
}

.matrix-model-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left !important;
}

.model-icon {
  font-size: 1.3rem;
}

.model-name-text {
  font-family: "Orbitron", monospace;
  font-size: 0.85rem;
  letter-spacing: 1px;
}

/* Matrix Cells */
.matrix-cell {
  vertical-align: middle;
}

.self-cell {
  background: rgba(255, 255, 255, 0.02);
}

.self-indicator {
  color: var(--text-muted);
  font-size: 1.2rem;
}

.no-games {
  opacity: 0.5;
}

.no-games-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Battle Record Styling */
.battle-record {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: "Orbitron", monospace;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.battle-record.winning {
  background: rgba(0, 255, 200, 0.12);
  border: 1px solid rgba(0, 255, 200, 0.3);
}

.battle-record.losing {
  background: rgba(255, 100, 100, 0.12);
  border: 1px solid rgba(255, 100, 100, 0.3);
}

.battle-record.neutral {
  background: rgba(255, 200, 50, 0.12);
  border: 1px solid rgba(255, 200, 50, 0.3);
}

.battle-record .wins {
  color: var(--human-primary);
}

.battle-record .losses {
  color: #ff6b6b;
}

.battle-record .draws {
  color: #ffc832;
}

.battle-record .separator {
  color: var(--text-muted);
  opacity: 0.5;
}

.total-games {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Win Rate Cell */
.win-rate-cell {
  min-width: 90px;
}

.win-rate {
  font-family: "Orbitron", monospace;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.win-rate.high {
  color: var(--human-primary);
  text-shadow: 0 0 10px rgba(0, 255, 200, 0.3);
}

.win-rate.medium {
  color: #ffc832;
}

.win-rate.low {
  color: #ff6b6b;
}

.total-record {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: "Orbitron", monospace;
  letter-spacing: 0.5px;
}

/* ===== Stats Summary ===== */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.1);
}

.stat-card.highlight {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(255, 170, 0, 0.04));
  border-color: rgba(255, 215, 0, 0.3);
}

.stat-card.highlight .stat-value {
  color: var(--accent-gold);
}

.stat-value {
  font-family: "Orbitron", monospace;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
}

.stat-label {
  font-family: "Orbitron", monospace;
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 2px;
}

/* ===== Leaderboard Table ===== */
.leaderboard-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  overflow: hidden;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Rajdhani", sans-serif;
}

.leaderboard-table th {
  font-family: "Orbitron", monospace;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-align: left;
  padding: 18px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.leaderboard-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 500;
}

.leaderboard-table tbody tr {
  transition: all 0.2s ease;
}

.leaderboard-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

/* Column Styles */
.rank-col {
  width: 70px;
  text-align: center !important;
}

.player-col {
  min-width: 150px;
}

.score-col {
  width: 120px;
  text-align: right !important;
}

.diff-col {
  width: 100px;
  text-align: center !important;
}

.date-col {
  width: 120px;
  text-align: right !important;
  color: var(--text-secondary) !important;
  font-size: 0.9rem !important;
}

/* Rank Badges */
.rank-badge {
  font-size: 1.4rem;
}

.rank-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  font-family: "Orbitron", monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Player Name */
.player-name {
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Player Type Badges */
.player-col {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-type-badge {
  font-size: 1rem;
  flex-shrink: 0;
}

.player-type-badge.human {
  opacity: 0.7;
}

.player-type-badge.model {
  opacity: 1;
}

.model-player .player-name {
  color: var(--ai-primary);
  font-style: italic;
}

/* Score Styles */
.human-score {
  color: var(--human-primary) !important;
  font-family: "Orbitron", monospace;
  font-weight: 600 !important;
}

.ai-score {
  color: var(--ai-primary) !important;
  font-family: "Orbitron", monospace;
  font-weight: 600 !important;
}

/* Result Column */
.result-col {
  width: 90px;
  text-align: center !important;
}

/* Result Badges */
.result-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: "Orbitron", monospace;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1px;
}

.result-badge.win {
  background: rgba(0, 255, 200, 0.15);
  color: var(--human-primary);
}

.result-badge.tie {
  background: rgba(255, 200, 50, 0.15);
  color: #ffc832;
}

.result-badge.lose {
  background: rgba(255, 100, 100, 0.15);
  color: #ff6b6b;
}

/* Margin Badge */
.margin-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: "Orbitron", monospace;
  font-size: 0.8rem;
  font-weight: 600;
}

.margin-badge.win-margin {
  background: rgba(0, 255, 200, 0.1);
  color: var(--human-primary);
}

.margin-badge.tie-margin {
  background: rgba(255, 200, 50, 0.1);
  color: #ffc832;
}

.margin-badge.lose-margin {
  background: rgba(255, 100, 100, 0.1);
  color: #ff6b6b;
}

/* Loading State */
.loading-row {
  text-align: center !important;
  padding: 60px 20px !important;
  color: var(--text-secondary) !important;
}

.loading-row span {
  display: block;
  margin-top: 12px;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.loading-spinner-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-gold);
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error State */
.error-row {
  text-align: center !important;
  padding: 40px 20px !important;
  color: var(--accent-red) !important;
  font-size: 0.95rem;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  opacity: 0.8;
}

.empty-state h3 {
  font-family: "Orbitron", monospace;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.play-now-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--human-primary), var(--human-secondary));
  color: var(--bg-primary);
  font-family: "Orbitron", monospace;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 0 30px rgba(0, 255, 200, 0.3);
}

.play-now-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 50px rgba(0, 255, 200, 0.5);
}

.play-now-btn .btn-icon {
  font-size: 1.1rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .leaderboard-page {
    padding: 20px 16px 40px;
    gap: 20px;
  }

  .leaderboard-header {
    flex-wrap: wrap;
    justify-content: center;
  }

  .back-link {
    order: -1;
    width: 100%;
    justify-content: center;
  }

  .header-spacer {
    display: none;
  }

  .leaderboard-title {
    text-align: center;
  }

  .undefeated-banner {
    padding: 20px;
  }

  .banner-content {
    flex-direction: column;
    text-align: center;
    gap: 16px;
  }

  .banner-icon {
    font-size: 2.5rem;
  }

  .banner-text h3 {
    font-size: 0.95rem;
    letter-spacing: 2px;
  }

  .banner-text p {
    font-size: 0.9rem;
  }

  .challenge-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    font-size: 0.75rem;
  }

  /* Model Comparison Responsive */
  .model-comparison-section {
    padding: 20px 16px;
  }

  .section-title {
    font-size: 0.85rem;
    letter-spacing: 2px;
  }

  .model-matrix th,
  .model-matrix td {
    padding: 10px 8px;
  }

  .model-matrix thead th {
    font-size: 0.55rem;
  }

  .matrix-header .header-icon {
    font-size: 1rem;
  }

  .matrix-corner {
    width: 100px;
  }

  .matrix-header {
    min-width: 80px;
  }

  .model-icon {
    font-size: 1.1rem;
  }

  .model-name-text {
    font-size: 0.75rem;
  }

  .battle-record {
    padding: 4px 8px;
    font-size: 0.7rem;
  }

  .total-games {
    font-size: 0.6rem;
  }

  .win-rate {
    font-size: 0.95rem;
  }

  .total-record {
    font-size: 0.6rem;
  }

  .stats-summary {
    grid-template-columns: 1fr;
  }

  .stat-card {
    flex-direction: row;
    justify-content: space-between;
    padding: 16px 20px;
  }

  .model-filter {
    flex-direction: column;
    gap: 12px;
  }

  .model-filter .model-select {
    width: 100%;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 12px 10px;
    font-size: 0.85rem;
  }

  .leaderboard-table th {
    font-size: 0.55rem;
  }

  .date-col {
    display: none;
  }

  .score-col {
    width: 80px;
  }

  .diff-col {
    width: 70px;
  }

  .result-col {
    width: 70px;
  }

  .result-badge {
    padding: 3px 6px;
    font-size: 0.6rem;
  }
}

@media (max-width: 480px) {
  .leaderboard-title {
    font-size: 1.3rem;
    letter-spacing: 2px;
  }

  .trophy {
    font-size: 1.2em;
  }

  .player-col {
    min-width: 100px;
  }

  .margin-badge {
    padding: 3px 6px;
    font-size: 0.7rem;
  }
}
