:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #7c3aed;
  --accent-ink: #ffffff;
  --pop: #0f172a;
  --free: #7c3aed;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 17px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 18px; }

/* header / footer / crumbs */
.site-head { border-bottom: 1px solid var(--line); background: var(--card); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { font-weight: 800; font-size: 19px; color: var(--pop); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.nav a { color: var(--muted); font-size: 15px; margin-left: 18px; }
.crumbs { font-size: 13px; color: var(--muted); margin: 18px 0 4px; }
.crumbs a { color: var(--muted); }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.02em; margin: 10px 0 14px; }
.lead { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 20px; margin: 30px 0 12px; letter-spacing: -.01em; }
.site-foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 22px 0 50px; color: var(--muted); font-size: 14px; background: var(--card); }
.site-foot a { color: var(--muted); }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; }

/* controls */
.controls { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 8px 0 18px; }
.controls label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 14px; }
.row + .row { margin-top: 14px; }
.row > div { flex: 1; min-width: 150px; }
.wordcell { flex: 1 1 100%; }
input, select, textarea { width: 100%; padding: 10px 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); font-family: inherit; }
textarea { resize: vertical; line-height: 1.4; }
.ctl-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.print-btn, .shuffle-btn { font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; border-radius: 10px; padding: 11px 20px; border: 0; }
.print-btn { background: var(--accent); color: var(--accent-ink); }
.print-btn:hover { filter: brightness(1.1); }
.shuffle-btn { background: #ffffff; color: var(--accent); border: 1px solid var(--accent); }
.shuffle-btn:hover { background: #f5f0ff; }
.hint { color: var(--muted); font-size: 13px; flex: 1; min-width: 200px; }

/* the bingo cards */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; margin: 0 0 22px; }
.cards:has(> .bingo-card:only-child) { grid-template-columns: 1fr; max-width: 560px; margin-left: auto; margin-right: auto; }
.bingo-card { background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 18px; break-inside: avoid; page-break-inside: avoid; }
.card-title { font-size: 22px; font-weight: 800; text-align: center; letter-spacing: .02em; margin: 0 0 12px; outline: none; color: var(--pop); }

table.bcard { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.bcard th {
  font-size: 26px; font-weight: 800; text-align: center; color: var(--accent-ink);
  background: var(--accent); border: 2px solid var(--accent);
  padding: 6px 0; letter-spacing: .02em;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
table.bcard td {
  border: 2px solid #334155; text-align: center; vertical-align: middle;
  height: 62px; padding: 3px; font-size: 18px; font-weight: 600; color: #1f2733;
  word-break: break-word; line-height: 1.15; overflow: hidden;
}
table.bcard td.free {
  color: var(--free); font-weight: 800; font-size: 15px; letter-spacing: .04em;
  text-transform: uppercase; background: #f5f0ff;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
table.bcard td[contenteditable] { cursor: text; }
table.bcard td[contenteditable]:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* link grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-bottom: 10px; }
.grid a { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; color: var(--ink); font-size: 15px; }
.grid a:hover { border-color: var(--accent); text-decoration: none; }
.chip-emoji { margin-right: 6px; }

/* prose + ads */
.prose { margin: 22px 0; }
.prose p { margin: 0 0 14px; }
.ad-slot {
  margin: 22px 0;
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, #eef2f6, #eef2f6 10px, #f4f7fa 10px, #f4f7fa 20px);
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  color: #94a3b8; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
}

@media (max-width: 620px) {
  h1 { font-size: 23px; }
  .cards { grid-template-columns: 1fr; max-width: 480px; margin-left: auto; margin-right: auto; }
  .bingo-card { padding: 12px; }
  table.bcard th { font-size: 20px; }
  table.bcard td { height: 52px; font-size: 15px; }
}

/* print: the cards are the page, everything else disappears */
@media print {
  body { background: #fff; font-size: 12pt; }
  .no-print, .ad-slot { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 0.3in; }
  .cards:has(> .bingo-card:only-child) { grid-template-columns: 1fr; max-width: none; }
  .bingo-card { border: none; box-shadow: none; border-radius: 0; padding: 0.15in; }
  .card-title { font-size: 18pt; }
  table.bcard td { height: 0.95in; font-size: 15pt; }
  table.bcard th { background: var(--accent) !important; color: #fff !important; }
  table.bcard td.free { background: #f5f0ff !important; }
}
