:root {
  --bg: #0b1220;
  --bg-2: #121c32;
  --card: #17233d;
  --card-2: #1e2d4d;
  --ink: #f5f7fb;
  --muted: #9aa8c2;
  --accent: #e8384f;
  --accent-2: #ff6b6b;
  --green: #2ecc71;
  --red: #e74c3c;
  --gold: #f1c40f;
  --radius: 14px;
  --tile: #2d3d63;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 700px at 50% -10%, #22335c 0%, var(--bg) 55%);
  color: var(--ink);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
}
button:active { transform: scale(0.98); }
button:disabled { cursor: default; opacity: 0.55; }

.center {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  gap: 18px;
}

h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }

.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.snow span {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  animation: fall linear infinite;
}
@keyframes fall {
  from { transform: translateY(-10px); }
  to { transform: translateY(105vh); }
}

.btn {
  padding: 14px 22px;
  font-weight: 700;
  font-size: 17px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow: 0 6px 0 #a82336;
}
.btn.secondary { background: var(--card-2); box-shadow: 0 6px 0 #0d172b; }
.btn:active { box-shadow: 0 2px 0 #a82336; }
.btn.secondary:active { box-shadow: 0 2px 0 #0d172b; }

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  text-align: left;
}
.field label { color: var(--muted); font-size: 14px; }
.field input, .field select, .field textarea {
  padding: 14px 16px;
  font-size: 18px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #2c3d63;
  border-radius: var(--radius);
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent-2); }
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  text-align: center;
  font-weight: 800;
  font-size: 30px !important;
}

.error { color: #ffb3b3; font-size: 15px; min-height: 20px; }
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- host ---------- */
.host { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: rgba(11, 18, 32, 0.7);
  border-bottom: 1px solid #223152;
}
.brand { font-weight: 900; letter-spacing: 0.02em; font-size: 20px; }
.brand .dot { color: var(--accent-2); }
.stage { flex: 1; display: flex; flex-direction: column; padding: 22px 30px 30px; gap: 18px; }
.kicker { color: var(--muted); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; font-size: 13px; }
.prompt { font-size: clamp(26px, 3.4vw, 46px); font-weight: 850; }
.timerbar { height: 14px; border-radius: 999px; background: #1b2745; overflow: hidden; }
.timerbar > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); transition: width 0.2s linear; }

.qbody { flex: 1; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 24px; min-height: 0; }
.qbody.no-image { grid-template-columns: 1fr; }
.qimage {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
}
.qimage img { max-width: 100%; max-height: 46vh; object-fit: contain; display: block; }
.qimage .placeholder { color: #45557a; font-size: 70px; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; }
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--tile);
  font-size: 22px;
  font-weight: 700;
  text-align: left;
}
.option.correct { background: var(--green); }
.option .letter { background: rgba(255,255,255,0.14); border-radius: 10px; width: 42px; height: 42px; display: grid; place-items: center; flex: none; }
.options.cols-1 { grid-template-columns: 1fr; }
.options.cols-2 { grid-template-columns: 1fr 1fr; }
.options.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.options.cols-4 { grid-template-columns: 1fr 1fr; }

.answer-list { display: flex; flex-direction: column; gap: 10px; font-size: 20px; }
.answer-list li { list-style: none; padding: 16px 20px; border-radius: 12px; background: var(--tile); }
.answer-list li.tall { font-size: 17px; }

.lobby { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 30px; align-items: center; padding: 10px 20px; }
.join-card { background: var(--card); border-radius: 20px; padding: 30px; text-align: center; }
.qr { background: #fff; padding: 14px; border-radius: 16px; width: 300px; height: 300px; margin: 0 auto; }
.qr img { width: 100%; height: 100%; display: block; }
.join-url { font-size: 22px; font-weight: 700; margin-top: 18px; word-break: break-all; }
.join-code { font-size: 46px; font-weight: 900; letter-spacing: 0.14em; margin-top: 10px; color: var(--gold); }
.players-wall { display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; }
.players-wall span { padding: 10px 16px; border-radius: 999px; background: var(--card-2); font-weight: 700; font-size: 18px; }

.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.leaderboard .row { display: flex; align-items: center; gap: 14px; padding: 12px 18px; background: var(--card); border-radius: 12px; font-size: 20px; font-weight: 700; }
.leaderboard .row .pos { color: var(--gold); width: 28px; text-align: right; }
.leaderboard .row .score { margin-left: auto; color: var(--muted); }
.leaderboard .row:nth-child(1) { background: linear-gradient(90deg, #3a2f0b, var(--card)); }
.leaderboard .move { font-size: 15px; font-weight: 900; }
.leaderboard .move.up { color: var(--green); }
.leaderboard .move.down { color: var(--red); }

/* Reveal layout: question, answers, then the leaderboard, all within one screen. */
.reveal { display: grid; grid-template-columns: 1.1fr 0.9fr; grid-template-rows: auto auto 1fr; gap: 8px 20px; }
.reveal .rhead { grid-column: 1 / -1; }
.reveal .rprompt { grid-column: 1 / -1; font-size: clamp(18px, 2vw, 30px); font-weight: 850; }
.reveal .qimage { grid-row: 3; min-height: 0; }
.reveal .qimage img { max-height: 36vh; max-width: 100%; }
.reveal .qside { display: flex; flex-direction: column; gap: 8px; min-height: 0; grid-row: 3; }
.reveal .option { padding: 11px 16px; font-size: 17px; }
.reveal .options { gap: 8px; }
.reveal .answers-block { grid-column: 1 / -1; }
.reveal .answer-list { font-size: 15px; gap: 4px; display: grid; grid-template-columns: 1fr 1fr; }
.reveal .answer-list li { padding: 7px 12px; }
.reveal .lb-block { grid-column: 1 / -1; }
.reveal .leaderboard { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.reveal .leaderboard .row { padding: 7px 13px; font-size: 16px; }
.reveal .leaderboard .row:nth-child(1) { background: linear-gradient(90deg, #3a2f0b, var(--card)); }
.reveal .kicker { font-size: 11px; }

.big-verdict { font-size: 40px; font-weight: 900; }
.controls { display: flex; gap: 14px; align-items: center; }
.controls .spacer { flex: 1; }
.meta { color: var(--muted); font-size: 15px; }
.players-count { font-weight: 800; }

/* ---------- player ---------- */
.player { min-height: 100vh; display: flex; flex-direction: column; }
.pstage { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 16px 14px 22px; }
.pheader { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.pprompt { font-size: 21px; font-weight: 800; line-height: 1.3; }
.pimage img { width: 100%; max-height: 26vh; object-fit: contain; border-radius: 12px; background: var(--card); display: block; }
.answers { display: flex; flex-direction: column; gap: 10px; }
.ansbtn {
  padding: 18px 18px;
  border-radius: 14px;
  background: var(--tile);
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
}
.ansbtn.selected { outline: 3px solid var(--gold); }
.ansbtn.green { background: var(--green); }
.ansbtn.red { background: var(--red); }
.ansbtn .letter { background: rgba(255,255,255,0.14); border-radius: 10px; width: 34px; height: 34px; display: grid; place-items: center; flex: none; font-size: 16px; }

.orderlist { display: flex; flex-direction: column; gap: 10px; }
.orderitem { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 12px; padding: 12px; }
.orderitem .num { width: 30px; text-align: center; font-weight: 900; color: var(--gold); }
.orderitem .label { flex: 1; font-weight: 700; }
.orderitem.fixed .label { padding: 8px 0; }
.orderitem button { width: 44px; height: 44px; border-radius: 10px; background: var(--tile); font-size: 20px; font-weight: 900; }

.tfrow { display: flex; gap: 12px; }
.tfrow .ansbtn { flex: 1; justify-content: center; font-size: 22px; }

.typeform { display: flex; flex-direction: column; gap: 10px; }
.typeform input { font-size: 20px; }

.status-card { background: var(--card); border-radius: 16px; padding: 18px; text-align: center; }
.scoreline { display: flex; justify-content: space-between; color: var(--muted); font-weight: 700; font-size: 14px; }
.rank { font-size: 34px; font-weight: 900; }
.waiting { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-weight: 700; padding: 18px; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--accent-2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.flash { position: fixed; inset: 0; display: grid; place-items: center; font-size: 70px; font-weight: 900; pointer-events: none; animation: flash 1s ease forwards; z-index: 50; }
.flash.good { color: var(--green); }
.flash.bad { color: var(--red); }
@keyframes flash { 0% { opacity: 0; transform: scale(0.7); } 20% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.1); } }

@media (max-width: 860px) {
  .lobby { grid-template-columns: 1fr; }
  .qbody { grid-template-columns: 1fr; }
  .qr { width: 220px; height: 220px; }
}
