/* =====================================================================
   Scattergories — Classroom Edition
   All styling. Design tokens live in :root — change them there and the
   whole game follows. The look: deep plum, a hot orange die, and a board
   of answer cards that go green when nobody else thought of them.
   ===================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg:        #100a22;
  --bg-2:      #1a1038;
  --surface:   #241748;
  --surface-2: #2e1e5c;
  --surface-3: #3a2775;
  --line:      rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.07);

  /* Ink */
  --ink:   #f6f2ff;
  --muted: rgba(246, 242, 255, 0.66);
  --faint: rgba(246, 242, 255, 0.38);

  /* The die and the verdicts */
  --orange:   #ff7a1a;
  --orange-2: #ffa552;
  --yellow:   #ffd23f;
  --lime:     #57e389;
  --lime-2:   #2fd27a;
  --rose:     #ff4d6d;
  --rose-2:   #e11d48;
  --sky:      #38bdf8;
  --violet:   #a78bfa;

  --green: var(--lime);
  --red:   var(--rose);
  --amber: var(--yellow);

  --radius:    16px;
  --radius-lg: 26px;
  --radius-sm: 10px;
  --shadow:     0 24px 60px rgba(0, 0, 0, 0.55);
  --shadow-sm:  0 6px 20px rgba(0, 0, 0, 0.35);
  --glow:       0 0 44px rgba(255, 122, 26, 0.32);

  --font-display: 'Bungee', 'Fredoka', system-ui, sans-serif;
  --font-head:    'Fredoka', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, -apple-system, sans-serif;

  --dur:  0.2s;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --tap:  48px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* `hidden` only sets `display:none` at the weakest specificity, so any rule
   that gives an element its own display (flex, grid…) silently beats it.
   This makes the attribute mean what it says, everywhere. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 50% -8%, rgba(255, 122, 26, 0.20), transparent 62%),
    radial-gradient(ellipse 60% 45% at 6% 100%, rgba(87, 227, 137, 0.12), transparent 64%),
    radial-gradient(ellipse 60% 45% at 94% 100%, rgba(167, 139, 250, 0.14), transparent 64%),
    linear-gradient(180deg, var(--bg-2), var(--bg) 72%);
  background-attachment: fixed;
}
body { overflow: hidden; -webkit-text-size-adjust: 100%; }

img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------------
   Screens
   --------------------------------------------------------------------- */
#app { height: 100%; }
.screen { height: 100%; display: flex; flex-direction: column; }
.screen-center {
  align-items: center; justify-content: center; gap: 18px;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  text-align: center; overflow-y: auto;
}
.scroll-area { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 20px; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px;
  border-radius: 999px; border: 2px solid var(--line);
  background: var(--surface-2); color: var(--ink);
  font-family: var(--font-head); font-weight: 600; font-size: 1rem; letter-spacing: 0.01em;
  transition: transform var(--dur) var(--ease), background var(--dur), border-color var(--dur), box-shadow var(--dur);
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-3); transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled, .btn.is-disabled { opacity: 0.42; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-2));
  border-color: transparent; color: #2b1200; box-shadow: 0 10px 30px rgba(255, 122, 26, 0.34);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--orange-2), var(--yellow)); }
.btn-danger { background: linear-gradient(135deg, var(--rose-2), var(--rose)); border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line-soft); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 0.88rem; }
.btn-lg { min-height: 58px; padding: 0 30px; font-size: 1.1rem; }
.btn-xl { min-height: 66px; padding: 0 38px; font-size: 1.22rem; }
.btn-block { width: 100%; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; border-radius: 10px; }
.btn.is-busy { opacity: 0.7; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn-row-lg { gap: 16px; }
.btn-row-sm { gap: 8px; justify-content: flex-start; }

/* ---------------------------------------------------------------------
   Bars
   --------------------------------------------------------------------- */
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line-soft); background: rgba(16, 10, 34, 0.72);
  backdrop-filter: blur(10px); flex-shrink: 0;
}
.bar-slim { padding: 8px 14px; }
.bar-bottom {
  border-bottom: none; border-top: 1px solid var(--line-soft);
  justify-content: space-between; padding-bottom: max(12px, env(safe-area-inset-bottom));
  /* room on the right for the connection pill, which floats over this bar */
  padding-right: 130px;
}
.bar-title { font-family: var(--font-head); font-size: 1.14rem; font-weight: 600; }
.bar-spacer { flex: 1; }
.bar-pin { font-size: 0.86rem; color: var(--muted); letter-spacing: 0.08em; }
.bar-pin b { color: var(--yellow); font-family: var(--font-display); letter-spacing: 0.12em; margin-left: 4px; }
.bar-round { font-family: var(--font-head); font-weight: 600; color: var(--orange-2); }
.bar-phase { font-size: 0.84rem; color: var(--faint); }
.back-link { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; }

/* ---------------------------------------------------------------------
   Landing
   --------------------------------------------------------------------- */
.brand-kicker { font-family: var(--font-head); text-transform: uppercase; letter-spacing: 0.3em; font-size: 0.76rem; color: var(--muted); }
.brand-title {
  font-family: var(--font-display); font-size: clamp(2.6rem, 11vw, 6rem); line-height: 0.95;
  letter-spacing: 0.01em; margin: 10px 0 6px;
  background: linear-gradient(120deg, var(--yellow), var(--orange) 55%, var(--rose));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 8px 30px rgba(255, 122, 26, 0.35));
}
.brand-title span { display: block; }
.brand-sub { color: var(--muted); max-width: 34ch; margin: 0 auto; }
.landing-foot .is-ok { color: var(--lime); }
.landing-foot .is-warn { color: var(--yellow); }
.landing-foot .is-error { color: var(--rose); }
.resume-box {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px;
  background: var(--surface); max-width: 460px;
}
.resume-text { margin-bottom: 10px; }

/* ---------------------------------------------------------------------
   Cards, fields, toggles (setup)
   --------------------------------------------------------------------- */
.setup-grid { max-width: 940px; margin: 0 auto; display: grid; gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.card-title { font-family: var(--font-head); font-size: 1.16rem; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-num {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--yellow)); color: #2b1200;
  font-family: var(--font-display); font-size: 0.8rem;
}
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line-soft);
  color: var(--muted); font-size: 0.9rem; font-family: var(--font-head);
}
.tab.is-active { background: var(--surface-3); color: var(--ink); border-color: var(--orange); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field-wide { grid-column: 1 / -1; }
.field > label, .field > span { font-size: 0.84rem; color: var(--muted); font-weight: 600; }
.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px;
  background: var(--bg-2); border: 2px solid var(--line); border-radius: var(--radius-sm); color: var(--ink);
}
.input:focus { border-color: var(--orange); outline: none; }
.input-pin { font-family: var(--font-display); font-size: 1.8rem; text-align: center; letter-spacing: 0.3em; }
.field-hint.is-ok { color: var(--lime); }
.field-hint.is-error { color: var(--rose); }

.chip-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.pick-chip {
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-2); font-size: 0.86rem; color: var(--muted);
}
.pick-chip.is-on { background: var(--surface-3); color: var(--ink); border-color: var(--lime); }
.chip-n { opacity: 0.55; font-size: 0.78rem; margin-left: 4px; }

.toggle-list { display: grid; gap: 10px; margin-top: 14px; }
.toggle { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; text-align: left; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  flex-shrink: 0; width: 48px; height: 28px; border-radius: 999px; margin-top: 2px;
  background: var(--surface-3); position: relative; transition: background var(--dur);
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: var(--ink); transition: transform var(--dur) var(--ease);
}
.toggle input:checked + .toggle-track { background: linear-gradient(135deg, var(--orange), var(--yellow)); }
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--orange); outline-offset: 2px; }
.toggle-text { display: flex; flex-direction: column; gap: 2px; }

.template-box { background: var(--bg-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.template-box h3 { font-family: var(--font-head); margin-bottom: 6px; }
.import-area {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 26px; border: 2px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); text-align: center; cursor: pointer;
}
.import-area.is-over { border-color: var(--orange); background: rgba(255, 122, 26, 0.08); color: var(--ink); }
.import-icon { font-size: 2rem; }
.upload-preview { margin-top: 12px; background: var(--bg-2); border-radius: var(--radius); padding: 14px; text-align: left; }
.upload-preview h3 { font-family: var(--font-head); margin-bottom: 8px; }
.preview-cats { columns: 2; column-gap: 20px; list-style: none; font-size: 0.86rem; color: var(--muted); }
.preview-cats li { break-inside: avoid; padding: 2px 0; }
.preview-warnings { margin-top: 10px; padding-left: 18px; color: var(--yellow); font-size: 0.82rem; }

.editor { display: grid; gap: 8px; margin: 10px 0; max-height: 46vh; overflow-y: auto; }
.ed-row { display: flex; align-items: center; gap: 8px; }
.ed-num { width: 26px; text-align: right; color: var(--faint); font-size: 0.82rem; }

.setup-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 20px; }
.setup-summary { font-size: 0.92rem; }
.setup-summary.is-warn { color: var(--yellow); }

/* ---------------------------------------------------------------------
   Host lobby
   --------------------------------------------------------------------- */
.lobby { flex: 1; display: grid; grid-template-columns: minmax(280px, 34%) 1fr; gap: 20px; padding: 20px; overflow: hidden; }
@media (max-width: 820px) { .lobby { grid-template-columns: 1fr; overflow-y: auto; } }

.join-card {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px; display: flex; flex-direction: column; justify-content: center; text-align: center;
  box-shadow: var(--shadow);
}
.join-step { color: var(--muted); text-transform: uppercase; letter-spacing: 0.22em; font-size: 0.72rem; }
.join-url { font-family: var(--font-head); font-size: clamp(1.1rem, 2.4vw, 1.7rem); font-weight: 600; margin: 6px 0 14px; word-break: break-all; color: var(--sky); }
.join-pin {
  font-family: var(--font-display); font-size: clamp(3rem, 8vw, 5.6rem); line-height: 1;
  letter-spacing: 0.1em; color: var(--yellow); margin-top: 6px;
  text-shadow: 0 0 40px rgba(255, 210, 63, 0.4);
}
.join-note { margin-top: 18px; }

.lobby-right { display: flex; flex-direction: column; min-height: 0; }
.zone-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.zone-head h2 { font-family: var(--font-head); font-size: 1.1rem; }
.zone-count {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px;
  border-radius: 999px; background: var(--surface-3); font-family: var(--font-display); font-size: 0.8rem;
}
.seat-list { flex: 1; overflow-y: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 10px; }
.seat {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px 8px 8px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 999px;
  animation: pop 0.32s var(--ease);
}
.seat.is-away { opacity: 0.45; }
.seat-name { font-weight: 600; }
.seat-x { color: var(--faint); font-size: 0.9rem; padding: 2px 4px; }
.seat-x:hover { color: var(--rose); }
.empty-note { padding: 30px; }
@keyframes pop { from { transform: scale(0.86); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font-family: var(--font-display); font-size: 0.9rem; color: #201033; flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 0.72rem; }
.avatar-lg { width: 68px; height: 68px; font-size: 1.7rem; }

/* ---------------------------------------------------------------------
   Host board — shared
   --------------------------------------------------------------------- */
.stage { flex: 1; min-height: 0; display: flex; padding: 18px; }
.panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.host-controls {
  display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap;
  padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft); background: rgba(16, 10, 34, 0.7); flex-shrink: 0;
}
.ctl-note { color: var(--muted); font-size: 0.9rem; }

/* ---- the wheel ---- */
.panel-roll { align-items: center; justify-content: center; gap: 18px; text-align: center; }
.roll-title { font-family: var(--font-head); font-size: clamp(1.4rem, 3.4vw, 2.2rem); }
.wheel-frame {
  display: grid; place-items: center; width: clamp(190px, 26vh, 290px); height: clamp(190px, 26vh, 290px);
  border-radius: 34px; background: linear-gradient(150deg, var(--orange), var(--rose) 120%);
  box-shadow: var(--glow), inset 0 -10px 30px rgba(0, 0, 0, 0.28);
  transform: rotate(-4deg);
}
.wheel {
  font-family: var(--font-display); font-size: clamp(6rem, 16vh, 11rem); line-height: 1; color: #2b1200;
  text-shadow: 0 6px 0 rgba(255, 255, 255, 0.24);
}
.wheel.is-spinning { animation: shake 0.16s linear infinite; }
.wheel.is-landed { animation: land 0.5s var(--ease); }
.wheel-sm { font-size: clamp(4.5rem, 26vw, 8rem); color: var(--yellow); text-shadow: 0 0 50px rgba(255, 210, 63, 0.45); }
@keyframes shake { 0%, 100% { transform: translate(-2px, 1px) rotate(-1deg); } 50% { transform: translate(2px, -1px) rotate(1deg); } }
@keyframes land { 0% { transform: scale(1.5); } 60% { transform: scale(0.94); } 100% { transform: scale(1); } }

.cat-preview {
  list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px 22px; max-width: 900px; text-align: left; color: var(--muted); font-size: 0.94rem;
  max-height: 26vh; overflow-y: auto;
}
.cat-preview li { display: flex; gap: 10px; align-items: baseline; }
.cat-num {
  font-family: var(--font-display); font-size: 0.72rem; color: var(--orange-2);
  min-width: 1.6em; flex-shrink: 0;
}

/* ---- the clock ---- */
.panel-write { flex-direction: row; gap: 20px; }
@media (max-width: 900px) { .panel-write { flex-direction: column; } }

.write-side { display: flex; flex-direction: column; align-items: center; gap: 14px; flex-shrink: 0; }
.letter-tile {
  display: grid; place-items: center; width: clamp(110px, 13vh, 170px); height: clamp(110px, 13vh, 170px);
  border-radius: 26px; background: linear-gradient(150deg, var(--orange), var(--rose) 130%);
  font-family: var(--font-display); font-size: clamp(3.6rem, 8vh, 6rem); color: #2b1200;
  box-shadow: var(--glow); text-shadow: 0 5px 0 rgba(255, 255, 255, 0.22);
}
.write-finished { font-family: var(--font-head); color: var(--lime); font-weight: 600; }

.timer { position: relative; width: clamp(96px, 12vh, 140px); height: clamp(96px, 12vh, 140px); }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 8; }
.t-track { stroke: rgba(255, 255, 255, 0.1); }
.t-ring {
  stroke: var(--lime); stroke-linecap: round;
  stroke-dasharray: 283; stroke-dashoffset: 0; transition: stroke-dashoffset 0.25s linear, stroke 0.4s;
}
.timer.is-warning .t-ring { stroke: var(--rose); }
.timer.is-warning .t-text { color: var(--rose); animation: pulse 1s infinite; }
.t-text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-display); font-size: clamp(1.6rem, 3.4vh, 2.4rem);
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.cat-board {
  flex: 1; min-width: 0; list-style: none; overflow-y: auto;
  /* space-evenly rather than start: ten categories should fill the board on a
     projector, not sit in a clump at the top with half a screen below them. */
  display: grid; align-content: space-evenly; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 18px;
}
.cat-board li {
  display: flex; gap: 12px; align-items: baseline;
  font-family: var(--font-head); font-size: clamp(1rem, 2.1vw, 1.5rem); font-weight: 500;
  padding: 4px 0; border-bottom: 1px solid var(--line-soft);
}
.cat-board.is-dense li { font-size: clamp(0.92rem, 1.7vw, 1.2rem); padding: 2px 0; }
.cat-board li:last-child { border-bottom: none; }
.cat-text { min-width: 0; }

.write-progress { width: clamp(200px, 22%, 300px); display: flex; flex-direction: column; min-height: 0; }
.write-progress h3 { font-family: var(--font-head); font-size: 0.94rem; color: var(--muted); margin-bottom: 8px; }
.write-progress ul { list-style: none; overflow-y: auto; display: grid; gap: 6px; align-content: start; }
.prow { display: grid; grid-template-columns: auto 1fr 60px auto; align-items: center; gap: 8px; font-size: 0.86rem; }
.prow.is-away { opacity: 0.4; }
.prow.is-done .prow-n { color: var(--lime); font-weight: 700; }
.prow-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow-bar { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.prow-bar i { display: block; height: 100%; border-radius: 999px; transition: width 0.4s var(--ease); }
.prow-n { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; min-width: 3ch; }
@media (max-width: 900px) { .write-progress { width: auto; max-height: 26vh; } }

/* ---- the reveal ---- */
.panel-reveal { gap: 14px; }
.reveal-head { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.letter-chip {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(150deg, var(--orange), var(--rose) 130%);
  font-family: var(--font-display); font-size: 1.9rem; color: #2b1200; flex-shrink: 0;
}
.letter-chip-lg { width: 66px; height: 66px; font-size: 2.3rem; }
.reveal-category { font-family: var(--font-head); font-size: clamp(1.3rem, 3.2vw, 2.3rem); font-weight: 600; flex: 1; min-width: 0; }
.reveal-step { font-family: var(--font-display); color: var(--faint); font-size: 0.9rem; }

.reveal-grid {
  flex: 1; min-height: 0; overflow-y: auto;
  /* `safe center` centres a small class but falls back to the top when a big
     one overflows, so the first row can never scroll out of reach. */
  align-content: center; align-content: safe center;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 12px;
  padding: 4px;
}
/* A class of thirty fills this; a class of eight should not leave the board
   two-thirds empty, so the cards centre themselves in whatever space there is. */
.ans {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 12px 14px; border-radius: var(--radius); border: 2px solid var(--line-soft);
  background: var(--surface); transition: transform var(--dur) var(--ease), border-color var(--dur), background var(--dur);
  animation: fadeUp 0.3s var(--ease) backwards;
}
.ans:hover { transform: translateY(-2px); }
.ans-text { font-family: var(--font-head); font-size: clamp(1.1rem, 1.5vw, 1.5rem); font-weight: 600; overflow-wrap: anywhere; }
.ans-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.84rem; }
.ans-who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ans-tag {
  padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1);
  font-family: var(--font-display); font-size: 0.66rem; letter-spacing: 0.04em; flex-shrink: 0;
}
.ans-bonus { position: absolute; top: -8px; right: -6px; font-size: 1.1rem; }

.ans.is-unique { border-color: var(--lime); background: linear-gradient(160deg, rgba(87, 227, 137, 0.18), var(--surface)); }
.ans.is-unique .ans-tag { background: var(--lime); color: #06331b; }
.ans.is-shared { border-color: rgba(255, 77, 109, 0.5); }
.ans.is-shared .ans-text { text-decoration: line-through; text-decoration-color: var(--rose); text-decoration-thickness: 3px; opacity: 0.75; }
.ans.is-shared .ans-tag { background: var(--rose); color: #fff; }
.ans.is-invalid { opacity: 0.6; border-style: dashed; }
.ans.is-invalid .ans-text { color: var(--yellow); }
.ans.is-vetoed { opacity: 0.5; }
.ans.is-vetoed .ans-text { text-decoration: line-through; }
.ans.is-blank { opacity: 0.3; }
.ans.is-selected { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.3); transform: translateY(-3px); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.reveal-stats { display: flex; gap: 10px; flex-wrap: wrap; flex-shrink: 0; }
.stat { padding: 5px 12px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: rgba(255, 255, 255, 0.07); }
.stat.is-unique { background: rgba(87, 227, 137, 0.2); color: var(--lime); }
.stat.is-shared { background: rgba(255, 77, 109, 0.18); color: var(--rose); }
.stat.is-invalid { background: rgba(255, 210, 63, 0.16); color: var(--yellow); }
.reveal-hint { flex-shrink: 0; }

/* ---- round table ---- */
.panel-round-end { gap: 14px; overflow: hidden; }
.round-title { font-family: var(--font-head); font-size: clamp(1.3rem, 3vw, 2rem); text-align: center; }
.round-table { flex: 1; min-height: 0; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-size: clamp(0.86rem, 1.6vw, 1.05rem); }
.table th {
  text-align: right; padding: 8px 12px; color: var(--muted); font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.1em; border-bottom: 1px solid var(--line);
}
.table th:first-child { text-align: left; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.table .td-name { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .is-unique { color: var(--lime); font-weight: 700; }
.table .is-invalid { color: var(--yellow); }
.table .is-round { color: var(--orange-2); font-family: var(--font-display); }
.table .is-total { font-family: var(--font-display); }
.table tr.is-best { background: rgba(87, 227, 137, 0.09); }

/* ---- podium ---- */
.panel-results { align-items: center; justify-content: center; gap: 20px; overflow-y: auto; }
.results-title { font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2.8rem); color: var(--yellow); }
.podium { display: flex; align-items: flex-end; gap: 16px; }
.pod {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 22px; border-radius: var(--radius-lg); background: var(--surface);
  border: 1px solid var(--line-soft); min-width: 140px;
}
.pod-1 { background: linear-gradient(170deg, rgba(255, 210, 63, 0.28), var(--surface)); border-color: var(--yellow); padding-bottom: 34px; }
.pod-2 { padding-bottom: 22px; }
.pod-name { font-family: var(--font-head); font-weight: 600; }
.pod-score { font-family: var(--font-display); font-size: 1.7rem; color: var(--orange-2); }
.pod-place { order: -1; font-size: 2rem; line-height: 1; }
.final-list { list-style: none; display: grid; gap: 6px; counter-reset: place 3; }
.final-list li { display: flex; align-items: center; gap: 10px; padding: 6px 14px; background: var(--surface); border-radius: 999px; }
.final-list li b { margin-left: auto; font-family: var(--font-display); }

/* ---- challenge box (host) ---- */
.challenge-box {
  position: fixed; right: 20px; bottom: 88px; z-index: 60; width: 300px;
  background: var(--surface-2); border: 2px solid var(--sky); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow); text-align: center;
}
.challenge-box h3 { font-family: var(--font-head); font-size: 1rem; color: var(--sky); }
.ch-answer { font-family: var(--font-head); font-size: 1.4rem; font-weight: 600; margin: 6px 0 2px; }
.ch-bars { display: flex; gap: 10px; margin: 12px 0; }
.ch-bar { flex: 1; padding: 10px; border-radius: var(--radius-sm); background: rgba(255, 255, 255, 0.06); }
.ch-bar b { display: block; font-family: var(--font-display); font-size: 1.6rem; }
.ch-bar.is-yes b { color: var(--lime); }
.ch-bar.is-no b { color: var(--rose); }

/* ---- reactions ---- */
.reaction-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.reaction { position: absolute; bottom: 60px; font-size: 2.2rem; animation: floatUp 2.4s ease-out forwards; }
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.5); opacity: 0; }
  15% { transform: translateY(-30px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-52vh) scale(1) rotate(12deg); opacity: 0; }
}

/* ---------------------------------------------------------------------
   Player
   --------------------------------------------------------------------- */
.join-title { font-family: var(--font-head); font-size: 1.7rem; }
.join-form { width: min(400px, 100%); display: grid; gap: 16px; }
.join-error { color: var(--rose); font-size: 0.9rem; }
.player-name { font-family: var(--font-head); font-size: 1.6rem; }
.wait-title { font-family: var(--font-display); font-size: clamp(1.6rem, 7vw, 2.4rem); color: var(--yellow); }
.wait-sub { max-width: 30ch; }
.pulse-dots { display: flex; gap: 8px; }
.pulse-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); animation: bounce 1.3s infinite; }
.pulse-dots span:nth-child(2) { animation-delay: 0.18s; }
.pulse-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-9px); opacity: 1; } }
.mini-roster { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-top: 6px; }
.pl-round { font-family: var(--font-head); color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.8rem; }

/* ---- the answer sheet ---- */
.sheet-head {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(26, 16, 56, 0.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
}
.sheet-meta { display: flex; flex-direction: column; min-width: 0; }
.sheet-round { font-size: 0.76rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.12em; }
.sheet-filled { font-family: var(--font-head); font-weight: 600; }
.sheet-others { font-size: 0.76rem; color: var(--lime); }
.sheet-timer-wrap { display: grid; place-items: center; min-width: 62px; height: 46px; border-radius: 14px; background: rgba(255, 255, 255, 0.07); }
.sheet-timer { font-family: var(--font-display); font-size: 1.5rem; }
.sheet-timer-wrap.is-warning { background: rgba(255, 77, 109, 0.22); }
.sheet-timer-wrap.is-warning .sheet-timer { color: var(--rose); animation: pulse 1s infinite; }
.sheet-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: rgba(255, 255, 255, 0.08); }
.sheet-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--orange), var(--lime)); transition: width 0.3s var(--ease); }

.sheet-list { flex: 1; overflow-y: auto; list-style: none; padding: 10px 12px 16px; display: grid; gap: 10px; }
.sheet-list.is-locked { opacity: 0.6; }
.srow { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.srow-num { font-family: var(--font-display); font-size: 0.72rem; color: var(--faint); width: 1.6em; text-align: right; }
.srow-body { display: grid; gap: 4px; min-width: 0; }
.srow-cat { font-size: 0.86rem; color: var(--muted); }
.srow-input { min-height: 50px; font-size: 1.05rem; }
.srow.is-ok .srow-input { border-color: var(--lime); }
.srow.is-bad .srow-input { border-color: var(--yellow); }
.srow-tick { width: 22px; text-align: center; font-family: var(--font-display); font-size: 1.1rem; color: var(--lime); }
.srow.is-bad .srow-tick { color: var(--yellow); }
.sheet-foot { padding: 12px 14px; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line-soft); background: rgba(26, 16, 56, 0.9); flex-shrink: 0; }

/* ---- player reveal ---- */
.rv-head { display: flex; align-items: center; gap: 12px; padding: 14px; padding-top: max(14px, env(safe-area-inset-top)); flex-shrink: 0; }
.rv-category { font-family: var(--font-head); font-size: 1.15rem; font-weight: 600; flex: 1; min-width: 0; }
.rv-step { font-family: var(--font-display); font-size: 0.78rem; color: var(--faint); }
#screen-player-reveal { overflow-y: auto; padding-bottom: 90px; }
#screen-player-reveal > div { padding: 0 14px 14px; }
.rv-mine {
  margin: 0 14px 14px; padding: 20px; border-radius: var(--radius-lg);
  border: 2px solid var(--line); background: var(--surface); text-align: center;
  display: flex; flex-direction: column; gap: 8px;
}
.rv-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.18em; color: var(--faint); }
.rv-answer { font-family: var(--font-head); font-size: 1.8rem; font-weight: 600; overflow-wrap: anywhere; }
.rv-badge { font-family: var(--font-display); font-size: 0.86rem; }
.rv-mine.is-unique { border-color: var(--lime); background: linear-gradient(160deg, rgba(87, 227, 137, 0.2), var(--surface)); }
.rv-mine.is-unique .rv-badge { color: var(--lime); }
.rv-mine.is-shared { border-color: var(--rose); }
.rv-mine.is-shared .rv-answer { text-decoration: line-through; text-decoration-color: var(--rose); }
.rv-mine.is-shared .rv-badge { color: var(--rose); }
.rv-mine.is-invalid { border-color: var(--yellow); }
.rv-mine.is-invalid .rv-badge { color: var(--yellow); }
.rv-list { list-style: none; display: grid; gap: 5px; margin-top: 6px; }
.rv-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 12px; background: var(--surface); border-radius: 999px; font-size: 0.9rem; }
.react-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px; padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: rgba(16, 10, 34, 0.9); backdrop-filter: blur(8px); z-index: 40; }
.react-btn { font-size: 1.6rem; width: 52px; height: 52px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-soft); }
.react-btn:active { transform: scale(0.86); }

/* ---- player round / final ---- */
.pr-title { font-family: var(--font-head); font-size: 1.2rem; color: var(--muted); }
.pr-points { font-family: var(--font-display); font-size: clamp(3.2rem, 16vw, 5rem); color: var(--lime); line-height: 1; }
.pr-breakdown { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip { padding: 5px 12px; border-radius: 999px; background: var(--surface); font-size: 0.8rem; }
.chip.is-unique { background: rgba(87, 227, 137, 0.2); color: var(--lime); }
.chip.is-invalid { background: rgba(255, 210, 63, 0.16); color: var(--yellow); }
.chip.is-bonus { background: rgba(255, 122, 26, 0.2); color: var(--orange-2); }
.board-list { list-style: none; width: min(400px, 100%); display: grid; gap: 6px; }
.board-list li { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--surface); border-radius: 999px; }
.board-list li.is-me { background: linear-gradient(100deg, rgba(255, 122, 26, 0.26), var(--surface)); border: 1px solid var(--orange); }
.board-list li b { margin-left: auto; font-family: var(--font-display); }
.fb-place { font-family: var(--font-display); font-size: 0.78rem; color: var(--faint); width: 1.6em; }
.fb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.final-place { font-family: var(--font-display); font-size: clamp(3.4rem, 18vw, 5.4rem); color: var(--yellow); line-height: 1; }
.final-score { font-family: var(--font-head); font-size: 1.3rem; }
.final-line { color: var(--muted); }

/* ---- challenge sheet (player) ---- */
.challenge-sheet {
  position: fixed; left: 12px; right: 12px; bottom: 12px; bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 90; padding: 18px; border-radius: var(--radius-lg);
  background: var(--surface-2); border: 2px solid var(--sky); box-shadow: var(--shadow); text-align: center;
  animation: slideUp 0.3s var(--ease);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.ch-q { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--sky); }
.ch-a { font-family: var(--font-head); font-size: 1.5rem; font-weight: 600; margin: 6px 0 2px; }
.ch-buttons { display: flex; gap: 10px; margin-top: 12px; }
.ch-buttons .btn { flex: 1; }
.ch-done { margin-top: 10px; color: var(--muted); }
/* The reaction bar sits under an open vote — one tap target at a time. */
.challenge-sheet:not([hidden]) ~ .reaction-layer { display: none; }

/* ---------------------------------------------------------------------
   Overlays: toasts, modals, banners, connection pill, interstitial
   --------------------------------------------------------------------- */
.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; pointer-events: none; }
.toast {
  padding: 12px 18px; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: 0.9rem;
  animation: toastIn 0.28s var(--ease); max-width: 90vw;
}
.toast.is-success { border-color: var(--lime); }
.toast.is-error { border-color: var(--rose); }
.toast.is-warn { border-color: var(--yellow); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: all 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.modal-overlay { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 20px; background: rgba(8, 4, 20, 0.72); backdrop-filter: blur(6px); }
.modal { width: min(480px, 100%); max-height: 86vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); }
.modal-wide { width: min(820px, 100%); }
.modal h2 { font-family: var(--font-head); margin-bottom: 12px; }
.modal-body { margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

.conn-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 95; padding: 9px 16px; text-align: center; font-size: 0.86rem; }
.conn-banner.is-warn { background: var(--yellow); color: #2b1200; }
.conn-banner.is-error { background: var(--rose); color: #fff; }

.conn-pill { position: fixed; right: 12px; bottom: 12px; z-index: 80; padding: 5px 11px; border-radius: 999px; font-size: 0.72rem; background: var(--surface); border: 1px solid var(--line-soft); color: var(--muted); pointer-events: none; }
.conn-pill.online { color: var(--lime); }
.conn-pill.reconnecting { color: var(--yellow); }
.conn-pill.offline { color: var(--faint); }

.interstitial {
  position: fixed; inset: 0; z-index: 105; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; text-align: center;
  background: rgba(16, 10, 34, 0.94); opacity: 0; pointer-events: none; transition: opacity 0.34s var(--ease);
}
.interstitial.show { opacity: 1; }
.int-icon { font-size: clamp(3rem, 12vw, 5rem); }
.int-text { font-family: var(--font-display); font-size: clamp(2rem, 9vw, 4.4rem); color: var(--yellow); }
.int-sub { color: var(--muted); font-size: 1.05rem; }

.confetti-piece { position: fixed; top: -20px; z-index: 99; pointer-events: none; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(680deg); opacity: 0; } }

/* ---------------------------------------------------------------------
   Themed dropdowns (dropdown.js). The class names come from that module —
   it hides the real <select> and drives a listbox, so these must match.
   --------------------------------------------------------------------- */
.dd { position: relative; }
select.dd-native { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; min-height: 0; padding: 0; margin: 0; border: 0; }
.dd-trigger {
  width: 100%; min-height: var(--tap); padding: 12px 40px 12px 14px; text-align: left; position: relative;
  background: var(--bg-2); border: 2px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color var(--dur);
}
.dd-trigger:hover { border-color: rgba(255, 255, 255, 0.28); }
.dd-trigger[aria-expanded="true"] { border-color: var(--orange); }
.dd-trigger::after {
  content: ''; position: absolute; right: 15px; top: 50%; width: 9px; height: 9px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); transition: transform var(--dur);
}
.dd-trigger[aria-expanded="true"]::after { transform: translateY(-30%) rotate(225deg); }
.dd-panel {
  position: fixed; z-index: 120; max-height: 320px; overflow-y: auto;
  background: var(--surface-2); border: 2px solid var(--orange); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 5px; animation: toastIn 0.14s var(--ease);
}
.dd-option {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 11px 12px; min-height: 44px;
  border-radius: var(--radius-sm); text-align: left; transition: background var(--dur);
}
.dd-option:hover, .dd-option.is-focus { background: rgba(255, 255, 255, 0.12); }
.dd-option.is-selected { color: var(--orange-2); }
.dd-option.is-selected::before { content: '✓'; }
.dd-option:not(.is-selected)::before { content: ''; width: 0.85em; }
.dd-option.is-disabled { opacity: 0.4; }

/* ---------------------------------------------------------------------
   Responsive
   --------------------------------------------------------------------- */
@media (max-width: 640px) {
  .conn-pill { width: 14px; height: 14px; padding: 0; border-radius: 50%; overflow: hidden; text-indent: -99px; }
  .conn-pill.online { background: var(--lime); }
  .conn-pill.connecting, .conn-pill.reconnecting { background: var(--yellow); }
  .conn-pill.offline { background: var(--rose); }
  .bar { padding: 8px 12px; gap: 8px; }
  .card { padding: 16px; }
  .settings-grid { grid-template-columns: 1fr; }
  .stage { padding: 10px; }
  .setup-actions { flex-direction: column; align-items: stretch; }
  .preview-cats { columns: 1; }
  .podium { flex-direction: column; align-items: stretch; }
  .challenge-box { left: 12px; right: 12px; width: auto; bottom: 96px; }
}
@media (max-width: 1000px) {
  .reveal-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* ---------------------------------------------------------------------
   Motion preferences
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .confetti-piece, .reaction { display: none !important; }
}
