/* ═══════════════════════════════════════════
   Song Quiz Battle — Styles
   ═══════════════════════════════════════════ */

:root {
  --bg-deep: #060914;
  --bg-card: rgba(15, 20, 50, 0.85);
  --bg-card-border: rgba(120, 130, 255, 0.15);
  --accent-1: #7c5cfc;
  --accent-2: #00d4ff;
  --accent-gradient: linear-gradient(135deg, var(--accent-1), var(--accent-2));
  --text-primary: #eef0ff;
  --text-secondary: rgba(200, 210, 255, 0.65);
  --text-dim: rgba(200, 210, 255, 0.35);
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --gold: #fbbf24;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(124, 92, 252, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(0, 212, 255, 0.06) 0%, transparent 50%);
}

/* ═══ Utility ═══ */
.hidden { display: none !important; }
.accent-text { background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* ═══ Screens ═══ */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
  padding: 20px;
}
.screen.active { opacity: 1; pointer-events: auto; }

/* ═══ Glass Card ═══ */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  padding: 40px;
  width: 100%;
  max-width: 440px;
}

/* ═══ Buttons ═══ */
.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 15px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 92, 252, 0.3);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 6px 30px rgba(124, 92, 252, 0.5); transform: translateY(-1px); }

.btn-secondary {
  background: rgba(124, 92, 252, 0.15);
  color: var(--accent-2);
  border: 1px solid rgba(124, 92, 252, 0.3);
}
.btn-secondary:hover:not(:disabled) { background: rgba(124, 92, 252, 0.25); }

.btn-large { padding: 18px 36px; font-size: 17px; width: 100%; }

/* ═══ JOIN SCREEN ═══ */
.join-container { text-align: center; }

.logo { margin-bottom: 36px; }
.logo-icon { font-size: 48px; display: block; margin-bottom: 8px; animation: float 3s ease-in-out infinite; }
.logo h1 { font-size: 32px; font-weight: 900; line-height: 1.1; }

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

.join-form input {
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-card-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}
.join-form input:focus { border-color: var(--accent-1); }
.join-form input::placeholder { color: var(--text-dim); }

#player-name { margin-bottom: 20px; text-align: center; font-weight: 600; }

.join-buttons { display: flex; flex-direction: column; gap: 14px; }
.join-buttons .btn-primary { width: 100%; }
.join-divider { text-align: center; color: var(--text-dim); font-size: 13px; text-transform: uppercase; letter-spacing: 2px; }

.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; text-align: center; font-weight: 700; letter-spacing: 4px; text-transform: uppercase; }
.join-row .btn { flex-shrink: 0; }

.error-text { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 20px; }

/* ═══ LOBBY ═══ */
.lobby-container { text-align: center; }
.lobby-container h2 { font-size: 28px; margin-bottom: 4px; }
.lobby-hint { color: var(--text-secondary); font-size: 14px; margin-bottom: 32px; }

.lobby-players { display: flex; align-items: center; justify-content: center; gap: 24px; margin-bottom: 32px; }

.lobby-player { text-align: center; min-width: 100px; }
.player-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 22px;
  margin: 0 auto 8px;
  box-shadow: 0 4px 16px rgba(124, 92, 252, 0.3);
}
.lobby-player .player-name { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.lobby-player.joined .player-name { color: var(--text-primary); }

.lobby-vs { font-weight: 900; font-size: 24px; color: var(--text-dim); }

/* ═══ ROUND INTRO ═══ */
#screen-round-intro { background: var(--bg-deep); }

.round-intro-content { text-align: center; }

.round-badge {
  font-size: 52px; font-weight: 900;
  background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: scaleIn 0.5s ease-out;
  margin-bottom: 12px;
}
.round-points-display, .round-points {
  font-size: 22px; font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

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


/* ═══ PLAYING SCREEN ═══ */
.playing-header {
  position: absolute; top: 20px; left: 20px; right: 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.round-label { font-weight: 700; font-size: 14px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

.scoreboard-mini { display: flex; gap: 8px; }
.score-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}
.score-pill .score-name { color: var(--text-secondary); font-weight: 600; }
.score-pill .score-val { font-weight: 900; color: var(--accent-2); }

/* Timer */
.timer-container { position: relative; width: 120px; height: 120px; margin-bottom: 20px; }
.timer-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: rgba(255, 255, 255, 0.06); stroke-width: 6; }
.timer-ring {
  fill: none;
  stroke: var(--success);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 339.292;
  stroke-dashoffset: 0;
  transition: stroke 0.5s;
}
.timer-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; font-weight: 900;
}

/* Visualizer */
.visualizer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 48px;
  margin-bottom: 28px;
}
.viz-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--accent-gradient);
  transition: height 0.05s linear;
  min-height: 3px;
}

/* Options */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 500px;
}

.option-btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  padding: 16px 12px;
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  line-height: 1.3;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--accent-1);
  background: rgba(124, 92, 252, 0.12);
  transform: translateY(-2px);
}
.option-btn:active:not(:disabled) { transform: scale(0.97); }
.option-btn:disabled { cursor: not-allowed; opacity: 0.6; }

.option-btn.selected {
  border-color: var(--accent-1);
  background: rgba(124, 92, 252, 0.2);
  box-shadow: 0 0 20px rgba(124, 92, 252, 0.3);
  animation: lockIn 0.3s ease-out;
}
.option-btn.correct {
  border-color: var(--success);
  background: rgba(34, 197, 94, 0.2);
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}
.option-btn.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.15);
}

@keyframes lockIn {
  0% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Opponent status */
.opponent-status {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: 50px;
  background: rgba(124, 92, 252, 0.15);
  border: 1px solid rgba(124, 92, 252, 0.3);
  font-size: 13px; font-weight: 600;
  color: var(--accent-2);
  animation: slideUp 0.3s ease-out;
  white-space: nowrap;
}
.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ═══ ROUND RESULT ═══ */
.result-container { text-align: center; width: 100%; max-width: 500px; }

.result-header { margin-bottom: 28px; }
.result-round { font-size: 14px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.result-label { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; }
.result-song { font-size: 22px; font-weight: 900; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.result-players { display: flex; gap: 16px; margin-bottom: 24px; }
.result-player {
  flex: 1;
  padding: 20px 16px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
}
.result-player-name { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.result-player-answer {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.result-player-answer.correct { color: var(--success); }
.result-player-answer.wrong { color: var(--danger); }

.result-player-points {
  font-size: 32px; font-weight: 900;
  margin-bottom: 4px;
}
.result-player-points.positive { color: var(--success); }
.result-player-points.negative { color: var(--danger); }
.result-player-points.zero { color: var(--text-dim); }


.result-player-total { font-size: 13px; color: var(--text-secondary); }

/* Reactions */
.reaction-bar {
  display: flex; justify-content: center; gap: 10px;
  margin-top: 8px;
}
.reaction-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  font-size: 22px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.reaction-btn:hover { transform: scale(1.2); background: rgba(255, 255, 255, 0.1); }
.reaction-btn:active { transform: scale(0.9); }

#floating-reactions {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 100;
}
.floating-emoji {
  position: absolute;
  font-size: 40px;
  animation: floatEmoji 1.5s ease-out forwards;
  pointer-events: none;
}
@keyframes floatEmoji {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-120px) scale(1.5); }
}

/* ═══ SUDDEN DEATH ═══ */
#screen-sudden-death {
  background:
    radial-gradient(ellipse at 50% 50%, rgba(239, 68, 68, 0.1) 0%, transparent 60%),
    var(--bg-deep);
}

.sd-header { text-align: center; margin-bottom: 20px; }
.sd-badge {
  font-size: 36px; font-weight: 900;
  color: var(--danger);
  text-shadow: 0 0 40px rgba(239, 68, 68, 0.5);
  animation: sdPulse 1s ease-in-out infinite;
}
.sd-hint { color: var(--text-secondary); font-size: 14px; margin-top: 8px; }
.sd-ring { stroke: var(--danger) !important; }

@keyframes sdPulse {
  0%, 100% { text-shadow: 0 0 40px rgba(239, 68, 68, 0.5); }
  50% { text-shadow: 0 0 60px rgba(239, 68, 68, 0.8); }
}

/* ═══ GAME OVER ═══ */
#screen-gameover { position: relative; }
.gameover-container { text-align: center; z-index: 2; position: relative; }

.gameover-crown {
  font-size: 64px;
  animation: crownBounce 0.6s ease-out;
  margin-bottom: 12px;
}
@keyframes crownBounce {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.3) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.gameover-title { font-size: 28px; font-weight: 900; margin-bottom: 32px; }

.gameover-scores { display: flex; gap: 16px; margin-bottom: 32px; max-width: 440px; }
.gameover-player {
  flex: 1;
  padding: 24px 16px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
}
.gameover-player.winner { border-color: var(--gold); box-shadow: 0 0 30px rgba(251, 191, 36, 0.15); }
.gameover-name { font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.gameover-score { font-size: 40px; font-weight: 900; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 8px; }
.gameover-rounds { font-size: 12px; color: var(--text-dim); }

#confetti-canvas {
  position: absolute; inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* Connection Status Pill */
.connection-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
}

.connection-status-pill .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.connection-status-pill.connecting {
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warning);
}
.connection-status-pill.connecting .status-dot {
  background: var(--warning);
  animation: pulse 1s ease-in-out infinite;
}

.connection-status-pill.connected {
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--success);
}
.connection-status-pill.connected .status-dot {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.connection-status-pill.disconnected {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}
.connection-status-pill.disconnected .status-dot {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

/* ═══ How to Play Section ═══ */
.how-to-play-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, transform 0.2s ease;
  user-select: none;
}
.how-to-play-toggle:hover {
  color: var(--accent-2);
  transform: translateY(-1px);
}
.how-to-play-toggle .info-icon {
  font-size: 16px;
  transition: transform 0.3s ease;
  display: inline-block;
}
.how-to-play-toggle.active .info-icon {
  transform: rotate(180deg);
}

.how-to-play-content {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  text-align: left;
  animation: slideDown 0.3s ease-out;
}

.rule-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.rule-item:last-child {
  margin-bottom: 0;
}
.rule-emoji {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1.2;
}
.rule-item p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
}
.rule-item strong {
  color: var(--accent-2);
}

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

/* ═══ Responsive ═══ */
@media (max-width: 540px) {
  .glass-card { padding: 28px 20px; }
  .logo h1 { font-size: 26px; }
  .round-badge { font-size: 40px; }
  .options-grid { grid-template-columns: 1fr; }
  .option-btn { min-height: 48px; padding: 12px; font-size: 13px; }
  .result-players { flex-direction: column; }
  .gameover-scores { flex-direction: column; }
  .timer-container { width: 100px; height: 100px; }
  .timer-text { font-size: 28px; }
  .result-song { font-size: 18px; }
  .sd-badge { font-size: 28px; }
}
