:root {
  --bg: #f5f4fa;
  --surface: #ffffff;
  --surface-2: #f0eef8;
  --text: #1c1a29;
  --muted: #676480;
  --border: #e2dfee;
  --primary: #5b3fd6;
  --primary-hover: #4a30c0;
  --primary-ink: #ffffff;
  --danger: #d0353c;
  --ok: #1d9a52;
  --warn: #b26b00;
  --stage-a: #24155f;
  --stage-b: #4a2ab0;
  --c0: #e5484d; --c1: #3e63dd; --c2: #e09b13; --c3: #2a9d5c; --c4: #8e4ec6; --c5: #0f9aa5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 10, 60, .06), 0 6px 20px rgba(20, 10, 60, .08);
  --font: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14121d; --surface: #1d1a2a; --surface-2: #262236; --text: #ecebf5; --muted: #a29fba;
    --border: #322d47; --primary: #7c62f0; --primary-hover: #8f78f5; --shadow: 0 6px 20px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14121d; --surface: #1d1a2a; --surface-2: #262236; --text: #ecebf5; --muted: #a29fba;
  --border: #322d47; --primary: #7c62f0; --primary-hover: #8f78f5; --shadow: 0 6px 20px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--primary); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px;
  padding: 10px 16px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--text);
  transition: background .15s, transform .05s, opacity .15s; text-decoration: none; white-space: nowrap; min-height: 42px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.lg { padding: 14px 24px; font-size: 1.1rem; min-height: 54px; border-radius: 12px; }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: .9rem; }
.btn.icon { padding: 0; width: 38px; min-height: 38px; }
.input, select.input, textarea.input { width: 100%; background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; outline: none; transition: border-color .15s; }
.input:focus { border-color: var(--primary); }
label.field { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1c1a29; color: #fff; padding: 12px 18px;
  border-radius: 12px; box-shadow: var(--shadow); z-index: 1000; max-width: calc(100% - 32px); font-weight: 500; animation: pop .2s ease-out; }
.toast.err { background: var(--danger); }
@keyframes pop { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ---------- stage (game screens) */
body.stage { background: linear-gradient(160deg, var(--stage-a), var(--stage-b)); color: #fff; min-height: 100%; background-attachment: fixed; }
body.stage .btn:not(.primary):not(.ans) { background: rgba(255,255,255,.14); color: #fff; }
body.stage .btn:not(.primary):not(.ans):hover { background: rgba(255,255,255,.22); }
body.stage .btn.primary { background: #fff; color: var(--stage-b); }
body.stage .btn.primary:hover:not(:disabled) { background: #ece7ff; }
body.stage .muted { color: rgba(255,255,255,.72); }
.brand { font-weight: 800; letter-spacing: -.02em; font-size: 1.4rem; }
.brand span { color: #ffd166; }
body:not(.stage) .brand span { color: var(--primary); }

.card { background: var(--surface); color: var(--text); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
body.stage .card { box-shadow: 0 10px 40px rgba(0,0,0,.25); }

/* ---------- answer tiles */
.opt-c0 { --oc: var(--c0); } .opt-c1 { --oc: var(--c1); } .opt-c2 { --oc: var(--c2); }
.opt-c3 { --oc: var(--c3); } .opt-c4 { --oc: var(--c4); } .opt-c5 { --oc: var(--c5); }
.shape { width: 1.6em; height: 1.6em; flex: none; fill: currentColor; }
.ans { background: var(--oc); color: #fff; border: 0; border-radius: 12px; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; font-weight: 700; font-size: 1.1rem; text-align: left; cursor: pointer; min-height: 72px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.18); transition: transform .08s, filter .15s, opacity .2s; word-break: break-word; position: relative; }
.ans:active { transform: scale(.98); }
.ans .ans-img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; background: rgba(255,255,255,.2); }
.ans.sel { outline: 4px solid #fff; outline-offset: -4px; }
.ans .tick { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; background: rgba(255,255,255,.3);
  display: grid; place-items: center; font-size: 15px; }
.ans.sel .tick { background: #fff; color: var(--oc); }
.ans.dim { opacity: .3; filter: saturate(.5); }
.answers { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.answers.n3, .answers.n5 { grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .answers.long { grid-template-columns: 1fr; } }

/* ---------- player */
.player { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.p-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 12px; }
.p-main { flex: 1; display: flex; flex-direction: column; padding: 0 16px 16px; gap: 14px; width: 100%; max-width: 760px; margin: 0 auto; }
.p-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(0,0,0,.22); font-weight: 700; }
.p-foot .score { background: rgba(255,255,255,.18); padding: 4px 12px; border-radius: 99px; }
.p-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 16px; }
.p-center h1 { font-size: clamp(1.8rem, 7vw, 2.6rem); margin: 0; line-height: 1.1; }
.p-center h2 { margin: 0; font-size: 1.3rem; font-weight: 600; }
.join-card { width: 100%; max-width: 380px; display: grid; gap: 12px; }
.join-card .input { font-size: 1.4rem; text-align: center; font-weight: 700; padding: 14px; letter-spacing: .04em; }
.timebar { height: 8px; background: rgba(255,255,255,.2); border-radius: 99px; overflow: hidden; }
.timebar > i { display: block; height: 100%; background: #fff; border-radius: 99px; transform-origin: left; }
.qtext { font-size: clamp(1.15rem, 4.6vw, 1.6rem); font-weight: 700; text-align: center; line-height: 1.25; margin: 4px 0; }
.qimg { max-height: 28vh; margin: 0 auto; border-radius: 12px; object-fit: contain; }
.p-answers { margin-top: auto; }
.big-num { font-size: clamp(3rem, 16vw, 5rem); font-weight: 800; line-height: 1; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 99px; background: rgba(255,255,255,.18); font-weight: 700; font-size: .9rem; }
.result.ok { background: var(--ok); }
.result.bad { background: var(--danger); }
.result.neutral { background: rgba(0,0,0,.12); }
.result-pts { font-size: 1.6rem; font-weight: 800; background: rgba(0,0,0,.2); padding: 8px 20px; border-radius: 12px; }
.spinner { width: 46px; height: 46px; border: 5px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.slider-wrap { background: rgba(255,255,255,.12); border-radius: 16px; padding: 18px; display: grid; gap: 14px; }
.slider-wrap input[type=range] { width: 100%; accent-color: #ffd166; height: 36px; }
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-val { text-align: center; font-size: 2.6rem; font-weight: 800; }
.order-list { display: grid; gap: 8px; }
.order-item { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; border: 0; background: rgba(255,255,255,.14);
  color: #fff; font-weight: 700; font-size: 1.05rem; text-align: left; cursor: pointer; min-height: 58px; }
.order-item .pos { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.2); flex: none; }
.order-item.placed { background: #fff; color: var(--stage-b); }
.order-item.placed .pos { background: var(--stage-b); color: #fff; }
.text-answer { font-size: 1.4rem; text-align: center; padding: 16px; font-weight: 700; }

/* ---------- host */
.host { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.h-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; gap: 16px; flex-wrap: wrap; }
.h-main { flex: 1; display: flex; flex-direction: column; padding: 0 24px 24px; gap: 18px; width: 100%; max-width: 1400px; margin: 0 auto; }
.h-bar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.lobby-head { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: stretch; }
.pin-card { display: flex; flex-direction: column; justify-content: center; gap: 6px; }
.pin-card .join-at { font-size: 1.15rem; color: var(--muted); }
.pin-card .join-at b { color: var(--text); }
.pin { font-size: clamp(3rem, 9vw, 6rem); font-weight: 800; letter-spacing: .04em; line-height: 1; }
.qr-card { padding: 12px; display: grid; place-items: center; cursor: zoom-in; }
.qr-card img { width: clamp(140px, 18vw, 220px); image-rendering: pixelated; }
.players-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.count-pill { background: rgba(0,0,0,.25); padding: 8px 16px; border-radius: 99px; font-weight: 800; font-size: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-content: flex-start; }
.chip { background: rgba(255,255,255,.95); color: var(--text); border: 0; padding: 10px 16px; border-radius: 10px; font-weight: 700;
  font-size: 1.1rem; cursor: pointer; animation: chip-in .25s ease-out; }
.chip:hover { text-decoration: line-through; background: #ffe2e3; }
.chip.off { opacity: .5; }
@keyframes chip-in { from { transform: scale(.6); opacity: 0; } }
.waiting-hint { text-align: center; font-size: 1.3rem; margin-top: 40px; }
.h-question { background: #fff; color: var(--text); border-radius: var(--radius); padding: 18px 24px; text-align: center;
  font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 800; line-height: 1.2; }
.h-mid { flex: 1; display: grid; grid-template-columns: 120px 1fr 120px; align-items: center; gap: 16px; min-height: 180px; }
.h-mid .qimg { max-height: 40vh; }
.circle { width: 110px; height: 110px; border-radius: 50%; background: var(--stage-b); border: 5px solid rgba(255,255,255,.85); display: grid; place-items: center;
  font-size: 2.6rem; font-weight: 800; }
.stat-box { text-align: center; }
.stat-box b { display: block; font-size: 2.6rem; line-height: 1; }
.h-answers { grid-template-columns: 1fr 1fr; }
.h-answers .ans { cursor: default; min-height: 84px; font-size: clamp(1.1rem, 2vw, 1.5rem); }
.preview-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.preview-wrap .h-question { background: transparent; color: #fff; font-size: clamp(1.8rem, 4.5vw, 3.4rem); }
.loadbar { width: min(600px, 80%); height: 10px; background: rgba(255,255,255,.2); border-radius: 99px; overflow: hidden; }
.loadbar i { display: block; height: 100%; background: #ffd166; }
.chart { flex: none; height: clamp(170px, 30vh, 320px); display: flex; align-items: stretch; justify-content: center; gap: 18px; padding-top: 10px; }
.bar { width: min(140px, 18vw); display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar .track { flex: 1; width: 100%; display: flex; align-items: flex-end; min-height: 0; }
.bar .col { width: 100%; background: var(--oc); border-radius: 8px 8px 0 0; min-height: 8px; transition: height .6s cubic-bezier(.2,.8,.2,1); }
.bar .lbl { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 1.4rem; }
.bar.dim { opacity: .4; }
.reveal-list { display: grid; gap: 8px; max-width: 700px; width: 100%; margin: 0 auto; }
.reveal-row { display: flex; justify-content: space-between; gap: 12px; background: rgba(255,255,255,.12); padding: 12px 16px; border-radius: 10px; font-weight: 700; font-size: 1.2rem; }
.reveal-row.ok { background: var(--ok); }
.answer-banner { background: var(--ok); color: #fff; border-radius: 12px; padding: 14px 20px; text-align: center; font-size: 1.5rem; font-weight: 800; }
.lb { display: grid; gap: 10px; max-width: 900px; width: 100%; margin: 0 auto; }
.lb-row { display: flex; align-items: center; gap: 16px; background: #fff; color: var(--text); padding: 14px 20px; border-radius: 12px;
  font-size: clamp(1.1rem, 2.2vw, 1.6rem); font-weight: 800; animation: slide-in .35s ease-out backwards; }
.lb-row .rk { width: 36px; color: var(--muted); }
.lb-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .gain { font-size: .8em; color: var(--ok); font-weight: 700; }
@keyframes slide-in { from { transform: translateY(16px); opacity: 0; } }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 16px; min-height: 320px; flex: 1; }
.pod { width: min(220px, 28vw); text-align: center; display: flex; flex-direction: column; gap: 10px; animation: rise .8s cubic-bezier(.2,.8,.2,1) backwards; }
.pod .nm { font-size: clamp(1.1rem, 2.4vw, 1.8rem); font-weight: 800; word-break: break-word; }
.pod .blk { background: rgba(255,255,255,.95); color: var(--stage-b); border-radius: 12px 12px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 14px; font-weight: 800; }
.pod .blk .medal { font-size: 2.6rem; }
.pod.p1 .blk { height: 240px; } .pod.p2 .blk { height: 180px; } .pod.p3 .blk { height: 130px; }
.pod.p1 { animation-delay: 1.2s; } .pod.p2 { animation-delay: .6s; } .pod.p3 { animation-delay: 0s; }
@keyframes rise { from { transform: translateY(60px); opacity: 0; } }
.results-table { width: 100%; border-collapse: collapse; color: var(--text); }
.results-table th, .results-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.results-table td.r, .results-table th.r { text-align: right; }
.overlay { position: fixed; inset: 0; background: rgba(10,5,30,.75); display: grid; place-items: center; z-index: 50; padding: 16px; }
.overlay img { width: min(80vh, 90vw); background: #fff; padding: 16px; border-radius: 16px; image-rendering: pixelated; }
.notice { background: rgba(255,209,102,.18); border: 1px solid rgba(255,209,102,.5); padding: 10px 14px; border-radius: 10px; font-size: .95rem; }
@media (max-width: 760px) {
  .h-top, .h-main { padding-left: 16px; padding-right: 16px; }
  .lobby-head { grid-template-columns: 1fr; }
  .qr-card { justify-self: center; }
  .h-mid { grid-template-columns: 1fr 1fr; }
  .h-mid .media { grid-column: 1 / -1; order: -1; }
  .circle { width: 80px; height: 80px; font-size: 1.8rem; }
  .h-answers { grid-template-columns: 1fr; }
  .bar .lbl { font-size: 1.1rem; }
  .chart { gap: 8px; }
}

/* ---------- app pages (quiz list + editor) */
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.topbar .grow { flex: 1; min-width: 160px; }
.topbar .title-input { font-size: 1.15rem; font-weight: 700; border-color: transparent; background: transparent; }
.topbar .title-input:hover { border-color: var(--border); }
.topbar .title-input:focus { border-color: var(--primary); background: var(--surface); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.quiz-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); margin-top: 18px; }
.quiz-card { display: flex; flex-direction: column; gap: 10px; }
.quiz-card h3 { margin: 0; font-size: 1.15rem; }
.quiz-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.quiz-card .actions { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; padding: 60px 16px; color: var(--muted); }

.editor { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 71px); min-height: calc(100dvh - 71px); }
.q-side { border-right: 1px solid var(--border); background: var(--surface); padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: calc(100vh - 71px); max-height: calc(100dvh - 71px); position: sticky; top: 71px; }
.q-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 10px; cursor: pointer; border: 1.5px solid transparent; background: var(--surface-2); text-align: left; width: 100%; color: var(--text); }
.q-item.active { border-color: var(--primary); background: var(--surface); }
.q-item .n { font-weight: 800; color: var(--muted); min-width: 22px; }
.q-item .t { flex: 1; min-width: 0; }
.q-item .t b { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.q-item .t span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.q-item .warn { color: var(--warn); font-weight: 800; }
.q-main { padding: 20px; display: flex; flex-direction: column; gap: 16px; max-width: 900px; width: 100%; margin: 0 auto; }
.q-main .qtitle { font-size: 1.3rem; font-weight: 700; text-align: center; padding: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.img-drop { border: 2px dashed var(--border); border-radius: var(--radius); min-height: 150px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 16px; position: relative; }
.img-drop img { max-height: 260px; border-radius: 10px; margin: 0 auto; }
.img-drop.drag { border-color: var(--primary); background: var(--surface-2); }
.img-tools { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.opts { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.opt-edit { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1.5px solid var(--border); border-left: 8px solid var(--oc); border-radius: 12px; padding: 8px; }
.opt-edit .shape { color: var(--oc); }
.opt-edit .input { border: 0; padding: 8px 4px; }
.opt-edit .thumb { width: 38px; height: 38px; object-fit: cover; border-radius: 6px; cursor: pointer; flex: none; }
.opt-edit.correct { border-color: var(--ok); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 30%, transparent); }
.correct-toggle { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: none; color: transparent; font-weight: 800; }
.correct-toggle.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.list-edit { display: grid; gap: 8px; }
.list-edit .row { flex-wrap: nowrap; }
.section-title { font-weight: 700; margin: 4px 0 -4px; }
.problems { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: 12px; padding: 10px 14px; font-size: .92rem; }
.problems ul { margin: 6px 0 0; padding-left: 18px; }
.modal-bg { position: fixed; inset: 0; background: rgba(10,5,30,.5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; padding: 22px; width: min(560px, 100%); max-height: 90vh; max-height: 90dvh; overflow: auto; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal h2 { margin: 0; }
.type-menu { position: absolute; z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; min-width: 220px; }
.type-menu button { background: transparent; border: 0; text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.type-menu button:hover { background: var(--surface-2); }
.type-menu button small { display: block; color: var(--muted); }
@media (max-width: 800px) {
  .editor { grid-template-columns: 1fr; }
  .q-side { position: static; max-height: none; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .q-item { min-width: 170px; }
  .opts { grid-template-columns: 1fr; }
  .q-main { padding: 16px; }
}

/* ---------- small additions */
body.stage .card .btn.primary { background: var(--primary); color: #fff; }
body.stage .card .btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.form-err { color: var(--danger); margin: 0; font-weight: 600; text-align: center; min-height: 1.2em; }
.net-banner { position: fixed; top: 0; left: 0; right: 0; background: var(--danger); color: #fff; text-align: center; padding: 6px; font-weight: 700; z-index: 200; font-size: .9rem; }
.between { justify-content: space-between; }
.brand.sm { font-size: 1.1rem; }
.full { width: 100%; }
.p-pick { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.p-pick .dot { width: 54px; height: 54px; border-radius: 12px; background: var(--oc); display: grid; place-items: center; color: #fff; font-size: 1.3rem; }
.mini-podium { display: grid; gap: 6px; width: 100%; max-width: 360px; }
.mini-podium div { display: flex; justify-content: space-between; background: rgba(255,255,255,.14); padding: 10px 14px; border-radius: 10px; font-weight: 700; }

/* ---------- drag to reorder */
.sortable-item { position: relative; }
.order-list .sortable-item, .drag-handle { touch-action: none; user-select: none; -webkit-user-select: none; }
.sorting .sortable-item { transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.sortable-item.dragging { transition: none !important; z-index: 5; box-shadow: 0 14px 34px rgba(0, 0, 0, .35); cursor: grabbing; }
.sortable-item.settling { transition: transform .17s ease-out !important; z-index: 5; }
.order-item { cursor: grab; background: #fff; color: var(--stage-b); }
.order-item .pos { background: var(--stage-b); color: #fff; }
.order-item .grip, .drag-handle { margin-left: auto; opacity: .55; font-size: 1.3rem; letter-spacing: -2px; line-height: 1; }
.order-item:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; }
.drag-handle { margin-left: 0; cursor: grab; background: transparent; border: 0; padding: 8px 6px; color: var(--muted); }
.list-edit .sortable-item { background: var(--bg); border-radius: 10px; padding: 2px 4px; }

/* ---------- maps */
.map-box { width: 100%; border-radius: 14px; overflow: hidden; background: #aad3df; position: relative; z-index: 0; }
.p-map { min-height: 260px; height: min(56vh, 520px); height: min(56dvh, 520px); cursor: crosshair; }
.h-map { height: 46vh; }
.h-map.big { height: 58vh; }
.e-map { height: 380px; border: 1.5px solid var(--border); }
.map-dot { display: block; border-radius: 50%; background: var(--pc); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45); box-sizing: border-box; }
.map-target { display: grid; place-items: center; width: 30px; height: 30px; font-size: 26px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.leaflet-tooltip.map-label { font-family: var(--font); font-weight: 700; font-size: .85rem; padding: 2px 8px; }
.map-missing { display: grid; place-items: center; height: 100%; padding: 16px; text-align: center; color: #333; }
.h-mid .media .map-box { min-width: 0; }

.leaflet-container.outline-map { background: #aad3df; }

.r-map { height: 38vh; height: 38dvh; min-height: 200px; }
.map-box { min-height: 200px; }

/* ---------- timeline */
.tl-end { text-align: center; font-weight: 800; letter-spacing: .04em; opacity: .85; }
.order-list.timeline { position: relative; padding-left: 26px; }
.order-list.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 4px; border-radius: 4px; background: linear-gradient(#ffd166, #fff); }
.order-list.timeline .order-item::before { content: ""; position: absolute; left: -23px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: #ffd166; border: 3px solid var(--stage-a); }
.tl-result, .h-timeline { display: grid; gap: 8px; width: 100%; max-width: 700px; margin: 0 auto; }
.tl-row, .h-tl-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: rgba(0,0,0,.2); font-weight: 700; text-align: left; }
.tl-row.ok { background: rgba(255,255,255,.22); }
.tl-row.bad { background: rgba(0,0,0,.28); }
.tl-row .tl-text, .h-tl-row .tl-text { flex: 1; }
.tl-year { min-width: 64px; font-weight: 800; color: #ffd166; font-variant-numeric: tabular-nums; }
.h-tl-row { background: #fff; color: var(--text); font-size: clamp(1.1rem, 2.2vw, 1.6rem); animation: slide-in .4s ease-out backwards; }
.h-tl-row .tl-year { color: var(--primary); min-width: 90px; }

/* ---------- side quest: red flames, hectic styling */
body.stage.quest {
  --stage-a: #1a0303; --stage-b: #7a0d06;
  background: radial-gradient(120% 80% at 50% 115%, #ff8a00 0%, #e0301e 28%, #7a0d06 55%, #1a0303 100%) fixed;
}
.flames { display: none; }
body.quest .flames { display: block; position: fixed; left: 0; right: 0; bottom: 0; height: 55vh; pointer-events: none; z-index: 0; overflow: hidden; filter: blur(14px); opacity: .85; }
.flames i {
  position: absolute; bottom: -60px; left: calc(var(--i) * 7.4% - 4%); width: 16vw; min-width: 90px; height: 34vh;
  border-radius: 50% 50% 35% 35%;
  background: radial-gradient(ellipse at 50% 85%, #fff3b0 0%, #ffb000 25%, #ff4d00 55%, rgba(200, 20, 0, 0) 75%);
  transform-origin: 50% 100%;
  animation: flame calc(1.1s + (var(--i) * 0.13s)) ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -0.37s);
}
@keyframes flame {
  0% { transform: scale(.9, .75) translateY(0) skewX(-4deg); opacity: .75; }
  50% { transform: scale(1.05, 1.15) translateY(-14px) skewX(5deg); opacity: 1; }
  100% { transform: scale(.95, .9) translateY(-4px) skewX(-6deg); opacity: .8; }
}
body.quest #app { position: relative; z-index: 1; }
body.quest .badge, body.quest .count-pill { background: rgba(0, 0, 0, .35); }
.quest-badge { background: linear-gradient(90deg, #ff4d00, #ffb000) !important; color: #1a0303; font-weight: 800; animation: pulse .8s ease-in-out infinite; }
body.quest .timebar { background: rgba(0, 0, 0, .35); height: 12px; }
body.quest .timebar > i { background: linear-gradient(90deg, #ffe066, #ff4d00); box-shadow: 0 0 14px #ff7a00; }
body.quest .circle { background: #e0301e; border-color: #ffd166; box-shadow: 0 0 30px #ff4d00; animation: pulse .6s ease-in-out infinite; }
body.quest .h-question { border: 3px solid #ffb000; box-shadow: 0 0 34px rgba(255, 120, 0, .65); }
body.quest .brand span { color: #ffb000; }
body.quest .result-pts { background: rgba(0, 0, 0, .35); box-shadow: 0 0 20px rgba(255, 140, 0, .6); }
body.quest .ans { box-shadow: inset 0 -4px 0 rgba(0,0,0,.25), 0 0 18px rgba(255, 90, 0, .45); }
.quest-intro h1, .quest-intro .h-question { text-shadow: 0 0 18px rgba(255, 120, 0, .9); }
.quest-kicker {
  font-size: clamp(1.5rem, 7.5vw, 4.6rem); font-weight: 800; letter-spacing: .04em; line-height: 1.05; text-wrap: balance;
  background: linear-gradient(180deg, #fff3b0, #ffb000 45%, #ff4d00); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 90, 0, .8)); animation: shake .45s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0); } 20% { transform: translate(-3px, 1px) rotate(-1.5deg); }
  40% { transform: translate(3px, -1px) rotate(1.5deg); } 60% { transform: translate(-2px, 2px) rotate(-1deg); } 80% { transform: translate(2px, -2px) rotate(1deg); }
}
@media (prefers-reduced-motion: reduce) {
  .flames i, .quest-kicker, .quest-badge, body.quest .circle { animation: none; }
}
/* editor */
.q-item.quest { border-left: 5px solid #e0301e; }
.quest-head { font-size: .78rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: #e0301e; padding: 6px 4px 0; flex: none; }
.quest-box { border: 2px solid color-mix(in srgb, #e0301e 45%, transparent); background: color-mix(in srgb, #e0301e 7%, var(--surface)); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }

/* ---------- auto-advance countdown */
.auto-bar { position: fixed; left: 0; right: 0; bottom: 0; height: 30px; background: rgba(0,0,0,.35); z-index: 30; display: flex; align-items: center; justify-content: center; }
.auto-bar i { position: absolute; inset: 0; background: rgba(255, 209, 102, .45); transform-origin: left; }
body.quest .auto-bar i { background: linear-gradient(90deg, rgba(255,224,102,.6), rgba(255,77,0,.6)); }
.auto-bar span { position: relative; font-weight: 800; letter-spacing: .02em; }
.host .h-main { padding-bottom: 40px; }
.p-auto { text-align: center; font-weight: 700; padding: 6px; opacity: .85; position: relative; z-index: 1; }

/* ---------- accounts */
.auth-card { width: 100%; max-width: 400px; display: grid; gap: 14px; text-align: left; }
.auth-card form { display: grid; gap: 12px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; }
.tab { border: 0; background: transparent; padding: 10px; border-radius: 8px; font-weight: 700; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.pw-wrap { display: flex; gap: 6px; align-items: center; }
.pw-wrap .input { flex: 1; }
.join-links { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.join-links a { color: rgba(255,255,255,.85); font-weight: 600; }
.mode-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 10px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: .95rem; }
.mode-bar.guest { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
/* text inside white cards on the dark stage pages */
body.stage .card .muted { color: var(--muted); }
body.stage .card .btn.ghost { background: var(--surface-2); color: var(--text); }
