/* ═══════════════════════════════════════════════════════════════════
   QUIZZ PARTY — Styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Themes ── */
:root, [data-theme="default"] {
  --primary: #6c5ce7;
  --primary-light: #a29bfe;
  --secondary: #00cec9;
  --bg: #0a0a1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #25254a;
  --text: #f0f0f0;
  --text-muted: #a0a0b8;
  --success: #00b894;
  --danger: #e17055;
  --warning: #fdcb6e;
  --option-a: #e74c3c;
  --option-b: #3498db;
  --option-c: #f39c12;
  --option-d: #2ecc71;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
}
[data-theme="ocean"] {
  --primary: #0984e3; --primary-light: #74b9ff; --bg: #041c32; --bg-card: #04293a; --bg-card-hover: #064663;
}
[data-theme="sunset"] {
  --primary: #e17055; --primary-light: #fab1a0; --secondary: #fdcb6e; --bg: #2d1b0e; --bg-card: #3d2317; --bg-card-hover: #4d2d1f;
}
[data-theme="forest"] {
  --primary: #00b894; --primary-light: #55efc4; --bg: #0a1f0a; --bg-card: #1a3a1a; --bg-card-hover: #2a4a2a;
}
[data-theme="neon"] {
  --primary: #fd79a8; --primary-light: #e84393; --secondary: #a29bfe; --bg: #0a0a0a; --bg-card: #1a0a1a; --bg-card-hover: #2a1a2a;
}
[data-theme="dark"] {
  --primary: #636e72; --primary-light: #b2bec3; --bg: #0d0d0d; --bg-card: #1a1a1a; --bg-card-hover: #2a2a2a;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* ── Animations ── */
.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes bounceIn { 0% { transform: scale(0); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }

.bounce-dot {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--primary); margin: 0 6px;
  animation: bounceDot 1.4s infinite ease-in-out;
}
.bounce-dot:nth-child(2) { animation-delay: 0.2s; }
.bounce-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounceDot { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-20px); } }

/* ── Logo ── */
.logo { font-size: 2.5rem; font-weight: 800; text-align: center; margin-bottom: 0.5rem; }
.tagline { text-align: center; color: var(--text-muted); font-size: 1.1rem; margin-bottom: 2rem; }

/* ── Home Cards ── */
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  background: var(--bg-card); border-radius: var(--radius); padding: 2.5rem 1.5rem;
  transition: all 0.3s; cursor: pointer; border: 2px solid transparent;
  box-shadow: var(--shadow);
}
.card:hover { background: var(--bg-card-hover); transform: translateY(-4px); border-color: var(--primary); }
.card-icon { font-size: 3rem; margin-bottom: 1rem; }
.card h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.card p { color: var(--text-muted); font-size: 0.9rem; }

/* ── Buttons ── */
.btn {
  display: inline-block; padding: 0.8rem 2rem; border: none; border-radius: 12px;
  font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
  text-align: center;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { filter: brightness(1.15); transform: translateY(-2px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--bg-card-hover); color: var(--text); border: 1px dashed var(--text-muted); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-large { width: 100%; padding: 1rem; font-size: 1.2rem; margin-top: 1.5rem; }
.btn-danger { background: var(--danger); color: white; }

/* ── Forms ── */
label { display: block; font-weight: 600; margin: 1rem 0 0.4rem; font-size: 0.95rem; }
.input-full, .input-pin, .input-small, select {
  width: 100%; padding: 0.75rem 1rem; border: 2px solid var(--bg-card-hover);
  border-radius: 12px; background: var(--bg-card); color: var(--text);
  font-size: 1rem; outline: none; transition: border-color 0.2s;
}
.input-full:focus, .input-pin:focus, select:focus { border-color: var(--primary); }
.input-pin { font-size: 2.5rem; text-align: center; letter-spacing: 1rem; font-weight: 800; }
.input-small { width: 100px; text-align: center; }
select option { background: var(--bg-card); }

/* ── Theme Picker ── */
.theme-picker { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.theme-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent;
  cursor: pointer; transition: all 0.2s;
}
.theme-btn.active, .theme-btn:hover { border-color: white; transform: scale(1.15); }

/* ── Questions Editor ── */
.questions-section { margin-top: 2rem; }
.questions-section h2 { margin-bottom: 1rem; }
.question-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 1.5rem;
  margin-bottom: 1rem; border-left: 4px solid var(--primary); position: relative;
}
.question-card .q-number { font-weight: 800; color: var(--primary); margin-bottom: 0.8rem; display: block; }
.question-card input[type="text"] {
  width: 100%; padding: 0.6rem 0.8rem; background: var(--bg); border: 1px solid var(--bg-card-hover);
  border-radius: 8px; color: var(--text); font-size: 0.95rem; margin-bottom: 0.4rem; outline: none;
}
.question-card input[type="text"]:focus { border-color: var(--primary); }
.options-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-top: 0.5rem; }
.option-row { display: flex; align-items: center; gap: 0.5rem; }
.option-row .color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.option-row input[type="radio"] { accent-color: var(--success); }
.btn-remove-q {
  position: absolute; top: 0.8rem; right: 0.8rem; background: none; border: none;
  color: var(--danger); cursor: pointer; font-size: 1.2rem; opacity: 0.6;
}
.btn-remove-q:hover { opacity: 1; }

/* ── Lobby ── */
.lobby-info { text-align: center; margin-bottom: 2rem; }
.pin-display { margin-bottom: 1.5rem; }
.pin-label { display: block; font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; }
.pin-value { font-size: 4rem; font-weight: 900; letter-spacing: 0.5rem; color: var(--primary-light); }
.qr-display { margin: 1.5rem auto; max-width: 200px; }
.qr-display svg { width: 100%; height: auto; }
.lobby-url { color: var(--text-muted); font-size: 0.85rem; word-break: break-all; }

.players-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.8rem; margin-top: 1rem;
}
.player-chip {
  background: var(--bg-card); padding: 0.8rem; border-radius: 12px;
  text-align: center; font-weight: 600; animation: bounceIn 0.4s;
}
.player-card {
  background: var(--bg-card); padding: 0.8rem 1rem; border-radius: 12px;
  display: flex; align-items: center; gap: 0.6rem; font-weight: 600;
  position: relative; animation: bounceIn 0.4s;
}
.player-avatar {
  width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: white; flex-shrink: 0;
}
.btn-kick {
  position: absolute; top: 4px; right: 6px; background: none; border: none;
  color: var(--text-muted); font-size: 1.3rem; cursor: pointer; padding: 2px 6px;
  border-radius: 50%; line-height: 1; opacity: 0; transition: all 0.2s;
}
.player-card:hover .btn-kick { opacity: 1; }
.btn-kick:hover { color: #ff7675; background: rgba(255,118,117,0.15); }

/* ── Game: Host ── */
.game-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem;
}
.q-counter { font-weight: 700; font-size: 1.1rem; color: var(--text-muted); }
.answer-count { font-size: 1rem; color: var(--text-muted); background: var(--bg-card); padding: 0.4rem 1rem; border-radius: 20px; }

/* Timer ring */
.timer-ring { width: 80px; height: 80px; position: relative; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: var(--bg-card); stroke-width: 6; }
.timer-fg { fill: none; stroke: var(--primary); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 283; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear, stroke 0.3s; }
.timer-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 800;
}

/* ── Question Display ── */
.question-display { text-align: center; }
.question-display h2 { font-size: 1.8rem; margin-bottom: 2rem; }
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.option-btn {
  padding: 1.5rem; border: none; border-radius: var(--radius); font-size: 1.2rem;
  font-weight: 700; color: white; cursor: pointer; transition: all 0.2s;
  text-align: center; min-height: 80px; display: flex; align-items: center; justify-content: center;
}
.option-btn:nth-child(1) { background: var(--option-a); }
.option-btn:nth-child(2) { background: var(--option-b); }
.option-btn:nth-child(3) { background: var(--option-c); }
.option-btn:nth-child(4) { background: var(--option-d); }
.option-btn:hover { filter: brightness(1.1); transform: scale(1.03); }
.option-btn:active { transform: scale(0.97); }
.option-btn.selected { outline: 4px solid white; outline-offset: -4px; }
.option-btn.correct { outline: 4px solid var(--success); outline-offset: -4px; animation: pulse 0.5s; }
.option-btn.wrong { opacity: 0.4; }
.option-btn:disabled { cursor: default; }

.host-options .option-btn { cursor: default; }
.host-options .option-btn:hover { filter: none; transform: none; }

.host-option {
  padding: 1rem 1.2rem; background: var(--bg-card); border-radius: var(--radius);
  font-size: 1.1rem; font-weight: 600; color: var(--text); transition: all 0.2s;
}
.host-option.host-correct {
  background: rgba(46, 204, 113, 0.2); outline: 3px solid var(--success);
  outline-offset: -3px;
}

.checkbox-row {
  display: flex; align-items: center; gap: 0.6rem; margin-top: 0.8rem;
}
.checkbox-row input[type="checkbox"] {
  width: 1.2rem; height: 1.2rem; accent-color: var(--primary); cursor: pointer;
}
.checkbox-row label { cursor: pointer; font-size: 0.95rem; color: var(--text); }

/* ── Timer Bar (player) ── */
.timer-bar-container {
  margin-top: 1.5rem; height: 8px; background: var(--bg-card); border-radius: 4px; overflow: hidden;
}
.timer-bar { height: 100%; background: var(--primary); transition: width 1s linear; width: 100%; }
.timer-bar.urgent { background: var(--danger); }

/* ── Feedback ── */
.feedback-screen { text-align: center; padding: 3rem 1rem; }
.feedback-icon { font-size: 5rem; display: block; margin-bottom: 1rem; animation: bounceIn 0.5s; }
.feedback-screen h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.feedback-screen.correct { }
.feedback-screen.wrong { }

/* ── Score Badge ── */
.score-badge { background: var(--primary); padding: 0.4rem 1rem; border-radius: 20px; font-weight: 700; }

/* ── Leaderboard ── */
.leaderboard { margin: 1.5rem 0; }
.lb-row {
  display: flex; align-items: center; padding: 0.9rem 1.2rem;
  background: var(--bg-card); border-radius: 12px; margin-bottom: 0.5rem;
  animation: fadeIn 0.3s ease-out;
}
.lb-row.top-1 { background: linear-gradient(90deg, rgba(255,215,0,0.2), var(--bg-card)); border-left: 4px solid gold; }
.lb-row.top-2 { background: linear-gradient(90deg, rgba(192,192,192,0.15), var(--bg-card)); border-left: 4px solid silver; }
.lb-row.top-3 { background: linear-gradient(90deg, rgba(205,127,50,0.15), var(--bg-card)); border-left: 4px solid #cd7f32; }
.lb-rank { font-weight: 900; font-size: 1.3rem; width: 40px; text-align: center; }
.lb-name { flex: 1; font-weight: 600; margin-left: 0.8rem; }
.lb-score { font-weight: 700; color: var(--primary-light); }

/* ── Results ── */
.results-title { text-align: center; font-size: 1.8rem; margin-bottom: 1rem; }
.correct-answer {
  text-align: center; background: rgba(0,184,148,0.15); border: 2px solid var(--success);
  border-radius: 12px; padding: 1rem; margin-bottom: 1.5rem; font-weight: 600; font-size: 1.1rem;
}

/* ── Final / Podium ── */
.final-title { text-align: center; font-size: 2.5rem; margin-bottom: 2rem; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 1rem; margin-bottom: 2rem; }
.podium-slot { text-align: center; border-radius: var(--radius) var(--radius) 0 0; }
.podium-slot .podium-name { font-weight: 700; margin-bottom: 0.5rem; }
.podium-slot .podium-score { font-size: 0.85rem; color: var(--text-muted); }
.podium-bar { border-radius: var(--radius) var(--radius) 0 0; width: 100px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 1rem 0.5rem; }
.podium-1 .podium-bar { height: 180px; background: linear-gradient(to top, rgba(255,215,0,0.3), rgba(255,215,0,0.1)); }
.podium-2 .podium-bar { height: 140px; background: linear-gradient(to top, rgba(192,192,192,0.3), rgba(192,192,192,0.1)); }
.podium-3 .podium-bar { height: 100px; background: linear-gradient(to top, rgba(205,127,50,0.3), rgba(205,127,50,0.1)); }
.podium-medal { font-size: 2.5rem; }

/* ── Player specific ── */
.player-name-badge {
  display: inline-block; background: var(--primary); padding: 0.4rem 1.5rem;
  border-radius: 20px; font-weight: 700; font-size: 1.1rem;
}
.play-question { text-align: center; font-size: 1.4rem; margin-bottom: 1.5rem; }
.final-rank { text-align: center; font-size: 1.5rem; margin-bottom: 1.5rem; }
.final-rank strong { color: var(--primary-light); font-size: 2rem; }

/* ── Waiting ── */
.waiting-screen { text-align: center; padding: 3rem 0; }
.waiting-screen h1 { margin-bottom: 2rem; }
.waiting-text { color: var(--text-muted); margin: 1.5rem 0; }

/* ── Join ── */
.join-form { max-width: 400px; margin: 0 auto; }
.error-msg { color: var(--danger); font-size: 0.9rem; min-height: 1.5rem; margin-top: 0.5rem; }
.back-link { display: block; text-align: center; margin-top: 2rem; color: var(--text-muted); }
.back-link:hover { color: var(--primary-light); }

/* ── Host Controls ── */
.host-controls {
  display: flex; gap: 0.8rem; justify-content: center; margin-top: 2rem;
}
.btn-control {
  padding: 0.8rem 1.5rem; border-radius: 12px; font-size: 1rem;
  font-weight: 600; cursor: pointer; border: 2px solid; transition: all 0.2s;
}
.btn-pause { background: rgba(253,203,110,0.25); color: #fdcb6e; border-color: #fdcb6e; }
.btn-pause:hover { background: rgba(253,203,110,0.45); }
.btn-stop { background: rgba(225,112,85,0.25); color: #ff7675; border-color: #ff7675; }
.btn-stop:hover { background: rgba(225,112,85,0.45); }
.btn-quit { background: rgba(180,180,200,0.2); color: #dfe6e9; border-color: #b2bec3; }
.btn-quit:hover { background: rgba(180,180,200,0.4); }

.pause-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.pause-box {
  background: var(--bg-card); border-radius: var(--radius); padding: 3rem;
  text-align: center; max-width: 400px; animation: bounceIn 0.4s;
}
.pause-icon { font-size: 4rem; display: block; margin-bottom: 1rem; }
.pause-box h2 { margin-bottom: 0.5rem; }
.pause-box p { color: var(--text-muted); margin-bottom: 1.5rem; }

.results-actions { margin-top: 1.5rem; text-align: center; }
.results-controls { display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }
.results-controls .btn-control { font-size: 1rem; padding: 0.8rem 1.5rem; }

/* ── Footer ── */
.home-footer { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-top: 2rem; }

.use-cases { margin-top: 2.5rem; text-align: center; }
.use-cases h2 { font-size: 1.4rem; margin-bottom: 0.6rem; }
.use-cases > p { color: var(--text-muted); font-size: 0.95rem; max-width: 600px; margin: 0 auto 1.5rem; line-height: 1.5; }
.use-case-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.use-case-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 1.3rem;
  text-align: center; transition: transform 0.2s, background 0.2s;
}
.use-case-card:hover { transform: translateY(-3px); background: var(--bg-card-hover); }
.use-case-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.use-case-card h3 { font-size: 1rem; margin-bottom: 0.4rem; }
.use-case-card p { color: var(--text-muted); font-size: 0.82rem; line-height: 1.4; }

/* ── AI Section ── */
.ai-section {
  background: var(--bg-card); border-radius: var(--radius); padding: 1.5rem;
  margin-top: 2rem; border: 2px solid var(--primary); position: relative; overflow: hidden;
}
.ai-section::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary, var(--primary-light)), var(--primary));
  background-size: 200% 100%; animation: shimmer 2s infinite linear;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.ai-section h2 { margin-bottom: 1rem; }
.ai-key-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.ai-key-row input { flex: 1; }
.ai-key-status { font-size: 0.85rem; color: var(--success); min-height: 1.3rem; margin-bottom: 0.5rem; }
.ai-key-status.error { color: var(--danger); }
.ai-gen-row { }
.theme-input-group { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.5rem; }
.ai-options-row { display: flex; gap: 1rem; margin: 0.5rem 0; }
.ai-options-row > div { flex: 1; }
.ai-options-row select { width: 100%; }
.btn-ai {
  background: linear-gradient(135deg, var(--primary), var(--secondary, var(--primary-light)));
  color: white; border: none; font-weight: 700;
}
.btn-ai:hover { filter: brightness(1.1); transform: translateY(-2px); }
.btn-ai:disabled { opacity: 0.6; cursor: wait; transform: none; filter: none; }
.ai-error { color: var(--danger); font-size: 0.9rem; min-height: 1.3rem; margin-top: 0.5rem; }

.spinner {
  display: inline-block; width: 18px; height: 18px; border: 3px solid rgba(255,255,255,0.3);
  border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite;
  vertical-align: middle; margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.separator {
  display: flex; align-items: center; margin: 2rem 0; gap: 1rem; color: var(--text-muted);
}
.separator::before, .separator::after {
  content: ''; flex: 1; height: 1px; background: var(--bg-card-hover);
}
.separator span { font-size: 0.9rem; white-space: nowrap; }

/* ── Sound Toggle ── */
.sound-toggle {
  position: fixed; top: 1rem; right: 1rem; background: var(--bg-card); border: none;
  color: var(--text); font-size: 1.5rem; width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; z-index: 100; display: flex; align-items: center; justify-content: center;
}
.sound-toggle:hover { background: var(--bg-card-hover); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .card-grid { grid-template-columns: 1fr; }
  .options-grid { grid-template-columns: 1fr; }
  .logo { font-size: 2rem; }
  .pin-value { font-size: 3rem; }
  .question-display h2 { font-size: 1.3rem; }
  .option-btn { font-size: 1rem; min-height: 60px; padding: 1rem; }
  .podium-bar { width: 80px; }
}
