/* MTOOT. Hebrew, right to left. Light "paper" for the host's work screens, a dark stage for the shared screen,
   and big, thumb-sized controls on the phone. Answer colours are paired with Hebrew letters (א ב ג ד ה ו),
   so colour is never the only cue. */
:root {
  --ink: #1c1a24;
  --ink-2: #3b3846;
  --muted: #6e6a78;
  --paper: #f6f2ea;
  --card: #fffdf9;
  --line: #e3dccd;
  --line-2: #d2c9b6;
  --accent: #d9482b;
  --accent-ink: #fff;
  --accent-soft: #fbe4dc;
  --ok: #17885c;
  --ok-soft: #dcf2e7;
  --bad: #c8372f;
  --bad-soft: #fbe1df;
  --warn: #a86a00;
  --warn-soft: #fdf0d3;
  --stage: #17141f;
  --stage-2: #231f2e;
  --stage-line: #3a3447;
  --a1: #0e7f86;
  --a2: #d24a2a;
  --a3: #c98a12;
  --a4: #4a3ea0;
  --a5: #a63b78;
  --a6: #4f7d22;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(28 26 36 / 6%), 0 6px 20px rgb(28 26 36 / 7%);
  --font: "Segoe UI", "Assistant", "Heebo", "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  direction: rtl;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

/* ── brand ─────────────────────────────────────────────────────────── */
.brand { display: inline-flex; align-items: baseline; gap: 2px; font-weight: 800; letter-spacing: 0.06em; text-decoration: none; color: inherit; direction: ltr; }
.brand b { color: var(--accent); }
.brand-dot { width: 0.42em; height: 0.42em; border-radius: 50%; background: var(--accent); display: inline-block; margin-inline-start: 3px; }

/* ── buttons and fields ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line-2);
  background: var(--card); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgb(28 26 36 / 6%); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn.big { min-height: 56px; padding: 12px 28px; font-size: 20px; }
.btn.icon { width: 38px; min-height: 38px; padding: 0; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 13px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 9px 13px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-2); background: #fff;
}
.input:focus { border-color: var(--ink-2); outline: none; box-shadow: 0 0 0 3px rgb(28 26 36 / 8%); }
textarea.input { resize: vertical; min-height: 84px; }
.input[readonly], .input:disabled { background: #f3efe6; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.error-text { color: var(--bad); font-weight: 600; }

/* ── page shell (host screens) ─────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 10px 24px;
  background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-size: 22px; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }
.page h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -0.01em; }
.page-head { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tab { padding: 10px 16px; border: 0; background: none; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.quiz-card { display: flex; flex-direction: column; overflow: hidden; }
.quiz-card .cover { aspect-ratio: 16 / 7; background: linear-gradient(135deg, var(--stage), #3a2f4f); display: grid; place-items: center; color: #fff; font-size: 38px; font-weight: 800; overflow: hidden; }
.quiz-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.quiz-card .body { padding: 14px 16px; display: grid; gap: 4px; flex: 1; }
.quiz-card h3 { margin: 0; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.quiz-card .meta { font-size: 13px; color: var(--muted); }
.quiz-card .actions { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--line); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.live { background: var(--accent); color: #fff; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); border: 2px dashed var(--line-2); border-radius: var(--radius); }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
table.list th, table.list td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: 13px; color: var(--muted); font-weight: 600; background: #faf7f1; }
table.list tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

/* ── dialogs and toasts ────────────────────────────────────────────── */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 24px 80px rgb(0 0 0 / 30%); color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgb(23 20 31 / 55%); }
dialog.wide { width: min(860px, calc(100vw - 32px)); }
.dialog-body { padding: 22px 24px; display: grid; gap: 16px; max-height: 75vh; overflow: auto; }
.dialog-body h2 { margin: 0; font-size: 22px; }
.dialog-foot { display: flex; gap: 10px; justify-content: flex-start; padding: 14px 24px; border-top: 1px solid var(--line); background: #faf7f1; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--line-2); border-radius: var(--radius-sm); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--ink); background: #fff; box-shadow: 0 0 0 2px var(--ink) inset; }
.choice input { margin-top: 4px; accent-color: var(--ink); }
.choice b { display: block; }
.choice small { color: var(--muted); }

#toasts { position: fixed; inset-inline: 0; bottom: 18px; display: grid; justify-items: center; gap: 8px; z-index: 1000; pointer-events: none; }
.toast { pointer-events: auto; max-width: min(520px, calc(100vw - 24px)); padding: 11px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 10px 30px rgb(0 0 0 / 25%); animation: toast-in 0.2s ease-out; }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ── answer colours ────────────────────────────────────────────────── */
.c1 { --c: var(--a1); } .c2 { --c: var(--a2); } .c3 { --c: var(--a3); }
.c4 { --c: var(--a4); } .c5 { --c: var(--a5); } .c6 { --c: var(--a6); }
.letter { display: inline-grid; place-items: center; width: 1.7em; height: 1.7em; border-radius: 0.45em; background: rgb(255 255 255 / 22%); font-weight: 800; flex: none; }

/* ── sign-in pages ─────────────────────────────────────────────────── */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: min(420px, 100%); padding: 30px 28px; display: grid; gap: 16px; }
.auth .brand { font-size: 30px; justify-self: start; }
.auth h1 { margin: 0; font-size: 22px; }

/* ── editor ────────────────────────────────────────────────────────── */
.editor { display: grid; grid-template-columns: 300px 1fr; min-height: calc(100dvh - 63px); }
.editor-side { border-inline-end: 1px solid var(--line); background: #f1ece2; display: flex; flex-direction: column; min-height: 0; position: sticky; top: 63px; height: calc(100dvh - 63px); }
.qlist { list-style: none; margin: 0; padding: 12px; display: grid; gap: 8px; overflow-y: auto; flex: 1; align-content: start; }
.qitem { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 9px 10px; border-radius: 11px; background: var(--card); border: 1.5px solid transparent; cursor: pointer; box-shadow: 0 1px 2px rgb(0 0 0 / 5%); }
.qitem:hover { border-color: var(--line-2); }
.qitem[aria-current="true"] { border-color: var(--ink); }
.qitem .num { font-weight: 800; color: var(--muted); text-align: center; }
.qitem .txt { min-width: 0; }
.qitem .txt b { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.qitem .txt span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.qitem .flag { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
.qitem.dragging { opacity: 0.4; }
.qitem.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.side-foot { padding: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.editor-main { padding: 26px 32px 80px; max-width: 920px; width: 100%; border: 0; margin: 0; min-width: 0; }
.editor-main h2 { margin: 0; font-size: 15px; color: var(--muted); font-weight: 600; }
.qtext { font-size: 22px; font-weight: 600; min-height: 90px; }
.settings-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.section { display: grid; gap: 14px; margin-top: 22px; }
.answers-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer-edit { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--c); color: #fff; }
.answer-edit input[type="text"] { flex: 1; min-width: 0; border: 0; background: rgb(255 255 255 / 94%); color: var(--ink); border-radius: 8px; padding: 8px 10px; }
.answer-edit .correct-toggle { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.answer-edit .correct-toggle input { width: 20px; height: 20px; accent-color: #fff; }
.answer-edit.is-correct { box-shadow: 0 0 0 3px var(--ink); }
.answer-edit .btn.icon { color: #fff; border-color: transparent; background: rgb(0 0 0 / 15%); min-height: 32px; width: 32px; }
.list-edit { display: grid; gap: 8px; }
.list-edit .item { display: flex; gap: 8px; align-items: center; }
.list-edit .item .n { width: 28px; text-align: center; font-weight: 800; color: var(--muted); }
.image-drop { border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: #fbf8f2; }
.image-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.image-preview { position: relative; display: inline-block; width: fit-content; max-width: 100%; }
.image-preview img { max-height: 280px; border-radius: var(--radius-sm); }
.image-preview .btn { position: absolute; top: 8px; inset-inline-start: 8px; }
.pin-editor { position: relative; display: inline-block; width: fit-content; justify-self: start; max-width: 100%; cursor: crosshair; user-select: none; }
.pin-editor img { max-height: 420px; border-radius: var(--radius-sm); }
.pin-zone { position: absolute; border-radius: 50%; border: 3px solid #fff; background: rgb(23 136 92 / 35%); box-shadow: 0 0 0 2px var(--ok); transform: translate(50%, -50%); pointer-events: none; }
.problems { background: var(--warn-soft); border: 1px solid #f0d699; border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; }
.problems ul { margin: 6px 0 0; padding-inline-start: 20px; }
.problems button { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; text-align: start; }
.save-state { font-size: 13px; color: var(--muted); min-width: 70px; }
.title-input { font-size: 18px; font-weight: 700; border: 1.5px solid transparent; background: transparent; padding: 6px 10px; border-radius: 8px; min-width: 0; width: 100%; max-width: 460px; }
.title-input:hover, .title-input:focus { border-color: var(--line-2); background: #fff; outline: none; }
.menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.menu button { text-align: start; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; }
.menu button:hover { border-color: var(--ink-2); }
.menu button b { display: block; }
.menu button small { color: var(--muted); }
.banner { padding: 10px 24px; background: var(--warn-soft); border-bottom: 1px solid #f0d699; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

@media (max-width: 820px) {
  .editor { grid-template-columns: 1fr; }
  .editor-side { position: static; height: auto; max-height: 260px; }
  .editor-main { padding: 18px 16px 60px; }
  .answers-edit { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; gap: 10px; }
}

/* ── the shared screen (stage) ─────────────────────────────────────── */
body.stage-body { background: var(--stage); color: #f6f2ea; overflow: hidden; }
.stage { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }
.stage-top { display: flex; align-items: center; gap: 18px; padding: 14px 28px; font-size: 18px; }
.stage-top .brand { font-size: 24px; color: #fff; }
.stage-top .pill { padding: 4px 14px; border-radius: 999px; background: var(--stage-2); border: 1px solid var(--stage-line); font-weight: 700; }
.stage-main { min-height: 0; padding: 0 3vw; display: flex; flex-direction: column; }
.stage-bottom { display: flex; align-items: center; gap: 12px; padding: 14px 28px 20px; }
.stage .btn { background: var(--stage-2); border-color: var(--stage-line); color: #fff; }
.stage .btn:hover { border-color: #8a829b; }
.stage .btn.primary { background: var(--accent); border-color: var(--accent); }
.stage .btn.ghost { background: transparent; border-color: transparent; }

.lobby { flex: 1; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 4vw; align-items: center; }
.join-box { display: grid; gap: 1.4vh; }
.join-box .how { font-size: clamp(20px, 2.2vw, 34px); color: #cfc8db; }
.join-box .addr { font-size: clamp(26px, 3.4vw, 56px); font-weight: 800; direction: ltr; text-align: right; color: #fff; }
.join-box .pin-label { font-size: clamp(18px, 1.8vw, 28px); color: #cfc8db; margin-top: 2vh; }
.join-box .pin { font-size: clamp(64px, 10vw, 170px); font-weight: 900; letter-spacing: 0.08em; line-height: 1; direction: ltr; text-align: right; font-variant-numeric: tabular-nums; }
.qr { width: min(30vh, 26vw); aspect-ratio: 1; background: #fff; border-radius: 16px; padding: 10px; }
.qr img { width: 100%; height: 100%; }
.lobby-side { display: flex; flex-direction: column; gap: 2vh; align-self: stretch; padding: 2vh 0; min-height: 0; }
.lobby-count { font-size: clamp(22px, 2.4vw, 40px); font-weight: 800; }
.players { display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start; overflow: auto; min-height: 0; flex: 1; }
.player-chip { padding: 8px 16px; border-radius: 999px; background: var(--stage-2); border: 1px solid var(--stage-line); font-size: clamp(16px, 1.5vw, 24px); font-weight: 700; cursor: pointer; color: #fff; animation: pop 0.25s ease-out; }
.player-chip:hover { border-color: var(--bad); text-decoration: line-through; }
.player-chip.static, .player-chip.more { cursor: default; }
.player-chip.static:hover, .player-chip.more:hover { border-color: var(--stage-line); text-decoration: none; }
.player-chip.more { background: var(--accent); border-color: var(--accent); }
.players.many { gap: 6px; }
.players.many .player-chip { padding: 4px 11px; font-size: clamp(13px, 1.1vw, 18px); animation: none; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }

.q-stage { flex: 1; display: grid; grid-template-rows: auto 1fr auto; gap: 2vh; min-height: 0; }
.q-title { font-size: clamp(26px, 3.6vw, 64px); font-weight: 800; line-height: 1.2; text-align: center; padding: 1vh 4vw 0; overflow-wrap: anywhere; }
.q-title.big { font-size: clamp(34px, 5vw, 88px); align-self: center; }
.q-middle { display: grid; grid-template-columns: 12vw 1fr 12vw; align-items: center; gap: 2vw; min-height: 0; }
.q-media { display: grid; place-items: center; min-height: 0; height: 100%; }
.q-media > img { height: 100%; width: 100%; max-height: 52vh; object-fit: contain; border-radius: 14px; }
.q-media .hint { font-size: clamp(20px, 2.2vw, 36px); color: #cfc8db; text-align: center; }
.timer { width: 10vw; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font-size: clamp(30px, 4vw, 70px); font-weight: 900; background: conic-gradient(var(--accent) calc(var(--p, 1) * 360deg), var(--stage-2) 0); position: relative; font-variant-numeric: tabular-nums; }
.timer::before { content: ""; position: absolute; inset: 9%; border-radius: 50%; background: var(--stage); }
.timer span { position: relative; }
.answered { text-align: center; }
.answered b { display: block; font-size: clamp(34px, 4.5vw, 76px); line-height: 1; }
.answered span { color: #cfc8db; font-size: clamp(14px, 1.3vw, 22px); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2vh 1vw; padding-bottom: 1vh; }
.tile { display: flex; align-items: center; gap: 1vw; padding: 1.6vh 1.4vw; border-radius: 14px; background: var(--c); color: #fff; font-size: clamp(18px, 2.2vw, 38px); font-weight: 700; min-height: 9vh; transition: opacity 0.3s, filter 0.3s; overflow-wrap: anywhere; }
.tile .letter { font-size: 0.9em; }
.tile .count { margin-inline-start: auto; font-variant-numeric: tabular-nums; }
.tile.dim { opacity: 0.28; filter: saturate(0.4); }
.tile .check { font-size: 1.1em; }
.preview-bar { height: 8px; border-radius: 99px; background: var(--stage-2); overflow: hidden; width: min(600px, 60vw); margin: 0 auto 4vh; }
.preview-bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width linear; }

.bars { display: flex; align-items: flex-end; justify-content: center; gap: 2vw; height: 100%; min-height: 0; padding: 0 4vw; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; width: min(140px, 14vw); height: 100%; }
.bar .fill { flex: none; }
.bar .fill { width: 100%; border-radius: 10px 10px 4px 4px; background: var(--c, #6b6480); min-height: 6px; transition: height 0.6s cubic-bezier(.2,.8,.2,1); }
.bar .num { font-size: clamp(20px, 2.4vw, 42px); font-weight: 800; font-variant-numeric: tabular-nums; }
.bar .lbl { font-size: clamp(14px, 1.3vw, 22px); color: #cfc8db; text-align: center; }
.bar.dim .fill { opacity: 0.3; }
.reveal-big { text-align: center; font-size: clamp(40px, 6vw, 110px); font-weight: 900; color: #fff; }
.reveal-sub { text-align: center; font-size: clamp(18px, 1.8vw, 30px); color: #cfc8db; }
.chips { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-content: center; padding: 0 4vw; }
.chip { padding: 10px 20px; border-radius: 999px; background: var(--stage-2); border: 1.5px solid var(--stage-line); font-size: clamp(18px, 1.8vw, 32px); font-weight: 700; }
.chip.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 30%, var(--stage-2)); }
.chip small { color: #cfc8db; margin-inline-start: 8px; }
.order-list { list-style: none; margin: 0 auto; padding: 0; display: grid; gap: 1.2vh; width: min(900px, 80vw); counter-reset: o; }
.order-list li { counter-increment: o; display: flex; gap: 1vw; align-items: center; padding: 1.4vh 1.4vw; border-radius: 12px; background: var(--stage-2); font-size: clamp(18px, 2vw, 34px); font-weight: 700; }
.order-list li::before { content: counter(o); display: inline-grid; place-items: center; width: 1.8em; height: 1.8em; border-radius: 50%; background: var(--ok); color: #fff; font-size: 0.8em; }
.order-list.plain li::before { background: #514a62; }
.cloud { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; align-items: baseline; gap: 0.4em 1em; padding: 2vh 6vw; height: 100%; overflow: hidden; }
.cloud span { font-weight: 800; line-height: 1.1; }
.texts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 0 2vw; overflow: auto; align-content: start; }
.texts div { padding: 14px 16px; border-radius: 12px; background: var(--stage-2); border: 1px solid var(--stage-line); font-size: clamp(16px, 1.5vw, 24px); overflow-wrap: anywhere; }
.pin-reveal { position: relative; display: inline-block; width: fit-content; justify-self: center; max-height: 100%; }
.pin-reveal img { max-width: none; border-radius: 12px; }
.pin-reveal .dot { position: absolute; width: 14px; height: 14px; border-radius: 50%; transform: translate(50%, -50%); border: 2px solid #fff; background: var(--bad); }
.pin-reveal .dot.ok { background: var(--ok); }
.pin-reveal .zone { position: absolute; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 3px var(--ok); transform: translate(50%, -50%); }
.hist { display: flex; align-items: flex-end; gap: 4px; height: 36vh; width: min(1000px, 84vw); margin: 0 auto; position: relative; border-bottom: 2px solid var(--stage-line); direction: ltr; }
.hist i { flex: 1; background: #6b6480; border-radius: 4px 4px 0 0; min-height: 2px; }
.hist i.ok { background: var(--ok); }
.hist-axis { display: flex; justify-content: space-between; width: min(1000px, 84vw); margin: 6px auto 0; color: #cfc8db; direction: ltr; font-size: clamp(14px, 1.3vw, 22px); }

.board { list-style: none; margin: 0 auto; padding: 0; width: min(1000px, 86vw); display: grid; gap: 0.9vh; align-content: start; }
.board li { display: grid; grid-template-columns: 3em 1fr auto 2.4em; align-items: center; gap: 1vw; padding: 0.9vh 1.6vw; border-radius: 12px; background: var(--stage-2); font-size: clamp(16px, min(2vw, 3.4vh), 34px); font-weight: 700; animation: slide-in 0.4s ease-out backwards; }
.board li:nth-child(1) { background: color-mix(in srgb, var(--a3) 34%, var(--stage-2)); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--a3) 70%, transparent); }
.board .rank { text-align: center; color: #cfc8db; }
.board .score { font-variant-numeric: tabular-nums; }
.board .move { font-size: 0.7em; text-align: center; }
.board .move.up { color: #6fd6a4; }
.board .move.down { color: #f08a80; }
@keyframes slide-in { from { transform: translateX(-30px); opacity: 0; } }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 2vw; height: 52vh; }
.step { width: min(260px, 22vw); display: flex; flex-direction: column; align-items: center; gap: 1vh; }
.step .who { font-size: clamp(20px, 2.4vw, 42px); font-weight: 800; text-align: center; overflow-wrap: anywhere; }
.step .pts { color: #cfc8db; font-size: clamp(16px, 1.6vw, 26px); font-variant-numeric: tabular-nums; }
.step .block { width: 100%; border-radius: 14px 14px 0 0; display: grid; place-items: start center; padding-top: 2vh; font-size: clamp(40px, 5vw, 90px); font-weight: 900; animation: rise 0.9s cubic-bezier(.2,.8,.2,1) backwards; }
.step.p1 .block { height: 30vh; background: var(--accent); animation-delay: 1.2s; }
.step.p2 .block { height: 22vh; background: #5b5270; animation-delay: 0.6s; }
.step.p3 .block { height: 15vh; background: #463f57; }
.step.p1 .who, .step.p1 .pts { animation: fade 0.4s 1.8s backwards; }
@keyframes rise { from { height: 0; } }
@keyframes fade { from { opacity: 0; } }
.slide-stage { flex: 1; display: grid; place-content: center; gap: 3vh; text-align: center; padding: 0 8vw; }
.slide-stage h2 { font-size: clamp(34px, 5vw, 90px); margin: 0; }
.slide-stage p { font-size: clamp(20px, 2.4vw, 42px); margin: 0; white-space: pre-line; color: #e2dcea; }
.slide-stage img { max-height: 45vh; margin: 0 auto; border-radius: 14px; }
.stage-msg { flex: 1; display: grid; place-content: center; text-align: center; gap: 16px; font-size: 24px; }

/* ── the phone ─────────────────────────────────────────────────────── */
body.play-body { background: var(--stage); color: #f6f2ea; }
.play { min-height: 100dvh; display: flex; flex-direction: column; }
.play-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; font-weight: 700; min-height: 52px; }
.play-top .brand { font-size: 18px; color: #fff; }
.play-top .score { margin-inline-start: auto; padding: 3px 12px; border-radius: 999px; background: var(--stage-2); font-variant-numeric: tabular-nums; }
.play-main { flex: 1; display: flex; flex-direction: column; padding: 8px 16px 20px; gap: 14px; }
.play-center { flex: 1; display: grid; place-content: center; text-align: center; gap: 14px; padding: 20px 8px; }
.play-center h1 { margin: 0; font-size: 28px; }
.play-center p { margin: 0; color: #cfc8db; font-size: 18px; }
.join-form { width: min(360px, 100%); margin: 0 auto; display: grid; gap: 14px; }
.join-form .input { min-height: 60px; font-size: 26px; text-align: center; font-weight: 800; border-radius: 14px; border: 0; color: var(--ink); }
.join-form .input.pin { letter-spacing: 0.2em; direction: ltr; font-variant-numeric: tabular-nums; }
.join-form .btn { min-height: 58px; font-size: 20px; border-radius: 14px; }
.timebar { height: 6px; border-radius: 99px; background: var(--stage-2); overflow: hidden; }
.timebar i { display: block; height: 100%; background: var(--accent); transform-origin: right; }
.play-q { font-size: 20px; font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.play-img { max-height: 28vh; margin: 0 auto; border-radius: 10px; }
.choices { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 52vh; }
.choices.few { grid-template-columns: 1fr; }
.choice-btn { border: 0; border-radius: 16px; background: var(--c); color: #fff; font-size: 20px; font-weight: 800; padding: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-align: center; overflow-wrap: anywhere; transition: transform 0.08s, opacity 0.2s; touch-action: manipulation; }
.choice-btn .letter { font-size: 26px; width: 1.7em; height: 1.7em; }
.choice-btn.only-letter .letter { font-size: 56px; background: none; }
.choice-btn:active { transform: scale(0.97); }
.choice-btn[aria-pressed="true"] { box-shadow: 0 0 0 4px #fff inset; }
.choice-btn[aria-pressed="false"].multi { opacity: 0.6; }
.send-btn { min-height: 58px; font-size: 20px; border-radius: 14px; }
.order-play { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order-play li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--stage-2); border: 1px solid var(--stage-line); font-size: 18px; font-weight: 700; touch-action: none; }
.order-play li .n { width: 28px; height: 28px; border-radius: 50%; background: #514a62; display: grid; place-items: center; font-size: 14px; flex: none; }
.order-play li .t { flex: 1; overflow-wrap: anywhere; }
.order-play li .btn.icon { width: 40px; min-height: 40px; background: #2f2a3c; border-color: var(--stage-line); color: #fff; }
.order-play li.dragging { opacity: 0.6; border-color: #fff; }
.slider-play { display: grid; gap: 16px; padding: 10px 0; }
.slider-value { text-align: center; font-size: 56px; font-weight: 900; font-variant-numeric: tabular-nums; direction: ltr; }
.slider-play input[type="range"] { width: 100%; height: 44px; accent-color: var(--accent); direction: ltr; }
.slider-ends { display: flex; justify-content: space-between; color: #cfc8db; direction: ltr; }
.nudge { display: flex; gap: 12px; justify-content: center; }
.nudge .btn { width: 64px; min-height: 52px; font-size: 26px; background: var(--stage-2); border-color: var(--stage-line); color: #fff; }
.pin-play { position: relative; width: fit-content; align-self: center; margin: 0 auto; touch-action: manipulation; }
.pin-play img { max-height: 55vh; border-radius: 10px; }
.pin-play .marker { position: absolute; width: 26px; height: 26px; transform: translate(50%, -50%); border-radius: 50%; border: 4px solid #fff; background: var(--accent); box-shadow: 0 2px 8px rgb(0 0 0 / 50%); pointer-events: none; }
.scale-play { display: grid; gap: 8px; }
.scale-btns { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; direction: ltr; }
.scale-btns button { min-height: 64px; border: 0; border-radius: 12px; background: var(--stage-2); color: #fff; font-size: 22px; font-weight: 800; cursor: pointer; }
.scale-btns button:active { background: var(--accent); }
.scale-ends { display: flex; justify-content: space-between; color: #cfc8db; font-size: 14px; direction: ltr; }
.text-play { width: 100%; min-height: 60px; border-radius: 14px; border: 0; padding: 12px 14px; font-size: 22px; color: var(--ink); }
textarea.text-play { min-height: 120px; resize: none; }
.result { flex: 1; display: grid; place-content: center; text-align: center; gap: 10px; border-radius: 20px; margin: 4px 0; padding: 30px 16px; }
.result.ok { background: var(--ok); }
.result.bad { background: var(--bad); }
.result.partial { background: var(--a3); }
.result.none { background: var(--stage-2); }
.result .mark { font-size: 64px; line-height: 1; }
.result h2 { margin: 0; font-size: 32px; }
.result .pts { font-size: 26px; font-weight: 800; padding: 4px 18px; border-radius: 999px; background: rgb(0 0 0 / 22%); justify-self: center; font-variant-numeric: tabular-nums; }
.result p { margin: 0; font-size: 18px; }
.result .sol { font-size: 16px; opacity: 0.95; }
.final-rank { font-size: 90px; font-weight: 900; line-height: 1; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid var(--stage-2); border-top-color: var(--accent); animation: spin 0.9s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.countdown { font-size: 120px; font-weight: 900; line-height: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}

/* ── report ────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat { padding: 16px 18px; }
.stat b { display: block; font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--ok); }
.cell-ok { color: var(--ok); font-weight: 700; }
.cell-bad { color: var(--bad); }
.cell-none { color: var(--muted); }
.qdetail { padding: 14px 18px; display: grid; gap: 8px; }
.dist { display: grid; gap: 6px; }
.dist-row { display: grid; grid-template-columns: minmax(120px, 260px) 1fr 44px; gap: 10px; align-items: center; font-size: 14px; }
.dist-row .meter i { background: #8b84a0; }
.dist-row.ok .meter i { background: var(--ok); }
h2.sec { font-size: 20px; margin: 30px 0 12px; }

/* ── a separate screen waiting for a host ──────────────────────────── */
.pair-box { flex: 1; display: grid; place-content: center; text-align: center; gap: 2vh; }
.pair-box .how { font-size: clamp(20px, 2.4vw, 40px); color: #cfc8db; }
.pair-box .pin { font-size: clamp(80px, 14vw, 240px); font-weight: 900; letter-spacing: 0.12em; line-height: 1; direction: ltr; font-variant-numeric: tabular-nums; color: #fff; margin: 3vh 0; }
.pair-box .muted { color: #8f87a1; }

/* ── controlling the game from a phone ─────────────────────────────── */
.control-body { padding-bottom: 100px; }
.ctl { max-width: 640px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.ctl-head { display: flex; gap: 12px; align-items: flex-start; }
.ctl-head h1 { margin: 0; font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.ctl-pin { text-align: center; background: var(--ink); color: #fff; border-radius: 14px; padding: 6px 14px; }
.ctl-pin b { display: block; font-size: 28px; letter-spacing: 0.08em; direction: ltr; font-variant-numeric: tabular-nums; }
.ctl-pin small { display: block; opacity: 0.7; font-size: 11px; }
.ctl-card { padding: 14px 16px; display: grid; gap: 10px; }
.ctl-q { margin: 0; font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
.ctl-answer { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: 8px 12px; display: grid; }
.ctl-answer small { font-weight: 600; }
.ctl-clock { font-size: 22px; font-variant-numeric: tabular-nums; }
.ctl-players { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.ctl-players li { display: flex; align-items: center; padding: 4px 2px; border-bottom: 1px solid var(--line); }
.ctl-top { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; }
.ctl-top li span { margin-inline-end: 10px; }
.ctl-bar { position: fixed; bottom: 0; inset-inline: 0; display: flex; gap: 10px; align-items: center; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgb(0 0 0 / 6%); z-index: 30; }
.ctl-bar .btn.big { font-size: 19px; }
.ok-text { color: var(--ok); font-weight: 600; }
body.stage-body.no-cursor, body.stage-body.no-cursor * { cursor: none !important; }
.board.rest li:nth-child(1) { background: var(--stage-2); box-shadow: none; }
