:root {
  --bg: #14032b;
  --bg2: #3a0b4a;
  --gold: #ffc94d;
  --gold2: #ff9f1c;
  --text: #fff8ec;
  --muted: #d9c6ea;
  --card: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 201, 77, 0.28);
  --o0: #e8590c;
  --o1: #c2255c;
  --o2: #1c7ed6;
  --o3: #2b8a3e;
  --ok: #2fb344;
  --bad: #e03131;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255, 159, 28, 0.25), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(194, 37, 92, 0.3), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

/* twinkling lamp lights along the top */
.sky {
  position: fixed; inset: 0 0 auto 0; height: 60px; pointer-events: none; z-index: 0;
  background:
    radial-gradient(circle at 5% 30%, #ffd166 0 3px, transparent 4px),
    radial-gradient(circle at 18% 60%, #ff9f1c 0 3px, transparent 4px),
    radial-gradient(circle at 31% 25%, #ffd166 0 3px, transparent 4px),
    radial-gradient(circle at 44% 65%, #ff4d6d 0 3px, transparent 4px),
    radial-gradient(circle at 57% 30%, #ffd166 0 3px, transparent 4px),
    radial-gradient(circle at 70% 60%, #ff9f1c 0 3px, transparent 4px),
    radial-gradient(circle at 83% 25%, #ffd166 0 3px, transparent 4px),
    radial-gradient(circle at 96% 60%, #ff4d6d 0 3px, transparent 4px);
  filter: drop-shadow(0 0 6px #ffc94d);
  animation: twinkle 2.4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.55; } to { opacity: 1; } }

.app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 32px 24px; display: flex; flex-direction: column; gap: 20px; }
.center { align-items: center; justify-content: center; text-align: center; }

h1, h2, h3 { margin: 0; line-height: 1.15; }
h1 { font-size: clamp(2rem, 5vw, 3.6rem); }
.title {
  background: linear-gradient(90deg, var(--gold), var(--gold2), #ff4d6d);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand { font-size: clamp(3rem, 8vw, 5.5rem); filter: drop-shadow(0 0 18px rgba(255, 180, 60, 0.8)); animation: flicker 3s ease-in-out infinite; }
@keyframes flicker { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06) rotate(-2deg); } }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
code { background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 6px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; backdrop-filter: blur(6px); }

/* buttons */
.btn {
  font: inherit; font-weight: 600; border: 0; cursor: pointer; border-radius: 12px;
  padding: 12px 22px; color: var(--text); background: rgba(255,255,255,0.12);
  transition: transform .1s, filter .15s, opacity .15s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #3a0b4a; box-shadow: 0 6px 24px rgba(255, 159, 28, 0.35); }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.btn-danger { background: transparent; border: 1px solid rgba(224,49,49,0.6); color: #ffb3b3; }
.btn-lg { font-size: 1.3rem; padding: 16px 34px; }
.btn-sm { font-size: 0.9rem; padding: 8px 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }

/* forms */
.form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.input {
  font: inherit; font-size: 1.3rem; text-align: center; padding: 14px; border-radius: 12px;
  border: 2px solid var(--border); background: rgba(0,0,0,0.25); color: var(--text); width: 100%;
}
.input:focus { outline: none; border-color: var(--gold); }
.input.code-input { font-size: 2rem; letter-spacing: 0.3em; font-weight: 700; }
.error { color: #ffb3b3; min-height: 1.4em; margin: 0; }

.pill { background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; font-weight: 600; }

/* ── Host: lobby ─────────────────────────────────────────── */
.lobby-top { display: flex; gap: 32px; align-items: center; justify-content: center; flex-wrap: wrap; }
.join-info { text-align: center; }
.join-url { font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 700; color: var(--gold); }
.code {
  font-size: clamp(3.5rem, 10vw, 7.5rem); font-weight: 800; letter-spacing: 0.08em; line-height: 1;
  background: #fff8ec; color: #3a0b4a; border-radius: 20px; padding: 12px 32px; margin-top: 8px;
  box-shadow: 0 0 0 6px rgba(255,201,77,0.4), 0 10px 40px rgba(0,0,0,0.4);
}
.qr { background: #fff; border-radius: 16px; padding: 10px; line-height: 0; }
.qr img { width: 210px; height: 210px; image-rendering: pixelated; }
.lobby-bar { display: flex; justify-content: space-between; align-items: center; font-size: 1.5rem; font-weight: 700; gap: 16px; flex-wrap: wrap; }
.player-chips { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-content: flex-start; }
.chip {
  font: inherit; font-size: 1.25rem; font-weight: 600; color: var(--text); cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 8px 18px;
  animation: pop .35s cubic-bezier(.2,1.6,.4,1);
}
.chip:hover { border-color: var(--bad); text-decoration: line-through; }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.waiting { font-size: 1.3rem; opacity: 0.8; animation: twinkle 1.5s ease-in-out infinite alternate; }

/* ── Host: question ──────────────────────────────────────── */
.q-top { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.q-top .spacer { flex: 1; }
.q-text {
  font-size: clamp(1.6rem, 3.6vw, 3rem); text-align: center; background: #fff8ec; color: #2a0838;
  border-radius: var(--radius); padding: 24px 28px; box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.q-img { max-height: 32vh; max-width: 100%; align-self: center; border-radius: var(--radius); }
.q-middle { display: flex; align-items: center; justify-content: center; gap: 24px; }
.timer {
  width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center;
  font-size: 3rem; font-weight: 800; color: #3a0b4a;
  background: radial-gradient(circle, var(--gold), var(--gold2));
  box-shadow: 0 0 30px rgba(255, 159, 28, 0.6);
}
.timer.low { background: radial-gradient(circle, #ff8787, var(--bad)); color: #fff; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.timebar { height: 10px; border-radius: 999px; background: rgba(255,255,255,0.12); overflow: hidden; }
.timebar > div { height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); transition: width .1s linear; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.option {
  display: flex; align-items: center; gap: 16px; border-radius: var(--radius); padding: 22px 24px;
  font-size: clamp(1.2rem, 2.4vw, 2rem); font-weight: 700; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  box-shadow: 0 6px 0 rgba(0,0,0,0.25); transition: opacity .3s, transform .3s;
}
.option .icon { font-size: 1.4em; flex-shrink: 0; }
.opt-0 { background: var(--o0); }
.opt-1 { background: var(--o1); }
.opt-2 { background: var(--o2); }
.opt-3 { background: var(--o3); }
.option.dim { opacity: 0.3; }
.option.correct { outline: 5px solid #fff; transform: scale(1.02); }
.option .tick { margin-left: auto; font-size: 1.3em; }

/* reveal bars */
.bars { display: flex; justify-content: center; align-items: flex-end; gap: 24px; height: clamp(110px, 20vh, 220px); }
.bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; width: 90px; gap: 6px; }
.bar-col.dim { opacity: 0.4; }
.bar { width: 100%; border-radius: 10px 10px 4px 4px; min-height: 8px; transition: height .8s cubic-bezier(.2,.8,.2,1); }
.bar-count { font-weight: 800; font-size: 1.5rem; }
.bar-label { font-size: 1.6rem; }
.fact { text-align: center; font-size: 1.2rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 20px; margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: auto; }

/* leaderboard */
.board { width: 100%; max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.board-row {
  display: flex; align-items: center; gap: 18px; padding: 16px 24px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border); font-size: clamp(1.2rem, 2.4vw, 1.8rem); font-weight: 700;
  animation: slideIn .5s both;
}
.board-row:nth-child(1) { background: linear-gradient(90deg, rgba(255,201,77,0.35), rgba(255,201,77,0.08)); }
.board-row .rank { width: 2.2em; color: var(--gold); }
.board-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .gain { font-size: 0.7em; color: #8ce99a; }
@keyframes slideIn { from { transform: translateX(-40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 16px; margin-top: 20px; }
.step { width: min(28vw, 240px); display: flex; flex-direction: column; align-items: center; gap: 8px; animation: rise .8s both; }
.step .who { font-size: clamp(1.1rem, 2.4vw, 1.9rem); font-weight: 800; text-align: center; word-break: break-word; }
.step .pts { color: var(--muted); font-weight: 600; }
.step .block { width: 100%; border-radius: 14px 14px 0 0; display: grid; place-items: center; font-size: 3rem; font-weight: 800; color: #3a0b4a; }
.step.p1 .block { height: 240px; background: linear-gradient(var(--gold), var(--gold2)); }
.step.p2 .block { height: 170px; background: linear-gradient(#e9ecef, #adb5bd); }
.step.p3 .block { height: 120px; background: linear-gradient(#f4a261, #b5651d); }
.step.p1 { animation-delay: .6s; } .step.p2 { animation-delay: .3s; }
@keyframes rise { from { transform: translateY(80px); opacity: 0; } to { transform: none; opacity: 1; } }

.fireworks { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 0; }

.fs-btn { position: fixed; right: 14px; bottom: 14px; z-index: 5; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: rgba(0,0,0,0.35); color: var(--text); font-size: 1.2rem; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); z-index: 10;
  background: #2a0838; border: 1px solid var(--border); padding: 12px 20px; border-radius: 12px;
  transition: transform .3s; max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

.spinner { width: 48px; height: 48px; border-radius: 50%; border: 5px solid rgba(255,255,255,0.15); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Player (phone) ──────────────────────────────────────── */
.player .screen { padding: 16px; max-width: 640px; gap: 14px; }
.phead { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: rgba(0,0,0,0.3); border-bottom: 1px solid var(--border); font-weight: 700; position: relative; z-index: 1; }
.phead .pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.phead .pscore { color: var(--gold); }
.ptop { display: flex; justify-content: space-between; align-items: center; }
.ptimer { font-weight: 800; font-size: 1.3rem; color: var(--gold); }
.pq { font-size: 1.15rem; font-weight: 600; text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.player-options { flex: 1; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr; min-height: 55vh; }
.player-options.n2 { grid-template-columns: 1fr; }
.player-options .option { flex-direction: column; justify-content: center; text-align: center; font-size: 1.15rem; padding: 14px 10px; border: 0; cursor: pointer; font-family: inherit; gap: 8px; }
.player-options .option .icon { font-size: 2.6rem; }
.player-options .option:active { transform: scale(0.96); }
.player-options .option:disabled { opacity: 0.5; cursor: default; }
.big-emoji { font-size: 5rem; line-height: 1; }
.result { border-radius: 20px; padding: 28px 20px; width: 100%; }
.result.good { background: linear-gradient(135deg, #2fb344, #1b7a2c); }
.result.bad { background: linear-gradient(135deg, #e03131, #9c1c1c); }
.result.none { background: linear-gradient(135deg, #6c5a80, #3d2f52); }
.result h2 { font-size: 2.2rem; margin: 8px 0; }
.points { font-size: 1.8rem; font-weight: 800; }
.locked-choice { display: inline-flex; gap: 10px; align-items: center; padding: 12px 20px; border-radius: 12px; font-weight: 700; font-size: 1.2rem; }

@media (max-width: 700px) {
  .options:not(.player-options) { grid-template-columns: 1fr; }
  .bars { gap: 10px; }
  .bar-col { width: 60px; }
}

/* landing */
.landing-links { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
