* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a;
  color: white;
}

button, input { font: inherit; }

.app {
  width: min(520px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.back-link { color: #93c5fd; text-decoration: none; font-weight: 700; }
.status { font-size: 13px; color: #94a3b8; }

.screen { display: none; }
.screen.active { display: block; }

h1 { margin: 16px 0 8px; font-size: 52px; line-height: 1; }
h2 { margin: 24px 0 14px; font-size: 28px; }

.subtitle, .hint { color: #cbd5e1; line-height: 1.5; }

label {
  display: block;
  margin-top: 22px;
  color: #cbd5e1;
  font-weight: 700;
}

input {
  width: 100%;
  margin-top: 8px;
  padding: 16px;
  border: 1px solid #334155;
  border-radius: 16px;
  background: #020617;
  color: white;
  outline: none;
  font-size: 18px;
}

input:focus { border-color: #93c5fd; }

button {
  width: 100%;
  margin-top: 18px;
  padding: 16px 18px;
  border: 0;
  border-radius: 16px;
  background: #2563eb;
  color: white;
  font-weight: 800;
  font-size: 18px;
  cursor: pointer;
}

button:active { transform: scale(0.99); }
button.secondary { background: #1e293b; }
button:disabled { opacity: 0.45; cursor: default; }

.divider { margin: 26px 0 6px; text-align: center; color: #64748b; }

.error { min-height: 24px; color: #fca5a5; font-weight: 700; }

/* ROOM CODE */
.room-code-box {
  padding: 22px;
  border-radius: 22px;
  background: #1e293b;
  border: 1px solid #334155;
  text-align: center;
}

.room-code-box span { display: block; color: #94a3b8; margin-bottom: 8px; }
.room-code-box strong { font-size: 44px; letter-spacing: 0.18em; }

/* PLAYER LIST (lobby) */
.player-list { list-style: none; padding: 0; margin: 0; }

.player-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #1e293b;
}

.player-list small { color: #94a3b8; }

.kick-btn {
  width: auto;
  margin-top: 0;
  padding: 2px 10px;
  font-size: 18px;
  line-height: 1;
  background: #991b1b;
  border-radius: 6px;
  color: #fca5a5;
  cursor: pointer;
}

/* PHASE INFO */
.phase-info {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.phase-info span {
  padding: 4px 10px;
  border-radius: 20px;
  background: #1e293b;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 700;
}

/* TIMER */
.timer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.timer-bar-wrap {
  flex: 1;
  height: 8px;
  background: #1e293b;
  border-radius: 4px;
  overflow: hidden;
}

.timer-bar {
  height: 100%;
  background: #2563eb;
  border-radius: 4px;
  transition: width 0.25s linear, background 0.5s;
  width: 100%;
}

.timer-bar.urgent { background: #dc2626; }

.timer-num {
  font-size: 22px;
  font-weight: 800;
  min-width: 32px;
  text-align: right;
  color: #93c5fd;
}

.timer-num.urgent { color: #fca5a5; }

/* QUESTION */
.question-text {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 22px;
}

.question-text.small { font-size: 17px; margin-bottom: 14px; }

/* ANSWER GRID */
.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.answer-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid #334155;
  border-radius: 16px;
  background: #1e293b;
  color: white;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 0;
  transition: border-color 0.15s, background 0.15s;
}

.answer-btn .letter {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #334155;
  color: #93c5fd;
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.answer-btn:hover:not(:disabled) {
  border-color: #2563eb;
  background: #1e3a8a;
}

.answer-btn.selected {
  border-color: #2563eb;
  background: #1e3a8a;
}

.answer-btn.selected .letter {
  background: #2563eb;
  color: white;
}

.answer-btn:disabled { opacity: 0.5; cursor: default; }

/* REVEAL answer grid */
.answer-grid.reveal .answer-btn { cursor: default; }

.answer-btn.wrong-selected {
  border-color: #dc2626;
  background: #450a0a;
  opacity: 1 !important;
}

.answer-btn.wrong-selected .letter {
  background: #dc2626;
  color: white;
}

.answer-btn.correct {
  border-color: #16a34a;
  background: #14532d;
  opacity: 1 !important;
}

.answer-btn.correct .letter {
  background: #16a34a;
  color: white;
}

.answer-btn.wrong {
  opacity: 0.4;
}

.answered-count {
  color: #64748b;
  font-size: 14px;
  text-align: center;
  margin: 0;
}

/* PLAYER RESULTS (reveal) */
.player-results {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
}

.player-results li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #1e293b;
  font-size: 15px;
}

.player-results .pr-name { flex: 1; font-weight: 700; }
.player-results .pr-answer { color: #94a3b8; }
.player-results .pr-correct { color: #4ade80; font-weight: 800; }
.player-results .pr-wrong { color: #f87171; font-weight: 800; }
.player-results .pr-points { margin-left: auto; font-weight: 800; color: #93c5fd; min-width: 40px; text-align: right; }
.pr-speed { font-size: 13px; }

.point-adjust {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.point-adjust button {
  width: 28px;
  height: 28px;
  margin-top: 0;
  padding: 0;
  font-size: 16px;
  border-radius: 6px;
  font-weight: 800;
  line-height: 1;
}

.point-adjust .btn-minus { background: #7f1d1d; color: #fca5a5; }
.point-adjust .btn-plus { background: #14532d; color: #4ade80; }

/* REVEAL ACTIONS */
.reveal-actions { margin-top: 14px; }

/* AUTO-ADVANCE BAR */
.auto-advance {
  margin-top: 12px;
  height: 4px;
  background: #1e293b;
  border-radius: 2px;
  overflow: hidden;
}

.auto-bar {
  height: 100%;
  background: #334155;
  border-radius: 2px;
  width: 100%;
  transition: width 0.25s linear;
}

/* ROUND SELECTOR (lobby) */
.config-label {
  color: #cbd5e1;
  font-weight: 700;
  margin: 22px 0 10px;
}

.config-btns {
  display: flex;
  gap: 8px;
}

.config-btn {
  flex: 1;
  margin-top: 0;
  padding: 12px 8px;
  font-size: 16px;
  background: #1e293b;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
}

.config-btn.active {
  border-color: #2563eb;
  background: #1e3a8a;
}

/* CATEGORY SELECT */
.category-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px 0;
}

.category-btn {
  padding: 20px 24px;
  border: 2px solid #334155;
  border-radius: 18px;
  background: #1e293b;
  color: white;
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  margin-top: 0;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
}

.category-btn:hover:not(:disabled) {
  border-color: #2563eb;
  background: #1e3a8a;
}

.category-btn:disabled { opacity: 0.45; cursor: default; }

/* RANKING */
.ranking-list { list-style: none; padding: 0; margin: 0; }

.ranking-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid #1e293b;
  font-size: 18px;
}

.rank-pos {
  width: 36px;
  font-weight: 800;
  font-size: 22px;
  color: #64748b;
  text-align: center;
}

.rank-pos.gold { color: #fbbf24; }
.rank-pos.silver { color: #94a3b8; }
.rank-pos.bronze { color: #b45309; }

.rank-name { flex: 1; font-weight: 700; }
.rank-score { font-weight: 800; color: #93c5fd; font-size: 20px; }

/* FINAL INTRO */
.final-intro {
  margin-top: 40px;
  text-align: center;
}

.final-badge {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 30px;
  background: linear-gradient(135deg, #f59e0b, #dc2626);
  color: white;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}

/* WINNER */
.winner-box {
  padding: 28px;
  border-radius: 22px;
  background: radial-gradient(circle at top left, #1d4ed8, transparent 50%), #1e293b;
  border: 1px solid #334155;
  text-align: center;
  margin-bottom: 24px;
}

.winner-box .winner-label {
  color: #93c5fd;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 13px;
}

.winner-box .winner-name {
  display: block;
  font-size: 40px;
  font-weight: 800;
  margin-top: 10px;
}

.winner-box .winner-score {
  display: block;
  color: #cbd5e1;
  margin-top: 6px;
}