/* Lamma: chunky game tiles on CODED's mist-blue ground.
   One family for display (Baloo Bhaijaan 2), one for reading (Readex Pro); both carry Arabic. */

@font-face { font-family: "Readex Pro"; src: url("/fonts/ReadexPro.ttf") format("truetype"); font-weight: 160 700; font-display: swap; }
@font-face { font-family: "Baloo Bhaijaan 2"; src: url("/fonts/BalooBhaijaan2.ttf") format("truetype"); font-weight: 400 800; font-display: swap; }

:root {
  --ground: #EEF3FC;
  --surface: #FFFFFF;
  --ink: #14243F;
  --muted: #4E5869;
  --line: #CFDAF0;
  --action: #012891;
  --action-edge: #00145A;
  --action-ink: #FFFFFF;
  --spark: #FFB938;
  --spark-ink: #14243F;
  --tile-edge: rgba(20, 36, 63, .22);
  --t0: #0B8A31; --t0-ink: #FFFFFF;
  --t1: #2474BA; --t1-ink: #FFFFFF;
  --t2: #FFB938; --t2-ink: #14243F;
  --t3: #D41544; --t3-ink: #FFFFFF;
  --o0: #D41544; --o1: #2474BA; --o2: #FFB938; --o3: #0B8A31;
  --o0-ink: #FFFFFF; --o1-ink: #FFFFFF; --o2-ink: #14243F; --o3-ink: #FFFFFF;
  --good: #0B8A31;
  --bad: #D41544;
  --radius: 14px;
  --display: "Baloo Bhaijaan 2", "Readex Pro", system-ui, sans-serif;
  --text: "Readex Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

[data-theme="academy"] {
  --ground: #0B1A36; --surface: #14243F; --ink: #EEF3FC; --muted: #B4BED0; --line: #2C3B5A;
  --action: #2A6ADA; --action-edge: #123E8F; --action-ink: #FFFFFF; --tile-edge: rgba(0, 0, 0, .45);
  color-scheme: dark;
}

[data-theme="night"] {
  --ground: #141B3D; --surface: #241A44; --ink: #FFF1C9; --muted: #D2C7EA; --line: #3E2E62;
  --action: #F2B544; --action-edge: #A8741A; --action-ink: #141B3D; --spark: #E8743B; --spark-ink: #FFFFFF;
  --tile-edge: rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--text);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--action); }
[data-theme="night"] a, [data-theme="academy"] a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--spark); outline-offset: 3px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* ---- Top bar and wordmark ---------------------------------------------- */
.topbar { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding-block: 4px 12px; }
.topbar.slim { padding-block-end: 4px; }
.topnav { display: flex; align-items: center; gap: 8px; }
.topnav a { font-weight: 500; text-decoration: none; padding: 8px 10px; }
.wordmark {
  font: 800 1.6rem/1 var(--display);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -.01em;
  direction: ltr;
}
.wordmark.small { font-size: 1.25rem; }
.brk { color: var(--action); font-weight: 600; }
.pin-small { font: 700 1.25rem/1 var(--display); letter-spacing: .08em; }

/* ---- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px;
  border: 0; border-radius: 999px;
  font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn-primary { background: var(--action); color: var(--action-ink); box-shadow: 0 4px 0 var(--action-edge); }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--action-edge); }
.btn-quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }
.btn-quiet:hover { box-shadow: inset 0 0 0 2px var(--action); }
.btn-spark { background: var(--spark); color: var(--spark-ink); box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.btn-big { min-height: 60px; font-size: 1.2rem; padding-inline: 32px; }
.btn-ghost { background: none; border: 0; padding: 8px 10px; cursor: pointer; font-weight: 500; border-radius: 8px; }
.btn-ghost[aria-pressed="true"] { opacity: .5; }
.btn-mini {
  border: 0; border-radius: 999px; padding: 4px 12px; min-height: 32px;
  background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); cursor: pointer; font-size: .9rem; text-decoration: none; color: var(--ink);
}
.btn-mini.danger, .btn.danger { background: var(--bad); color: #fff; box-shadow: none; }
.link { font-size: .95rem; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 20px; }
.actions.end { justify-content: flex-end; }
.actions.start { justify-content: flex-start; }
.actions.spread { justify-content: space-between; }
.actions.sticky { position: sticky; bottom: 0; background: var(--ground); padding-block: 12px; justify-content: flex-end; }

.pill { display: inline-block; padding: 4px 14px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 600; }
.pill-spark { background: var(--spark); color: var(--spark-ink); box-shadow: none; }
.banner { background: var(--spark); color: var(--spark-ink); text-align: center; padding: 6px; border-radius: 10px; margin: 0 0 8px; font-weight: 600; }
.hint { color: var(--muted); margin: 6px 0; }
.form-error { color: var(--bad); font-weight: 600; min-height: 1.4em; margin: 8px 0; }
[data-theme="night"] .form-error, [data-theme="academy"] .form-error { color: #FF8FA8; }

/* ---- Tiles: the signature ------------------------------------------------ */
.pin-box { position: relative; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; width: 100%; max-width: 420px; margin-inline: auto; cursor: text; }
.pin-tile {
  aspect-ratio: 4 / 5; display: grid; place-items: center;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: inset 0 0 0 2px var(--line), 0 5px 0 var(--tile-edge);
  font: 800 clamp(1.8rem, 9vw, 2.8rem)/1 var(--display); color: var(--ink);
}
.pin-tile.filled { box-shadow: inset 0 0 0 2px var(--action), 0 5px 0 var(--action-edge); }
.pin-tile.next { box-shadow: inset 0 0 0 3px var(--spark), 0 5px 0 var(--tile-edge); }
.pin-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; font-size: 16px; caret-color: transparent; border: 0;
}

.pin-show { display: flex; justify-content: center; gap: clamp(6px, 1vw, 14px); width: 100%; }
.pin-show .pin-tile { flex: 0 1 clamp(48px, 6.5vw, 120px); min-width: 0; font-size: clamp(2.2rem, 5.4vw, 6rem); }
.pin-show .gap { margin-inline-end: clamp(10px, 1.6vw, 28px); }

/* ---- Home ---------------------------------------------------------------- */
.home { display: grid; gap: 56px; max-width: 980px; width: 100%; margin-inline: auto; padding-bottom: 32px; }
.display { font: 800 clamp(2rem, 6vw, 3.6rem)/1.08 var(--display); margin: 0 0 20px; letter-spacing: -.01em; }
.join-hero { text-align: center; padding-top: clamp(12px, 6vh, 64px); display: grid; justify-items: center; gap: 14px; }
.join-hero .display { max-width: 14ch; }
.join-card {
  width: min(100%, 480px); background: var(--surface); border-radius: 24px;
  padding: 24px clamp(16px, 4vw, 32px) 28px; box-shadow: 0 8px 0 var(--tile-edge), inset 0 0 0 2px var(--line);
  display: grid; gap: 10px; text-align: center;
}
.pin-label { font: 700 1.25rem/1.2 var(--display); }
.join-card .btn { margin-top: 6px; }
.how h2, .modes h2, .safe h2 { font: 800 1.7rem/1.2 var(--display); margin: 0 0 16px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; padding: 0; margin: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: inset 0 0 0 2px var(--line); }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; margin-bottom: 10px; background: var(--action); color: var(--action-ink); font: 800 1.3rem/1 var(--display); box-shadow: 0 3px 0 var(--action-edge); }
.mode-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.mode-card { background: var(--surface); border-radius: 20px; padding: 20px; box-shadow: inset 0 0 0 2px var(--line); }
.mode-card h3 { font: 800 1.4rem/1.2 var(--display); margin: 14px 0 6px; }
.mode-card p { margin: 0; color: var(--muted); }
.mini-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 240px; }
.mt { display: grid; place-items: center; height: 44px; border-radius: 10px; font: 800 1.1rem/1 var(--display); box-shadow: 0 3px 0 var(--tile-edge); }
.mt0 { background: var(--o0); color: var(--o0-ink); } .mt1 { background: var(--o1); color: var(--o1-ink); }
.mt2 { background: var(--o2); color: var(--o2-ink); } .mt3 { background: var(--o3); color: var(--o3-ink); }
.safe { max-width: 64ch; }
.safe p { margin: 0; }
.foot { margin-top: auto; padding-top: 24px; color: var(--muted); font-size: .9rem; text-align: center; }

/* ---- Forms --------------------------------------------------------------- */
.field { display: grid; gap: 6px; text-align: start; }
.field label { font-weight: 600; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
}
.input:focus { border-color: var(--action); outline: none; }
.input-big { min-height: 60px; font-size: 1.3rem; text-align: center; }
textarea.input { resize: vertical; }
.bad > .input, .bad .input, .field.bad .input, .opt-row.bad .input { border-color: var(--bad); }
.cat-card.bad { box-shadow: inset 0 0 0 2px var(--bad); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: 8px; }
.room-title { font-weight: 600; color: var(--muted); margin: 0; }

/* ---- Player phone -------------------------------------------------------- */
.play { flex: 1; display: grid; place-items: center; text-align: center; width: 100%; max-width: 560px; margin-inline: auto; }
.play > * { width: 100%; }
.wait, .result, .answer { display: grid; gap: 14px; justify-items: center; }
.big-word { font: 800 clamp(2.2rem, 11vw, 3.6rem)/1.05 var(--display); margin: 0; }
.lead { font-size: 1.2rem; margin: 0; }
.gain { font: 800 1.8rem/1 var(--display); color: var(--good); margin: 0; }
[data-theme="night"] .gain, [data-theme="academy"] .gain { color: #7FE39A; }
.me-chip { font-weight: 600; padding: 4px 12px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--line); max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-pick legend { text-align: center; width: 100%; }
.team-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.team-btn {
  min-height: 64px; border: 0; border-radius: var(--radius); cursor: pointer; font-weight: 700; font-size: 1.1rem;
  box-shadow: 0 4px 0 var(--tile-edge); display: flex; align-items: center; justify-content: center; gap: 8px;
}
.team-btn[aria-pressed="true"] { outline: 4px solid var(--ink); outline-offset: 2px; }
.team-btn.any { grid-column: 1 / -1; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); min-height: 48px; }
.team-0 { --tc: var(--t0); --tci: var(--t0-ink); } .team-1 { --tc: var(--t1); --tci: var(--t1-ink); }
.team-2 { --tc: var(--t2); --tci: var(--t2-ink); } .team-3 { --tc: var(--t3); --tci: var(--t3-ink); }
.team-btn[class*="team-"], .team-badge { background: var(--tc); color: var(--tci); }
.team-badge { padding: 8px 20px; border-radius: 999px; font-weight: 700; font-size: 1.2rem; margin: 0; }
.ti { font-size: 1.2em; }

.q-head { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 12px; }
.q-cat { font-weight: 600; color: var(--muted); }
.timer {
  display: grid; place-items: center; min-width: 52px; height: 52px; padding-inline: 8px; border-radius: 50%;
  background: var(--action); color: var(--action-ink); font: 800 1.5rem/1 var(--display); box-shadow: 0 3px 0 var(--action-edge);
}
.q-text { font: 600 clamp(1.2rem, 5vw, 1.6rem)/1.35 var(--text); margin: 0; overflow-wrap: anywhere; }
.opts { display: grid; gap: 12px; width: 100%; }
.opts.n2, .opts.n3, .opts.n4 { grid-template-columns: 1fr; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: start;
  min-height: 72px; padding: 12px 18px; border: 0; border-radius: var(--radius);
  font-weight: 700; font-size: 1.15rem; cursor: pointer; overflow-wrap: anywhere;
  box-shadow: 0 6px 0 var(--tile-edge); transition: transform .08s ease, box-shadow .08s ease, opacity .2s ease;
}
button.opt:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--tile-edge); }
.opt0 { background: var(--o0); color: var(--o0-ink); } .opt1 { background: var(--o1); color: var(--o1-ink); }
.opt2 { background: var(--o2); color: var(--o2-ink); } .opt3 { background: var(--o3); color: var(--o3-ink); }
.shape { font-size: 1.4em; line-height: 1; flex: none; width: 1.4em; text-align: center; }
.opt-text { flex: 1; }
.opt.chosen { width: 100%; }
.opt.dim { opacity: .35; }
.correct-opt { box-shadow: inset 0 0 0 5px var(--ink), 0 6px 0 var(--tile-edge); width: 100%; }
.result.good .big-word { color: var(--good); }
.result.bad .big-word { color: var(--bad); }
[data-theme="night"] .result.good .big-word, [data-theme="academy"] .result.good .big-word { color: #7FE39A; }
[data-theme="night"] .result.bad .big-word, [data-theme="academy"] .result.bad .big-word { color: #FF8FA8; }
.score-strip { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.score-chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 14px; border-radius: 999px; background: var(--tc); color: var(--tci); font-size: 1.1rem; }
.score-chip.turn { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---- Host / TV ----------------------------------------------------------- */
.stage { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 1600px; margin-inline: auto; }
.lobby { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(16px, 3vw, 48px); align-items: start; flex: 1; }
.door { display: grid; gap: 16px; justify-items: center; text-align: center; background: var(--surface); border-radius: 28px; padding: clamp(16px, 3vw, 40px); box-shadow: 0 8px 0 var(--tile-edge), inset 0 0 0 2px var(--line); }
.join-at { font: 700 clamp(1.1rem, 2.2vw, 2rem)/1.2 var(--display); margin: 0; }
.qr-wrap { margin: 0; display: grid; gap: 6px; justify-items: center; }
.qr { width: clamp(160px, 20vw, 300px); height: auto; border-radius: 12px; }
.qr-wrap figcaption { color: var(--muted); font-weight: 600; }
.roster-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.roster h2 { font: 800 clamp(1.4rem, 2.4vw, 2.2rem)/1.1 var(--display); margin: 0; }
.pchips { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pchip { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pchip-name { border: 0; cursor: pointer; padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: clamp(1rem, 1.3vw, 1.3rem); background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line), 0 3px 0 var(--tile-edge); }
.pchip.off .pchip-name { opacity: .45; }
.pmenu { display: flex; gap: 6px; flex-wrap: wrap; }
.team-cols { display: grid; gap: 12px; margin-top: 12px; }
.team-cols.n2 { grid-template-columns: 1fr 1fr; } .team-cols.n3, .team-cols.n4 { grid-template-columns: 1fr 1fr; }
.team-col { border-radius: 16px; padding: 12px; box-shadow: inset 0 0 0 3px var(--tc); background: var(--surface); }
.team-col h3 { margin: 0; font: 800 1.3rem/1.2 var(--display); }

.team-bar { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 16px; }
.team-score { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; padding: 10px 16px; border-radius: 16px; background: var(--tc); color: var(--tci); box-shadow: 0 5px 0 var(--tile-edge); }
.team-score.active { outline: 4px solid var(--ink); outline-offset: 3px; }
.tname { font-weight: 700; font-size: clamp(1rem, 1.4vw, 1.4rem); }
.tpoints { font: 800 clamp(1.6rem, 3vw, 3rem)/1 var(--display); }
.fix { display: flex; gap: 4px; width: 100%; justify-content: flex-end; }
.fix .btn-mini { min-height: 26px; padding: 2px 8px; font-size: .8rem; }

.board-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 14px; }
.turn { font: 800 clamp(1.4rem, 2.6vw, 2.4rem)/1.1 var(--display); margin: 0; padding: 4px 16px; border-radius: 12px; background: var(--tc); color: var(--tci); }
.board { display: grid; gap: clamp(8px, 1vw, 16px); flex: 1; }
.board.n2 { grid-template-columns: repeat(2, 1fr); } .board.n3 { grid-template-columns: repeat(3, 1fr); }
.board.n4 { grid-template-columns: repeat(4, 1fr); } .board.n5 { grid-template-columns: repeat(5, 1fr); }
.board.n6 { grid-template-columns: repeat(6, 1fr); } .board.n7 { grid-template-columns: repeat(7, 1fr); } .board.n8 { grid-template-columns: repeat(8, 1fr); }
.board-col { display: grid; gap: clamp(8px, 1vw, 14px); align-content: start; }
.board-cat { margin: 0; min-height: 3.2em; display: grid; place-items: center; text-align: center; padding: 8px; border-radius: 12px; background: var(--ink); color: var(--ground); font: 700 clamp(1rem, 1.6vw, 1.6rem)/1.15 var(--display); overflow-wrap: anywhere; }
.tile {
  min-height: clamp(56px, 9vh, 110px); border: 0; border-radius: var(--radius); cursor: pointer;
  background: var(--action); color: var(--action-ink); font: 800 clamp(1.4rem, 3vw, 3rem)/1 var(--display);
  box-shadow: 0 6px 0 var(--action-edge); transition: transform .08s ease, box-shadow .08s ease;
}
.tile:hover:not(.used) { transform: translateY(-2px); box-shadow: 0 8px 0 var(--action-edge); }
.tile:active:not(.used) { transform: translateY(5px); box-shadow: 0 1px 0 var(--action-edge); }
.tile.used { background: transparent; box-shadow: inset 0 0 0 2px var(--line); cursor: default; }

.question, .reveal { display: flex; flex-direction: column; gap: clamp(12px, 2vh, 24px); flex: 1; }
.q-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.q-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.q-meta .pill[class*="team-"] { background: var(--tc); color: var(--tci); box-shadow: none; }
.timer.big { width: clamp(72px, 8vw, 128px); height: clamp(72px, 8vw, 128px); font-size: clamp(2rem, 4vw, 3.6rem); }
.q-text.tv { font: 700 clamp(1.6rem, 3.6vw, 3.6rem)/1.2 var(--display); text-align: center; max-width: 30ch; margin-inline: auto; }
.q-text.tv.small { font-size: clamp(1.2rem, 2.4vw, 2.2rem); }
.opts.tv { grid-template-columns: 1fr 1fr; gap: clamp(10px, 1.4vw, 20px); }
.opts.tv .opt { min-height: clamp(80px, 13vh, 160px); font-size: clamp(1.2rem, 2.4vw, 2.4rem); padding-inline: clamp(14px, 2vw, 32px); position: relative; overflow: hidden; }
.opts.tv .correct-opt { width: auto; }
.bar-count { font: 800 1.2em/1 var(--display); z-index: 1; }
.bar { position: absolute; inset-block-end: 0; inset-inline-start: 0; height: 8px; width: calc(var(--w, 0) * 100%); background: rgba(255, 255, 255, .7); }
.count { font-weight: 600; color: var(--muted); }
.outcome { font: 800 clamp(1.6rem, 3vw, 3rem)/1.1 var(--display); text-align: center; margin: 0; padding: 8px 20px; border-radius: 16px; background: var(--tc, var(--surface)); color: var(--tci, var(--ink)); align-self: center; }
.leaders { list-style: none; padding: 0; margin: 0 auto; width: min(100%, 720px); display: grid; gap: 8px; }
.leaders li { display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); font-size: clamp(1.1rem, 1.8vw, 1.8rem); }
.lrank { font: 800 1.2em/1 var(--display); color: var(--action); min-width: 1.6em; }
[data-theme="night"] .lrank { color: var(--action); }
.lname { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.end { display: flex; flex-direction: column; align-items: center; gap: 24px; flex: 1; }
.end .display { text-align: center; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: clamp(8px, 2vw, 24px); width: min(100%, 980px); }
.step { flex: 1; display: grid; justify-items: center; gap: 6px; align-content: start; padding: 16px 10px; border-radius: 18px 18px 6px 6px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line), 0 6px 0 var(--tile-edge); text-align: center; }
.step[class*="team-"] { background: var(--tc); color: var(--tci); box-shadow: 0 6px 0 var(--tile-edge); }
.place-1 { min-height: 300px; order: 0; } .place-2 { min-height: 230px; } .place-3 { min-height: 180px; } .place-4 { min-height: 140px; }
.pname { font-weight: 700; font-size: clamp(1.1rem, 2vw, 2rem); overflow-wrap: anywhere; }
.pscore { font: 800 clamp(1.6rem, 3.4vw, 3.2rem)/1 var(--display); }
.pplace { font: 800 clamp(2rem, 5vw, 4.4rem)/1 var(--display); opacity: .5; }
.rest { width: min(100%, 720px); }

/* ---- Host setup ---------------------------------------------------------- */
.setup { max-width: 760px; width: 100%; margin-inline: auto; }
.setup-form { display: grid; gap: 22px; }
.choices { display: grid; gap: 8px; }
.choices.row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.choices legend { grid-column: 1 / -1; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice-body { display: grid; gap: 2px; padding: 12px 16px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); }
.choice-body small { color: var(--muted); font-size: .92rem; }
.choice input:checked + .choice-body { box-shadow: inset 0 0 0 3px var(--action); }
.choice input:focus-visible + .choice-body { outline: 3px solid var(--spark); outline-offset: 3px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--action); }

/* ---- Editor ---------------------------------------------------------------- */
.create { max-width: 860px; width: 100%; margin-inline: auto; }
.create h2 { font: 800 1.5rem/1.2 var(--display); margin: 32px 0 8px; }
.set-list { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.set-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); }
.set-row small { display: block; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.editor { display: grid; gap: 18px; }
.cat-card { display: grid; gap: 14px; padding: 16px; border-radius: 18px; background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); }
.cat-head { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.cat-head .field { flex: 1; min-width: 200px; }
.q-card { display: grid; gap: 10px; padding: 14px; border-radius: 14px; background: var(--ground); }
.opt-edit { display: grid; gap: 8px; }
.opt-row { display: flex; align-items: center; gap: 8px; }
.opt-row .shape { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-size: 1.1rem; }
.opt-row.opt0 .shape { background: var(--o0); color: var(--o0-ink); } .opt-row.opt1 .shape { background: var(--o1); color: var(--o1-ink); }
.opt-row.opt2 .shape { background: var(--o2); color: var(--o2-ink); } .opt-row.opt3 .shape { background: var(--o3); color: var(--o3-ink); }
.opt-row { background: none; }
.correct-pick { display: flex; align-items: center; gap: 4px; font-size: .9rem; white-space: nowrap; }
.correct-pick input { width: 20px; height: 20px; accent-color: var(--good); }
.q-settings { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.q-settings label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.q-settings .input { width: auto; min-height: 40px; padding: 6px 10px; }

.notfound { text-align: center; justify-content: center; gap: 8px; }

/* ---- Small screens --------------------------------------------------------- */
@media (max-width: 860px) {
  .lobby { grid-template-columns: 1fr; }
  .opts.tv { grid-template-columns: 1fr; }
  .board { overflow-x: auto; }
  .board.n4, .board.n5, .board.n6, .board.n7, .board.n8 { grid-template-columns: repeat(var(--cols, 4), minmax(120px, 1fr)); }
  .team-cols.n2, .team-cols.n3, .team-cols.n4 { grid-template-columns: 1fr; }
}
@media (min-width: 560px) {
  .opts.n4 { grid-template-columns: 1fr 1fr; }
}

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

/* User-written text takes its direction from its own content, so an English
   question inside the Arabic UI keeps "?" at the end (and the reverse). */
.q-text, .opt-text, .lname, .pname, .pchip-name, .me-chip, .board-cat, .room-title, .q-cat, .set-row b, .outcome { unicode-bidi: plaintext; }
.form-error:empty { display: none; }
.pin-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
