:root {
  color-scheme: dark;
  --bg: #0f172a;
  --card: #1e293b;
  --muted: #94a3b8;
  --text: #f8fafc;
  --accent: #f59e0b;
  --ok: #10b981;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(circle at top, #1e293b, #0f172a 55%);
  color: var(--text);
  min-height: 100vh;
}

.page {
  max-width: 1360px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: color-mix(in oklab, var(--card) 92%, black);
  border: 1px solid #334155;
  border-radius: 16px;
  padding: 16px;
}

h1, h2, h3, p {
  margin: 0 0 12px;
}

.title {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  text-align: center;
  color: var(--accent);
  margin-bottom: 18px;
}

.hidden {
  display: none !important;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

input, button {
  border-radius: 10px;
  border: 1px solid #475569;
  background: #0f172a;
  color: var(--text);
  padding: 10px 12px;
  font-size: 1rem;
}

button {
  cursor: pointer;
  background: #1d4ed8;
  border-color: #1e40af;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.host-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 3fr 1fr;
}

@media (max-width: 860px) {
  .host-grid {
    grid-template-columns: 1fr;
  }
}

.question-image {
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  border-radius: 12px;
  background: #0b1220;
  border: 1px solid #334155;
}

.slide-stage {
  position: relative;
}

.slide-timer-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  background: rgba(11, 18, 32, 0.9);
  border: 1px solid #64748b;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
}

.lobby-overlay {
  position: absolute;
  left: 24px;
  bottom: 24px;
  max-width: min(520px, calc(100% - 48px));
  background: rgba(11, 18, 32, 0.88);
  border: 1px solid #64748b;
  border-radius: 14px;
  padding: 14px;
  z-index: 4;
}

.lobby-player-list-wrap {
  max-height: 200px;
  overflow: auto;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px;
  background: rgba(2, 6, 23, 0.45);
}

.lobby-player-list {
  margin: 0;
  padding-left: 18px;
}

.lobby-player-list li {
  margin-bottom: 4px;
}

.qr-wrap {
  margin: 10px 0 12px;
  display: flex;
  justify-content: center;
}

.join-qr-image {
  width: 140px;
  height: 140px;
  border-radius: 10px;
  border: 1px solid #64748b;
  background: #fff;
  padding: 6px;
}

.choices {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 640px) {
  .choices {
    grid-template-columns: 1fr;
  }
}

.choice {
  text-align: left;
  font-weight: 700;
  min-height: 110px;
  font-size: 1.25rem;
  background: #334155;
  border: 1px solid #475569;
  color: #f8fafc;
}

.choice.correct {
  background: #064e3b;
  border-color: var(--ok);
}

.choice.correct-glow {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.85), 0 0 24px rgba(16, 185, 129, 0.65);
}

.answer-color-0 {
  background: #e11d48;
  border-color: #be123c;
}

.answer-color-1 {
  background: #2563eb;
  border-color: #1d4ed8;
}

.answer-color-2 {
  background: #ca8a04;
  border-color: #a16207;
}

.answer-color-3 {
  background: #16a34a;
  border-color: #15803d;
}

.host-choice {
  display: grid;
  gap: 8px;
  align-content: center;
  padding: 16px 18px;
}

.host-choice-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.host-choice-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.host-choice-text {
  font-weight: 800;
  font-size: 1.3rem;
}

.host-choice-count {
  min-width: 34px;
  text-align: center;
  border-radius: 999px;
  background: #0b1220;
  border: 1px solid #64748b;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 1.05rem;
}

.host-choice-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #0b1220;
  border: 1px solid #475569;
  overflow: hidden;
}

.host-choice-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22d3ee, #38bdf8);
}

.host-choice.answer-color-0 .host-choice-bar-fill {
  background: linear-gradient(90deg, #fb7185, #f43f5e);
}

.host-choice.answer-color-1 .host-choice-bar-fill {
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
}

.host-choice.answer-color-2 .host-choice-bar-fill {
  background: linear-gradient(90deg, #facc15, #eab308);
}

.host-choice.answer-color-3 .host-choice-bar-fill {
  background: linear-gradient(90deg, #4ade80, #22c55e);
}

.intermission-bar-row {
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.intermission-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.intermission-bar-stats {
  font-weight: 800;
  font-size: 0.9rem;
  background: #0b1220;
  border: 1px solid #64748b;
  border-radius: 999px;
  padding: 3px 8px;
}

.intermission-bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0b1220;
  overflow: hidden;
}

.intermission-bar-fill {
  height: 100%;
}

.intermission-bar-row.answer-color-0 .intermission-bar-fill {
  background: linear-gradient(90deg, #fb7185, #f43f5e);
}

.intermission-bar-row.answer-color-1 .intermission-bar-fill {
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
}

.intermission-bar-row.answer-color-2 .intermission-bar-fill {
  background: linear-gradient(90deg, #facc15, #eab308);
}

.intermission-bar-row.answer-color-3 .intermission-bar-fill {
  background: linear-gradient(90deg, #4ade80, #22c55e);
}

.player-choice-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.shape-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  flex-shrink: 0;
}

.host-choice .shape-icon {
  width: 28px;
  height: 28px;
}

.player-choice-label .shape-icon {
  width: 16px;
  height: 16px;
}

.shape-0 {
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  background: #ffffff;
}

.shape-1 {
  transform: rotate(45deg);
  background: #ffffff;
}

.shape-2 {
  border-radius: 999px;
  background: #ffffff;
}

.shape-3 {
  background: #ffffff;
}

.choice.submitted {
  outline: 2px solid #22d3ee;
}

.meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.leaderboard ol {
  margin: 0;
  padding-left: 20px;
}

.leaderboard li {
  margin-bottom: 8px;
}

.score-chip {
  position: fixed;
  top: 10px;
  right: 10px;
  background: #0b1220;
  border: 1px solid #334155;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
}

.status-banner {
  text-align: center;
  margin: 10px 0 14px;
  color: var(--muted);
}

.timer-wrap {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
}

#timerPulse {
  display: none !important;
}

.timer-pulse {
  width: 92px;
  height: 92px;
  border-radius: 999px;
  border: 3px solid #64748b;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 800;
  background: #0b1220;
}

.timer-pulse.hot {
  border-color: #ef4444;
  animation: pulse 0.65s infinite;
}

.timer-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #0b1220;
  border: 1px solid #334155;
  overflow: hidden;
}

.timer-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #10b981, #22c55e, #f59e0b, #ef4444);
  transform-origin: left;
}

.question-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.editor-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

@media (max-width: 920px) {
  .question-editor {
    grid-template-columns: 1fr;
  }
}

.question-edit-row {
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px;
  background: #0f172a;
}

.question-edit-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.question-thumb {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0b1220;
  margin-bottom: 8px;
}

.image-dropzone {
  position: relative;
  border-radius: 8px;
  margin-bottom: 8px;
  outline: 2px dashed transparent;
  transition: outline-color 120ms ease, background-color 120ms ease;
}

.image-dropzone .question-thumb {
  margin-bottom: 0;
}

.dropzone-hint {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 0.75rem;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #475569;
  border-radius: 999px;
  padding: 3px 8px;
  pointer-events: none;
}

.image-dropzone.dragover {
  outline-color: #22d3ee;
  background: rgba(34, 211, 238, 0.12);
}

.row.tight {
  gap: 6px;
}

.url-input {
  width: 100%;
}

.name-input {
  width: 100%;
}

.other-name-input {
  width: 100%;
  min-width: 130px;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

body.presentation-mode .title,
body.presentation-mode #hostSetupCard,
body.presentation-mode #hostTopMeta,
body.presentation-mode #prompt,
body.presentation-mode #choices,
body.presentation-mode #hostGrid aside,
body.presentation-mode #editorCard,
body.presentation-mode #finalBoard {
  display: none !important;
}

body.presentation-mode .page {
  max-width: 100%;
  padding: 0;
}

body.presentation-mode #hostGrid {
  display: block;
}

body.presentation-mode #hostMainCard {
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 100vh;
  background: #000;
}

body.presentation-mode .slide-stage {
  height: 100vh;
  display: grid;
  place-items: center;
}

body.presentation-mode .question-image {
  width: 100%;
  height: 100vh;
  max-height: none;
  object-fit: contain;
  border: none;
  border-radius: 0;
  background: #000;
}

body.presentation-mode .slide-timer-badge {
  top: 18px;
  right: 18px;
  font-size: 1.3rem;
  padding: 10px 14px;
}

body.lobby-room-mode .title,
body.lobby-room-mode #hostSetupCard,
body.lobby-room-mode #hostTopMeta,
body.lobby-room-mode #prompt,
body.lobby-room-mode #choices,
body.lobby-room-mode #hostGrid aside,
body.lobby-room-mode #editorCard,
body.lobby-room-mode #finalBoard,
body.lobby-room-mode #slideTimerBadge {
  display: none !important;
}

body.lobby-room-mode .page {
  max-width: 100%;
  padding: 0;
}

body.lobby-room-mode .title {
  display: block !important;
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  margin: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

body.lobby-room-mode #hostGrid {
  display: block;
}

body.lobby-room-mode #hostMainCard {
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 100vh;
  background: #000;
}

body.lobby-room-mode .slide-stage {
  height: 100vh;
}

body.lobby-room-mode .question-image {
  width: 100%;
  height: 100vh;
  max-height: none;
  object-fit: cover;
  border: none;
  border-radius: 0;
  background: #000;
}

body.final-mode .title,
body.final-mode #hostGrid,
body.final-mode #hostSetupCard {
  display: none !important;
}

body.final-mode .page {
  max-width: 900px;
  padding-top: 24px;
}

body.final-mode #finalBoard {
  display: block !important;
}
