/* Roomful Bingo's live screens (v2.0, P5a): the host's setup, joining, the card on every phone (host bar on the host's),
   the TV (js/bingo-stage.js) and the results. Mobile-first; the design system (site.css rf- classes, tokens) does the rest.
   Every class here starts bg-. */

/* ---------- Setup ---------- */
.page.gn .bg-setup-title { flex: 1; font-size: 28px; white-space: nowrap; }
.bg-sets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.bg-set {
  position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 10px;
  min-height: 64px; padding: 10px 12px; border: var(--rf-line) solid var(--rf-outline); border-radius: 18px; background: var(--rf-white);
  color: var(--rf-ink); box-shadow: var(--rf-press-sm); cursor: pointer; font-weight: 800; line-height: 1.15;
}
.bg-set input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.bg-set:has(input:checked) { background: var(--rf-tile, var(--rf-primary)); outline: 3px solid var(--rf-link-cream); outline-offset: 2px; }
.bg-set:has(input:focus-visible) { outline: 3px solid var(--rf-focus, var(--rf-link-cream)); outline-offset: 3px; }
.bg-set-emoji { grid-row: span 2; font-size: 26px; line-height: 1; }
.bg-set-name { font-size: 15px; overflow-wrap: anywhere; }
.bg-set-count { font-size: 13px; font-weight: 700; color: var(--rf-muted-cream); }
.bg-set:has(input:checked) .bg-set-count { color: var(--rf-ink); }
.bg-switch { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 800; cursor: pointer; }
.bg-switch input { width: 26px; height: 26px; accent-color: var(--rf-blue); }
.voice-picker { display: grid; gap: 8px; padding: 12px; border: 2px solid var(--rf-line-cream); border-radius: 18px; background: var(--rf-white); color: var(--rf-ink); }
.voice-picker[hidden] { display: none; }
.voice-picker > label:first-child { font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; }
.voice-row { display: flex; gap: 8px; min-width: 0; }
.voice-row select { flex: 1; min-width: 0; min-height: 48px; border: var(--rf-line) solid var(--rf-outline); border-radius: 14px; padding: 0 10px; font: inherit; font-weight: 700; background: var(--rf-white); color: var(--rf-ink); }
.voice-row .rf-btn { min-width: 72px; }
.voice-picker label.check { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 700; }
.voice-picker label.check input { width: 22px; height: 22px; }
.voice-note { margin: 0; font-size: 14px; color: var(--rf-muted-cream); }
.bg-tvcard { display: flex; align-items: center; gap: 12px; padding: 14px; text-decoration: none; color: var(--rf-ink); }
.bg-tvcard-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--rf-night); color: var(--rf-white); }
.bg-tvcard-text { display: flex; flex-direction: column; min-width: 0; font-size: 15px; }
.bg-tvcard-text span { color: var(--rf-link-cream); font-weight: 700; overflow-wrap: anywhere; }

/* ---------- Join ---------- */
.bg-join-title { margin: 0; font-size: 44px; line-height: 1; }
.bg-join .rf-code-input { text-transform: uppercase; }
.bg-join-links { margin: 0; text-align: center; }

/* ---------- The phone: top bar, last call, card, BINGO ---------- */
.bg-me { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 17px; }
.bg-me b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bg-host-pill .rf-icon { width: 16px; height: 16px; }
.bg-last { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 22px; background: var(--rf-night); color: var(--rf-white); }
.bg-last-emoji { font-size: 40px; line-height: 1; }
.bg-last-text { display: flex; flex-direction: column; min-width: 0; }
.bg-last-text .rf-label { color: var(--rf-muted-room); }
.bg-last-label { font-size: 26px; font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.bg-play { gap: 14px; }
.bg-card-wrap { display: flex; flex-direction: column; gap: 4px; }
.bg-letters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; text-align: center; font-size: 26px; font-weight: 800; color: var(--rf-primary); }
.bg-card { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.bg-card li { min-width: 0; }
.bg-sq {
  position: relative; appearance: none; width: 100%; aspect-ratio: 1 / 1.08; min-height: 62px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 3px 2px; border: 2px solid var(--rf-outline); border-radius: 12px; background: var(--rf-cream); color: var(--rf-ink);
  box-shadow: 0 3px 0 var(--rf-outline); font: inherit; text-align: center; cursor: pointer; touch-action: manipulation; overflow: hidden;
  transition: transform 80ms ease-out, box-shadow 80ms ease-out;
}
.bg-sq:active { transform: translateY(3px); box-shadow: 0 0 0 var(--rf-outline); }
.bg-sq.is-marked { background: var(--rf-tile, var(--rf-primary)); box-shadow: inset 0 0 0 3px var(--rf-ink), 0 1px 0 var(--rf-outline); transform: translateY(2px); }
.bg-sq.is-free { background: var(--rf-primary); }
.bg-card.is-auto .bg-sq { cursor: default; }
.bg-sq-emoji { font-size: 22px; line-height: 1; }
.bg-sq-label { font-size: 16px; font-weight: 800; line-height: 1.05; overflow-wrap: normal; word-break: normal; max-width: 100%; }
.bg-sq-label.px14 { font-size: 14px; }
.bg-sq-label.px12 { font-size: 12px; }
.bg-sq-label.px11 { font-size: 11px; }
.bg-sq-label.px10 { font-size: 10px; }
.bg-sq-label.hyph { hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere; }
.bg-card--numbers .bg-sq-label { font-size: 28px; font-variant-numeric: tabular-nums; }
/* v2.2 (QA-B #4): FREE on one line, centred under its star, on every card and phone (360-412 px squares are 58-72 px) */
.bg-card .bg-sq.is-free { justify-content: center; gap: 1px; }
.bg-card .bg-sq.is-free .bg-sq-emoji { font-size: 20px; line-height: 1; }
.bg-card .bg-sq.is-free .bg-sq-label { font-size: 14px; letter-spacing: 0.03em; line-height: 1; white-space: nowrap; overflow-wrap: normal; hyphens: none; }
.bg-stamp { position: absolute; top: 2px; right: 2px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--rf-ink); color: var(--rf-white); }
.bg-stamp .rf-icon { width: 14px; height: 14px; stroke-width: 3; }
.bg-thumb { position: sticky; bottom: 0; z-index: 5; gap: 8px; margin-left: -16px; margin-right: -16px; padding: 8px 16px max(8px, env(safe-area-inset-bottom, 0px)); background: var(--rf-blue); }
.bg-bingo-btn { font-size: 34px; letter-spacing: 0.06em; }
.bg-bingo-btn:disabled { opacity: 0.55; }
.bg-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; min-height: 24px; text-align: center; font-weight: 800; font-size: 17px; }
.bg-note .rf-icon { width: 18px; height: 18px; }
.bg-note--rule { color: var(--rf-muted-room); font-weight: 700; }
.bg-note--win { color: var(--rf-primary); font-size: 22px; }
.bg-note--error { color: #ffe0ea; }

/* ---------- Host: lobby, check a printed card, TV view ---------- */
.bg-invite { display: flex; flex-direction: column; gap: 14px; }
.bg-count-num { font-size: 18px; }
.bg-tvs { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--rf-muted-room); font-weight: 700; }
.bg-summary { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; font-weight: 700; color: var(--rf-muted-room); text-align: center; }
.bg-summary .rf-icon { width: 20px; height: 20px; flex: none; }
.bg-hello { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding-top: 12px; }
.bg-check { display: flex; flex-direction: column; gap: 6px; }
.bg-check .rf-label { color: var(--rf-muted-room); }
.bg-check-row { display: flex; gap: 8px; }
.bg-check-row .rf-input { flex: 1; min-width: 0; min-height: 48px; }
.bg-check-result { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 16px; background: var(--rf-cream); color: var(--rf-ink); font-weight: 800; }
.bg-check-result p { margin: 0; }
.bg-mini { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; font-size: 11px; }
.bg-mini li { padding: 4px 2px; border-radius: 6px; background: var(--rf-white); text-align: center; overflow-wrap: anywhere; }
.bg-mini li.is-hit { background: var(--rf-green); }
.bg-mini li.is-line { outline: 2px solid var(--rf-ink); }
.bg-presenter { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.bg-presenter > .rf-hostbar { margin: 10px 16px 0; font-size: 16px; }
.bg-presenter > .rf-tv-stage { min-height: 0; flex: 1; }

/* ---------- The final screen on a phone ---------- */
.bg-final .rf-winner { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 16px 32px; text-align: center; }
.bg-final .rf-winner .rf-pill { align-self: center; }
.bg-wait-host { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 56px; border: 2px dashed var(--rf-line-cream); border-radius: 18px; }

/* ---------- Results ---------- */
.bg-called { margin: 0; padding-left: 1.6em; display: grid; gap: 4px; font-weight: 700; }

/* ---------- The TV (js/bingo-stage.js): read-only, 10-foot ---------- */
.bg-tv .rf-codepill { font-size: var(--rf-fs-label); }
.bg-tv-join { flex: 1; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: center; gap: clamp(24px, 3vw, 96px); }
.bg-tv-code { display: flex; flex-direction: column; gap: 24px; }
.bg-tv-code .rf-code > span { font-size: var(--rf-fs-code, 120px); }
.bg-tv .rf-qr--lg { justify-self: end; }
.bg-tv-foot { min-height: 80px; }
.bg-tv-split { flex: 1; display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr); gap: clamp(24px, 2.5vw, 72px); align-items: start; }
.bg-call { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: clamp(24px, 2vw, 56px); border-radius: 36px; background: var(--rf-blue); }
.bg-call-emoji { font-size: clamp(96px, 8vw, 220px); line-height: 1; }
.bg-call-label { margin: 0; font-size: var(--rf-fs-title); font-weight: 800; line-height: 1.02; letter-spacing: -0.02em; overflow-wrap: break-word; hyphens: auto; text-wrap: balance; }
.bg-call-fact { margin: 0; font-size: var(--rf-fs-body); line-height: 1.25; color: var(--rf-muted-room); }
.bg-board { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 11vw, 300px), 1fr)); gap: 6px; }
.bg-board li { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 4px 10px; border-radius: 16px; background: rgba(255, 255, 255, 0.08); color: var(--rf-muted-room); font-size: 28px; font-weight: 700; line-height: 1.05; }
.bg-board li.is-called { background: var(--rf-green); color: var(--rf-ink); font-weight: 800; }
.bg-board-emoji { display: none; }

.bg-board-label { min-width: 0; line-height: 1.05; }
.bg-board--numbers { display: flex; flex-direction: column; gap: 8px; }
.bg-board-row { display: flex; align-items: center; gap: 10px; }
.bg-board-letter { width: 1.4em; font-size: 40px; font-weight: 800; color: var(--rf-primary); text-align: center; }
.bg-board-list { list-style: none; margin: 0; padding: 0; flex: 1; display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; }
.bg-board--numbers li { justify-content: center; min-height: 48px; padding: 4px 0; font-size: 28px; font-variant-numeric: tabular-nums; }
.bg-tv-banner { padding: 20px 32px; border-radius: 28px; text-align: center; }
.bg-banner-kicker { margin: 0; font-size: var(--rf-fs-title); font-weight: 800; color: var(--rf-primary); }
.bg-banner-names { margin: 0; font-size: var(--rf-fs-display); font-weight: 800; line-height: 1.05; }
.bg-paused .rf-icon { width: 1em; height: 1em; }
.bg-tv-winner { display: flex; flex-direction: column; align-items: center; gap: 24px; padding: 40px; border-radius: 36px; text-align: center; }
.bg-winners { margin: 0; padding: 0; list-style: none; font-size: var(--rf-fs-body); font-weight: 700; }
.bg-tv-next { display: flex; justify-content: center; }
.bg-tv-next .rf-qr--lg { justify-self: center; }

/* v2.2 (QA-B #3): the TV board fits a short screen (BingoStage.fit sets --bg-fit, 0.4 to 1) and no label runs into the next */
.bg-board--tv { --bg-fit: 1; grid-template-columns: repeat(auto-fill, minmax(calc(clamp(150px, 11vw, 300px) * var(--bg-fit)), 1fr)); gap: calc(6px * var(--bg-fit)); }
.bg-board--tv li { min-width: 0; min-height: calc(52px * var(--bg-fit)); padding: calc(4px * var(--bg-fit)) calc(10px * var(--bg-fit)); border-radius: calc(16px * var(--bg-fit));
  font-size: calc(28px * var(--bg-fit)); overflow: hidden; }
.bg-board--tv .bg-board-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; max-width: 100%; line-height: 1.12; overflow-wrap: normal; hyphens: auto; -webkit-hyphens: auto; }
.bg-board--tv .bg-board-label.is-tight { font-size: 0.85em; }
.bg-board--tv .bg-board-label.is-tighter { font-size: 0.72em; overflow-wrap: anywhere; }

/* A phone-sized TV view (the host's phone mirrored): one column, smaller type */
@media (max-width: 759px) {
  .bg-tv-join, .bg-tv-split { grid-template-columns: 1fr; }
  .bg-tv .rf-qr--lg { justify-self: center; }
  .bg-board { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .bg-board-list { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
@media (max-width: 759px) {
  .bg-presenter .rf-tv-stage { padding: 12px 16px; gap: 14px; }
  .bg-presenter .bg-board li { min-height: 40px; font-size: 16px; }
  .bg-presenter .bg-board-letter { font-size: 24px; }
  .bg-presenter .bg-board--numbers li { min-height: 32px; font-size: 16px; }
  .bg-presenter .bg-call-label { font-size: 32px; }
  .bg-presenter .bg-call-emoji { font-size: 56px; }
}

/* v2.2 (QA-B #5): a short phone (360x640) shows the whole card above the sticky BINGO! area without scrolling: tighter
   last call, letters, squares and gaps (squares stay at least 52 px tall) */
@media (max-height: 700px) and (max-width: 759px) {
  .bg-play { gap: 8px; }
  .bg-last { gap: 10px; padding: 6px 12px; border-radius: 18px; }
  .bg-last-emoji { font-size: 30px; }
  .bg-last-label { font-size: 22px; }
  .bg-letters { font-size: 20px; }
  .bg-sq { aspect-ratio: 1 / 0.9; min-height: 52px; }
  .bg-thumb { gap: 4px; padding-top: 6px; }
  .bg-bingo-btn { min-height: 60px; font-size: 30px; }
  .bg-note { min-height: 20px; font-size: 16px; }
}
