/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --bg2: #1a1a2e;
  --bg3: #25254a;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --accent: #feca57;
  --accent2: #ff6b6b;
  --green: #1dd1a1;
  --red: #ee5a24;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

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

/* ── Screens ── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── Typography ── */
.game-title {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -1px;
}
.game-title-sm { font-size: 2rem; font-weight: 900; }
.accent { color: var(--accent); }
.subtitle { color: var(--text-dim); font-size: 1.1rem; margin-top: 0.5rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border: 2px solid var(--bg3);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.btn:hover { background: var(--bg3); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-large { padding: 1rem 2rem; font-size: 1.2rem; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-accent { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-accent:hover { background: #ffe066; }
.btn-sub { font-size: 0.75rem; font-weight: 400; opacity: 0.7; margin-top: 0.2rem; }

/* ── Landing ── */
.landing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}
.landing-buttons {
  display: flex;
  gap: 1.5rem;
  margin-top: 2.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.btn-host { border-color: var(--accent); }
.btn-player { border-color: var(--green); }

/* ── Host Lobby ── */
.host-body .screen { padding: 2rem; }
.host-header { text-align: center; margin-bottom: 1.5rem; }

.lobby-layout {
  display: flex;
  gap: 3rem;
  flex: 1;
  align-items: flex-start;
}

.lobby-join-info {
  flex: 0 0 320px;
  text-align: center;
  background: var(--bg2);
  padding: 2rem;
  border-radius: var(--radius);
  border: 2px solid var(--bg3);
}
.join-label { color: var(--text-dim); font-size: 1.1rem; margin-bottom: 0.25rem; }
.join-url { font-size: 1.3rem; font-weight: 700; color: var(--accent); word-break: break-all; }
.lobby-code-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 1.5rem;
  padding: 1.5rem;
  background: var(--bg3);
  border-radius: var(--radius);
}
.code-label { font-size: 0.85rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; }
.code {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: 8px;
  color: var(--accent);
  font-family: 'Courier New', monospace;
}

.qr-container {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.qr-container img {
  width: 180px;
  height: 180px;
  border-radius: var(--radius-sm);
}
.qr-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.lobby-players-area { flex: 1; }
.lobby-players-area h2 { margin-bottom: 1rem; }
.player-count { color: var(--text-dim); font-weight: 400; }

.player-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.player-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--player-color);
}
.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #000;
  flex-shrink: 0;
}
.player-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  color: #000;
  flex-shrink: 0;
}
.player-name { font-weight: 600; flex: 1; }
.btn-kick {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.player-card:hover .btn-kick { opacity: 1; }
.btn-kick:hover { color: var(--red); background: rgba(238, 90, 36, 0.15); }

.lobby-actions { text-align: center; padding: 2rem 0; }

/* ── Phase: Creating ── */
.phase-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
}
.phase-subtitle { color: var(--text-dim); margin-top: 0.5rem; font-size: 1.2rem; }
.progress-ring-container { margin: 3rem 0; }
.progress-big {
  font-size: 5rem;
  font-weight: 900;
  line-height: 1;
}
.progress-num { color: var(--accent); }
.progress-sep { color: var(--text-dim); margin: 0 0.25rem; }
.progress-den { color: var(--text-dim); }
.progress-ring-container p { color: var(--text-dim); margin-top: 0.5rem; font-size: 1.1rem; }

/* ── Phase: Answering (Host) ── */
.question-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90vh;
  padding: 2rem;
  text-align: center;
}
.question-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.question-counter {
  background: var(--bg3);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.question-author { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; }
.author-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.question-text { font-size: 2rem; max-width: 700px; margin-bottom: 2rem; line-height: 1.3; }

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
  max-width: 700px;
}
.option-box {
  padding: 1.5rem;
  border-radius: var(--radius);
  font-size: 1.3rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
}
.option-letter {
  font-weight: 900;
  font-size: 1.5rem;
  opacity: 0.5;
  flex-shrink: 0;
}

.option-color-0 { background: #c0392b; }
.option-color-1 { background: #2980b9; }
.option-color-2 { background: #27ae60; }
.option-color-3 { background: #f39c12; }

.answering-status { margin-top: 2rem; }
.answer-progress {
  font-size: 1.3rem;
  color: var(--text-dim);
  background: var(--bg2);
  padding: 0.5rem 1.5rem;
  border-radius: 20px;
}

/* ── Question Results (Host) ── */
.results-container {
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.results-meta {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg2);
  border-radius: 20px;
  font-size: 0.95rem;
}
.badge-assigned { border: 1px solid var(--accent); }
.badge-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.results-options { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2rem; }
.result-option {
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--bg3);
}
.result-option.correct { border-color: var(--green); }
.result-option.wrong { opacity: 0.7; }
.result-option-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
}
.correct-badge { color: var(--green); margin-left: auto; font-size: 0.95rem; }
.result-voters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1.25rem 1rem;
}
.voter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  background: var(--bg3);
  border-radius: 20px;
  font-size: 0.85rem;
}
.voter-assigned {
  border: 1px solid var(--accent);
  background: rgba(254, 202, 87, 0.1);
}
.voter-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.round-scores { margin-bottom: 2rem; }
.round-scores h3 { margin-bottom: 0.75rem; color: var(--text-dim); font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; }
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}
.score-row:nth-child(even) { background: var(--bg2); }
.score-player { display: flex; align-items: center; gap: 0.5rem; }
.score-pts { font-weight: 700; font-size: 1.1rem; }
.score-pts.positive { color: var(--green); }
.score-pts.negative { color: var(--red); }

.results-actions { text-align: center; padding: 1rem 0; }

/* ── Game Over ── */
.gameover-container {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gameover-container h1 { font-size: 3rem; margin-bottom: 2rem; }

.rankings { width: 100%; margin-bottom: 2rem; }
.rank-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  background: var(--bg2);
}
.rank-first {
  background: linear-gradient(135deg, rgba(254,202,87,0.15), rgba(254,202,87,0.05));
  border: 1px solid var(--accent);
  font-size: 1.1rem;
  padding: 1rem;
}
.rank-pos { font-weight: 900; color: var(--text-dim); min-width: 2.5rem; }
.rank-first .rank-pos { color: var(--accent); }
.rank-player { display: flex; align-items: center; gap: 0.5rem; flex: 1; font-weight: 600; }
.rank-score { font-weight: 700; }

.special-questions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  width: 100%;
  margin-bottom: 2rem;
}
.special-q {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.special-q h3 { margin-bottom: 0.75rem; font-size: 1rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); }
#best-question { border: 1px solid var(--green); }
#best-question h3 { color: var(--green); }
#worst-question { border: 1px solid var(--red); }
#worst-question h3 { color: var(--red); }
.sq-question { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; font-style: italic; }
.sq-meta { color: var(--text-dim); font-size: 0.9rem; }

.gameover-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* ═══════════════════════════════
   PLAYER (PHONE) STYLES
   ═══════════════════════════════ */

.player-body .screen {
  justify-content: flex-start;
}

.player-container {
  padding: 1.5rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.player-container.center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
}

.waiting-icon { font-size: 4rem; margin-bottom: 1rem; }
.waiting-text { color: var(--text-dim); margin-top: 0.5rem; }

.player-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding: 1rem;
  background: var(--bg2);
  border-radius: var(--radius);
  font-weight: 600;
}

/* ── Join form ── */
.join-form {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.join-form label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.5rem;
}
.join-form input[type="text"] {
  padding: 0.85rem 1rem;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}
#input-name { text-transform: none; }
.join-form input:focus { border-color: var(--accent); }

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  padding: 0.5rem 0;
}
.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.color-swatch.selected { border-color: #fff; transform: scale(1.15); }
.color-swatch:hover { transform: scale(1.1); }

.error-msg { color: var(--red); text-align: center; min-height: 1.5rem; margin-top: 0.5rem; }

/* ── Create question ── */
.assigned-banner {
  text-align: center;
  padding: 1.5rem;
  background: var(--bg2);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  border: 1px solid var(--bg3);
}
.assigned-banner p:first-child { color: var(--text-dim); margin-bottom: 0.5rem; }
.assigned-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 800;
}
.assigned-hint { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.5rem; }

.question-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.question-form label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.question-form textarea {
  padding: 0.85rem 1rem;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  resize: vertical;
  outline: none;
  font-family: inherit;
}
.question-form textarea:focus { border-color: var(--accent); }

.option-hint { font-weight: 400; font-size: 0.8rem; color: var(--text-dim); text-transform: none; letter-spacing: 0; }

.option-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.option-input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: var(--bg2);
  border: 2px solid var(--bg3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  font-family: inherit;
}
.option-input:focus { border-color: var(--accent); }

.btn-correct {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--bg3);
  background: var(--bg2);
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-correct:hover { border-color: var(--green); color: var(--green); }
.btn-correct.selected {
  background: var(--green);
  border-color: var(--green);
  color: #000;
}

/* ── Answer options (player) ── */
.answer-header { text-align: center; margin-bottom: 1rem; padding-top: 1rem; }

.answer-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.btn-answer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s;
}
.btn-answer:active { transform: scale(0.97); }

/* ── Player game over ── */
.final-rank { text-align: center; }
.rank-big { font-size: 5rem; font-weight: 900; color: var(--accent); }
.rank-score-big { font-size: 1.5rem; color: var(--text-dim); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .lobby-layout { flex-direction: column; gap: 1.5rem; }
  .lobby-join-info { flex: auto; width: 100%; }
  .code { font-size: 3rem; }
  .game-title { font-size: 2.2rem; }
  .question-text { font-size: 1.4rem; }
  .options-grid { grid-template-columns: 1fr; }
  .special-questions { grid-template-columns: 1fr; }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.screen.active { animation: fadeIn 0.3s ease; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.progress-big { animation: pulse 2s ease infinite; }
