/*
  Bingo on Cue 3.19 · cue desk
  Loaded after style.css. It owns the caller and sets the conventions every other page follows.

  Theme data keeps its historic names: --bg is a theme's ink and --fg its paper, and Forge
  swaps them so the page is dark. These aliases say what each colour is for.

  Colour has one job each
    ink     the number, labels, the called board
    accent  the single next action, the current ball on the board, the audio meter while it runs
    amber   rehearsal only (nothing else on screen is amber)
    gold    the Winner button and nothing else
    red dot live only

  Type: Inter throughout (local). Labels 12px caps 700. Controls 15-16px 600. Number: 46% of the stage.
  Shape: 8px controls, 10px panels. No shadows, no gradients. Borders are hairlines.
  Motion: nothing on the deck moves. Only words, a meter and colour change inside fixed boxes.
*/
html {
  --surface: var(--fg);
  --ink: var(--bg);
  --raise: color-mix(in srgb, var(--surface) 93%, var(--ink));
  --raise-2: color-mix(in srgb, var(--surface) 86%, var(--ink));
  --edge: color-mix(in srgb, var(--surface) 76%, var(--ink));
  --quiet: color-mix(in srgb, var(--surface) 22%, var(--ink));
  --rehearse: #e8b84a;
  --rehearse-ink: #1a1306;
  --live: #e5484d;
  --winner: #f2b33d;
  --winner-ink: #1a1305;
  --r-control: 8px;
  --r-panel: 10px;
  --gap: clamp(0.625rem, 1.4vw, 1rem);
  --rail: 5.25rem;
  --dock: calc(3.75rem + env(safe-area-inset-bottom, 0px));
  --touch: 2.75rem;
  /* Stage: the one dark-on-light (or light-on-dark) block the host reads from arm's length. */
  --stage-bg: var(--ink);
  --stage-ink: var(--surface);
  --stage-quiet: color-mix(in srgb, var(--stage-ink) 68%, var(--stage-bg));
  --stage-edge: color-mix(in srgb, var(--stage-ink) 24%, var(--stage-bg));
  --panel: var(--raise);
  --line: var(--edge);
  --wash: var(--raise);
  --rule: var(--edge);
  --muted: var(--quiet);
  background: var(--surface);
  color: var(--ink);
  font: 400 1rem/1.5 Inter, Arial, sans-serif;
}
html[data-layout="forge"] {
  --stage-bg: color-mix(in srgb, var(--surface) 82%, var(--ink));
  --stage-ink: var(--ink);
}
body { background: var(--surface); color: var(--ink); }
:where(h1, h2, h3, p) { overflow-wrap: anywhere; }
h1, h2, h3 { font-family: Inter, sans-serif; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 3vw, 2.25rem); font-weight: 700; }
h2 { font-size: clamp(1.2rem, 2vw, 1.5rem); font-weight: 700; }
html[data-layout] h1 { font-size: clamp(1.6rem, 3vw, 2.25rem); font-weight: 700; letter-spacing: -0.02em; }
html[data-layout] h2 { font-size: clamp(1.2rem, 2vw, 1.5rem); font-weight: 700; letter-spacing: -0.02em; }
html[data-layout] h3 { font: 700 0.75rem/1.2 Inter, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--quiet); }
.kicker { font: 700 0.75rem/1.2 Inter, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }
.sub, .quiet { color: var(--quiet); }

/* ---------- Controls: one grammar for every page ---------- */
button, select, input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"]), textarea {
  border-radius: var(--r-control);
}
button {
  min-height: var(--touch);
  padding: 0.5rem 0.95rem;
  background: transparent;
  border: 1px solid var(--edge);
  color: var(--ink);
  font: 600 0.95rem/1.2 Inter, sans-serif;
  box-shadow: none;
}
@media (hover: hover) { button:enabled:hover { background: var(--raise-2); box-shadow: none; } }
button:enabled:active { background: var(--raise-2); filter: none; transform: none; }
button:disabled { opacity: 0.42; }
button.primary:disabled { opacity: 1; background: var(--raise-2); border-color: var(--edge); color: var(--quiet); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--actionText);
}
@media (hover: hover) { button.primary:enabled:hover { background: var(--accent); filter: brightness(1.08); } }
:where(button, input, select, textarea, summary, a):focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--surface);
}
button.primary:focus-visible { outline-color: var(--ink); }
input:not([type]), input[type="text"], input[type="number"], input[type="search"], input[type="time"], input[type="date"], input[type="url"], select, textarea {
  min-height: var(--touch);
  border: 1px solid var(--edge);
  background: var(--surface);
  color: var(--ink);
  padding: 0.45rem 0.7rem;
}
label, .field > span:first-child { font-weight: 600; }
.panel { border: 1px solid var(--edge); border-radius: var(--r-panel); background: transparent; box-shadow: none; padding: 1rem; }
.tag { border: 1px solid var(--edge); border-radius: 6px; background: transparent; color: var(--ink); font-size: 0.75rem; font-weight: 700; padding: 0.1rem 0.45rem; }

/* ---------- Shell: a rail on wide screens, a dock on narrow ones ---------- */
.brand { font: 750 1.05rem/1.1 Inter, sans-serif; letter-spacing: -0.03em; text-transform: none; }
.mark { width: 2.1rem; background: var(--accent); border: 0; color: var(--actionText); font-weight: 800; }
html[data-layout] body > header {
  background: var(--raise);
  border-bottom: 1px solid var(--edge);
  padding: 0.5rem max(env(safe-area-inset-left), 1rem);
}
html[data-layout] body > header nav { position: static; display: flex; background: none; border: 0; gap: 0.25rem; }
html[data-layout] body > header nav button {
  border: 0;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--quiet);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.8rem;
  min-height: 3.4rem;
  padding: 0.3rem 0.5rem;
  box-shadow: none;
}
html[data-layout] body > header nav button.active { color: var(--ink); background: var(--raise-2); box-shadow: inset 0 -3px var(--accent); }
html[data-layout] body > header nav button::before { content: ""; width: 1.1rem; height: 1.1rem; border: 1.7px solid currentColor; border-radius: 50%; background: none; }
html[data-layout] body > header nav button[data-page="prepare"]::before { border-radius: 3px; background: linear-gradient(currentColor, currentColor) center/55% 2px no-repeat; }
html[data-layout] body > header nav button[data-page="settings"]::before { content: "⚙"; border: 0; font: 1.2rem/1 sans-serif; width: auto; height: auto; }
html[data-layout] body > header nav button[data-act="help"]::before { content: "?"; border-radius: 50%; font: 700 0.75rem/1rem Inter, sans-serif; text-align: center; }
main { width: auto; max-width: none; margin: 0; padding: 0; }
body:not([data-page="host"]) main { max-width: 74rem; padding: clamp(1rem, 3vw, 2rem) max(env(safe-area-inset-right), clamp(1rem, 3vw, 2rem)) clamp(1.5rem, 4vw, 3rem); }
.miniMark { display: none; }

@media (min-width: 900px) {
  html[data-layout] body { padding-inline-start: var(--rail); }
  html[data-layout] body > header {
    position: fixed; inset: 0 auto 0 0; width: var(--rail); z-index: 10;
    flex-direction: column; align-items: center; justify-content: flex-start; gap: 1.1rem;
    padding: 1rem 0.4rem; border-bottom: 0; border-inline-end: 1px solid var(--edge);
  }
  .brand > span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  html[data-layout] body > header nav { flex-direction: column; width: 100%; }
  html[data-layout] body > header nav button { min-height: 4.1rem; width: 100%; }
}
@media (max-width: 899px) {
  html[data-layout] body { padding-bottom: var(--dock); }
  html[data-layout] body > header { padding: 0; border: 0; background: none; }
  .brand { display: none; }
  html[data-layout] body > header nav {
    position: fixed; inset: auto 0 0; z-index: 10; width: 100%; max-width: none;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    background: var(--raise); border-top: 1px solid var(--edge);
    padding: 0.25rem max(0.4rem, env(safe-area-inset-left)) calc(0.25rem + env(safe-area-inset-bottom, 0px));
  }
  html[data-layout] body > header nav button { min-height: 3.25rem; font-size: 0.78rem; }
  .miniMark { display: grid; width: 1.7rem; }
}

/* ---------- Banner and toast never cover the deck ---------- */
#problem:not([hidden]) {
  position: fixed; z-index: 60; top: 0.6rem; left: 50%; translate: -50% 0; width: min(44rem, calc(100vw - 1.5rem));
  margin: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.6rem 0.75rem 0.6rem 1rem; border: 2px solid var(--ink); border-radius: var(--r-panel); background: var(--surface);
}
#notice {
  position: fixed; z-index: 50; top: 0.6rem; right: 0.8rem; bottom: auto; left: auto; translate: none; width: auto; max-width: min(26rem, calc(100vw - 1.6rem));
  margin: 0; padding: 0.55rem 0.85rem; border-radius: var(--r-control); background: var(--ink); color: var(--surface);
  font-size: 0.9rem; font-weight: 600; pointer-events: none;
}

/* ---------- The desk ---------- */
.desk {
  --deck-row: 4.4rem;
  display: grid;
  gap: var(--gap);
  height: 100vh; height: 100dvh;
  padding: var(--gap) max(var(--gap), env(safe-area-inset-right)) max(var(--gap), env(safe-area-inset-bottom)) var(--gap);
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "bar bar" "stage side" "deck side";
}
.deskBar { grid-area: bar; display: flex; align-items: center; gap: 0.5rem 1.25rem; min-height: var(--touch); min-width: 0; }
.deskId { display: flex; align-items: center; gap: 0.7rem; min-width: 0; flex: 1 1 0; }
html[data-layout] .showName { margin: 0; font: 700 1.2rem/1.2 Inter, sans-serif; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.modeTag {
  flex: none; display: inline-flex; align-items: center; gap: 0.45rem; height: 1.9rem; padding: 0 0.7rem; border-radius: 6px;
  font: 800 0.75rem/1 Inter, sans-serif; letter-spacing: 0.09em; text-transform: uppercase;
}
.modeTag.isLive { border: 1px solid var(--ink); }
.modeTag.isLive i { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--live); }
.modeTag.isRehearsal { background: var(--rehearse); color: var(--rehearse-ink); border: 1px solid var(--rehearse); }
.modeTag.isRehearsal i { width: 0.55rem; height: 0.55rem; border-radius: 2px; background: var(--rehearse-ink); }
.deskFacts { display: flex; align-items: center; gap: 1rem; flex: 0 1 auto; max-width: 52%; min-width: 0; color: var(--quiet); font-size: 0.9rem; font-weight: 500; }
.deskFacts > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.deskFacts .objective { color: var(--ink); font-weight: 650; flex: none; max-width: 14rem; }
.deskActions { flex: none; display: flex; gap: 0.5rem; }

/* Stage: number, call line, cue, recent calls */
.stage {
  grid-area: stage; container-type: size; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--stage-bg); color: var(--stage-ink);
  border-radius: var(--r-panel); border: 1px solid var(--stage-edge);
  overflow: hidden;
}
.stage.isRehearsal { box-shadow: inset 0 0 0 4px var(--rehearse); }
.stage .kicker { color: var(--stage-quiet); }
.stageTop { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 1.2rem 0; min-height: 2.4rem; }
.stageTop .logo { max-height: 2rem; max-width: 7rem; object-fit: contain; }
html[data-layout] .stage .ballStage { flex: 1 1 0; min-height: 0; display: grid; place-items: center; padding: 0 1rem; background: none; border: 0; }
html[data-layout] .stage .ballStage::before, html[data-layout] .stage .ballStage::after { display: none; }
html[data-layout] .stage .ball {
  width: auto; aspect-ratio: auto; padding: 0; border: 0; outline: 0; background: none; box-shadow: none; border-radius: 0;
  color: var(--stage-ink);
  font: 800 clamp(5rem, min(50cqh, 62cqw), 22rem)/0.86 var(--head), Inter, sans-serif;
  letter-spacing: -0.06em; font-variant-numeric: lining-nums tabular-nums;
}
html[data-layout] .stage .is-empty .ball { color: var(--stage-quiet); font-weight: 650; letter-spacing: -0.03em; }
.readyLabel { font: 650 clamp(1.5rem, 7cqw, 2.6rem)/1.1 Inter, sans-serif; letter-spacing: -0.03em; }
.hostLines { min-height: 4.6rem; padding: 0 1.2rem; text-align: center; display: grid; align-content: start; gap: 0.1rem; }
.hostLines p { margin: 0; }
.hostCall { font: 650 clamp(1.15rem, 5cqw, 1.6rem)/1.25 Inter, sans-serif; min-height: 1.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cueTitle { font: 600 1rem/1.4 Inter, sans-serif; color: var(--stage-quiet); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 1.4rem; }
.cueNote { font-size: 0.9rem; line-height: 1.35; color: var(--stage-ink); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; min-height: 1.2rem; }
.cueNote strong { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--stage-quiet); margin-inline-end: 0.5rem; }
.ticketFoot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 3.2rem; padding: 0.5rem 1.2rem; border-top: 1px solid var(--stage-edge); color: var(--stage-quiet); font-size: 0.85rem; font-weight: 600; }
.lastCalls { display: flex; align-items: center; gap: 0.4rem; min-width: 0; overflow: hidden; }
.lastCalls > span { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; font-weight: 700; margin-inline-end: 0.3rem; }
html[data-layout] .stage .lastCalls b {
  display: inline-grid; place-items: center; min-width: 2.2rem; height: 2rem; padding: 0 0.4rem;
  border: 1px solid var(--stage-edge); border-radius: 6px; background: none; color: var(--stage-ink);
  font: 700 1rem/1 Inter, sans-serif; font-variant-numeric: tabular-nums;
}
.lastCalls em { font-style: normal; }
.count { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Deck: four fixed slots. Nothing is ever hidden, inserted or resized. */
.deck {
  grid-area: deck;
  display: grid; gap: 0.6rem;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
}
.deck button { min-width: 0; }
.drawBtn { height: 4.4rem; min-height: 4.4rem; font: 750 1.3rem/1.15 Inter, sans-serif; letter-spacing: -0.015em; }
.drawBtn:not(.primary) { border-width: 2px; border-color: var(--ink); }
.bingoBtn {
  height: 4.4rem; min-height: 4.4rem; overflow: hidden; display: grid; align-content: center; justify-items: center; gap: 0.1rem; text-align: center;
  border: 2px solid var(--ink); background: transparent;
}
.bingoBtn strong { font: 800 1.35rem/1.1 Inter, sans-serif; letter-spacing: -0.015em; }
.bingoBtn small { font: 600 0.78rem/1.2 Inter, sans-serif; color: var(--quiet); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bingoBtn.isPlaying { background: var(--ink); color: var(--surface); }
.bingoBtn.isPlaying small { color: var(--surface); }
.bingoBtn:disabled { border-style: dashed; }
.bingoBtn.winnerBtn { background: var(--winner); border-color: var(--winner); color: var(--winner-ink); }
.bingoBtn.winnerBtn small { color: var(--winner-ink); }

.cueSlot {
  grid-column: 1 / -1; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center; gap: 0.2rem; text-align: left;
  height: 5.4rem; min-height: 5.4rem; padding: 0.55rem 1rem 0.7rem;
  border: 1px solid var(--edge); border-radius: var(--r-control); background: var(--raise); color: var(--ink);
}
.cueSlot.is-none { border-style: dashed; background: transparent; color: var(--quiet); }
.cueTop { display: flex; justify-content: space-between; gap: 1rem; font: 700 0.72rem/1.2 Inter, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--quiet); }
.cueTop > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cueTop #timeLeft { flex: none; font-variant-numeric: tabular-nums; color: var(--ink); min-width: 5.5ch; text-align: right; }
.cueMain { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.cueVerb { flex: none; width: 1.5rem; font-size: 1.15rem; text-align: center; }
.cueName { flex: 1 1 auto; min-width: 0; font: 700 1.15rem/1.2 Inter, sans-serif; letter-spacing: -0.01em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.cueSlot.is-none .cueName { font-weight: 550; font-size: 1rem; -webkit-line-clamp: 1; }
.cueLen { flex: none; font: 650 0.95rem/1 Inter, sans-serif; font-variant-numeric: tabular-nums; color: var(--quiet); }
.cueSlot .meter { position: absolute; inset: auto 0 0 0; height: 0.3rem; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform 0.25s linear; opacity: 0; }
.cueSlot[data-phase="playing"] .meter, .cueSlot[data-phase="fading"] .meter { opacity: 1; }
.cueSlot[data-phase="fading"] .meter { opacity: 0.55; }
.cueSlot.isNext { background: var(--accent); border-color: var(--accent); color: var(--actionText); }
.cueSlot.isNext .cueTop, .cueSlot.isNext .cueLen, .cueSlot.isNext .cueTop #timeLeft { color: var(--actionText); }
.cueSlot[data-phase="playing"], .cueSlot[data-phase="fading"] { border: 2px solid var(--accent); padding-inline: calc(1rem - 1px); opacity: 1; background: var(--raise); color: var(--ink); }
.cueSlot[data-phase="playing"] .cueTop, .cueSlot[data-phase="fading"] .cueTop { color: var(--ink); }
.cueSlot:disabled { opacity: 0.5; }
.cueSlot:disabled[data-phase="playing"], .cueSlot:disabled[data-phase="fading"] { opacity: 1; }

.transport { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.transport button { min-height: 3.4rem; padding-inline: 0.4rem; }
.transport .stopBtn.isLive { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.transport button[data-act="keep-playing"] { grid-column: auto; }

/* Side column: board, soundboard, tools */
.side { grid-area: side; min-height: 0; min-width: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: var(--gap); }
.sideTabs { flex: none; display: grid; grid-template-columns: 1fr 1.5fr; gap: 0.4rem; }
.sideTabs button { border-radius: var(--r-control); }
.sideTabs button[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.side .panel { flex: none; margin: 0; padding: 0.7rem 0.8rem; }
.panelTitle { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.55rem; }
html[data-layout] .boardPanel h2, html[data-layout] .soundboard h2 { font: 700 0.75rem/1.2 Inter, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; color: var(--quiet); margin: 0; }
html[data-layout] .claim-panel h2, html[data-layout] .runOrder h2 { font: 700 1.05rem/1.2 Inter, sans-serif; letter-spacing: -0.01em; text-transform: none; color: var(--ink); margin: 0; }
.board { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.board .cell, .board button.cell {
  display: grid; place-items: center; min-height: 0; aspect-ratio: 1 / 0.68; padding: 0;
  border: 1px solid var(--edge); border-radius: 5px; background: transparent; color: var(--quiet);
  font: 600 clamp(0.72rem, 1.7vw, 0.95rem)/1 Inter, sans-serif; font-variant-numeric: tabular-nums;
}
.board .cell.called { background: color-mix(in srgb, var(--ink) 16%, var(--surface)); color: var(--ink); border-color: transparent; font-weight: 750; }
.board .cell.current { background: var(--accent); color: var(--actionText); border-color: var(--accent); font-weight: 800; }
.board button.cell { min-height: 2.5rem; aspect-ratio: auto; font-size: 0.9rem; }
.board button.cell.claim-picked { background: var(--accent); color: var(--actionText); border-color: var(--accent); }
.rehearseBar { display: flex; align-items: end; gap: 0.6rem; margin-top: 0.65rem; padding-top: 0.65rem; border-top: 1px dashed var(--rehearse); }
.rehearseBar .field { position: relative; flex: none; width: 5rem; margin: 0; }
.rehearseBar .field > span:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.rehearseBar input { width: 100%; }
.rehearseBar button { flex: 1 1 auto; }

.soundboard { margin: 0; }
.soundboard .panelTitle h2 { margin: 0; }
.effectGrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem; }
.effectPad { display: flex; flex-flow: column; align-items: flex-start; justify-content: center; gap: 0.1rem; text-align: left; min-height: 3.6rem; padding: 0.4rem 0.6rem; width: 100%; border-radius: var(--r-control); }
html[data-layout] .effectPad:enabled { background: var(--raise); color: var(--ink); border: 1px solid var(--ink); }
.effectPad:disabled { border-style: dashed; background: transparent; opacity: 0.55; }
.effectPad strong { font: 700 0.92rem/1.2 Inter, sans-serif; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; max-width: 100%; margin: 0; }
.effectMeta, .effectHint { font: 600 0.72rem/1.2 Inter, sans-serif; color: var(--quiet); }
.effectSlot { min-width: 0; display: grid; gap: 0.3rem; }

.toolsPanel { display: grid; gap: 1rem; }
.toolGroup h3 { margin: 0 0 0.45rem; }
.toolRow, .pads, .smallActions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
/* Tools: equal-width buttons on a grid, so rows line up and no single button is left stranded. */
.toolRow { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.75rem, 1fr)); }
.toolRow > button { width: 100%; justify-content: center; text-align: center; }
.toolGroup .sub { margin: 0 0 0.5rem; font-size: 0.85rem; }

/* Claim: a pane in the side column. The number and the deck stay exactly where they were. */
.claimDesk { border: 2px solid var(--ink); display: grid; gap: 0.8rem; align-content: start; padding: 0.9rem; }
html[data-layout] .claimHead h2 { font: 750 1.5rem/1.15 Inter, sans-serif; letter-spacing: -0.02em; text-transform: none; color: var(--ink); margin: 0.15rem 0 0; }
.claimActions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 0.6rem; }
.claimActions button { min-height: 4rem; font-size: 1.05rem; }
.claimDesk details { border-top: 1px solid var(--edge); padding-top: 0.5rem; }
.claimDesk summary, #livePlan summary { min-height: var(--touch); display: flex; align-items: center; font-weight: 650; cursor: pointer; }
.claimDesk .panel { border: 0; padding: 0; }
.claim-board { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.claim-summary { margin: 0.5rem 0; }
.claim-panel .pads { margin-top: 0.7rem; }

/* ---------- Portrait iPad and tablets ---------- */
@media (max-aspect-ratio: 5/4), (max-width: 899px) {
  .desk {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(9rem, 0.8fr) auto minmax(0, 1fr);
    grid-template-areas: "bar" "stage" "deck" "side";
    height: 100vh; height: 100dvh;
  }
  html[data-layout] body:has(.desk) { padding-bottom: 0; }
  .desk { padding-bottom: calc(var(--dock) + 0.4rem); }
}
@media (max-aspect-ratio: 5/4) and (min-width: 760px) {
  .side { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-content: start; align-items: start; }
  .sideTabs { grid-column: 1 / -1; }
  .side > .claimDesk { grid-column: 1 / -1; }
}

/* ---------- Phone ---------- */
@media (max-width: 759px) {
  .desk { --gap: 0.55rem; }
  .deskBar { flex-wrap: wrap; gap: 0.3rem 0.6rem; }
  .deskFacts { order: 3; flex: 1 1 100%; max-width: none; gap: 0.7rem; font-size: 0.8rem; }
  .miniMark { display: grid; flex: none; }
  .deskId { flex: 1 1 0; }
  html[data-layout] .showName { font-size: 1rem; }
  .deskActions button { min-height: var(--touch); padding-inline: 0.7rem; font-size: 0.85rem; }
  .stage { border-radius: 8px; }
  .stageTop { padding: 0.5rem 0.8rem 0; min-height: 1.7rem; }
  .hostLines { min-height: 3.4rem; padding-inline: 0.8rem; }
  .hostCall { font-size: 1.05rem; min-height: 1.4rem; }
  .cueTitle { font-size: 0.9rem; min-height: 1.2rem; }
  .cueNote { display: none; }
  .ticketFoot { min-height: 2.7rem; padding: 0.3rem 0.8rem; }
  .lastCalls b { min-width: 1.9rem; height: 1.7rem; font-size: 0.9rem; }
  .drawBtn, .bingoBtn { height: 3.8rem; min-height: 3.8rem; }
  .drawBtn { font-size: 1.15rem; }
  .bingoBtn strong { font-size: 1.15rem; }
  .cueSlot { height: 4.8rem; min-height: 4.8rem; }
  .cueName { font-size: 1rem; }
  .transport button { min-height: 3rem; font-size: 0.85rem; }
  .effectGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side > .soundboard { order: 1; }
  .side > .panel:not(.soundboard) { order: 2; }
  .desk[data-claim="true"] .deck, .desk[data-claim="true"] .hostLines, .desk[data-claim="true"] .ticketFoot { display: none; }
  .desk[data-claim="true"] { grid-template-rows: auto minmax(6rem, 0.45fr) minmax(0, 1.6fr); grid-template-areas: "bar" "stage" "side"; }
  .claimActions { grid-template-columns: 1fr; }
}

/* ---------- Phone on its side (short landscape) ----------
   The number takes the whole left half. The deck stays fixed at the top of the right half, and the
   board, tools and claim check scroll beneath it. Navigation becomes a slim left rail. */
@media (orientation: landscape) and (max-height: 520px) {
  html { --rail: 4.1rem; --gap: 0.5rem; }
  html[data-layout] body { padding-inline-start: var(--rail); padding-bottom: 0; }
  html[data-layout] body > header {
    position: fixed; inset: 0 auto 0 0; width: var(--rail); z-index: 10; padding: 0.4rem 0.25rem;
    flex-direction: column; align-items: center; justify-content: center; gap: 0;
    background: var(--raise); border: 0; border-inline-end: 1px solid var(--edge);
  }
  html[data-layout] body > header nav {
    position: static; inset: auto; width: 100%; display: flex; flex-direction: column; gap: 0.15rem;
    background: none; border: 0; padding: 0;
  }
  html[data-layout] body > header nav button { min-height: 2.9rem; width: 100%; font-size: 0.7rem; padding: 0.15rem; }
  .desk {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "stage bar" "stage deck" "stage side";
    height: 100vh; height: 100dvh; padding: var(--gap) max(var(--gap), env(safe-area-inset-right)) var(--gap) var(--gap);
  }
  .deskBar { flex-wrap: nowrap; gap: 0.5rem; }
  .deskFacts, .miniMark { display: none; }
  .deskBar .modeTag { flex: none; }
  .deskActions button { min-height: var(--touch); padding-inline: 0.6rem; font-size: 0.8rem; }
  .stage .hostLines { gap: 0; }
  .stage .cueNote { display: none; }
  .drawBtn, .bingoBtn { height: 3.2rem; min-height: 3.2rem; }
  .drawBtn { font-size: 1.05rem; }
  .bingoBtn strong { font-size: 1rem; }
  .bingoBtn small { font-size: 0.68rem; }
  .cueSlot { height: 3.5rem; min-height: 3.5rem; padding: 0.35rem 0.7rem 0.5rem; }
  .transport button { min-height: 2.75rem; font-size: 0.8rem; }
  .side { padding-bottom: 0.2rem; }
  .desk[data-claim="true"] { grid-template-rows: auto auto minmax(0, 1fr); grid-template-areas: "stage bar" "stage side" "stage side"; }
  .desk[data-claim="true"] .deck { display: none; }
}

/* ---------- Dialogs: always scrollable, always dismissible ---------- */
dialog { border: 1px solid var(--edge); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 1rem; max-width: min(46rem, calc(100vw - 1rem)); box-shadow: none; }
dialog::backdrop { background: color-mix(in srgb, var(--ink) 55%, transparent); }
#modal[open] { display: flex; flex-direction: column; width: min(46rem, calc(100vw - 1rem)); max-height: calc(100dvh - 1rem); overflow: hidden; }
#modal #dialogBody { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0.2rem 0.25rem 0.5rem; }
#modal > #closeDialog { flex: none; align-self: stretch; margin-top: 0.6rem; min-height: 3rem; }
#modal:has(#helpSearch) > #closeDialog { align-self: stretch; }

/* ---------- Prepare, Settings, Help: the same grammar ---------- */
.pageTitle { margin-bottom: 1.2rem; }
.pageTitle h1 { margin: 0.2rem 0 0; }
.setupLayout { grid-template-columns: minmax(11rem, 15rem) minmax(0, 1fr); gap: clamp(1rem, 3vw, 2rem); }
.setupSteps button { border: 1px solid var(--edge); border-radius: var(--r-control); background: transparent; color: var(--ink); text-align: left; padding: 0.6rem 0.8rem; }
.setupSteps [aria-current="step"], html[data-layout] .setupSteps [aria-current="step"] { background: var(--ink); color: var(--surface); border-color: var(--ink); box-shadow: inset 4px 0 var(--accent); }
.setupSteps small { color: inherit; opacity: 0.8; }
.setupPanel { border: 1px solid var(--edge); border-radius: var(--r-panel); padding: clamp(1rem, 2.5vw, 1.6rem); background: transparent; }
.setupPanel h2 { margin: 0 0 0.6rem; }
.setupPanel h3 { margin-top: 1.4rem; }
.themeTile { border: 1px solid var(--edge); border-radius: var(--r-control); background: transparent; color: var(--ink); }
.themeTile[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); outline: 0; }
.settingsGrid .panel { border: 0; border-bottom: 1px solid var(--edge); border-radius: 0; padding: 1rem 0; }
.helpTopics section { border-top: 1px solid var(--edge); }
.cueRow, .runList li { border-color: var(--edge); }
details > summary { min-height: var(--touch); }

@media (max-width: 760px) {
  .setupLayout { grid-template-columns: minmax(0, 1fr); }
  .setupSteps { display: flex; flex-wrap: wrap; gap: 0.4rem; }
  .pageTitle h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .cueSlot .meter { transition: none; }
}

.pageTitle .kicker::before { content: none; }
.toolsPanel .runOrder, .toolsPanel .panel { border: 0; padding: 0; margin: 0; }

/* Claim check: the award buttons stay in view while the host reads numbers off the ticket. */
.claim-panel .pads { position: sticky; bottom: 0; z-index: 1; padding: 0.6rem 0 0.1rem; background: var(--panel); border-top: 1px solid var(--line); }
.claimDesk .claim-panel [data-act="reject"] { display: none; }
.claim-panel .pads { display: grid; grid-template-columns: 1.7fr 1.2fr 0.9fr; gap: 0.5rem; }
.claim-panel .pads button { min-height: var(--touch); padding-inline: 0.5rem; font-size: 0.9rem; line-height: 1.15; }

/* Winner music rows in the Winner dialog */
.winnerMusic { display: grid; gap: 0.4rem; }
.winnerRow { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.4rem 0.6rem; border: 1px solid var(--edge); border-radius: var(--r-control); }
.winnerRow span { display: grid; min-width: 0; }
.winnerRow small { color: var(--quiet); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winnerRow button { flex: none; min-width: 5.5rem; }
#winnerPreviewFrame { width: min(100%, 25rem) !important; display: block; margin-inline: auto; }

/* ---------- Top safe area: status bar, camera housing and window controls ---------- */
:root { --safe-top: env(safe-area-inset-top, 0px); }
html[data-layout] .desk {
  padding-top: max(var(--gap), var(--safe-top));
  padding-left: max(var(--gap), env(safe-area-inset-left, 0px));
}
body:not([data-page="host"]) main { padding-top: calc(clamp(1rem, 3vw, 2rem) + var(--safe-top)); }
@media (min-width: 900px) {
  html[data-layout] body > header { padding-top: calc(1rem + var(--safe-top)); }
}

/* ---------- Rehearsal: the draw control stays on screen while the side panel scrolls ---------- */
.side > .rehearseBar {
  position: sticky; bottom: 0; z-index: 2; margin-top: 0.65rem;
  background: var(--surface, var(--bg)); padding: 0.65rem 0.25rem 0.4rem;
}

/* Dialog headings take focus so screen readers announce them. They are not controls, so no ring. */
h2[tabindex="-1"]:focus, h2[tabindex="-1"]:focus-visible { outline: none; }

/* Press feedback in the theme's own accent: a pressed control fills and outlines for a moment. */
button { transition: background-color .12s ease, box-shadow .12s ease, filter .12s ease; }
button:enabled:active, button.tapped {
  background: color-mix(in srgb, var(--accent) 24%, var(--surface));
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--accent);
}
button.primary:enabled:active, button.primary.tapped {
  background: var(--accent);
  color: var(--actionText);
  filter: brightness(0.82);
  box-shadow: inset 0 0 0 2px var(--actionText);
}

/* Fixed test game inside the rehearsal bar */
.testRunPanel { border-style: dashed; border-color: var(--rehearse); }
.testRun p { margin: 0 0 0.5rem; font-size: 0.85rem; }
.testNumbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 0.75rem; }
.tagList { margin: 0.25rem 0 0; padding-left: 1.2rem; }

/* ---------- iPhone refinements ---------- */
/* The toast and the problem banner sit below the status bar and the camera housing. */
html[data-layout] #notice { transform: none; top: calc(var(--safe-top) + 0.6rem); }
html[data-layout] #problem:not([hidden]) { top: calc(var(--safe-top) + 0.6rem); }

/* The tab bar is a flat dock, never a pill, and its labels stay on one line. */
@media (max-width: 899px) {
  :root { --dock: calc(3.9rem + env(safe-area-inset-bottom, 0px)); }
  html[data-layout] body > header nav { border-radius: 0; }
  html[data-layout] body > header nav button { white-space: nowrap; font-size: 0.74rem; padding-inline: 0.1rem; }
  /* Toasts rise above the dock on phones instead of covering the status bar. */
  html[data-layout] #notice { top: auto; bottom: calc(var(--dock) + 0.6rem); left: 0.8rem; right: 0.8rem; max-width: none; text-align: center; }
}

/* Phone upright: the number gets room, the deck is slimmer, and the rehearsal panel scrolls with the side column. */
@media (max-width: 759px) and (orientation: portrait) {
  .desk { grid-template-rows: auto minmax(12.5rem, 1.5fr) auto minmax(6.5rem, 1fr); }
  .hostLines { min-height: 3rem; }
  .cueSlot { height: 3.7rem; min-height: 3.7rem; }
  .transport button { min-height: 2.75rem; }
  .side > .rehearseBar { position: static; }
}

/* App mark in the show bar: the real app icon, always visible. */
.appMark { display: block; flex: none; width: 2.1rem; height: 2.1rem; border-radius: 22%; box-shadow: 0 0 0 1px color-mix(in srgb, var(--fg) 18%, transparent); }

/* Sound output chooser */
.soundChoices { display: grid; gap: .6rem; margin: .8rem 0; }
.soundChoice { display: grid; gap: .2rem; text-align: left; min-height: 2.75rem; padding: .7rem .9rem; border-radius: .7rem; border: 2px solid color-mix(in srgb, var(--fg) 25%, transparent); background: transparent; color: inherit; font: inherit; }
.soundChoice small { opacity: .75; }
.soundChoice[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* Settings: grouped by when you use them, with a jump bar. Frequent show and screen settings come before looks. */
.settingsJump { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: -0.4rem 0 1rem; position: sticky; top: 0; z-index: 2; padding: 0.4rem 0; background: var(--surface); }
.settingsGroup { margin-bottom: 1.4rem; scroll-margin-top: 3.5rem; }
.groupLabel { margin: 0 0 0.2rem; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--quiet); }
/* The theme gallery is one swipeable row, not a block that pushes the rest of the page down. */
.settingsGrid .themeGallery { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 0.6rem; padding-bottom: 0.4rem; scroll-snap-type: x proximity; }
.settingsGrid .themeGallery .themeTile { flex: 0 0 11rem; scroll-snap-align: start; }
/* Reset is last, set apart, and marked as the risky one. */
.settingsGrid .dangerZone { border-top: 2px solid #c0332b; margin-top: 0.5rem; }
.settingsGrid .dangerZone h2 { color: #c0332b; }
/* Help is not a page: keep it at the foot of the rail, away from the three places you navigate between. */
@media (min-width: 761px) { html[data-layout] body > header nav button[data-act="help"] { margin-top: 1.1rem; border-top: 1px solid var(--edge); border-radius: 0 0 8px 8px; } }

/* Help guide */
.helpBody { padding: 0.2rem 0 0.6rem; }
.helpBody p, .helpBody li { line-height: 1.5; }
.helpBody ul, .helpBody ol { margin: 0.4rem 0 0.6rem 1.2rem; padding: 0; }
.helpTable { width: 100%; border-collapse: collapse; margin: 0.4rem 0 0.8rem; font-size: 0.92rem; }
.helpTable th, .helpTable td { text-align: left; vertical-align: top; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--edge); }
.helpTable th { font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--quiet); }
.helpTable td:first-child { width: 36%; font-weight: 600; }
kbd { display: inline-block; min-width: 1.5rem; padding: 0.05rem 0.4rem; border: 1px solid var(--edge); border-bottom-width: 2px; border-radius: 5px; background: var(--raise); font: 600 0.8rem/1.4 Inter, sans-serif; text-align: center; }
[data-help-group] > h3 { margin: 1.1rem 0 0.3rem; }
@media (max-width: 760px) { .helpTable td:first-child { width: auto; } }

/* Buttons placed straight into a dialog never touch: spacing for any loose row, plus a gap for rows built as flex. */
#dialogBody > button, #dialogBody > div:not([class]) > button { margin: 0 0.5rem 0.6rem 0; }
#dialogBody .pads, #dialogBody .toolRow, #dialogBody .smallActions { gap: 0.6rem; margin-block: 0.4rem 0.6rem; }
#dialogBody .pads { display: flex; flex-wrap: wrap; }
