/* ============================================================
   EYES ONLY - Highscore Leaderboards CSS
   Arcade-style embellishments with CRT aesthetic
   ============================================================ */

/* ---- SCROLL FIX: Override crt.css lockdown for standalone pages ---- */
html, body {
  overflow: auto !important;
  overflow-x: hidden !important;
  height: auto !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
}
#crt-screen {
  position: relative !important;
  height: auto !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  overflow: visible !important;
}

/* Base styles */
body {
  margin: 0;
  padding: 0;
  font-family: var(--theme-font-data, 'Courier New', monospace);
  background: var(--bg, #000);
  color: var(--phosphor);
  background: #0c0e0c;
}

/* Let the page scroll INSIDE the CRT frame instead of spilling off-screen */
#crt-frame {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.highscore-container {
  flex: 1;
  min-height: 0; /* critical for nested scroll containers */
  overflow-y: auto;
  padding-bottom: 1.5rem;

  /* scrollbar styling to match the UI */
  scrollbar-width: thin;
  scrollbar-color: var(--phosphor) rgba(0, 0, 0, 0.35);
}

.highscore-container::-webkit-scrollbar {
  width: 10px;
}

.highscore-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.35);
  border-left: 1px solid rgba(100, 88, 50, 0.12);
}

.highscore-container::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(120, 100, 50, 0.4), rgba(80, 68, 30, 0.3));
  border: 1px solid rgba(100, 88, 50, 0.2);
  border-radius: 10px;
}

.highscore-container::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(160, 140, 70, 0.5), rgba(100, 88, 50, 0.4));
  border-color: rgba(140, 120, 60, 0.4);
}


/* Header — metal-framed bezel */
.highscore-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background:
    linear-gradient(90deg, rgba(30, 26, 16, 0.2), rgba(20, 18, 10, 0.1) 50%, rgba(30, 26, 16, 0.2)),
    linear-gradient(180deg, var(--panel-bg, #0a2a1f) 0%, var(--bg, #000) 100%);
  border-bottom: 2px solid;
  border-image: linear-gradient(90deg, #3a3220, #7a6c48 30%, #5a5038 50%, #7a6c48 70%, #3a3220) 1;
  box-shadow:
    inset 0 1px 0 rgba(180, 160, 100, 0.06),
    0 2px 12px rgba(0, 0, 0, 0.4),
    0 0 20px var(--phosphor-glow);
}

.header-title {
  display: flex;
  flex-direction: column;
}

.title-main {
  font-size: 1.5rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-shadow: 0 0 10px var(--phosphor), 0 0 20px var(--phosphor);
}

.title-sub {
  font-size: 0.9rem;
  color: rgba(160, 140, 90, 0.5);
  letter-spacing: 0.05em;
}

.back-btn {
  background: linear-gradient(175deg, rgba(30, 26, 16, 0.5), rgba(20, 18, 10, 0.3));
  border: 1px solid rgba(100, 88, 50, 0.3);
  color: rgba(200, 180, 120, 0.7);
  padding: 0.5rem 1.5rem;
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(180, 160, 100, 0.06);
}

.back-btn:hover {
  background: linear-gradient(175deg, rgba(50, 44, 26, 0.6), rgba(30, 26, 16, 0.4));
  border-color: rgba(140, 120, 60, 0.5);
  color: rgba(220, 200, 140, 0.9);
  box-shadow: 0 0 12px rgba(180, 160, 80, 0.15), inset 0 1px 0 rgba(180, 160, 100, 0.1);
}

/* Container */
.highscore-container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 2rem;
}

/* Tab Navigation — brass-accented */
.tab-navigation {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid rgba(100, 88, 50, 0.25);
}

.tab-btn {
  flex: 1;
  background: linear-gradient(180deg, rgba(20, 18, 10, 0.4), rgba(12, 14, 12, 0.9));
  border: 1px solid rgba(100, 88, 50, 0.2);
  border-bottom: none;
  color: rgba(160, 140, 90, 0.5);
  padding: 1rem;
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
}

.tab-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.2s ease;
}

.tab-btn:hover {
  color: rgba(200, 180, 120, 0.8);
  border-color: rgba(140, 120, 60, 0.4);
  background: linear-gradient(180deg, rgba(30, 26, 16, 0.5), rgba(16, 18, 14, 0.9));
}

.tab-btn.active {
  background: linear-gradient(180deg, rgba(30, 26, 16, 0.5), var(--panel-bg, #0d2a1f));
  border-color: rgba(140, 120, 60, 0.4);
  color: var(--phosphor);
  box-shadow: inset 0 0 10px var(--phosphor-glow), inset 0 1px 0 rgba(180, 160, 100, 0.08);
}

.tab-btn.active::before {
  background: linear-gradient(90deg, transparent, rgba(180, 160, 100, 0.4), var(--phosphor), rgba(180, 160, 100, 0.4), transparent);
}

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

.tab-label {
  font-weight: bold;
  letter-spacing: 0.05em;
}

/* Filters — brass-accented */
.filters {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: flex-end;
}

.filter-group {
  display: flex;
  gap: 0.5rem;
  background: rgba(12, 14, 12, 0.8);
  padding: 0.5rem;
  border: 1px solid rgba(100, 88, 50, 0.2);
  border-radius: 4px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.filter-btn {
  background: transparent;
  border: 1px solid rgba(100, 88, 50, 0.15);
  color: rgba(160, 140, 90, 0.5);
  padding: 0.5rem 1rem;
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  color: rgba(200, 180, 120, 0.8);
  border-color: rgba(140, 120, 60, 0.4);
}

.filter-btn.active {
  background: linear-gradient(175deg, rgba(40, 34, 18, 0.7), rgba(24, 20, 10, 0.5));
  border-color: rgba(140, 120, 60, 0.5);
  color: var(--phosphor);
  font-weight: bold;
  box-shadow: inset 0 1px 0 rgba(180, 160, 100, 0.08);
}

/* Tab Content */
.tab-content {
  position: relative;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* Leaderboard Table — CRT content area with brass border */
.leaderboard-table-container {
  background: rgba(8, 12, 8, 0.9);
  border: 1px solid rgba(100, 88, 50, 0.25);
  border-radius: 6px;
  padding: 1rem;
  box-shadow:
    0 0 15px var(--phosphor-glow),
    inset 0 1px 0 rgba(180, 160, 100, 0.04),
    inset 0 0 0 1px rgba(0, 0, 0, 0.3);
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.leaderboard-table thead {
  background:
    linear-gradient(90deg, rgba(30, 26, 16, 0.15), rgba(20, 18, 10, 0.08) 50%, rgba(30, 26, 16, 0.15)),
    var(--panel-bg, #0d2a1f);
  border-bottom: 2px solid rgba(100, 88, 50, 0.3);
}

.leaderboard-table th {
  padding: 0.75rem;
  text-align: left;
  font-weight: bold;
  color: rgba(200, 180, 120, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-right: 1px solid rgba(100, 88, 50, 0.12);
}

.leaderboard-table th:last-child {
  border-right: none;
}

.leaderboard-table tbody tr {
  border-bottom: 1px solid rgba(100, 88, 50, 0.08);
  transition: background 0.2s ease;
}

.leaderboard-table tbody tr:hover {
  background: rgba(20, 18, 10, 0.3);
}

.leaderboard-table tbody tr.top-3 {
  background: linear-gradient(90deg, rgba(30, 26, 16, 0.2) 0%, transparent 100%);
}

.leaderboard-table tbody tr.rank-1 {
  color: #ffd700;
}

.leaderboard-table tbody tr.rank-2 {
  color: #c0c0c0;
}

.leaderboard-table tbody tr.rank-3 {
  color: #cd7f32;
}

.leaderboard-table td {
  padding: 0.75rem;
  border-right: 1px solid rgba(100, 88, 50, 0.06);
  color: rgba(220, 210, 180, 0.85);
}

.leaderboard-table td:last-child {
  border-right: none;
}

.rank-col {
  width: 80px;
  text-align: center;
  font-weight: bold;
}

.name-col {
  width: 200px;
}

.mode-col {
  width: 100px;
  text-align: center;
}

.score-col {
  width: 120px;
  text-align: right;
  font-weight: bold;
  font-size: 1.1rem;
}

.stats-col {
  width: 120px;
  text-align: center;
  color: rgba(160, 140, 90, 0.45);
}

/* Score flip animation */
.score-flip {
  display: inline-block;
  animation: flipNumber 0.5s ease;
}

@keyframes flipNumber {
  0% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(90deg);
    opacity: 0;
  }
  100% {
    transform: rotateX(0deg);
    opacity: 1;
  }
}

/* Mode badges — subtle brass-bordered */
.mode-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mode-badge.human {
  background: rgba(10, 22, 16, 0.8);
  color: var(--phosphor);
  border: 1px solid rgba(100, 88, 50, 0.3);
  box-shadow: inset 0 1px 0 rgba(180, 160, 100, 0.04);
}

.mode-badge.agent {
  background: rgba(40, 12, 30, 0.8);
  color: #ff1c9b;
  border: 1px solid rgba(100, 88, 50, 0.3);
  box-shadow: inset 0 1px 0 rgba(180, 160, 100, 0.04);
}

/* Empty state */
.empty-row td {
  text-align: center;
  color: rgba(140, 120, 70, 0.35);
  padding: 2rem;
  font-style: italic;
}

/* Footer — metal-framed */
.highscore-footer {
  margin-top: 2rem;
  padding: 1rem 2rem;
  text-align: center;
  font-size: 0.85rem;
  background:
    linear-gradient(90deg, rgba(30, 26, 16, 0.15), rgba(20, 18, 10, 0.08) 50%, rgba(30, 26, 16, 0.15)),
    linear-gradient(0deg, #1a160e 0%, #221e16 60%, #2e2820 100%);
  border-top: 2px solid;
  border-image: linear-gradient(90deg, #3a3220, #7a6c48 30%, #5a5038 50%, #7a6c48 70%, #3a3220) 1;
  box-shadow: inset 0 1px 0 rgba(180, 160, 100, 0.06);
  color: rgba(160, 140, 90, 0.5);
}

.highscore-footer p {
  margin: 0.5rem 0;
}

.footer-icon {
  color: rgba(200, 180, 120, 0.7);
  font-weight: bold;
}

.footer-copyright {
  color: rgba(120, 100, 60, 0.4);
}

/* Header actions row */
.header-actions {
  display: flex;
  gap: 0.5rem;
}

/* Game column (arcade tab) */
.game-col {
  width: 140px;
  text-align: center;
}

/* Arcade sub-navigation — pill buttons */
.arcade-sub-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: rgba(12, 14, 12, 0.6);
  border: 1px solid rgba(100, 88, 50, 0.15);
  border-radius: 4px;
}

.arcade-sub-btn {
  background: transparent;
  border: 1px solid rgba(100, 88, 50, 0.2);
  color: rgba(160, 140, 90, 0.5);
  padding: 0.35rem 0.8rem;
  font-family: var(--theme-font-data, 'Courier New', monospace);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.15s;
}

.arcade-sub-btn:hover {
  color: rgba(200, 180, 120, 0.8);
  border-color: rgba(140, 120, 60, 0.4);
}

.arcade-sub-btn.active {
  background: linear-gradient(175deg, rgba(40, 34, 18, 0.7), rgba(24, 20, 10, 0.5));
  border-color: rgba(140, 120, 60, 0.5);
  color: var(--phosphor);
  box-shadow: inset 0 1px 0 rgba(180, 160, 100, 0.08);
}

/* Arcade personal bests strip */
.arcade-bests {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.arcade-best-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: rgba(12, 14, 12, 0.7);
  border: 1px solid rgba(100, 88, 50, 0.18);
  border-radius: 4px;
  font-size: 0.75rem;
  transition: border-color 0.15s;
}

.arcade-best-card:hover {
  border-color: rgba(140, 120, 60, 0.35);
}

.arcade-best-icon {
  font-size: 1.1rem;
}

.arcade-best-name {
  color: rgba(200, 180, 120, 0.6);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.arcade-best-score {
  color: var(--phosphor);
  font-weight: bold;
  letter-spacing: 0.04em;
}

.arcade-game-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(20, 18, 10, 0.6);
  border: 1px solid rgba(100, 88, 50, 0.2);
  color: rgba(200, 180, 120, 0.7);
}

/* Scanlines effect (subtle) */
#scanlines {
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  z-index: 9999;
}

/* Responsive */
@media (max-width: 768px) {
  .highscore-container {
    padding: 0 1rem;
  }

  .tab-btn {
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
  }

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

  .tab-label {
    font-size: 0.75rem;
  }

  .leaderboard-table {
    font-size: 0.85rem;
  }

  .leaderboard-table th,
  .leaderboard-table td {
    padding: 0.5rem 0.25rem;
  }

  .stats-col {
    width: 80px;
  }

  .name-col {
    width: 150px;
  }

  .game-col {
    width: 100px;
    font-size: 0.75rem;
  }

  .header-actions {
    flex-direction: column;
    gap: 0.25rem;
  }

  .header-actions .back-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
  }

  .arcade-sub-nav {
    gap: 0.3rem;
    padding: 0.4rem;
  }

  .arcade-sub-btn {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
  }

  .arcade-bests {
    gap: 0.35rem;
  }

  .arcade-best-card {
    font-size: 0.65rem;
    padding: 0.3rem 0.5rem;
  }
}
