/* Tambola - uses the tokens of /assets/site.css (light and dark), plus the print sheets. */

.tb-skip { position: absolute; left: -9999px; top: 0; }
.tb-skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--paper-raised); padding: 8px 14px; border-radius: 10px; }

.tb-crumbs { margin: var(--s5) 0 0; font-weight: 700; color: var(--ink-soft); font-size: 0.94rem; }
.tb-crumbs a { display: inline-flex; align-items: center; min-height: var(--tap); }
.tb-page-title, .tb-setup h1, .tb-live h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -0.02em; line-height: 1.15; margin: var(--s2) 0 var(--s2); }
.tb-lede { color: var(--ink-soft); max-width: 62ch; margin: 0 0 var(--s5); font-size: 1.05rem; }
.hint { color: var(--ink-soft); font-size: 0.9rem; margin: 0 0 var(--s3); }
.tb-h { font-size: 1.25rem; margin: var(--s6) 0 var(--s3); letter-spacing: -0.01em; }
.tb-actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin: var(--s4) 0 0; }
.tb-empty { margin-bottom: var(--s3); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.95em; }
/* Chrome on a phone paints a 40% blue box over a tapped control: the text fell to 3.3:1.
   The pages draw their own press state instead, which keeps the tokens' contrast. */
.site .btn, .site summary, .site .card, .tb-check, .tb-radios label { -webkit-tap-highlight-color: transparent; }
.site .btn:active:not([disabled]) { filter: brightness(0.92); }
kbd {
  font: 700 0.72rem/1 ui-monospace, Consolas, monospace; padding: 3px 6px; border-radius: 6px;
  border: 1px solid currentColor; opacity: 0.8;
}

/* ---------- panels and form rows ---------- */
.tb-panel {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: var(--s5); margin: 0 0 var(--s4);
}
.tb-panel h2 { font-size: 1.15rem; margin: 0 0 var(--s3); }
.tb-check { display: flex; gap: var(--s3); align-items: flex-start; min-height: var(--tap); padding: 10px 0; font-weight: 600; cursor: pointer; }
.tb-check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--plum); }
.tb-rule { display: block; font-weight: 400; color: var(--ink-soft); font-size: 0.92rem; }
.tb-radios { border: 0; padding: 0; margin: 0 0 var(--s3); }
.tb-radios legend { font-size: 0.86rem; font-weight: 700; color: var(--ink-soft); padding: 0; margin-bottom: 4px; }
.tb-radios label { display: flex; gap: var(--s3); align-items: center; min-height: var(--tap); font-weight: 600; cursor: pointer; }
.tb-radios input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--plum); }
.tb-pattern-row { display: grid; grid-template-columns: 1fr minmax(160px, 260px); gap: var(--s2) var(--s4); align-items: center; border-bottom: 1px solid var(--line); padding: var(--s1) 0; }
.tb-pattern-row:last-child { border-bottom: 0; }
.tb-setup form { max-width: 760px; }
.tb-setup, .tb-live { padding-bottom: var(--s6); }

/* ---------- landing ---------- */
.tb-start .card h3 { font-size: 1.2rem; }
.tb-resume { margin-bottom: var(--s5); border-color: var(--amber); }
.tb-resume h2 { margin: 0; font-size: 1.25rem; }
.tb-resume p { margin: 0; }
.tb-how { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--s5); }
.tb-steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: var(--s2); }
.tb-pattern-cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.tb-pattern-cards li { background: var(--paper-raised); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.tb-pattern-cards strong { display: block; color: var(--plum); }
.tb-recent { list-style: none; margin: 0 0 var(--s3); padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.tb-recent h3 { margin: 0; }
.tb-recent-wins { margin: 0; padding-left: 1.2em; color: var(--ink-soft); }
.tb-recent details summary { cursor: pointer; font-weight: 700; color: var(--plum); min-height: var(--tap); display: flex; align-items: center; }
.tb-order { word-break: break-word; }
@media (max-width: 760px) { .tb-how { grid-template-columns: 1fr; } }

/* ---------- live caller ---------- */
.tb-live-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); }
.tb-count { margin: 0; font-weight: 800; font-size: 1.15rem; color: var(--amber-text); }
.tb-stage { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s5); align-items: start; margin-top: var(--s3); }
.tb-current {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px);
  box-shadow: var(--shadow); padding: var(--s5); text-align: center;
}
.tb-current-label { margin: 0; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 800; font-size: 0.8rem; color: var(--ink-soft); }
.tb-ball {
  --size: clamp(150px, 26vw, 260px);
  width: var(--size); height: var(--size); margin: var(--s3) auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 32% 28%, #fff 0 8%, transparent 9%), radial-gradient(circle at 50% 50%, var(--amber) 0 58%, var(--rose) 100%);
  box-shadow: inset 0 -10px 24px rgba(0, 0, 0, 0.18), var(--shadow);
}
.tb-ball span {
  display: flex; align-items: center; justify-content: center; width: 62%; height: 62%; border-radius: 50%;
  background: #fff; color: #241c2c; font-weight: 800; font-size: calc(var(--size) * 0.3); line-height: 1; font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: no-preference) {
  .tb-ball.pop { animation: tb-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
  @keyframes tb-pop { 0% { transform: scale(0.6) rotate(-25deg); opacity: 0.2; } 100% { transform: none; opacity: 1; } }
  .tb-cell { transition: background-color 0.2s ease, color 0.2s ease; }
}
.tb-call-text { font-size: 1.25rem; font-weight: 700; margin: 0 0 var(--s3); min-height: 2em; }
.tb-last { list-style: none; display: flex; justify-content: center; gap: var(--s2); padding: 0; margin: 0; flex-wrap: wrap; }
.tb-last li {
  width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--sunk); border: 1px solid var(--line); font-weight: 800; font-variant-numeric: tabular-nums;
}
.tb-last li:first-child { background: var(--plum-soft); color: var(--plum); }
.tb-controls { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.tb-controls .btn { width: 100%; }
.tb-controls .tb-next { grid-column: 1 / -1; min-height: 64px; font-size: 1.25rem; }
.tb-controls .tb-claim-btn { grid-column: 1 / -1; background: var(--amber); color: #241c2c; }
.tb-controls kbd { margin-left: 2px; }

.tb-chips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s3); }
.tb-chip { border-radius: 14px; padding: 10px 14px; border: 1px solid var(--line); background: var(--paper-raised); display: flex; flex-direction: column; gap: 2px; }
.tb-chip.won { background: var(--teal-soft); border-color: var(--teal); }
.tb-chip-state { font-size: 0.92rem; color: var(--ink-soft); }
.tb-chip.won .tb-chip-state { color: var(--teal-text); font-weight: 700; }
.tb-chip-prize { font-size: 0.85rem; font-weight: 700; color: var(--amber-text); }

.tb-board { display: flex; flex-direction: column; gap: 4px; max-width: 640px; }
.tb-board-row { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.tb-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 10px;
  background: var(--sunk); color: var(--ink-soft); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1rem;
}
.tb-cell.on { background: var(--plum); color: var(--on-plum); font-weight: 800; }
.tb-cell.latest { outline: 3px solid var(--amber); outline-offset: 1px; }

.tb-over, .tb-results {
  margin-top: var(--s5); padding: var(--s5); border-radius: var(--radius);
  background: var(--amber-soft); border: 1px solid var(--amber);
}
.tb-over h2, .tb-results h2 { margin: 0 0 var(--s2); }
.tb-over p { margin: 0; }
.tb-result-list { margin: 0; padding-left: 1.2em; }
.tb-log { margin-top: var(--s5); }
.tb-log summary { cursor: pointer; font-weight: 700; min-height: var(--tap); display: flex; align-items: center; }
.tb-log ul { margin: 0; padding-left: 1.2em; }
.tb-ok { color: var(--teal-text); font-weight: 800; }
.tb-bad { color: var(--rose-text); font-weight: 800; }
.tb-end-row { margin-top: var(--s5); }

@media (max-width: 860px) {
  .tb-stage { grid-template-columns: 1fr; }
}

/* ---------- TV mode: the number and the board fill the screen ---------- */
.tb-tv .topbar, .tb-tv .tb-crumbs, .tb-tv .site-foot, .tb-tv .tb-log, .tb-tv .tb-end-row, .tb-tv #board-hint { display: none; }
.tb-tv.has-tabs { padding-bottom: 0; }
.tb-tv .wrap { max-width: none; }
.tb-tv .tb-live { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: var(--s3) var(--s6); align-items: start; padding-top: var(--s4); }
.tb-tv .tb-live > * { grid-column: 1; }
.tb-tv .tb-live > .tb-live-head { grid-column: 1 / -1; }
.tb-tv #board-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tb-tv .tb-board { grid-column: 2; grid-row: 2 / span 12; max-width: none; margin-top: var(--s3); }
.tb-tv .tb-stage { grid-template-columns: 1fr; gap: var(--s3); }
.tb-tv .tb-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tb-tv .tb-controls .tb-claim-btn { grid-column: auto; }
.tb-tv .tb-ball { --size: min(36vh, 26vw); }
.tb-tv .tb-call-text { font-size: 1.6rem; }
.tb-tv .tb-cell { font-size: clamp(1rem, 2.2vw, 2rem); }
.tb-tv .tb-count { font-size: 1.6rem; }
@media (max-width: 860px) {
  .tb-tv .tb-live { grid-template-columns: 1fr; }
  .tb-tv #board-title, .tb-tv .tb-board { grid-column: 1; grid-row: auto; }
}

/* ---------- dialogs ---------- */
.tb-dialog {
  border: 0; padding: 0; background: transparent; color: var(--ink);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
}
.tb-dialog::backdrop { background: rgba(23, 19, 28, 0.55); }
.tb-dialog-shell {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: calc(100dvh - 32px);
}
.tb-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5) 0; }
.tb-dialog-head h2 { margin: 0; font-size: 1.3rem; }
.tb-dialog-body { padding: var(--s4) var(--s5) var(--s5); overflow: auto; }
.tb-confirm .tb-dialog-body h2 { margin: 0 0 var(--s2); font-size: 1.25rem; }
.tb-confirm p { margin: 0; }
.icon-close { font-size: 1.5rem; line-height: 1; min-width: var(--tap); padding: 0; }
@media (prefers-reduced-motion: no-preference) {
  .tb-dialog[open] { animation: tb-rise 0.18s ease-out; }
  @keyframes tb-rise { from { transform: translateY(12px); opacity: 0; } }
}

.tb-verdict { margin-top: var(--s4); padding: var(--s4); border-radius: var(--radius); border: 2px solid var(--line); }
.tb-verdict.ok { border-color: var(--teal); background: var(--teal-soft); }
.tb-verdict.bad { border-color: var(--rose); background: var(--rose-soft); }
.tb-verdict-word { margin: 0; font-size: 2rem; font-weight: 800; line-height: 1.1; }
.tb-verdict.ok .tb-verdict-word { color: var(--teal-text); }
.tb-verdict.bad .tb-verdict-word { color: var(--rose-text); }
.tb-verdict p { margin: var(--s2) 0; }
.tb-verdict-id { font-weight: 700; }
.tb-verdict .tk-grid { width: 100%; border-collapse: separate; border-spacing: 3px; table-layout: fixed; }
.tb-verdict .tk-grid td {
  height: 40px; text-align: center; border-radius: 8px; background: var(--paper-raised); border: 1px solid var(--line);
  font-weight: 800; font-variant-numeric: tabular-nums; padding: 0;
}
.tb-verdict .tk-grid td.tk-empty { background: transparent; border-color: transparent; }
.tb-verdict .tk-grid td.tk-called { background: var(--plum); color: var(--on-plum); border-color: var(--plum); }
.tb-verdict .tk-grid td.tk-missing { background: var(--paper-raised); color: var(--rose-text); border: 2px dashed var(--rose); }
/* numbers outside the claimed line: quieter colours that still pass 4.5:1 */
.tb-verdict .tk-grid td.tk-other { background: var(--sunk); color: var(--ink-soft); border-color: var(--line); }
.tb-verdict .tk-grid td.tk-other.tk-called { background: var(--plum-soft); color: var(--plum); border-color: var(--plum-soft); }
.tb-verdict .tk-grid td.tk-deciding { outline: 3px solid var(--amber); outline-offset: 1px; }

/* ---------- phones ---------- */
@media (max-width: 640px), (max-height: 500px) {
  .tb-lede, .tb-rule { font-size: 1rem; }
  .tb-panel { padding: var(--s4); }
  .tb-pattern-row { grid-template-columns: 1fr; padding: var(--s2) 0; }
  .tb-current { padding: var(--s4) var(--s3); }
  .tb-call-text { font-size: 1.1rem; }
  .tb-cell { font-size: 0.9rem; border-radius: 8px; }
  .tb-board, .tb-board-row { gap: 3px; }
  .tb-chips { grid-template-columns: 1fr; }
  .tb-chip-prize, .tb-chip-state { font-size: 1rem; }
  .tb-actions .btn { flex: 1 1 100%; }
  .tb-controls kbd { display: none; }
  .tb-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; }
  .tb-dialog-shell { height: 100dvh; max-height: none; border-radius: 0; border: 0; }
  .tb-dialog-head { padding: max(12px, env(safe-area-inset-top)) 16px 0; }
  .tb-dialog-body { padding: 12px 16px calc(24px + env(safe-area-inset-bottom)); }
  .tb-confirm { height: auto; margin: auto 0 0; }
  .tb-confirm .tb-dialog-shell { height: auto; border-radius: var(--radius) var(--radius) 0 0; }
  .tb-verdict .tk-grid td { height: 36px; font-size: 0.95rem; }
}

/* ---------- print page: the form ---------- */
.tb-print-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.tb-print-form .tb-panel { margin: 0; }
.tb-print-actions { grid-column: 1 / -1; margin: 0; }
.tb-print-actions .hint { margin: 0; flex-basis: 100%; }
.tb-book-row { display: flex; gap: var(--s2); align-items: flex-end; }
.tb-book-row .field { flex: 1; }
.tb-book-row .btn { margin-bottom: 12px; flex: none; }
.tb-book-row input { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
@media (max-width: 900px) { .tb-print-form { grid-template-columns: 1fr; } }

/* ---------- print page: the sheets (always white paper) ---------- */
.tb-preview { --fit: 1; display: flex; flex-direction: column; align-items: center; gap: var(--s4); overflow: hidden; padding-bottom: var(--s4); }
.tb-preview .sheet { zoom: var(--fit); box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18); }

.sheet {
  --ink-p: #1d1622; --accent: #6d3f9e; --accent-soft: #f0e8fb; --cut: #8a8090;
  width: 210mm; height: 297mm; padding: 10mm; background: #fff; color: var(--ink-p);
  display: flex; flex-direction: column; font-family: var(--font); overflow: hidden; flex: none;
}
.sheet.paper-letter { width: 215.9mm; height: 279.4mm; }
.sheet.style-bw { --accent: #000; --accent-soft: #fff; --cut: #555; }
.sheet-head { height: 9mm; display: flex; align-items: center; gap: 2mm; font-weight: 800; font-size: 4mm; color: var(--accent); border-bottom: 0.4mm solid var(--accent); }
.sheet-foot { height: 7mm; display: flex; align-items: flex-end; justify-content: space-between; gap: 3mm; font-size: 3mm; color: #4a4250; }
.sheet-tickets { flex: 1; display: grid; grid-template-columns: 1fr; grid-template-rows: repeat(6, minmax(0, 1fr)); min-height: 0; border: 0.3mm dashed var(--cut); margin-top: 2mm; }
.sheet.per-12 .sheet-tickets { grid-template-columns: 1fr 1fr; }
.tk { position: relative; display: flex; flex-direction: column; padding: 2.5mm; min-height: 0; border-top: 0.3mm dashed var(--cut); border-left: 0.3mm dashed var(--cut); }
.sheet.per-6 .tk:first-child, .sheet.per-12 .tk:nth-child(-n + 2) { border-top: 0; }
.sheet.per-6 .tk, .sheet.per-12 .tk:nth-child(odd) { border-left: 0; }
/* a scissor at the start of each cut line */
.tk::before { content: "\2702"; position: absolute; top: -2.3mm; left: 1mm; font-size: 3.4mm; line-height: 1; color: var(--cut); background: #fff; padding: 0 0.5mm; }
.sheet.per-6 .tk:first-child::before, .sheet.per-12 .tk:nth-child(-n + 2)::before { content: none; }
.tk-top { height: 6mm; display: flex; align-items: center; justify-content: space-between; gap: 2mm; flex: none; }
.tk-title { font-weight: 800; font-size: 3.4mm; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-id { font: 800 4.6mm/1 ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace; letter-spacing: 0.3mm; white-space: nowrap; }
.tk-body { flex: 1; display: flex; gap: 2.5mm; align-items: stretch; min-height: 0; margin-top: 1mm; }
.sheet .tk-grid { flex: 1; height: 100%; border-collapse: collapse; table-layout: fixed; }
.sheet .tk-grid td {
  border: 0.35mm solid var(--ink-p); text-align: center; vertical-align: middle; padding: 0;
  font-weight: 800; font-size: 5.6mm; font-variant-numeric: tabular-nums; color: var(--ink-p);
}
.sheet .tk-grid td.tk-empty { background: var(--accent-soft); }
.sheet .qr { width: 30mm; height: 30mm; flex: none; align-self: center; }
.sheet.per-12 .tk-grid td { font-size: 4.4mm; }
.sheet.per-12 .qr { width: 19mm; height: 19mm; }
.sheet.per-12 .tk-id { font-size: 3.8mm; }
.sheet.per-12 .tk-title { font-size: 3mm; }

.sheet-summary-body { flex: 1; padding: 8mm 4mm; font-size: 4.2mm; line-height: 1.5; }
.sheet-summary-body h2 { font-size: 8mm; margin: 0 0 4mm; color: var(--accent); }
.sum-book { font-size: 6mm; margin: 0 0 4mm; }
.sum-book b { font: 800 9mm/1 ui-monospace, Consolas, monospace; letter-spacing: 1mm; border: 0.5mm solid var(--ink-p); padding: 1mm 3mm; border-radius: 2mm; }
.sheet-summary-body dl { display: grid; grid-template-columns: 35mm 1fr; gap: 1.5mm 4mm; margin: 0 0 5mm; }
.sheet-summary-body dt { font-weight: 800; }
.sheet-summary-body dd { margin: 0; }
.sheet-summary-body ol { padding-left: 6mm; margin: 0 0 5mm; }
.sum-note { font-weight: 700; }

@media print {
  body.tb-print { background: #fff; padding: 0 !important; }
  .tb-print .topbar, .tb-print .site-foot, .tb-print main > :not(#preview), .tb-print .navlinks { display: none !important; }
  .tb-print main.wrap { max-width: none; padding: 0 !important; margin: 0; }
  .tb-preview { display: block; padding: 0; overflow: visible; gap: 0; }
  .tb-preview .sheet { zoom: 1; box-shadow: none; margin: 0; break-after: page; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .tb-preview .sheet:last-child { break-after: auto; }
}
