:root {
  --gold: #ffd700;
  --gold-glow: rgba(255, 215, 0, 0.4);
  --neon-pink: #ff2d78;
  --neon-cyan: #00f0ff;
  --neon-green: #39ff14;
  --p1: #ff6b3d;
  --p1-glow: rgba(255, 107, 61, 0.5);
  --p1-bg: rgba(255, 107, 61, 0.12);
  --p2: #00c8ff;
  --p2-glow: rgba(0, 200, 255, 0.5);
  --p2-bg: rgba(0, 200, 255, 0.12);
  --bg-dark: #0a0e1a;
  --bg-card: #111827;
  --bg-card-alt: #151d2e;
  --surface: #1a2236;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8edf5;
  --text-muted: #6b7a94;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --transition: 0.3s ease;
}

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

body {
  font-family: 'Exo 2', 'Rajdhani', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Scanline overlay */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* ===== HEADER ===== */
header {
  text-align: center;
  padding: 3rem 1rem 2.5rem;
  background: linear-gradient(180deg, #0f1629 0%, var(--bg-dark) 100%);
  position: relative;
  overflow: hidden;
}

.header-glow {
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(255, 215, 0, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.neon-title {
  font-family: 'Orbitron', monospace;
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow:
    0 0 10px var(--gold-glow),
    0 0 30px var(--gold-glow),
    0 0 60px rgba(255, 215, 0, 0.2);
  letter-spacing: 8px;
  animation: flicker 4s infinite;
}

.sub-title {
  font-family: 'Orbitron', monospace;
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 6px;
  color: var(--text-muted);
  margin-top: 0.3rem;
  text-transform: uppercase;
}

.tagline {
  margin-top: 0.8rem;
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 300;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.8; }
  94% { opacity: 1; }
  96% { opacity: 0.9; }
  97% { opacity: 1; }
}

/* ===== MAIN ===== */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* ===== SEARCH SECTION ===== */
.search-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-top: -1rem;
  position: relative;
  z-index: 10;
}

.search-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.search-group {
  flex: 1;
  min-width: 200px;
}

.search-group label {
  display: block;
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 3px;
  margin-bottom: 0.5rem;
}

.player-1 label { color: var(--p1); }
.player-2 label { color: var(--p2); }

.player-badge {
  font-family: 'Orbitron', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.4rem;
}

.player-1 .player-badge {
  background: var(--p1-bg);
  color: var(--p1);
  border: 1px solid rgba(255, 107, 61, 0.3);
}

.player-2 .player-badge {
  background: var(--p2-bg);
  color: var(--p2);
  border: 1px solid rgba(0, 200, 255, 0.3);
}

.search-wrapper { position: relative; }

.search-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Exo 2', sans-serif;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface);
  color: var(--text);
}

.player-1 input:focus {
  border-color: var(--p1);
  box-shadow: 0 0 12px var(--p1-glow);
}

.player-2 input:focus {
  border-color: var(--p2);
  box-shadow: 0 0 12px var(--p2-glow);
}

.selected-label {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  min-height: 1.3em;
}

.vs-badge {
  align-self: center;
  margin-top: 1.6rem;
  flex-shrink: 0;
}

.vs-glow {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--gold);
  text-shadow: 0 0 15px var(--gold-glow), 0 0 30px var(--gold-glow);
}

/* Dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: none;
  overflow: hidden;
}

.dropdown.open { display: block; }

.dropdown-item {
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: rgba(255, 255, 255, 0.05); }
.dropdown-item .city { font-weight: 700; }
.dropdown-item .region { color: var(--text-muted); font-size: 0.82rem; }

/* Compare Button */
#compareBtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.8rem auto 0;
  padding: 0.9rem 3rem;
  border: 2px solid var(--gold);
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

#compareBtn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--p1), var(--gold), var(--p2));
  opacity: 0;
  transition: opacity var(--transition);
}

#compareBtn:not(:disabled):hover::before { opacity: 0.2; }

.btn-text {
  font-family: 'Orbitron', monospace;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
  position: relative;
  z-index: 1;
}

.btn-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  position: relative;
  z-index: 1;
}

#compareBtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#compareBtn:not(:disabled):hover {
  box-shadow: 0 0 25px var(--gold-glow);
  transform: translateY(-2px);
}

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 4rem 1rem;
}

.spinner-ring {
  width: 64px;
  height: 64px;
  border: 3px solid transparent;
  border-top-color: var(--p1);
  border-bottom-color: var(--p2);
  border-radius: 50%;
  margin: 0 auto 1.2rem;
  animation: spin 1s linear infinite;
  position: relative;
}

.spinner-inner {
  position: absolute;
  inset: 6px;
  border: 3px solid transparent;
  border-left-color: var(--gold);
  border-right-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.6s linear infinite reverse;
}

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

.loading-text {
  font-family: 'Orbitron', monospace;
  font-size: 0.85rem;
  letter-spacing: 3px;
  color: var(--gold);
}

.dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

.hidden { display: none !important; }

/* Error */
.error-message {
  text-align: center;
  padding: 1.2rem;
  margin-top: 1.5rem;
  background: rgba(255, 45, 120, 0.1);
  border: 1px solid rgba(255, 45, 120, 0.3);
  color: var(--neon-pink);
  border-radius: 8px;
  font-weight: 600;
}

/* ===== WINNER BANNER ===== */
.winner-banner {
  text-align: center;
  padding: 3rem 2rem;
  margin-top: 2.5rem;
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.08) 0%, transparent 100%);
  border: 2px solid rgba(255, 215, 0, 0.25);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.winner-banner::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--p1), var(--gold), var(--p2));
  opacity: 0.1;
  z-index: 0;
}

.trophy {
  font-size: 4rem;
  position: relative;
  z-index: 1;
  animation: bounce 2s ease-in-out infinite;
}

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

.winner-title {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  letter-spacing: 10px;
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold-glow);
  position: relative;
  z-index: 1;
  margin-top: 0.5rem;
}

.winner-name {
  font-family: 'Orbitron', monospace;
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--text);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
  position: relative;
  z-index: 1;
  margin-top: 0.3rem;
}

.winner-name.p1-winner { color: var(--p1); text-shadow: 0 0 30px var(--p1-glow); }
.winner-name.p2-winner { color: var(--p2); text-shadow: 0 0 30px var(--p2-glow); }

.winner-score-display {
  margin-top: 1rem;
  position: relative;
  z-index: 1;
}

.score-label {
  display: block;
  font-family: 'Orbitron', monospace;
  font-size: 0.6rem;
  letter-spacing: 4px;
  color: var(--text-muted);
}

.score-value {
  font-family: 'Orbitron', monospace;
  font-size: 3rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold-glow), 0 0 40px var(--gold-glow);
}

/* ===== CONFETTI ===== */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  top: -10px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}

/* ===== SCOREBOARD ===== */
.scoreboard {
  margin-top: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.board-title {
  font-family: 'Orbitron', monospace;
  font-size: 1rem;
  letter-spacing: 5px;
  text-align: center;
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold-glow);
}

.board-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.3rem;
  margin-bottom: 1.5rem;
}

.score-bars {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

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

.score-bar-name {
  font-family: 'Orbitron', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 140px;
  text-align: right;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-bar-name.p1 { color: var(--p1); }
.score-bar-name.p2 { color: var(--p2); }

.score-bar-track {
  flex: 1;
  height: 32px;
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.score-bar-fill {
  height: 100%;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.8rem;
  font-family: 'Orbitron', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  transition: width 1.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  min-width: 50px;
}

.score-bar-fill.p1 {
  background: linear-gradient(90deg, rgba(255, 107, 61, 0.3), var(--p1));
  box-shadow: 0 0 15px var(--p1-glow);
}

.score-bar-fill.p2 {
  background: linear-gradient(90deg, rgba(0, 200, 255, 0.3), var(--p2));
  box-shadow: 0 0 15px var(--p2-glow);
}

.score-bar-fill.winner-bar {
  box-shadow: 0 0 20px var(--gold-glow), 0 0 8px currentColor;
}

/* ===== HEAD TO HEAD ===== */
.h2h-section {
  margin-top: 2.5rem;
}

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

.h2h-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  transition: transform var(--transition), box-shadow var(--transition);
}

.h2h-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.h2h-card.p1-wins { border-color: rgba(255, 107, 61, 0.3); }
.h2h-card.p2-wins { border-color: rgba(0, 200, 255, 0.3); }

.h2h-category {
  font-family: 'Orbitron', monospace;
  font-size: 0.65rem;
  letter-spacing: 3px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}

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

.h2h-value {
  font-family: 'Rajdhani', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.h2h-loc-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.h2h-player { text-align: center; }

.h2h-player.p1 .h2h-value { color: var(--p1); }
.h2h-player.p2 .h2h-value { color: var(--p2); }

.h2h-winner-value {
  text-shadow: 0 0 10px currentColor;
}

.h2h-badge {
  font-family: 'Orbitron', monospace;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  background: rgba(255, 215, 0, 0.15);
  color: var(--gold);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.h2h-vs {
  font-family: 'Orbitron', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ===== CHARTS ===== */
.charts-section {
  margin-top: 2.5rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(480px, 1fr));
  gap: 1.2rem;
  margin-top: 1.5rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

footer a {
  color: var(--gold);
  text-decoration: none;
}

footer a:hover {
  text-shadow: 0 0 8px var(--gold-glow);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .neon-title { font-size: 2rem; letter-spacing: 4px; }
  .sub-title { font-size: 0.75rem; letter-spacing: 3px; }
  .search-row { flex-direction: column; }
  .vs-badge { align-self: center; margin-top: 0; }
  .h2h-grid { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .score-bar-name { min-width: 80px; font-size: 0.65rem; }
  .winner-name { font-size: 1.4rem; }
  .score-value { font-size: 2rem; }
}
