/* Bingo: plain CSS, no build step. Colors meet 4.5:1 contrast on their backgrounds. */
:root {
  --bg: #f7f5ff;
  --surface: #ffffff;
  --text: #1d1b2e;
  --muted: #5b5872;
  --border: #d6d2ea;
  --accent: #5b3fd6;
  --accent-text: #ffffff;
  --drawn: #fff4c2;
  --marked: #d9f7e3;
  --mark-ink: #0f7a3a;
  --danger: #b42318;
  --line: #ffb020;
  --radius: 12px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14121f;
    --surface: #1f1c2e;
    --text: #f2f0fa;
    --muted: #b5b1cc;
    --border: #3a3654;
    --accent: #9b85ff;
    --accent-text: #14121f;
    --drawn: #4a3f12;
    --marked: #12402a;
    --mark-ink: #6fe3a0;
    --danger: #ff8a80;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.4; }
a { color: var(--accent); }
h1, h2 { margin: 0 0 0.5rem; }
h2 { font-size: 1.1rem; }
.page { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.page.narrow { max-width: 640px; }
.page.wide { max-width: 1400px; }
.page.full { max-width: none; padding: 1.5rem 2rem; }
.logo { font-size: 2.5rem; letter-spacing: -0.02em; }
.logo.small { font-size: 1.4rem; }
.lede { color: var(--muted); font-size: 1.1rem; }
.muted { color: var(--muted); margin: 0.25rem 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.error { color: var(--danger); font-weight: 600; }
.badge { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: 0.8em; }

/* Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
  min-height: 44px; padding: 0.5rem 1rem; border-radius: var(--radius);
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.big { font-size: 1.15rem; padding: 0.75rem 1.5rem; }
.btn.small { min-height: 36px; padding: 0.25rem 0.75rem; font-size: 0.9rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
input, select { font: inherit; padding: 0.5rem; border-radius: 8px; border: 2px solid var(--border); background: var(--surface); color: var(--text); min-height: 44px; }
fieldset { border: 2px solid var(--border); border-radius: var(--radius); margin: 0 0 1rem; padding: 0.75rem 1rem 1rem; }
legend { font-weight: 700; padding: 0 0.3rem; }

/* Landing */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.theme-opt { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 0.75rem; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: center; }
.theme-opt input, .seg input { position: absolute; opacity: 0; }
.theme-opt:has(input:focus-visible), .seg label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.theme-opt.selected, .seg label.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.theme-opt img { width: 72px; height: 72px; object-fit: contain; image-rendering: auto; }
.theme-opt small, .seg small { display: block; color: var(--muted); font-weight: 400; }
.seg { display: flex; gap: 0.75rem; }
.seg label { flex: 1; padding: 0.75rem; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; font-weight: 700; }

/* Tiles: icon + number + name */
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem; width: 100%; height: 100%; text-align: center; }
.tile img { width: 70%; aspect-ratio: 1; object-fit: contain; }
.tile-text { display: flex; flex-direction: column; align-items: center; min-width: 0; max-width: 100%; }
.tile-num { font-weight: 800; font-size: 0.95rem; }
.tile-label { font-size: 0.72rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sm img { width: 36px; }
.tile-sm .tile-label { font-size: 0.65rem; }
.tile-xl img { width: min(40vw, 220px); }
.tile-xl .tile-num { font-size: 2.5rem; }
.tile-xl .tile-label { font-size: 1.4rem; white-space: normal; }
.free-star { font-size: 2rem; color: var(--line); }

/* Card */
.card { display: grid; gap: 6px; width: min(100%, 560px); }
.card-row { display: contents; }
.cell { position: relative; aspect-ratio: 1; border-radius: 10px; background: var(--surface); border: 2px solid var(--border); }
.cell > button { all: unset; box-sizing: border-box; display: block; width: 100%; height: 100%; padding: 4px; border-radius: 8px; cursor: pointer; position: relative; }
.cell > button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cell.undrawn > button { cursor: not-allowed; }
.cell.drawn { background: var(--drawn); border-style: dashed; border-color: var(--text); }
.cell.marked { background: var(--marked); border-color: var(--mark-ink); }
.cell.free { background: var(--marked); }
.cell.in-line { box-shadow: 0 0 0 3px var(--line); }
.stamp { position: absolute; top: 2px; right: 4px; font-weight: 900; font-size: 1.3rem; color: var(--mark-ink); }
.cell.marked .tile img { opacity: 0.75; }
/* Leave room for number + name under the icon inside square cells. */
.cell .tile img { width: auto; height: 58%; max-width: 92%; }

/* Player */
.player-head { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
.conn { font-size: 0.85rem; padding: 0.1rem 0.6rem; border-radius: 999px; border: 1px solid var(--border); }
.conn.ok::before { content: '● '; color: var(--mark-ink); }
.conn.down::before { content: '○ '; }
.banner-info { padding: 0.6rem 1rem; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--border); }
.player-main { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: 1.5rem; align-items: start; }
@media (max-width: 720px) { .player-main { grid-template-columns: 1fr; } }
.card-wrap { display: flex; flex-direction: column; gap: 0.75rem; }
.bingo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.btn.bingo { font-size: 1.6rem; padding: 0.8rem 2rem; min-height: 64px; letter-spacing: 0.05em; }
.btn.bingo.ready:not(:disabled) { background: var(--line); border-color: var(--line); color: #1d1b2e; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.note { min-height: 1.4em; margin: 0; font-weight: 600; }
.join { display: flex; flex-direction: column; gap: 0.5rem; max-width: 360px; }
.join label { font-weight: 700; }
.gone { text-align: center; padding: 2rem 1rem; }

/* Current draw */
.current { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.current-h { font-size: 1rem; color: var(--muted); }
.current-tile { display: flex; justify-content: center; min-height: 200px; }
.current-tile.placeholder { align-items: center; font-size: 4rem; color: var(--muted); }
.pop { animation: pop 0.4s ease-out; }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.current-big .tile-xl img { width: min(45vh, 420px); }
.current-big .tile-xl .tile-num { font-size: 5rem; }
.current-big .tile-xl .tile-label { font-size: 2.5rem; }

/* Drawn strip & pool */
.strip { margin-top: 1rem; }
.strip summary { cursor: pointer; font-weight: 700; padding: 0.4rem 0; }
.strip-list, .pool { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.strip-list li, .pool-item { background: var(--surface); border: 2px solid var(--border); border-radius: 8px; padding: 4px; }
.pool-item { opacity: 0.4; }
.pool-item.lit { opacity: 1; background: var(--drawn); border-color: var(--text); }
.pool-item.last { box-shadow: 0 0 0 3px var(--accent); }

/* Host */
.controls { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.status-line { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; margin-top: 0; }
.pill { text-transform: uppercase; font-size: 0.8rem; font-weight: 800; padding: 0.15rem 0.6rem; border-radius: 999px; border: 2px solid currentColor; }
.auto { margin-top: 1rem; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.auto input[type='number'] { width: 5rem; }
.auto input[type='checkbox'] { width: 1.3rem; height: 1.3rem; min-height: 0; vertical-align: middle; }
.host-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.join-panel, .roster, .activity { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.join-panel { display: flex; flex-direction: column; gap: 0.75rem; }
.links { display: flex; flex-direction: column; gap: 0.5rem; }
.copy-label { font-size: 0.85rem; font-weight: 700; }
.copy-row { display: flex; gap: 0.4rem; }
.copy-row input { flex: 1; min-width: 0; }
.roster ul, .activity ol { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.roster li, .activity li { padding: 0.35rem 0; border-bottom: 1px solid var(--border); }
.activity time { color: var(--muted); font-variant-numeric: tabular-nums; }
.qr { margin: 0; text-align: center; }
.qr-img { width: 180px; margin: 0 auto; background: #fff; padding: 6px; border-radius: 8px; }
.qr-img svg { display: block; width: 100%; height: auto; }
.qr-url { font-weight: 700; word-break: break-all; }

/* Viewer */
.viewer-main { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; align-items: center; margin-bottom: 1.5rem; }
.viewer-side { text-align: center; }
.viewer-side h1 { font-size: 2.5rem; }
.viewer .qr-img { width: min(28vw, 300px); }
.viewer .pool { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }

/* Celebration overlay */
.celebration { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgb(10 8 30 / 0.55); pointer-events: none; }
.celebration-banner { background: var(--surface); color: var(--text); border: 4px solid var(--line); border-radius: 20px; padding: 1.5rem 2.5rem; font-size: clamp(1.8rem, 6vw, 4rem); font-weight: 900; text-align: center; animation: pop 0.4s ease-out; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Print page */
.print-form { max-width: 1000px; margin: 1rem auto; padding: 0 1rem; }
.print-cards { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem; }
.print-card { background: #fff; color: #000; border: 2px solid #000; border-radius: 12px; padding: 0.75rem; break-inside: avoid; page-break-inside: avoid; text-align: center; }
.print-card h2 { font-size: 1.3rem; }
.print-card .card { margin: 0 auto; }
.print-card .cell { background: #fff; border-color: #000; }
.layout-2up .print-card .card { width: 4.4in; }
.layout-1up .print-card .card { width: 7.2in; }
.layout-1up .print-card .tile-num { font-size: 1.4rem; }
.layout-1up .print-card .tile-label { font-size: 1rem; white-space: normal; }
.print-only { display: none; }

@media print {
  @page { size: letter portrait; margin: 0.4in; }
  :root { color-scheme: light; --surface: #fff; --text: #000; --border: #000; --bg: #fff; }
  body { background: #fff; color: #000; }
  .no-print, .celebration { display: none !important; }
  .print-only { display: block; }
  .print-cards { padding: 0; gap: 0.3in; }
  .layout-2up .print-card:nth-child(2n) { break-after: page; }
  .layout-1up .print-card { break-after: page; }
  .print-card { border-radius: 0; }
  /* Player "Print my card": just the card, unmarked look */
  .player-main { display: block; }
  .player .cell { background: #fff !important; border: 2px solid #000 !important; box-shadow: none !important; }
  .player .stamp { display: none; }
  .player .card { width: 7in; margin: 0 auto; }
  .player .card-wrap { align-items: center; text-align: center; }
  .page .logo.small { display: none; }
}

/* Icon-license credits */
.card-credit { margin: 0.3rem 0 0; font-size: 0.7rem; }
.card-credit a { color: inherit; }
.site-footer { text-align: center; padding: 1.5rem 1rem 2rem; font-size: 0.85rem; color: var(--muted); }
.site-footer p { margin: 0.2rem 0; }
@media print { .site-footer { display: block !important; padding: 0.1in 0 0; font-size: 8pt; } .site-footer a { color: #000; } }
