:root {
  --ink: #1f2430;
  --muted: #5d6475;
  --line: #e3e5ec;
  --bg: #fffdf8;
  --panel: #ffffff;
  --brand: #e11d48;
  --brand-dark: #be123c;
  --radius: 12px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.55; }
a { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.5rem); letter-spacing: -.02em; }
h2 { font-size: 1.35rem; margin-top: 2rem; }
p { margin: 0 0 1em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.site-head { border-bottom: 1px solid var(--line); background: var(--panel); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
.logo { font-weight: 800; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.logo b { color: var(--brand); }
.site-head nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: .95rem; }
.site-head nav a { text-decoration: none; color: var(--muted); }
.site-head nav a:hover { color: var(--ink); }
.hero { padding: 28px 0 8px; }
.hero p { color: var(--muted); max-width: 62ch; font-size: 1.08rem; }
.crumbs { font-size: .9rem; color: var(--muted); margin: 16px 0 0; }
.crumbs a { color: var(--muted); }

.gen { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0 8px; }
@media (max-width: 800px) { .gen { grid-template-columns: 1fr; padding: 14px; } }
.gen-form label { display: block; font-weight: 600; font-size: .92rem; margin: 12px 0 4px; }
.gen-form label:first-child { margin-top: 0; }
.gen-form input[type=text], .gen-form input[type=number], .gen-form select, .gen-form textarea {
  width: 100%; font: inherit; padding: 9px 10px; border: 1px solid #c9cdd8; border-radius: 8px; background: #fff; color: var(--ink);
}
.gen-form textarea { min-height: 170px; resize: vertical; }
.row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; }
.check input { width: 18px; height: 18px; }
.label-line { display: flex; justify-content: space-between; align-items: baseline; }
.label-line small, .hint { color: var(--muted); font-weight: 400; font-size: .85rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-dark); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; outline: 1px solid #c9cdd8; cursor: pointer; padding: 0; }
.swatch[aria-pressed=true] { outline: 3px solid var(--ink); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.btn { display: inline-block; font: inherit; font-weight: 700; padding: 11px 18px; border-radius: 10px; border: 1px solid #c9cdd8; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.msg { background: #fff4e5; border: 1px solid #f5c98a; border-radius: 8px; padding: 10px 12px; margin-top: 12px; font-size: .95rem; }
.preview-col { min-width: 0; }
.preview-col .hint { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
#preview { max-width: 460px; margin: 0 auto; }

/* ---- The bingo card (shared by preview and print) ---- */
.card { container-type: inline-size; border: 2px solid var(--accent); border-radius: 10px; padding: 3%; background: #fff; color: #111; break-inside: avoid; }
.card-title { text-align: center; font-weight: 800; font-size: 7cqw; line-height: 1.15; color: var(--accent); padding: 1cqw 0 3cqw; overflow-wrap: anywhere; }
.bingo-head { display: grid; grid-template-columns: repeat(5, 1fr); text-align: center; font-weight: 900; font-size: 9cqw; color: var(--accent); line-height: 1.2; }
.grid { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); border-top: 1.5px solid #222; border-left: 1.5px solid #222; }
.cell { aspect-ratio: 1; border-right: 1.5px solid #222; border-bottom: 1.5px solid #222; display: flex; align-items: center; justify-content: center; text-align: center; padding: 4%; overflow: hidden; font-weight: 600; line-height: 1.12; }
.cell span { overflow-wrap: anywhere; }
.cell.free { background: var(--accent); color: #fff; font-weight: 900; font-size: calc(22cqw / var(--n)); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.card-foot { text-align: center; font-size: 2.6cqw; color: #666; padding-top: 2cqw; }

/* ---- Content ---- */
.cols { columns: 3 180px; padding-left: 1.2em; }
.cols li { break-inside: avoid; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 0; list-style: none; margin: 0 0 8px; }
.theme-grid a { display: block; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 600; }
.theme-grid a:hover { border-color: var(--brand); }
.steps { padding-left: 1.2em; }
.pass-box { background: #fff1f3; border: 1px solid #fecdd3; border-radius: var(--radius); padding: 18px 20px; margin: 28px 0; }
.pass-box h2 { margin-top: 0; }
details { border-bottom: 1px solid var(--line); padding: 12px 0; }
summary { font-weight: 700; cursor: pointer; }
details p { margin: 8px 0 0; color: var(--muted); }
.site-foot { border-top: 1px solid var(--line); margin-top: 48px; padding: 24px 0 40px; color: var(--muted); font-size: .9rem; }
.site-foot a { color: var(--muted); margin-right: 14px; }
.prose { max-width: 70ch; padding-top: 24px; }

dialog { border: 0; border-radius: 14px; padding: 24px; max-width: min(480px, calc(100vw - 32px)); width: 100%; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); color: var(--ink); }
dialog::backdrop { background: rgba(20, 22, 30, .55); }
dialog h2 { margin-top: 0; }
dialog ul { padding-left: 1.2em; }
.dlg-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
#caller-current { font-size: clamp(1.8rem, 7vw, 3rem); font-weight: 800; text-align: center; padding: 22px 8px; background: #fff1f3; border-radius: 12px; overflow-wrap: anywhere; }
#caller-history { max-height: 150px; overflow: auto; columns: 2; padding-left: 1.2em; color: var(--muted); font-size: .95rem; }

/* ---- Print ---- */
#print-area { display: none; }
@page { margin: 10mm; }
@media print {
  body { background: #fff; }
  #site, dialog { display: none !important; }
  #print-area { display: block; }
  .sheet { break-after: page; display: grid; justify-content: center; align-content: start; gap: 8mm; }
  .sheet:last-child { break-after: auto; }
  .sheet.per-1 .card { width: 180mm; }
  .sheet.per-2 .card { width: 104mm; }
  .sheet.per-4 { grid-template-columns: repeat(2, 90mm); gap: 6mm 8mm; }
  .sheet.per-4 .card { width: 90mm; }
  .sheet.calls { display: block; font-size: 12pt; }
  .sheet.calls ul { columns: 3; list-style: "☐  "; padding-left: 1.4em; }
  .sheet.calls li { break-inside: avoid; padding: 1.2mm 0; }
}
