:root {
  --bg-dark: #07070c;
  --panel-bg: rgba(15, 15, 25, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #ffffff;
  --text-secondary: #a0a0ba;
  
  /* Game Themes */
  --runner-color: #ff0080;
  --runner-glow: rgba(255, 0, 128, 0.3);
  --tap-color: #00f2fe;
  --tap-glow: rgba(0, 242, 254, 0.3);
  --stacker-color: #bc13fe;
  --stacker-glow: rgba(188, 19, 254, 0.3);
  --snake-color: #39ff14;
  --snake-glow: rgba(57, 255, 20, 0.3);
  
  /* Active Theme Variables (updated dynamically by body class) */
  --active-color: #00f2fe;
  --active-glow: rgba(0, 242, 254, 0.3);
}

.runner-theme {
  --active-color: var(--runner-color);
  --active-glow: var(--runner-glow);
}

.tap-theme {
  --active-color: var(--tap-color);
  --active-glow: var(--tap-glow);
}

.stacker-theme {
  --active-color: var(--stacker-color);
  --active-glow: var(--stacker-glow);
}

.snake-theme {
  --active-color: var(--snake-color);
  --active-glow: var(--snake-glow);
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.8s ease;
}

/* Background Effects */
.stars-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(white, rgba(255,255,255,.15) 1px, transparent 40px),
    radial-gradient(white, rgba(255,255,255,.1) 1px, transparent 30px);
  background-size: 550px 550px, 350px 350px;
  background-position: 0 0, 40px 60px;
  opacity: 0.12;
  z-index: -2;
  pointer-events: none;
}

.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(160px);
  opacity: 0.25;
  z-index: -1;
  pointer-events: none;
  transition: background 1s ease, left 1s ease, top 1s ease;
}

.orb-1 {
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, var(--active-color) 0%, transparent 70%);
  top: -10vw;
  left: -5vw;
}

.orb-2 {
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, var(--active-color) 0%, transparent 70%);
  bottom: -15vw;
  right: -5vw;
}

/* Header */
header {
  padding: 2.2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  border-bottom: 1px solid var(--border-color);
}

.logo-container {
  display: flex;
  flex-direction: column;
}

h1.glitch {
  font-family: 'Orbitron', sans-serif;
  font-size: 2.3rem;
  font-weight: 900;
  letter-spacing: 2px;
  position: relative;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
  background: linear-gradient(45deg, #fff, var(--active-color), #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: background 0.8s ease;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 0.25rem;
  letter-spacing: 0.5px;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-badge {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 0.6rem 1.2rem;
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

.timer-badge {
  border-color: var(--active-color);
  box-shadow: 0 0 15px var(--active-glow);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.8rem 1.6rem;
  font-size: 0.9rem;
  gap: 0.8rem;
  transition: border-color 0.8s ease, box-shadow 0.8s ease;
}

.timer-label {
  color: var(--text-secondary);
  font-weight: 700;
}

.timer-value {
  color: var(--active-color);
  font-weight: 900;
  font-size: 1.45rem;
  min-width: 65px;
  text-align: center;
  transition: color 0.8s ease;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #39ff14;
  border-radius: 50%;
  box-shadow: 0 0 8px #39ff14;
  animation: pulse 1.5s infinite;
}

/* Arena Layout */
.arcade-arena {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 2rem 2.5rem 3rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.arena-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 3rem;
  width: 100%;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.arena-layout.switching {
  opacity: 0;
  transform: scale(0.98) translateY(5px);
}

/* Game Hero Card */
.game-hero-card {
  background: var(--panel-bg);
  border-radius: 24px;
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(15px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
  transition: border-color 0.8s ease;
}

.game-hero-card:hover {
  border-color: var(--active-color);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.5), 0 0 30px var(--active-glow);
}

.card-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: var(--active-color);
  box-shadow: 0 2px 10px var(--active-color);
  transition: background 0.8s ease, box-shadow 0.8s ease;
}

.hero-content {
  padding: 3rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: center;
}

.game-badge {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--active-color);
  margin-bottom: 0.6rem;
  transition: color 0.8s ease;
}

#active-game-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 1px;
  text-shadow: 0 0 20px var(--active-glow);
  transition: text-shadow 0.8s ease;
}

.game-tag {
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  margin-top: 0.2rem;
  color: var(--active-color);
  font-weight: 600;
  transition: color 0.8s ease;
}

.description {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.6;
  margin: 1.8rem 0 2.5rem;
}

/* Play Section with QR */
.play-section {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-color);
  padding: 1.6rem;
  border-radius: 18px;
}

.qr-container {
  width: 150px;
  height: 150px;
  background: #11111b;
  border-radius: 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.qr-code {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-scanner-line {
  position: absolute;
  width: 90%;
  height: 2px;
  left: 5%;
  color: var(--active-color);
  background: var(--active-color);
  box-shadow: 0 0 10px var(--active-color);
  animation: scan 2.5s infinite linear;
  opacity: 0.8;
  transition: color 0.8s ease, background 0.8s ease, box-shadow 0.8s ease;
}

.play-instructions {
  flex: 1;
}

.phone-icon {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.instr-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #fff;
  margin-bottom: 0.3rem;
}

.instr-subtitle {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Leaderboard Panel */
.leaderboard-card {
  background: var(--panel-bg);
  border-radius: 24px;
  border: 1px solid var(--border-color);
  padding: 2.5rem;
  backdrop-filter: blur(15px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

.leaderboard-header {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.leaderboard-header h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  letter-spacing: 1.5px;
  color: #fff;
}

.leaderboard-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.leaderboard-container {
  flex: 1;
  overflow-y: auto;
}

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

.leaderboard-table th {
  text-align: left;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 0.6rem 0.8rem;
  text-transform: uppercase;
}

.leaderboard-table td {
  padding: 0.9rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.leaderboard-row {
  transition: background 0.2s ease;
}

.leaderboard-row:hover {
  background: rgba(255, 255, 255, 0.015);
}

.rank-cell {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  width: 60px;
}

.rank-1 { color: #ffd700; font-size: 1.3rem; }
.rank-2 { color: #c0c0c0; font-size: 1.2rem; }
.rank-3 { color: #cd7f32; font-size: 1.1rem; }

.name-cell {
  font-weight: 600;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-cell {
  text-align: right;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  color: var(--active-color);
  font-size: 1.05rem;
  text-shadow: 0 0 10px var(--active-glow);
  transition: color 0.8s ease, text-shadow 0.8s ease;
}

.empty-list, .placeholder-row td {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 4rem 0;
  font-style: italic;
}

/* Footer */
footer {
  padding: 2rem 2.5rem;
  border-top: 1px solid var(--border-color);
  max-width: 1400px;
  width: 100%;
  margin: auto auto 0;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.link-item code {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: var(--active-color);
  font-family: monospace;
  transition: color 0.8s ease;
}

/* Animations & Transitions */
header, .arcade-arena, footer {
  transition: opacity 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes scan {
  0% { top: 0%; }
  50% { top: 96%; }
  100% { top: 0%; }
}

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

.animate-fade-in {
  animation: fadeIn 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

/* Celebration Phase Overlay */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 4, 8, 0.96);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.celebration-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.celebration-content {
  text-align: center;
  transform: scale(0.92);
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-width: 650px;
  width: 90%;
  padding: 2rem;
}

.celebration-overlay.active .celebration-content {
  transform: scale(1);
}

.trophy-glow {
  font-size: 6rem;
  margin-bottom: 1rem;
  animation: floatTrophy 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px var(--active-color));
}

.celeb-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(45deg, #fff, var(--active-color), #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px var(--active-glow);
  margin-bottom: 0.4rem;
}

.celeb-game-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--active-color);
  letter-spacing: 2px;
  margin-bottom: 2rem;
  text-shadow: 0 0 10px var(--active-glow);
}

.winner-announcement {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 45px var(--active-glow);
  margin-bottom: 2.5rem;
  position: relative;
  overflow: hidden;
}

.winner-announcement::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--active-color);
  box-shadow: 0 0 15px var(--active-color);
}

.winner-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--text-secondary);
  margin-bottom: 0.8rem;
}

.winner-name {
  font-family: 'Orbitron', sans-serif;
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 0 30px var(--active-glow);
  margin-bottom: 0.6rem;
}

.winner-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1.2rem;
  border-radius: 100px;
  font-size: 0.85rem;
  letter-spacing: 1px;
  font-family: 'Orbitron', sans-serif;
  color: var(--text-secondary);
}

.winner-score-val {
  color: var(--active-color);
  font-weight: 900;
  font-size: 1.05rem;
}

.celeb-countdown {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.celeb-countdown-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.celeb-timer-val {
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  color: var(--active-color);
  text-shadow: 0 0 20px var(--active-glow);
}

@keyframes floatTrophy {
  0% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

/* Responsive Scaling */
@media (max-width: 950px) {
  header {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }
  
  .arena-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-content {
    padding: 2rem;
  }

  .play-section {
    flex-direction: column;
    text-align: center;
  }

  .footer-content {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}
