/* Whirl Bingo: a fairground at night for the editor, cream cards that print cleanly, and a caller
   stage with a glass ball machine. Shares styles.css for buttons, fields, sheets and the about block. */
.bg-page { --accent: #8B3FD9; --accent-ink: #FFFFFF; --accent-soft: #F1E6FD; --accent-text: #7A2FC7; --gold: #FFE07A; background: var(--bg); }
.bg-page #bgSound .off, .bg-page #bgSound[aria-pressed="false"] .on { display: none; }
.bg-page #bgSound[aria-pressed="false"] .off { display: block; }

/* ---------- The night ---------- */
.bg-night {
  position: relative; overflow: hidden; color: #FFF7EC; padding-bottom: 56px;
  background:
    radial-gradient(40% 30% at 15% 20%, rgba(227, 70, 125, .22), transparent 70%),
    radial-gradient(40% 30% at 85% 30%, rgba(127, 208, 240, .18), transparent 70%),
    radial-gradient(120% 80% at 50% 0%, #4A2272 0%, #24103D 55%, #14071F 100%);
}
.bg-night::before { /* fairground string lights */
  content: ""; position: absolute; left: 0; right: 0; top: 64px; height: 26px; pointer-events: none; opacity: .9;
  background: radial-gradient(circle at 12px 8px, #FFE07A 0 4px, transparent 5px) 0 0 / 48px 26px repeat-x,
    radial-gradient(circle at 36px 16px, #E3467D 0 4px, transparent 5px) 0 0 / 48px 26px repeat-x;
  animation: string-lights 1.6s steps(2) infinite;
}
@keyframes string-lights { 50% { filter: hue-rotate(60deg) brightness(1.3); } }
.bg-night > * { position: relative; z-index: 1; }
.bg-bar { display: flex; align-items: center; gap: 10px; max-width: 1000px; margin: 0 auto; padding: 14px 16px; }
.bg-brand { display: inline-flex; align-items: center; gap: 9px; color: #FFF7EC; text-decoration: none; font: 800 21px var(--f-display); letter-spacing: -.02em; white-space: nowrap; }
.bg-brand svg { width: 28px; height: 28px; }
.bg-by { color: #C7B3E0; font-size: 13.5px; font-weight: 600; text-decoration: none; margin-right: auto; white-space: nowrap; }
.bg-by:hover { color: var(--gold); }
.bg-night .pill { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .16); color: #FFF7EC; }
.bg-main { max-width: 900px; margin: 0 auto; padding: 22px 16px 0; display: grid; gap: 26px; }
.bg-hero { text-align: center; }
.bg-hero h1 { margin: 0 auto; max-width: 16em; font: 800 clamp(30px, 6vw, 56px)/1.04 var(--f-display); letter-spacing: -.035em; text-wrap: balance; text-shadow: 0 6px 30px rgba(0, 0, 0, .35); }
.bg-hero p { margin: 12px auto 0; max-width: 34em; color: #D9CCEA; font-size: clamp(15.5px, 2.2vw, 18px); text-wrap: balance; }
#bgApp { display: grid; gap: 24px; }
.bg-switch { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: #C7B3E0; }
.bg-picker { max-width: 60%; padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .08); color: #FFF7EC; font-weight: 600; }
.bg-picker option { color: var(--ink); }

/* BINGO in bouncing balls, over the title */
.bg-sign { display: grid; justify-items: center; gap: 10px; }
.bg-sign-balls { display: flex; gap: clamp(6px, 1.4vw, 12px); }
.bg-sign-balls span {
  display: grid; place-items: center; width: clamp(48px, 9vw, 72px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFFFFF 0 14%, var(--ball) 15% 100%); color: #1B2033;
  font: 800 clamp(24px, 4.6vw, 36px) var(--f-display); box-shadow: inset -6px -8px 0 rgba(0, 0, 0, .15), 0 10px 18px rgba(0, 0, 0, .35);
  animation: ball-drop .8s var(--spring) backwards, ball-bob 2.6s ease-in-out infinite;
  animation-delay: calc(var(--i) * 90ms), calc(var(--i) * 180ms + .8s);
}
@keyframes ball-drop { from { translate: 0 -140px; opacity: 0; } }
@keyframes ball-bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
.bg-title-input {
  width: min(100%, 560px); border: 0; border-bottom: 2px dashed rgba(255, 247, 236, .3); background: transparent; text-align: center; padding: 4px 0 6px;
  font: 800 clamp(26px, 5vw, 40px)/1.15 var(--f-display); letter-spacing: -.02em; color: #FFF7EC;
}
.bg-title-input::placeholder { color: rgba(255, 247, 236, .45); }
.bg-title-input:focus { outline: none; border-bottom-color: var(--gold); }

/* Words or numbers: two big pick buttons */
.bg-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: min(100%, 560px); justify-self: center; }
.bg-mode { display: grid; gap: 2px; padding: 14px 16px; border-radius: 18px; border: 2px solid rgba(255, 255, 255, .15); background: rgba(255, 255, 255, .05); color: #FFF7EC; cursor: pointer; text-align: center; transition: background .15s, border-color .15s, transform .14s var(--ease-out); }
.bg-mode strong { font: 800 20px var(--f-display); }
.bg-mode span { color: #C7B3E0; font-size: 13px; font-weight: 600; }
.bg-mode[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1B2033; }
.bg-mode[aria-pressed="true"] span { color: #5A4A20; }
.bg-mode:active { transform: scale(.97); }

/* The cloud of words */
.bg-words { display: grid; gap: 12px; justify-items: center; }
.bg-words-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 4px 12px; }
.bg-words-head h2 { margin: 0; font: 800 22px var(--f-display); }
.bg-words-count { color: var(--gold); font-weight: 700; font-size: 14px; }
.bg-words-count.short { color: #FF8AB3; }
.bg-cloud { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; }
.bg-word { display: inline-flex; align-items: center; gap: 4px; padding: 6px 6px 6px 14px; border-radius: 999px; background: var(--ball); color: #1B2033; font-weight: 700; font-size: 14.5px; box-shadow: 0 4px 10px rgba(0, 0, 0, .25); animation: pop-in .35s var(--spring) backwards; }
.bg-word { padding-left: 4px; }
.bg-word button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(27, 32, 51, .14); color: inherit; font-size: 11px; cursor: pointer; }
.bg-word .bg-word-name { width: auto; height: auto; padding: 0 4px 0 10px; border-radius: 999px; background: none; font: inherit; }
.bg-word.has-clue .bg-word-name::after { content: "?"; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 5px; border-radius: 50%; background: #1B2033; color: #FFF7EC; font-size: 10px; font-weight: 800; vertical-align: 1px; }
.bg-clues { display: grid; justify-items: center; gap: 8px; max-width: 36em; text-align: center; }
.bg-clues p { margin: 0; color: #D9CCEA; font-size: 14px; }
.bg-add { display: inline-flex; border-radius: 999px; background: #FFF7EC; box-shadow: 0 4px 10px rgba(0, 0, 0, .25); }
.bg-add-input { width: 130px; padding: 6px 4px 6px 14px; border: 0; background: transparent; color: var(--ink); font: 700 14.5px var(--f-body); }
.bg-add-input:focus { outline: none; }
.bg-add-btn { width: 34px; border: 0; border-radius: 0 999px 999px 0; background: var(--gold); color: #1B2033; font: 800 18px var(--f-display); cursor: pointer; }
.bg-list-btn { border: 0; background: none; padding: 4px; color: var(--gold); font-weight: 700; font-size: 14.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* Options */
.bg-options { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 16px; }
.bg-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.bg-chip { padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .06); color: #EDE4F7; font-weight: 700; font-size: 14px; cursor: pointer; }
.bg-chip[aria-pressed="true"] { background: #FFF7EC; border-color: #FFF7EC; color: #1B2033; }
.bg-chip:disabled { cursor: default; }
.bg-stepper { display: inline-flex; align-items: center; gap: 8px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .08); font-weight: 700; font-size: 14px; }
.bg-stepper span { min-width: 6.5em; text-align: center; }
.bg-stepper button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #FFF7EC; font-size: 18px; cursor: pointer; }
.bg-stepper button:disabled { opacity: .35; }
.bg-problem { margin: 0; justify-self: center; padding: 12px 18px; border-radius: 14px; background: rgba(255, 138, 179, .15); color: #FFD1E2; font-weight: 600; text-align: center; }

/* A card (on screen and on paper) */
.bg-preview { display: grid; justify-items: center; gap: 10px; }
.bg-card { width: min(100%, 420px); padding: 16px 16px 18px; border-radius: 20px; background: #FFFCF6; color: var(--ink); box-shadow: 0 24px 60px rgba(0, 0, 0, .45); rotate: -1deg; animation: pop-in .5s var(--spring) backwards; }
.bg-card.reshuffled .bg-card-cell { animation: cell-flip .45s var(--ease-out) backwards; }
.bg-card.reshuffled .bg-card-cell:nth-child(3n) { animation-delay: .06s; } .bg-card.reshuffled .bg-card-cell:nth-child(3n+1) { animation-delay: .12s; }
@keyframes cell-flip { from { transform: rotateY(90deg); } }
.bg-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.bg-card-title { font: 800 20px var(--f-display); letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bg-card-num { flex: none; font-size: 13px; font-weight: 800; color: var(--accent-text); letter-spacing: .04em; text-transform: uppercase; }
.bg-card-letters { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 5px; }
.bg-card-letters span { display: grid; place-items: center; height: 34px; border-radius: 10px; background: var(--ball); font: 800 22px var(--f-display); color: #1B2033; }
.bg-card-grid { display: grid; grid-template-columns: repeat(var(--size), 1fr); gap: 5px; }
.bg-card-cell {
  display: grid; place-items: center; aspect-ratio: 1; padding: 4px; border-radius: 10px; background: #F5EEE4; text-align: center;
  font: 700 clamp(12px, 2.6vw, 16px)/1.15 var(--f-body); overflow-wrap: anywhere;
}
.bg-card-cell.long { font-size: clamp(10px, 2.1vw, 13px); }
.bg-card-cell.free { background: #FFE07A; gap: 0; }
.bg-card-cell.free span { font-size: 22px; line-height: 1; }
.bg-card-cell.free small { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }

/* Actions */
.bg-actions { display: grid; justify-items: center; gap: 12px; text-align: center; }
.bg-call-btn {
  height: 66px; padding: 0 44px; border: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(180deg, #F0679A, #E3467D 55%, #C93A6C); color: #FFFFFF; font: 800 24px var(--f-display);
  box-shadow: 0 14px 34px rgba(227, 70, 125, .45); transition: transform .15s var(--ease-out);
}
.bg-call-btn.ready { animation: call-glow 2.4s ease-in-out infinite; }
.bg-call-btn:hover { transform: translateY(-2px) scale(1.03); }
.bg-call-btn:disabled { opacity: .45; cursor: default; animation: none; }
@keyframes call-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 224, 122, .5), 0 14px 34px rgba(227, 70, 125, .45); } 50% { box-shadow: 0 0 0 12px rgba(255, 224, 122, 0), 0 14px 34px rgba(227, 70, 125, .45); } }
.bg-actions-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px; }
.bg-print-btn { padding: 12px 24px; border-radius: 999px; border: 0; background: var(--gold); color: #1B2033; font: 800 17px var(--f-display); cursor: pointer; box-shadow: 0 8px 20px rgba(0, 0, 0, .3); }
.bg-print-btn:disabled { opacity: .45; cursor: default; }
.bg-keys { margin: 0; max-width: 38em; color: #C7B3E0; font-size: 13.5px; }

/* ---------- Printing: only the cards ---------- */
.bg-print-sheet { display: none; }
@media print {
  @page { margin: 12mm; }
  body.print-bingo > :not(.bg-print-sheet) { display: none !important; }
  body.print-bingo { background: #FFFFFF; }
  /* Plain blocks, not a grid: browsers only honour page breaks reliably between blocks. */
  body.print-bingo .bg-print-sheet { display: block; }
  .bg-print-sheet .bg-card { display: block; width: 100%; max-width: 150mm; margin: 0 auto 10mm; rotate: none; box-shadow: none; border: 1.5px solid #1B2033; animation: none; break-inside: avoid; page-break-inside: avoid; }
  .bg-print-sheet.size-5 .bg-card { max-width: 100mm; } /* two cards to an A4 or Letter page */
  .bg-print-sheet.size-5 .bg-card:nth-child(2n) { break-after: page; page-break-after: always; }
  .bg-print-sheet.size-3 .bg-card, .bg-print-sheet.size-4 .bg-card { display: inline-block; width: 48%; margin: 0 1% 8mm; vertical-align: top; }
  .bg-print-sheet .bg-card-cell { background: #FFFFFF; border: 1px solid #1B2033; font-size: 14pt; }
  .bg-print-sheet .bg-card-cell.long { font-size: 11pt; }
  .bg-print-sheet .bg-card-cell.free, .bg-print-sheet .bg-card-letters span { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ---------- The caller ---------- */
body.bg-open { overflow: hidden; }
.bg-stage {
  position: fixed; inset: 0; z-index: 25; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 2vh; overflow: hidden;
  padding: 2.4vh 2.4vw calc(2vh + env(safe-area-inset-bottom, 0px)); color: #FFF7EC;
  background: radial-gradient(40% 40% at 20% 30%, rgba(227, 70, 125, .25), transparent 70%), radial-gradient(120% 90% at 50% 0%, #4A2272, #24103D 55%, #12061C);
  animation: fade .35s;
}
.bg-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }
.bg-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; position: relative; z-index: 1; }
.bg-title { margin: 0; font: 800 clamp(20px, 3.4vh, 36px) var(--f-display); }
.bg-count { color: #C7B3E0; font-weight: 700; font-size: clamp(13px, 1.8vh, 18px); font-variant-numeric: tabular-nums; }
.bg-top-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; }
.bg-top-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .07); color: #EDE4F7; font-weight: 700; font-size: 14px; cursor: pointer; }
.bg-top-btn[aria-pressed="false"] { opacity: .55; text-decoration: line-through; }
.bg-top-btn.gold { background: var(--gold); border-color: var(--gold); color: #1B2033; }
.bg-top-btn:disabled { opacity: .35; }
.bg-stage kbd { background: transparent; border-color: rgba(255, 255, 255, .3); color: inherit; font-size: .8em; }
.bg-floor { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 3vw; min-height: 0; }
.bg-left { display: grid; justify-items: center; align-content: center; gap: 2.4vh; min-height: 0; }
.bg-right { display: grid; align-content: center; min-height: 0; overflow: auto; }

/* The ball machine */
.bg-machine { position: relative; display: grid; justify-items: center; }
.bg-dome {
  position: relative; width: clamp(130px, 22vh, 220px); aspect-ratio: 1; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .35), rgba(255, 255, 255, .06) 45%, rgba(255, 255, 255, .02));
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .25), inset 0 -20px 40px rgba(0, 0, 0, .3), 0 18px 40px rgba(0, 0, 0, .4);
}
.bg-machine-balls i { position: absolute; bottom: 8%; width: 18%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFFFFF 0 12%, var(--ball) 13%); animation: dome-bounce 1.3s ease-in-out infinite alternate; }
@keyframes dome-bounce { from { translate: 0 0; } to { translate: 10px -120%; } }
.bg-machine.churning .bg-dome { animation: dome-shake .22s ease-in-out infinite; }
.bg-machine.churning .bg-machine-balls i { animation-duration: .3s; }
@keyframes dome-shake { 25% { rotate: -5deg; } 75% { rotate: 5deg; } }
.bg-chute { width: 28%; height: 14px; margin-top: -2px; border-radius: 0 0 10px 10px; background: rgba(255, 255, 255, .2); }

/* A ball */
.bg-ball {
  display: grid; place-items: center; width: 54px; aspect-ratio: 1; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 34% 28%, #FFFFFF 0 10%, var(--ball) 12% 100%); box-shadow: inset -6px -8px 0 rgba(0, 0, 0, .18), 0 8px 18px rgba(0, 0, 0, .35);
}
.bg-ball-face { display: grid; place-items: center; width: 68%; aspect-ratio: 1; border-radius: 50%; background: #FFFCF6; color: #1B2033; line-height: 1; text-align: center; padding: 4%; }
.bg-ball-face small { font: 800 .55em var(--f-display); color: var(--accent-text); }
.bg-ball-face strong { font-family: var(--f-display); font-weight: 800; white-space: nowrap; }
.bg-ball { font-size: 14px; }
.bg-ball.big { width: clamp(150px, 30vh, 300px); font-size: clamp(30px, 6vh, 62px); }
.bg-current { display: grid; justify-items: center; gap: 1vh; min-height: clamp(150px, 30vh, 300px); align-content: center; }
.bg-ready { margin: 0; color: #D9CCEA; font-weight: 600; font-size: clamp(15px, 2.2vh, 22px); text-align: center; }
.bg-clue { margin: 0; max-width: 22ch; font: 800 clamp(22px, 4.4vh, 46px)/1.15 var(--f-display); text-align: center; text-wrap: balance; animation: rise .4s var(--ease-out); }
.bg-clue.shown { font-size: clamp(16px, 2.6vh, 26px); color: #D9CCEA; }
.bg-board-hint { margin: 1.6vh 0 0; color: #C7B3E0; font-size: clamp(12px, 1.7vh, 16px); text-align: center; }
button.bg-cell { border: 0; cursor: pointer; }
button.bg-cell:hover { outline: 2px solid rgba(255, 255, 255, .45); }
.bg-recent { display: flex; gap: 8px; min-height: 54px; }
.bg-recent .bg-ball { opacity: .85; animation: pop-in .3s var(--spring); }
.bg-next { display: inline-flex; align-items: center; gap: 10px; padding: 14px 30px; border: 0; border-radius: 999px; cursor: pointer; background: var(--gold); color: #1B2033; font: 800 clamp(18px, 2.8vh, 28px) var(--f-display); box-shadow: 0 12px 26px rgba(0, 0, 0, .35); }
.bg-next.small { padding: 10px 20px; font-size: 18px; }
.bg-next kbd { border-color: rgba(27, 32, 51, .3); }
.bg-next:disabled { opacity: .4; }

/* The board of everything called */
.bg-board.numbers { display: grid; gap: .8vh; }
.bg-board-row { display: grid; grid-template-columns: 2.4em repeat(15, minmax(0, 1fr)); gap: .5vw; align-items: center; }
.bg-board-letter { font: 800 clamp(18px, 3.4vh, 36px) var(--f-display); color: var(--gold); text-align: center; }
.bg-cell { display: grid; place-items: center; min-height: clamp(26px, 5.2vh, 52px); padding: 2px 6px; border-radius: 10px; background: rgba(255, 255, 255, .06); color: rgba(255, 247, 236, .45); font: 700 clamp(12px, 2vh, 20px) var(--f-body); text-align: center; transition: background .3s, color .3s; }
.bg-cell.on { background: var(--ball); color: #1B2033; font-weight: 800; box-shadow: 0 0 16px color-mix(in srgb, var(--ball) 60%, transparent); }
.bg-cell.just { animation: chip-pop .6s var(--spring); outline: 3px solid #FFFFFF; }
.bg-board.words { display: flex; flex-wrap: wrap; gap: 8px; align-content: center; }
.bg-board.words .bg-cell { padding: 6px 14px; border-radius: 999px; }

/* Checking a card */
.bg-check-veil { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 3vh 3vw; background: rgba(12, 4, 20, .7); animation: fade .2s; }
.bg-check { display: grid; justify-items: center; gap: 14px; width: min(100%, 520px); max-height: 100%; overflow: auto; padding: 24px; border-radius: 24px; background: #FFFCF6; color: var(--ink); text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); animation: pop-in .35s var(--spring); }
.bg-check h3 { margin: 0; font: 800 26px var(--f-display); }
.bg-check-form { display: flex; align-items: end; gap: 10px; }
.bg-check-form label { display: grid; gap: 4px; font-weight: 700; font-size: 13.5px; color: var(--muted); }
.bg-check-input { width: 5em; padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px; font: 800 26px var(--f-display); text-align: center; }
.bg-check-input:focus { outline: none; border-color: var(--accent); }
.bg-check-result { display: grid; justify-items: center; gap: 12px; width: 100%; }
.bg-check-msg { margin: 0; font-weight: 700; font-size: 17px; }
.bg-check-msg.win { font: 800 28px var(--f-display); color: var(--accent-text); animation: chip-pop .6s var(--spring); }
.bg-check .bg-top-btn { background: var(--sunk); color: var(--ink); border-color: var(--line); }
.bg-mini { display: grid; grid-template-columns: repeat(var(--size), 1fr); gap: 4px; width: min(100%, 360px); }
.bg-mini-cell { display: grid; place-items: center; aspect-ratio: 1; padding: 2px; border-radius: 8px; background: #F5EEE4; font: 700 12px/1.1 var(--f-body); overflow-wrap: anywhere; color: var(--muted); }
.bg-mini-cell.on, .bg-mini-cell.free { background: #FFE07A; color: #1B2033; }
.bg-mini-cell.line { background: #E3467D; color: #FFFFFF; }

@media (max-width: 760px) {
  .bg-floor { grid-template-columns: 1fr; overflow: auto; }
  .bg-right { overflow: visible; }
  .bg-board-row { gap: 3px; }
  .bg-top-actions { margin-left: 0; }
}
@media (max-width: 480px) {
  .bg-modes { grid-template-columns: 1fr; }
  .bg-card { padding: 12px; }
}
