/* =====================================================================
   Lobby and guided match setup (lobby-view.js, match/setup-view.js).

   The lobby desk keeps two things: who is in the room and which match
   you will play. The invitation lives on the stage (the code itself is on
   the studio emblem). Setup happens in a dialog that asks one thing at a
   time: a presenter column on the left (title and the words a narrator
   will say, plus the running order of steps) and the choices on the right.

   --tone: the colour of a choice (game, format, category). Each element
   that carries one reads it; nothing else is coloured.
   ===================================================================== */

/* --- Shared bits ------------------------------------------------------ */
.sw-medal {
  --tone: var(--signal);
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px; border-radius: 14px;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--tone) 30%, var(--ink-4)), color-mix(in srgb, var(--tone) 10%, var(--ink-2)));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 50%, transparent), 0 6px 18px -8px color-mix(in srgb, var(--tone) 70%, transparent);
  color: var(--tone); font-size: 1.75rem;
}
.sw-medal--sm { width: 40px; height: 40px; border-radius: 11px; font-size: 1.3rem; }
.sw-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: rgb(255 255 255 / .06); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
}
.sw-chip--preview { background: var(--warning-soft); color: var(--warning); }
.sw-saving { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: .8rem; }
.sw-saving:empty { display: none; }
@keyframes swSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) { body:not(.reduce-motion) .sw-spin { animation: swSpin 1s linear infinite; } }

/* --- Choice cards: formats, games, combinations ---------------------- */
.sw-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 14px; }
.sw-card {
  --tone: var(--signal);
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; column-gap: 16px;
  width: 100%; min-width: 0; min-height: 150px; padding: 20px 18px;
  border-radius: var(--r-lg); border: 1px solid var(--line-2);
  background: var(--surface-raised); color: var(--text-1);
  font: inherit; text-align: left; cursor: pointer;
  transition: border-color var(--dur-fast), background var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.sw-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--tone) 22%, transparent), transparent 60%);
  transition: opacity var(--dur-base);
}
.sw-card .sw-medal { grid-row: span 2; }
.sw-card-copy { display: grid; gap: 6px; min-width: 0; padding-right: 22px; }
.sw-card-copy strong { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; line-height: 1.05; letter-spacing: .01em; }
.sw-card-copy > span { color: var(--text-2); font-size: .88rem; line-height: 1.45; }
.sw-card-meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.sw-card-check { position: absolute; top: 14px; right: 14px; font-size: 1.45rem; color: var(--tone); opacity: 0; transform: scale(.6); transition: opacity var(--dur-fast), transform var(--dur-base) var(--ease-pop); }
.sw-card.is-selected {
  border-color: var(--tone);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 14%, #17233a) 0%, #0f1828 100%);
  box-shadow: inset 0 0 0 1px var(--tone), 0 14px 34px -18px color-mix(in srgb, var(--tone) 80%, transparent);
}
.sw-card.is-selected::after { opacity: 1; }
.sw-card.is-selected .sw-card-check { opacity: 1; transform: none; }
.sw-card:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: 3px; }
.sw-card:disabled { cursor: not-allowed; opacity: .45; }
@media (hover: hover) {
  .sw-card:not(:disabled):hover { border-color: color-mix(in srgb, var(--tone) 70%, var(--line-2)); transform: translateY(-2px); }
  .sw-card:not(:disabled):hover::after { opacity: .7; }
}
.sw-route-mini { display: inline-flex; align-items: center; gap: 4px; }
.sw-route-dot { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: color-mix(in srgb, var(--tone) 18%, var(--ink-3)); color: var(--tone); font-size: .95rem; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 40%, transparent); }
.sw-route-sep { color: var(--text-3); font-size: .7rem; }

/* Compact format cards on the lobby desk: medal and name on one line. */
.sw-card--compact { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px; row-gap: 6px; min-height: 0; padding: 12px; }
.sw-card--compact .sw-medal { grid-row: auto; width: 36px; height: 36px; border-radius: 10px; font-size: 1.2rem; }
.sw-card--compact .sw-card-copy { display: contents; }
.sw-card--compact .sw-card-copy strong { font-size: 1.12rem; padding-right: 18px; }
.sw-card--compact .sw-card-copy > span { grid-column: 1 / -1; font-size: .8rem; line-height: 1.35; }
.sw-card--compact .sw-card-meta { grid-column: 1 / -1; margin-top: 0; }
.sw-card--compact .sw-card-meta:empty { display: none; }
.sw-card--compact .sw-card-check { top: 10px; right: 10px; font-size: 1.2rem; }
.setup-launcher .sw-cards--kinds { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }

/* --- Option tiles: one radio per value ------------------------------ */
.sw-choices { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.sw-choices--numQuestions, .sw-choices--duration { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.sw-choices[data-count="2"], .sw-choices[data-count="3"] { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.sw-choices[data-count="4"] { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.sw-choice {
  --tone: var(--signal);
  position: relative; display: grid; justify-items: center; align-content: center; gap: 6px;
  min-height: 128px; padding: 22px 12px 16px;
  border-radius: var(--r-lg); border: 1px solid var(--line-2);
  background: var(--surface-control); color: var(--text-1);
  text-align: center; cursor: pointer; user-select: none;
  transition: border-color var(--dur-fast), background var(--dur-fast), box-shadow var(--dur-base), transform var(--dur-fast) var(--ease-out);
}
/* The tile's own light, like an atril screen: on when chosen. */
.sw-choice::before {
  content: ""; position: absolute; top: -1px; left: 24%; right: 24%; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--tone); opacity: 0; box-shadow: 0 0 14px var(--tone);
  transition: opacity var(--dur-fast);
}
.sw-choice-icon { font-size: 1.9rem; color: var(--tone); }
.sw-choice-value { font-family: var(--font-display); font-weight: 700; font-size: 1.3rem; line-height: 1.05; letter-spacing: .01em; overflow-wrap: anywhere; }
.sw-choice.is-numeric .sw-choice-value { font-size: 2.6rem; font-variant-numeric: tabular-nums; }
.sw-choice-hint { color: var(--text-3); font-size: .8rem; }
.sw-choice-basic {
  position: absolute; top: 8px; right: 8px;
  padding: 1px 8px; border-radius: var(--r-pill);
  background: var(--spot-soft); color: var(--spot); font-size: .7rem; font-weight: 700;
}
.sw-choice:has(input:checked), .sw-choice.is-checked {
  border-color: var(--tone);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 18%, var(--ink-4)) 0%, color-mix(in srgb, var(--tone) 6%, var(--ink-2)) 100%);
  box-shadow: inset 0 0 0 1px var(--tone), 0 14px 30px -16px color-mix(in srgb, var(--tone) 85%, transparent);
}
.sw-choice:has(input:checked)::before, .sw-choice.is-checked::before { opacity: 1; }
.sw-choice:has(input:checked) .sw-choice-hint { color: var(--text-1); }
.sw-choice:has(input:focus-visible) { outline: 2px solid var(--signal-strong); outline-offset: 3px; }
.sw-choice:has(input:disabled) { cursor: not-allowed; opacity: .5; }
@media (hover: hover) { .sw-choice:not(:has(input:checked)):hover { border-color: color-mix(in srgb, var(--tone) 60%, var(--line-2)); transform: translateY(-2px); } }
.sw[aria-busy="true"] .sw-choice { cursor: progress; }
/* Few choices: big tiles, easy to read from the sofa. */
.sw-choices[data-count="2"] .sw-choice, .sw-choices[data-count="3"] .sw-choice, .sw-choices[data-count="4"] .sw-choice { min-height: 200px; gap: 10px; }
.sw-choices[data-count="2"] .sw-choice-icon, .sw-choices[data-count="3"] .sw-choice-icon, .sw-choices[data-count="4"] .sw-choice-icon { font-size: 2.8rem; }
.sw-choices[data-count="2"] .sw-choice-value, .sw-choices[data-count="3"] .sw-choice-value, .sw-choices[data-count="4"] .sw-choice-value { font-size: 1.7rem; }
.sw-choices[data-count="2"] .is-numeric .sw-choice-value, .sw-choices[data-count="3"] .is-numeric .sw-choice-value, .sw-choices[data-count="4"] .is-numeric .sw-choice-value { font-size: 3.4rem; }
.sw-choices[data-count="2"] .sw-choice-hint, .sw-choices[data-count="3"] .sw-choice-hint, .sw-choices[data-count="4"] .sw-choice-hint { font-size: .9rem; }

/* --- Custom: the running order and the add shelf --------------------- */
.sw-builder { display: grid; gap: 18px; }
.sw-blocks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sw-block {
  --tone: var(--signal);
  display: grid; grid-template-columns: 26px auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 12px 12px 14px; border-radius: var(--r-md);
  background: var(--surface-raised); border: 1px solid var(--line-2); border-left: 3px solid var(--tone);
}
.sw-block-num { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--text-3); text-align: center; }
.sw-block-info { display: grid; gap: 3px; min-width: 0; }
.sw-block-info strong { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.1; }
.sw-block-sum { color: var(--text-2); font-size: .82rem; overflow-wrap: anywhere; }
.sw-block-tools { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.sw-tool {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--r-sm); border: 1px solid var(--line-1); background: transparent;
  color: var(--text-2); font: inherit; font-size: 1.05rem; cursor: pointer;
}
.sw-tool--text { display: inline-flex; align-items: center; gap: 6px; width: auto; padding: 0 14px; font-size: .9rem; font-weight: 600; color: var(--text-1); border-color: var(--line-2); background: var(--surface-control); }
.sw-tool:disabled { opacity: .3; cursor: default; }
.sw-tool:focus-visible, .sw-add-btn:focus-visible, .sw-rule:focus-visible, .sw-rail-step:focus-visible, .sw-path:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: 2px; }
@media (hover: hover) { .sw-tool:not(:disabled):hover { color: var(--text-1); border-color: var(--line-3); background: rgb(255 255 255 / .05); } }
.sw-add { padding: 16px; border-radius: var(--r-lg); border: 1px dashed var(--line-3); }
.sw-add-title { display: flex; align-items: baseline; gap: 8px; margin: 0 0 12px; color: var(--text-2); font-size: .9rem; font-weight: 600; }
.sw-add-title .gs-num { color: var(--text-3); font-weight: 500; }
.sw-add-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.sw-add-btn {
  --tone: var(--signal);
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px;
  border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--surface-control);
  color: var(--text-1); font: inherit; font-weight: 600; text-align: left; cursor: pointer;
}
.sw-add-btn > i:first-child { color: var(--tone); font-size: 1.4rem; }
.sw-add-plus { margin-left: auto; color: var(--text-3); }
.sw-add-btn:disabled { opacity: .4; cursor: not-allowed; }
@media (hover: hover) { .sw-add-btn:not(:disabled):hover { border-color: var(--tone); } }

/* --- Review: the match as a running order --------------------------- */
.sw-rundown { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.sw-round {
  --tone: var(--signal);
  position: relative; padding: 20px; border-radius: var(--r-lg);
  background: var(--surface-raised); border: 1px solid var(--line-2);
}
.sw-round::before { content: ""; position: absolute; top: -1px; left: 20px; width: 64px; height: 3px; border-radius: 0 0 3px 3px; background: var(--tone); box-shadow: 0 0 12px var(--tone); }
.sw-round-head { display: flex; align-items: flex-start; gap: 14px; }
.sw-round-head > div { flex: 1; min-width: 0; }
.sw-round-head h4 { margin: 0; font-family: var(--font-display); font-size: 1.7rem; line-height: 1.05; }
.sw-round-head p { margin: 4px 0 0; max-width: 62ch; color: var(--text-2); font-size: .9rem; line-height: 1.45; }
.sw-rundown.is-several .sw-round { margin-left: 44px; }
.sw-rundown.is-several .sw-round-head h4 { font-size: 1.35rem; }
.sw-round-num {
  position: absolute; left: -44px; top: 18px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--ink-4); box-shadow: inset 0 0 0 2px var(--tone); color: var(--text-1);
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
}
/* The thread that joins the rounds. */
.sw-rundown.is-several { position: relative; }
.sw-rundown.is-several::before { content: ""; position: absolute; left: 14px; top: 34px; bottom: 34px; width: 2px; background: var(--line-2); }
.sw-rules { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-top: 16px; }
.sw-rule {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-sunken); border: 1px solid var(--line-1);
  color: var(--text-1); font: inherit; text-align: left;
}
.sw-rule > i:first-child { grid-row: span 2; font-size: 1.35rem; color: var(--tone); }
.sw-rule-label { color: var(--text-3); font-size: .75rem; }
.sw-rule strong { font-size: 1rem; overflow-wrap: anywhere; }
.sw-rule-edit { position: absolute; top: 9px; right: 9px; color: var(--text-3); font-size: .85rem; }
.sw-rule.is-editable { cursor: pointer; padding-right: 28px; }
@media (hover: hover) { .sw-rule.is-editable:hover { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 8%, var(--ink-2)); } .sw-rule.is-editable:hover .sw-rule-edit { color: var(--tone); } }

/* =====================================================================
   The dialog
   ===================================================================== */
.setup-wizard-dialog {
  position: fixed; inset: 0; margin: auto;
  padding: 0; border: 1px solid var(--line-2); border-radius: 22px;
  width: min(1180px, calc(100vw - 64px)); height: min(800px, calc(100dvh - 56px));
  max-width: none; max-height: none; overflow: hidden;
  background: linear-gradient(180deg, #111b2e 0%, var(--ink-2) 40%); color: var(--text-1);
  box-shadow: var(--shadow-3), inset 0 1px 0 rgb(255 255 255 / .06);
}
/* The studio stays faintly in sight behind the desk. */
.setup-wizard-dialog::backdrop { background: radial-gradient(ellipse at 50% 40%, rgb(2 5 12 / .62), rgb(2 5 12 / .88)); backdrop-filter: blur(3px); }
.sw {
  height: 100%; gap: 0;
  display: grid; grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "top top" "progress progress" "side main";
}
.sw-top { grid-area: top; display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 24px; border-bottom: 1px solid var(--line-1); }
.sw-format { --tone: var(--signal); display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.sw-format i { color: var(--tone); font-size: 1.3rem; }
.sw-top .sw-saving { margin-right: auto; }
.sw-top .sw-saving:empty { display: block; margin-right: auto; }
.sw-close { min-height: 40px; }
.sw-progress { grid-area: progress; height: 3px; background: var(--line-1); }
.sw-progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--signal), var(--signal-strong)); box-shadow: 0 0 10px var(--signal); }

/* Presenter column: the words a narrator will say, then the running order. */
.sw-side { grid-area: side; display: flex; flex-direction: column; min-height: 0; padding: 28px 18px 18px 26px; border-right: 1px solid var(--line-1); background: linear-gradient(180deg, rgb(3 6 12 / .3), rgb(3 6 12 / .6)); }
.sw-host { display: grid; gap: 16px; padding-bottom: 22px; border-bottom: 1px solid var(--line-1); }
.sw-host-mic {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #2b3c62, #0d1526); color: var(--spot); font-size: 1.4rem;
  box-shadow: 0 0 0 2px var(--spot-line), 0 0 26px rgb(246 183 82 / .22);
}
.sw-host-copy { display: grid; gap: 8px; }
.sw-step-count { margin: 0; color: var(--text-3); font-size: .8rem; font-weight: 600; }
.sw .guide-heading { margin: 0; font-family: var(--font-display); font-size: 2.1rem; font-weight: 700; line-height: 1.02; color: var(--text-1); }
.sw .guide-heading:focus { outline: none; }
.sw .guide-heading:focus-visible { outline: 2px solid var(--signal); outline-offset: 5px; }
.sw-host-text { margin: 0; color: var(--text-2); font-size: 1rem; line-height: 1.55; max-width: 34ch; }

.sw-rail { list-style: none; margin: 14px 0 0; padding: 0 6px 0 0; flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.sw-rail-group { margin: 12px 0 2px 6px; color: var(--text-3); font-size: .75rem; font-weight: 600; }
.sw-rail-step {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: 100%; min-height: 40px; padding: 6px 10px 6px 6px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text-2); font: inherit; font-size: .9rem; text-align: left; cursor: pointer;
}
.sw-rail-dot { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-3); font-size: 10px; }
.sw-rail-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw-rail-value { max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-3); font-size: .82rem; }
.sw-rail-step.is-done .sw-rail-dot { border-color: var(--signal); background: var(--signal); color: var(--signal-ink); }
.sw-rail-step.is-done .sw-rail-value { color: var(--text-1); }
.sw-rail-step.is-current { background: rgb(255 255 255 / .06); color: var(--text-1); font-weight: 600; }
.sw-rail-step.is-current .sw-rail-dot { border-color: var(--signal); box-shadow: 0 0 0 4px var(--signal-soft); }
.sw-rail-step.is-current .sw-rail-value { color: var(--signal-strong); }
.sw-rail-step:disabled { cursor: progress; }
@media (hover: hover) { .sw-rail-step:not(.is-current):not(:disabled):hover { background: rgb(255 255 255 / .035); color: var(--text-1); } }

/* Choices and the way forward. */
.sw-main { grid-area: main; display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 28px 32px 22px; }
.sw-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: -6px; padding: 6px; align-content: start; }
.sw-main > .mc-notice, .sw-main > .mc-error { margin-top: 14px; flex-shrink: 0; }
.sw-error { max-height: 140px; overflow-y: auto; }
.sw-error p:first-child { display: flex; gap: 6px; align-items: center; }

.sw-nav { display: flex; align-items: stretch; flex-wrap: wrap; gap: 12px; flex-shrink: 0; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-1); }
.sw-back { min-height: 56px; align-self: flex-end; margin-right: auto; }
.sw-next { min-height: 56px; min-width: 210px; font-size: 1.05rem; }
.sw-path {
  display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 20px;
  border-radius: var(--r-md); font: inherit; text-align: left; cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), box-shadow var(--dur-base);
}
.sw-path > i { font-size: 1.5rem; flex: none; }
.sw-path strong { display: block; font-size: 1.05rem; line-height: 1.2; }
.sw-path small { display: block; font-size: .8rem; opacity: .78; }
.sw-path:disabled { opacity: .55; cursor: progress; }
.sw-path--custom { flex: 1 1 0; min-width: 0; max-width: 280px; background: var(--surface-control); border: 1px solid var(--line-2); color: var(--text-1); }
.sw-path--custom > i { color: var(--signal); }
.sw-path--basic {
  flex: 1.4 1 0; min-width: 0; max-width: 380px; border: 1px solid var(--spot); background: var(--spot); color: var(--spot-ink);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .38), 0 12px 28px -12px rgb(246 183 82 / .7);
}
@media (hover: hover) {
  .sw-path--basic:not(:disabled):hover { background: var(--spot-strong); border-color: var(--spot-strong); }
  .sw-path--custom:not(:disabled):hover { border-color: var(--signal-line); background: var(--surface-control-hover); }
}
.sw-nav--paths { flex-wrap: nowrap; }
.sw-final { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px 20px; }
.sw-facts { display: flex; flex-wrap: wrap; gap: 16px; margin: 0; color: var(--text-2); font-size: .92rem; }
.sw-facts span { display: inline-flex; align-items: center; gap: 6px; }
.sw-facts i { color: var(--text-3); }
.sw-start { min-height: 60px; min-width: 250px; padding: 0 30px; font-size: 1.15rem; gap: 10px; }
.sw-start-hint { width: 100%; margin: 0; text-align: right; color: var(--text-3); font-size: .85rem; }
.sw .waiting-msg { flex: 1; }

/* Tablets and narrow windows: the presenter goes on top, the rail hides
   (the progress bar and "Paso n de m" keep the place). */
@media (max-width: 899px) {
  .sw { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto minmax(0, 1fr); grid-template-areas: "top" "progress" "side" "main"; }
  .sw-side { padding: 18px 20px 0; border-right: 0; background: none; }
  .sw-host { grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 14px; padding-bottom: 14px; }
  .sw-host-mic { width: 40px; height: 40px; font-size: 1.15rem; }
  .sw .guide-heading { font-size: 1.6rem; }
  .sw-host-text { font-size: .92rem; max-width: none; }
  .sw-rail { display: none; }
  .sw-main { padding: 16px 20px 18px; }
}
/* Phones: the whole screen, the simple path first. */
@media (max-width: 640px) {
  .setup-wizard-dialog { width: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .sw-top { padding: calc(6px + env(safe-area-inset-top)) 8px 6px 16px; }
  .sw-close { padding-inline: 10px; }
  .sw-main { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .sw-nav { gap: 8px; }
  .sw-nav--paths { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .sw-nav--paths .sw-path--basic { order: -1; grid-column: 1 / -1; max-width: none; }
  .sw-nav--paths .sw-path--custom { max-width: none; margin: 0; min-height: 56px; }
  .sw-next { min-width: 0; flex: 1; }
  .sw-final, .sw-start { width: 100%; min-width: 0; }
  .sw-final { justify-content: stretch; }
  .sw-choices { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
  .sw-choice, .sw-choices[data-count] .sw-choice { min-height: 96px; padding: 24px 8px 12px; }
  .sw-choice-basic { top: 5px; right: 5px; padding: 0 6px; font-size: .62rem; }
  .sw-choice.is-numeric .sw-choice-value { font-size: 2rem; }
  .sw-block { grid-template-columns: 22px auto minmax(0, 1fr); }
  .sw-block-tools { grid-column: 1 / -1; justify-content: flex-start; }
  .sw-rundown.is-several .sw-round { margin-left: 36px; }
  .sw-round-num { left: -36px; }
  .sw-rundown.is-several::before { left: 14px; }
}
@media (max-height: 560px) {
  .setup-wizard-dialog { height: 100dvh; }
  .sw-side { padding-top: 12px; }
  .sw-host { padding-bottom: 10px; }
  .sw-host-text { display: none; }
  .sw-main { padding-top: 10px; }
  .sw-choice { min-height: 84px; }
}

/* =====================================================================
   The lobby desk
   ===================================================================== */
#screenLobby .lobby-guide { margin: 0 0 18px; }
#screenLobby .lobby-guide h1 { margin: 0; font-size: 1.7rem; }
#screenLobby .room-navigation { padding-bottom: 4px; }
.lobby-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.lobby-section-head .panel-title { margin: 0; }
.lobby-players { margin-bottom: 26px; }
.lobby-setup .section-hint { margin: 0 0 14px; }

/* Contestants: one seat each, lit with the player's colour like the atriles. */
.lobby-roster { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.lobby-roster .lb-item {
  align-items: center; gap: 10px; min-height: 68px; padding: 10px 8px 10px 10px;
  border: 1px solid color-mix(in srgb, var(--pc) 32%, transparent); border-radius: var(--r-md);
  background: linear-gradient(180deg, color-mix(in srgb, var(--pc) 12%, var(--ink-3)) 0%, var(--ink-2) 100%);
}
.lobby-roster .lb-item::before { left: 14px; right: 14px; top: -1px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; box-shadow: 0 0 10px var(--pc); }
.lobby-roster .lb-item.is-me { border-color: color-mix(in srgb, var(--pc) 60%, transparent); }
.lb-avatar--seat { width: 46px; height: 46px; }
.lb-seat-copy { display: grid; gap: 4px; flex: 1; min-width: 0; }
.lobby-roster .lb-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; overflow-wrap: anywhere; line-height: 1.2; font-size: .95rem; }
.lb-seat-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.lb-seat-tags:empty { display: none; }
.lb-host-tag { display: inline-flex; align-items: center; gap: 4px; color: var(--spot); font-size: .72rem; font-weight: 700; }
.lb-menu { position: relative; align-self: flex-start; flex: none; }
.lb-menu > summary { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; list-style: none; cursor: pointer; color: var(--text-3); font-size: 1.15rem; }
.lb-menu > summary::-webkit-details-marker { display: none; }
.lb-menu > summary:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: 1px; }
.lb-menu[open] > summary, .lb-menu > summary:hover { background: rgb(255 255 255 / .08); color: var(--text-1); }
.lb-menu-list { position: absolute; top: 36px; right: 0; z-index: 6; display: grid; gap: 2px; min-width: 190px; padding: 6px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--ink-3); box-shadow: var(--shadow-2); }
.lb-menu-list .btn { justify-content: flex-start; gap: 8px; width: 100%; border: 0; }
.lb-menu-list .lb-kick { color: var(--danger-strong); }
.lobby-seat-invite { padding: 0; border: 1px dashed var(--line-3); background: transparent; }
.lobby-seat-invite::before { display: none; }
.lobby-seat-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 66px; padding: 10px; border: 0; border-radius: inherit; background: transparent; color: var(--text-2); font: inherit; text-align: left; cursor: pointer; }
.lobby-seat-btn > i { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 50%; border: 1px dashed var(--line-3); font-size: 1.3rem; }
.lobby-seat-btn strong { display: block; color: var(--text-1); font-size: .95rem; }
.lobby-seat-btn small { color: var(--text-3); font-size: .78rem; }
.lobby-seat-btn:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: 2px; }
@media (hover: hover) { .lobby-seat-btn:hover { color: var(--text-1); background: rgb(255 255 255 / .03); } }

/* Your name: a small popover instead of a section of its own. */
.lobby-identity { position: relative; }
.lobby-identity > summary { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line-1); list-style: none; cursor: pointer; color: var(--text-2); font-size: .82rem; }
.lobby-identity > summary::-webkit-details-marker { display: none; }
.lobby-identity > summary:focus-visible { outline: 2px solid var(--signal-strong); outline-offset: 2px; }
.lobby-identity[open] > summary, .lobby-identity > summary:hover { color: var(--text-1); border-color: var(--line-2); }
.lobby-identity-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 7; width: min(300px, 80vw); padding: 14px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--ink-3); box-shadow: var(--shadow-2); }

/* What will be played, and the way into the setup. */
.setup-launcher { display: grid; gap: 12px; }
.setup-lobby-summary {
  --tone: var(--signal);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--line-2); background: var(--surface-sunken);
}
.setup-lobby-what { display: grid; gap: 2px; min-width: 0; }
.setup-lobby-what span { color: var(--text-3); font-size: .78rem; }
.setup-lobby-what strong { font-family: var(--font-display); font-size: 1.35rem; line-height: 1.05; overflow-wrap: anywhere; }
.setup-lobby-go { grid-column: 1 / -1; min-height: 52px; font-size: 1.05rem; gap: 8px; }
.setup-lobby-rules { grid-column: 1 / -1; }
.setup-lobby-rules > summary { cursor: pointer; padding: 6px 0; color: var(--text-2); font-size: .9rem; }
.setup-lobby-rules[open] > summary { margin-bottom: 10px; }
.setup-lobby-rules .sw-rundown.is-several .sw-round { margin-left: 36px; }
.setup-lobby-rules .sw-round { padding: 14px; }
.setup-lobby-rules .sw-round-num { left: -36px; }
.setup-lobby-rules .sw-round-head p { display: none; }
.setup-lobby-rules .sw-rules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.setup-lobby-wait { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text-2); font-size: .88rem; }

/* --- The invitation on the stage (lobby only) ------------------------ */
.room-invite {
  position: absolute; right: 16px; bottom: 58px; z-index: 3;
  display: none; gap: 10px; width: min(320px, calc(100% - 32px)); padding: 14px 16px 16px;
  border-radius: var(--r-lg); border: 1px solid var(--line-2);
  background: rgb(4 7 13 / .8); backdrop-filter: blur(10px);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgb(255 255 255 / .05);
}
body[data-screen="lobby"]:not(.game-active) .room-invite { display: grid; }
.room-invite-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.room-invite .room-name { margin: 0; color: var(--text-2); font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.room-invite-details { min-width: 0; display: grid; gap: 6px; }
.room-invite-code { display: grid; gap: 2px; margin: 0; }
.room-invite-code > span { font-size: .7rem; color: var(--text-3); }
.room-invite-code > strong { font-family: var(--font-display); font-size: 2.2rem; line-height: 1.2; letter-spacing: .08em; color: var(--spot); white-space: nowrap; }
.room-invite-actions { display: flex; gap: 8px; }
.room-invite-actions.hidden { display: none; }
.room-invite-actions .btn { flex: 1; min-height: 40px; gap: 6px; }
.btn.is-copied { background: var(--success); border-color: var(--success); color: var(--success-ink); }
/* Portrait: a slim strip along the bottom of the stage band. */
@media (orientation: portrait), (max-width: 639px) {
  .room-invite { left: 8px; right: 8px; bottom: 8px; width: auto; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 8px 8px 8px 12px; }
  .room-invite-head { display: none; }
  .room-invite-details { gap: 2px; }
  .room-invite .room-name { font-size: .8rem; -webkit-line-clamp: 1; }
  .room-invite-code { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
  .room-invite-code > strong { font-size: 1.4rem; }
  .room-invite-actions .btn { min-height: 36px; padding-inline: 10px; }
  .room-invite-actions .btn span { display: none; }
  body[data-screen="lobby"] .motion-toggle { display: none; }
}
