/*
 * The Cluster (הקלאסטר) theme.
 * Deep teal surfaces layered with soft depth, rounded geometry, the logo's
 * hexagons as a faint texture, cyan for actions, a colour per answer letter,
 * amber for first place. Condensed numerals for anything that's a score.
 */
:root {
  --bg: #0a212b;
  --bg-deep: #071a22;
  --surface: #0f2e3b;
  --surface-2: #143a4a;
  --surface-3: #1a4558;
  --line: rgba(160, 225, 240, 0.09);
  --line-strong: rgba(160, 225, 240, 0.18);
  --highlight: rgba(255, 255, 255, 0.05);
  --text: #eef8fa;
  --text-2: #a3c2ca;
  --text-3: #6b8f99;
  --accent: #5fe6f4;
  --accent-rgb: 95, 230, 244;
  --accent-hover: #8ff0fa;
  --accent-ink: #052530;
  --gold: #f4b740;
  --gold-rgb: 244, 183, 64;
  --silver: #c3d3da;
  --bronze: #dc955f;
  --good: #3ad296;
  --good-rgb: 58, 210, 150;
  --good-ink: #03251a;
  --bad: #f26d6d;
  --bad-rgb: 242, 109, 109;
  --bad-ink: #2b0808;
  /* one colour per answer letter, the same on the projector and the phones */
  --o0: #57dcef; --o0-rgb: 87, 220, 239;
  --o1: #f4b545; --o1-rgb: 244, 181, 69;
  --o2: #f27fb2; --o2-rgb: 242, 127, 178;
  --o3: #a593ff; --o3-rgb: 165, 147, 255;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 0 var(--highlight) inset, 0 10px 30px -12px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 1px 0 var(--highlight) inset, 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --font: Rubik, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --num: "Barlow Condensed", Rubik, ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
html, body { min-height: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--text); background: var(--bg);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
/* Faint hexagon texture from the logo, lit from the top. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 520px at 50% -160px, rgba(var(--accent-rgb), 0.10), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cpath d='M28 0l28 16.2v32.4L28 64.8 0 48.6V16.2zM28 64.8v32.4M0 97V80.8M56 97V80.8' fill='none' stroke='%2385e6f2' stroke-opacity='.05' stroke-width='1'/%3E%3C/svg%3E");
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 75%);
  mask-image: linear-gradient(to bottom, #000, transparent 75%);
}
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
code {
  font-family: var(--mono); font-size: 0.84em; color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1); border: 1px solid rgba(var(--accent-rgb), 0.16);
  border-radius: 6px; padding: 0.04em 0.36em;
}
svg { display: block; }

/* ---------- Hebrew ---------- */
/* Barlow Condensed has no Hebrew letters, so Hebrew labels fall back to Rubik: no wide tracking for those. */
:lang(he) .eyebrow, :lang(he) .label, :lang(he) .tag, :lang(he) .pill { letter-spacing: 0.02em; }
/* Numbers, PINs, addresses and clocks always read left to right. */
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- type ---------- */
.eyebrow, .label {
  font-family: var(--num); font-size: 15px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-3);
}
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 14px; }
.error {
  padding: 12px 14px; border-radius: var(--r); font-size: 14px; line-height: 1.45; color: var(--text);
  background: rgba(var(--bad-rgb), 0.12); border: 1px solid rgba(var(--bad-rgb), 0.4);
}
.error:empty { display: none; }
.h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.h2 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.num { font-family: var(--num); font-weight: 700; letter-spacing: 0.01em; }

/* ---------- app shell ---------- */
.appbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
  background: rgba(7, 26, 34, 0.72); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; flex: none; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-mark { height: 34px; width: auto; filter: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.25)); }
.brand .sub { font-weight: 400; color: var(--text-3); }
.brand-logo { display: block; margin: 0 auto; height: auto; }
.appbar-right { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 15px; }
.appbar-right b { color: var(--text); }
.chip-info {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; white-space: nowrap;
}
.chip-info .sep { width: 1px; height: 16px; background: var(--line-strong); }
.chip-info.warn { color: var(--bad); border-color: rgba(var(--bad-rgb), 0.5); background: rgba(var(--bad-rgb), 0.08); }

/* Full-viewport screens for the projector: body + bottom bar. */
.fill { height: calc(100vh - 64px); height: calc(100dvh - 64px); display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.fill-body { min-height: 0; padding: clamp(24px, 4vh, 48px) clamp(24px, 4vw, 64px); }
.bar {
  position: sticky; bottom: 0; z-index: 6; display: flex; align-items: center; gap: 14px; padding: 14px clamp(24px, 4vw, 64px);
  background: rgba(7, 26, 34, 0.78); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(140%) blur(14px); backdrop-filter: saturate(140%) blur(14px);
}
.bar .spacer { flex: 1; }

.page { max-width: 720px; margin: 0 auto; padding: 40px 20px 60px; }
.center { display: grid; place-items: center; text-align: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 28px; }
.stack > * + * { margin-top: 18px; }
.stack-sm > * + * { margin-top: 8px; }

/* ---------- icons, avatars, tags ---------- */
.icon { width: 20px; height: 20px; flex: none; }
/* Initials in a plain circle; the text scales with the circle. */
.avatar {
  flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; overflow: hidden;
  container-type: inline-size; background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text);
}
.avatar > span { font-family: var(--font); font-weight: 600; font-size: 14px; font-size: 38cqw; line-height: 1; letter-spacing: 0.02em; }
.tag {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px;
  font-family: var(--num); font-size: 15px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); background: rgba(var(--accent-rgb), 0.1); border: 1px solid rgba(var(--accent-rgb), 0.2);
}
.tag.gray { color: var(--text-2); background: var(--surface); border-color: var(--line); }
.pill {
  display: inline-block; font-family: var(--num); font-size: 15px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent);
}
.pill.gray { color: var(--text-3); }

/* ---------- forms ---------- */
label.field { display: block; font-size: 14px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }
label.field .subtle { font-weight: 400; }
input[type="text"], input[type="password"] { -webkit-appearance: none; appearance: none; }
input[type="text"], input[type="password"], select {
  width: 100%; height: 50px; padding: 0 16px; font: 500 16px var(--font); color: var(--text);
  background: var(--bg-deep); border: 1px solid var(--line-strong); border-radius: var(--r); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select option { background: var(--surface); color: var(--text); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.14); }
input::placeholder { color: var(--text-3); }
input.pin { direction: ltr; height: 64px; font-family: var(--num); font-size: 36px; font-weight: 700; letter-spacing: 0.32em; text-align: center; padding: 0 0 0 0.32em; }
.input-wrap { position: relative; }
.input-wrap input { padding-inline-end: 52px; }
.input-wrap .icon-btn { position: absolute; inset-inline-end: 5px; top: 5px; width: 40px; height: 40px; border: 0; background: transparent; }

.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px;
  padding: 12px 22px; font: 600 15px/1 var(--font); border-radius: var(--r);
  border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 8px 22px -10px rgba(var(--accent-rgb), 0.7);
  -webkit-appearance: none; appearance: none; transition: background 0.15s, border-color 0.15s, transform 0.12s, box-shadow 0.15s;
}
button { touch-action: manipulation; }
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn:focus-visible, .icon-btn:focus-visible, .answer:focus-visible, .seg label:has(input:focus-visible), .toggle-chip:has(input:focus-visible) {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn.block { width: 100%; }
.btn.lg { min-height: 54px; padding: 16px 28px; font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 14px; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: 0 1px 0 var(--highlight) inset; }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--bad); border-color: rgba(var(--bad-rgb), 0.35); box-shadow: none; }
.btn.danger:hover { background: rgba(var(--bad-rgb), 0.1); border-color: var(--bad); }
.btn kbd {
  font: 600 11px/1 var(--font); padding: 4px 6px; border-radius: 6px;
  background: rgba(5, 37, 48, 0.12); border: 1px solid rgba(5, 37, 48, 0.25);
}

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; cursor: pointer;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); }
.icon-btn[aria-pressed="true"] { color: var(--accent); }

/* Music: speaker toggle + volume in one pill */
.sound {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding-inline-end: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.sound .icon-btn { border: 0; background: transparent; border-radius: 999px; width: 40px; height: 38px; }
.sound .icon-btn.start { width: auto; padding: 0 12px 0 14px; display: inline-flex; gap: 8px; font: 600 14px var(--font); color: var(--accent); }
.range {
  --v: 70%;
  direction: ltr; -webkit-appearance: none; appearance: none; width: 96px; height: 18px; margin: 0; background: transparent; cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--v), var(--surface-3) var(--v)); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--surface-3); }
.range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: var(--text); border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 0; }
.range:disabled { opacity: 0.35; }
@media (max-width: 700px) { .sound .range { display: none; } .sound { padding-inline-end: 0; } }

/* Multi-select topic chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 14px; cursor: pointer; user-select: none;
  border: 1px solid var(--line-strong); border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--text-2);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.toggle-chip:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.4); }
.toggle-chip input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-chip .tick {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--text-3); display: grid; place-items: center; transition: all 0.15s;
}
.toggle-chip .tick svg { width: 10px; height: 10px; opacity: 0; color: var(--accent-ink); }
.toggle-chip:has(input:checked) { border-color: rgba(var(--accent-rgb), 0.55); color: var(--text); background: rgba(var(--accent-rgb), 0.12); }
.toggle-chip:has(input:checked) .tick { background: var(--accent); border-color: var(--accent); }
.toggle-chip:has(input:checked) .tick svg { opacity: 1; }
.toggle-chip .n { color: var(--text-3); font-family: var(--num); font-size: 15px; font-weight: 600; }

/* Segmented control (radio buttons) */
.seg { display: flex; padding: 4px; gap: 4px; background: var(--bg-deep); border: 1px solid var(--line-strong); border-radius: var(--r); }
.seg label {
  position: relative; flex: 1; display: grid; place-items: center; height: 40px; padding: 0 8px; cursor: pointer; user-select: none;
  border-radius: var(--r-sm); font-size: 15px; font-weight: 500; color: var(--text-2); white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.seg label:hover { color: var(--text); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 var(--highlight) inset, 0 2px 8px rgba(0, 0, 0, 0.3); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; color: var(--text-2); user-select: none; }
.switch input { -webkit-appearance: none; appearance: none; flex: none; width: 42px; height: 24px; border-radius: 12px; background: var(--surface-3); position: relative; cursor: pointer; transition: background 0.2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); transition: transform 0.2s var(--ease); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(-18px); background: #fff; }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- answers: colour-coded letter + the answer text ---------- */
.answers { display: grid; gap: 10px; }
.answer[data-i="0"] { --o: var(--o0); --o-rgb: var(--o0-rgb); }
.answer[data-i="1"] { --o: var(--o1); --o-rgb: var(--o1-rgb); }
.answer[data-i="2"] { --o: var(--o2); --o-rgb: var(--o2-rgb); }
.answer[data-i="3"] { --o: var(--o3); --o-rgb: var(--o3-rgb); }
.answer {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px;
  text-align: left; font: 500 17px/1.35 var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s, opacity 0.3s, transform 0.12s, box-shadow 0.2s;
}
.answer::before { /* colour edge */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--o); opacity: 0.9;
}
.answer > * { position: relative; }
.answer .badge {
  flex: none; align-self: stretch; min-height: 44px; width: 48px; display: grid; place-items: center; border-radius: 10px;
  font-family: var(--num); font-size: 24px; font-weight: 700; color: var(--o); background: rgba(var(--o-rgb), 0.14);
  transition: background 0.2s, color 0.2s;
}
.answer .answer-text { flex: 1; min-width: 0; padding: 4px 4px 4px 0; overflow-wrap: anywhere; }
.answer .answer-meta { flex: none; padding: 0 10px 0 4px; text-align: right; font-family: var(--num); font-size: 1.25em; font-weight: 700; color: var(--text-2); line-height: 1.05; }
.answer .answer-meta small { display: block; font-family: var(--font); font-size: 0.55em; font-weight: 400; color: var(--text-3); }
.answer .answer-fill {
  position: absolute; inset: 0 auto 0 0; width: var(--pct, 0%); background: rgba(var(--o-rgb), 0.12);
  animation: grow 1s var(--ease) 0.15s backwards;
}

button.answer { cursor: pointer; -webkit-appearance: none; appearance: none; }
button.answer:active { transform: scale(0.985); }
@media (hover: hover) {
  button.answer:hover { border-color: rgba(var(--o-rgb), 0.45); background: var(--surface-2); }
}
.answer.chosen { border-color: var(--o); background: rgba(var(--o-rgb), 0.12); box-shadow: 0 0 0 1px var(--o), var(--shadow); }
.answer.chosen .badge { background: var(--o); color: #08232c; }
.answers.locked .answer:not(.chosen) { opacity: 0.38; }
.answers.locked .answer { pointer-events: none; }

.answer.correct { --o: var(--good); --o-rgb: var(--good-rgb); border-color: var(--good); box-shadow: 0 0 0 1px var(--good), 0 12px 32px -14px rgba(var(--good-rgb), 0.6); }
.answer.correct .badge { background: var(--good); color: var(--good-ink); }
.answer.correct .answer-meta { color: var(--good); }
.answer.wrong { color: var(--text-2); }
.answer.wrong::before { background: var(--text-3); opacity: 0.4; }
.answer.wrong .badge { color: var(--text-3); background: rgba(255, 255, 255, 0.04); }
.answer.wrong .answer-fill { background: rgba(255, 255, 255, 0.05); }

/* ---------- timer bar ---------- */
.timebar { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.timebar > i {
  display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--accent);
  transform-origin: right; transition: background 0.3s;
}
.timebar.low > i { background: var(--bad); }
.bar > .timebar { position: absolute; top: -1px; left: 0; right: 0; height: 3px; border-radius: 0; background: transparent; }

/* ---------- ranking list ---------- */
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-row {
  position: relative; display: grid; grid-template-columns: 2.4em minmax(0, 1fr) auto 5.4em; align-items: center; gap: 16px;
  padding: 8px 20px 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); animation: rise 0.35s var(--ease) both;
}
.rank-row .rank {
  justify-self: center; display: grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%;
  font-family: var(--num); font-size: 1.1em; font-weight: 700; color: var(--text-2); background: var(--bg-deep);
}
.rank-row .who { display: flex; align-items: center; gap: 14px; min-width: 0; }
.rank-row .avatar { width: 1.5em; height: 1.5em; }
.rank-row .name { min-width: 0; font-weight: 600; line-height: 1.15; overflow-wrap: anywhere; }
.rank-row .move { font-family: var(--num); font-size: 0.75em; font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.rank-row .move.up { color: var(--good); }
.rank-row .move.down { color: var(--text-3); }
.rank-row .move svg { width: 0.9em; height: 0.9em; }
.rank-row .delta {
  font-family: var(--num); font-size: 0.8em; font-weight: 700; color: var(--good);
  padding: 0.15em 0.55em; border-radius: 999px; background: rgba(var(--good-rgb), 0.12);
}
.rank-row .delta:empty { visibility: hidden; }
.rank-row .score { font-family: var(--num); font-size: 1.3em; font-weight: 700; text-align: right; }
.flip .rank-row { animation: none; }
.rank-row.r1 { border-color: rgba(var(--gold-rgb), 0.5); background: linear-gradient(90deg, rgba(var(--gold-rgb), 0.12), var(--surface) 55%); }
.rank-row.r1 .rank { background: var(--gold); color: #2a1c00; }
.rank-row.r1 .score { color: var(--gold); }
.rank-row.r2 .rank { background: var(--silver); color: #142028; }
.rank-row.r3 .rank { background: var(--bronze); color: #2a1406; }

/* ---------- misc ---------- */
.dot-loader { display: inline-flex; gap: 6px; }
.dot-loader i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.dot-loader i:nth-child(2) { animation-delay: 0.15s; }
.dot-loader i:nth-child(3) { animation-delay: 0.3s; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(var(--accent-rgb), 0.25); border-top-color: var(--accent); animation: spin 0.8s linear infinite; flex: none; }

/* Small stat tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px; }
.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 0; }
.tile .k { display: block; font-size: 13px; color: var(--text-3); }
.tile .v { display: block; margin-top: 4px; font-family: var(--num); font-size: 26px; font-weight: 700; line-height: 1.05; overflow-wrap: anywhere; }
.tile .v small { font-size: 0.6em; color: var(--text-3); font-weight: 600; }
.tile.wide { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tile.wide .v { margin: 0; font-family: var(--font); font-size: 16px; font-weight: 600; text-align: right; }

/* ---------- dialogs (instead of the browser's confirm()) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: rgba(3, 14, 19, 0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fadeIn 0.18s ease-out both;
}
.modal {
  width: min(440px, 100%); padding: 28px 28px 22px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 20px; box-shadow: var(--shadow-lg);
  animation: modalIn 0.28s var(--ease) both;
}
.modal .avatar, .modal .modal-icon { width: 64px; height: 64px; margin: 0 auto 14px; }
.modal-icon { display: grid; place-items: center; border-radius: 50%; color: var(--bad); background: rgba(var(--bad-rgb), 0.14); }
.modal-icon svg { width: 30px; height: 30px; }
.modal-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.modal-body { margin-top: 8px; color: var(--text-2); font-size: 15px; line-height: 1.5; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn { flex: 1; }
.modal-actions .spacer { display: none; }
.modal-actions:has([data-r="extra"]) { flex-wrap: wrap; }
.modal-actions [data-r="extra"] { flex-basis: 100%; }
.modal-backdrop.closing { animation: fadeOut 0.16s ease-in both; }
.modal-backdrop.closing .modal { animation: modalOut 0.16s ease-in both; }
@media (max-width: 480px) { .modal-actions { flex-direction: column-reverse; } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
@keyframes modalOut { to { opacity: 0; transform: scale(0.97); } }
.btn.danger-solid { background: var(--bad); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 8px 22px -10px rgba(var(--bad-rgb), 0.8); }
.btn.danger-solid:hover { background: #f58585; }

/* ---------- inline form messages (instead of the browser's bubbles) ---------- */
.field-msg {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; color: var(--bad);
  animation: rise 0.2s ease-out both;
}
.field-msg::before {
  content: "!"; flex: none; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  font: 700 12px/1 var(--font); color: var(--bad-ink); background: var(--bad);
}
input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 4px rgba(var(--bad-rgb), 0.15); }
input.shake { animation: shake 0.35s ease-in-out; }
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

.toast {
  position: fixed; left: 50%; bottom: 100px; z-index: 30; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid rgba(var(--bad-rgb), 0.5); box-shadow: var(--shadow-lg);
  font-weight: 600; animation: toastIn 0.3s var(--ease) both;
}

.screen-enter { animation: screenIn 0.4s var(--ease) backwards; }
@keyframes screenIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes grow { from { width: 0; } }
@keyframes okpulse { 0% { transform: scale(1); } 35% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes dim { to { opacity: 0.55; } }
@keyframes bump { 40% { transform: scale(1.18); } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(0.6); } 70% { transform: scale(1.06); } 100% { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); } 40% { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
/* Kahoot-style bouncing players: drop in with a squash, then hop now and then. */
@keyframes jumpIn {
  0% { opacity: 0; transform: translateY(-38px) scale(0.5); }
  50% { opacity: 1; transform: translateY(5px) scale(1.08, 0.9); }
  72% { transform: translateY(-7px) scale(0.97, 1.04); }
  88% { transform: translateY(1px) scale(1.02, 0.98); }
  100% { opacity: 1; transform: none; }
}
@keyframes bigJump {
  0%, 100% { transform: none; }
  14% { transform: translateY(4px) scale(1.14, 0.84); }
  42% { transform: translateY(-48px) scale(0.92, 1.1); }
  64% { transform: translateY(0) scale(1.16, 0.84); }
  78% { transform: translateY(-10px) scale(0.97, 1.04); }
  90% { transform: translateY(0) scale(1.04, 0.96); }
}
@keyframes bob {
  0%, 55%, 100% { transform: none; }
  8% { transform: translateY(2px) scale(1.05, 0.94); }
  22% { transform: translateY(-16px) scale(0.96, 1.05); }
  36% { transform: translateY(0) scale(1.08, 0.92); }
  45% { transform: translateY(-4px); }
}
/* Podium celebration: a happy hop, then a pause. */
@keyframes cheer {
  0%, 60%, 100% { transform: none; }
  8% { transform: translateY(3px) scale(1.1, 0.88); }
  24% { transform: translateY(-26px) scale(0.94, 1.08) rotate(-6deg); }
  38% { transform: translateY(0) scale(1.12, 0.88); }
  46% { transform: translateY(-8px) rotate(4deg); }
  54% { transform: translateY(0); }
}
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.08); opacity: 0.15; } }
.answer.correct { animation: okpulse 0.6s ease-out 0.15s; }
.answer.wrong { animation: dim 0.5s ease 0.2s both; }
.bump { display: inline-block; animation: bump 0.3s ease-out; }
.player.leaving { opacity: 0; transform: scale(0.8); transition: opacity 0.18s, transform 0.18s; }
.rise { animation: rise 0.35s var(--ease) both; }
.pop { animation: pop 0.45s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
