:root {
  --bg-color: #0b0f19;
  --bg-gradient: radial-gradient(circle at 50% 10%, #1e293b 0%, #0b0f19 80%);
  --panel-bg: rgba(18, 24, 38, 0.85);
  --panel-border: rgba(255, 255, 255, 0.1);
  --primary: #22c55e;
  --primary-glow: rgba(34, 197, 94, 0.4);
  --danger: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --gold: #ffd700;
  --silver: #e2e8f0;
  --bronze: #cd7f32;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
}

/* HEADER ESPECTADOR */
.spec-header {
  height: 64px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-logo {
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.room-pin-display {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pin-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.pin-code {
  font-size: 1.1rem;
  font-weight: 900;
  color: #38bdf8;
  letter-spacing: 1.5px;
}

.match-info-badge {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #4ade80;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 800;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 4px 12px;
  border-radius: 20px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 10px #4ade80; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* VISTAS */
.spec-view {
  display: none;
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.spec-view.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease;
}

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

.glass-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* PIN ENTRY */
.pin-entry-card {
  max-width: 480px;
  margin: 80px auto;
  padding: 40px;
  text-align: center;
}

.pin-entry-card h1 {
  font-size: 1.8rem;
  margin-bottom: 12px;
  color: #38bdf8;
}

.pin-entry-card p {
  color: var(--text-muted);
  margin-bottom: 28px;
}

#spec-pin-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#spec-input-pin {
  background: rgba(30, 41, 59, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.15);
  padding: 16px;
  border-radius: 14px;
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  color: #38bdf8;
  letter-spacing: 4px;
  outline: none;
  transition: all 0.2s ease;
}

#spec-input-pin:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}

.btn-join-spec {
  background: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  color: #0b0f19;
  border: none;
  padding: 16px;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-join-spec:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.4);
}

.error-msg {
  color: #f87171;
  margin-top: 14px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* LOBBY ESPECTADOR */
.spec-lobby-hero {
  max-width: 600px;
  margin: 60px auto;
  padding: 40px;
  text-align: center;
}

.spec-lobby-top {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #38bdf8;
  margin-bottom: 20px;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  background: #38bdf8;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.spec-hero-title {
  font-size: 1.8rem;
  margin-bottom: 12px;
}

.spec-hero-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 30px;
}

.spec-players-counter {
  display: inline-flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  padding: 16px 28px;
  border-radius: 16px;
}

.counter-val {
  font-size: 2.5rem;
  font-weight: 900;
  color: #4ade80;
}

.counter-tag {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* CUENTA REGRESIVA */
.countdown-hero {
  max-width: 480px;
  margin: 80px auto;
  padding: 50px 30px;
  text-align: center;
}

.countdown-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.25) 0%, rgba(15, 23, 42, 0.8) 100%);
  border: 4px solid #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  box-shadow: 0 0 40px rgba(56, 189, 248, 0.4);
}

.countdown-giant-number {
  font-size: 4rem;
  font-weight: 900;
  color: #ffffff;
}

/* TABLA EN VIVO */
.game-top-bar {
  padding: 12px 24px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.spec-stats {
  display: flex;
  gap: 20px;
  font-size: 0.95rem;
}

.text-green { color: #4ade80; }
.text-red { color: #f87171; }

.spec-leaderboard-container {
  display: flex;
  flex-direction: column;
}

.spec-leaderboard-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.spec-card {
  background: rgba(18, 24, 38, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-left: 5px solid var(--p-color, #38bdf8);
  transition: transform 0.2s ease;
}

.spec-card:hover {
  transform: translateY(-2px);
}

.spec-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spec-card-rank {
  font-size: 1.1rem;
  font-weight: 900;
  width: 32px;
  text-align: center;
}

.spec-card-avatar {
  font-size: 1.6rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.spec-card-name {
  font-size: 1rem;
  font-weight: 800;
  color: #ffffff;
}

.spec-card-action {
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 2px;
}

.spec-card-action.running { color: #4ade80; }
.spec-card-action.jumping { color: #38bdf8; }
.spec-card-action.ducking { color: #fbbf24; }
.spec-card-action.crashed { color: #f87171; }

.spec-card-right {
  text-align: right;
}

.spec-card-score {
  font-size: 1.3rem;
  font-weight: 900;
  font-family: monospace;
  color: #4ade80;
}

.spec-card-dist {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* PODIO */
.podium-container {
  padding: 30px;
  text-align: center;
}

.podium-header-meta {
  margin-bottom: 12px;
}

.podium-match-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #38bdf8;
}

.podium-match-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.podium-heading {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 24px;
  background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.podium-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  margin: 30px 0;
  min-height: 280px;
}

.podium-pillar {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 140px;
}

.winner-avatar {
  font-size: 2.2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  background: #1e293b;
}

.winner-name {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.winner-score {
  font-size: 0.95rem;
  font-weight: 800;
  color: #4ade80;
  margin-bottom: 12px;
  font-family: monospace;
}

.step {
  width: 100%;
  border-radius: 16px 16px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
  font-weight: 900;
}

.step-1 { height: 160px; background: linear-gradient(180deg, #ffd700 0%, #b8860b 100%); color: #000; }
.step-2 { height: 120px; background: linear-gradient(180deg, #e2e8f0 0%, #64748b 100%); color: #000; }
.step-3 { height: 90px; background: linear-gradient(180deg, #cd7f32 0%, #8b4513 100%); color: #fff; }

.crown { font-size: 1.8rem; margin-bottom: -10px; }
.medal { font-size: 1.5rem; }
.step-num { font-size: 1.8rem; }

/* TABLA GENERAL */
.full-leaderboard-box {
  margin-top: 30px;
  background: rgba(15, 23, 42, 0.7);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--panel-border);
}

.full-leaderboard-box h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: #38bdf8;
}

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

.leaderboard-table th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-bottom: 1px solid var(--panel-border);
}

.leaderboard-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.95rem;
}

.status-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-chip.alive { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.status-chip.crashed { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}
