@font-face { font-family: "Bricolage"; src: url("fonts/bricolage-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bg: #f3f4f2; --surface: #ffffff; --ink: #18181b; --muted: #50535a; --line: #d6d9d6; --soft: #eceeeb;
  --red: #b3122e; --red-ink: #ffffff; --red-soft: #fbe9ec; --good: #1d6b45; --good-soft: #e3f2ea;
  --head: "Bricolage", "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 6px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1c17; --surface: #142a23; --ink: #eef1ec; --muted: #a8b9b0; --line: #2a463c; --soft: #1a352c;
    --red: #ff8a8a; --red-ink: #2a0a0f; --red-soft: #3a1e22; --good: #86d6a8; --good-soft: #173a2b;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--body); }
a { color: var(--red); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--red); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4.6vw, 2.75rem); margin: 0 0 .4rem; max-width: 22ch; }
h2 { font-size: 1.55rem; margin: 2.4rem 0 .6rem; }
h3 { font-size: 1.15rem; margin: 1.4rem 0 .4rem; }
p, li { max-width: 70ch; }
small { font-size: .85em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 18px; }

/* Header: a thin "card back" lattice, wordmark and section links */
.lattice { height: 8px; background-color: var(--red);
  background-image: repeating-linear-gradient(45deg, transparent 0 4px, rgba(255,255,255,.35) 4px 5px), repeating-linear-gradient(-45deg, transparent 0 4px, rgba(255,255,255,.35) 4px 5px); }
.top { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; align-items: center; justify-content: space-between; padding: .8rem 0; }
.brand { font: 700 1.15rem var(--head); color: var(--ink); text-decoration: none; display: inline-flex; gap: .45rem; align-items: center; }
.brand svg { width: 26px; height: 26px; }
.top nav { display: flex; flex-wrap: wrap; gap: .2rem 1.1rem; font-size: .98rem; }
.top nav a { color: var(--ink); text-decoration: none; padding: .5rem 0; border-bottom: 2px solid transparent; }
.top nav a[aria-current="page"] { border-bottom-color: var(--red); font-weight: 600; }
.top nav a:hover { color: var(--red); }

.hero { padding: 1.2rem 0 1rem; }
.hero p { margin: 0; color: var(--muted); font-size: 1.08rem; }
.crumbs { font-size: .95rem; color: var(--muted); margin: .4rem 0 0; }
.crumbs a { color: var(--muted); }

/* Planner layout */
.planner { display: grid; gap: 1.2rem; align-items: start; }
@media (min-width: 900px) { .planner { grid-template-columns: 300px 1fr; gap: 2rem; } .controls { position: sticky; top: 1rem; } }
.controls { display: grid; gap: 1rem; }
.field { display: grid; gap: .3rem; }
.field > label, .field > .lbl { font-weight: 600; font-size: .98rem; }
select, input[type="number"], input[type="text"], textarea {
  font: inherit; font-size: 17px; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r); padding: .55rem .7rem; min-height: 46px; width: 100%;
}
textarea { min-height: 9rem; resize: vertical; line-height: 1.4; }
select:focus, input:focus, textarea:focus { border-color: var(--red); outline: none; box-shadow: 0 0 0 3px var(--red-soft); }
.stepper { display: grid; grid-template-columns: 44px minmax(2.6rem, 1fr) 44px; gap: .3rem; }
.stepper input { padding: .3rem .2rem; min-width: 0; text-align: center; font: 700 1.3rem var(--head); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.hint { font-size: .92rem; color: var(--muted); margin: 0; }
details.names summary { cursor: pointer; font-weight: 600; padding: .4rem 0; min-height: 44px; display: flex; align-items: center; }
details.names[open] summary { margin-bottom: .3rem; }

button, .btn {
  font: 600 1rem var(--body); min-height: 46px; padding: .55rem 1rem; border-radius: var(--r); cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; gap: .45rem; text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--ink); }
button.primary, .btn.primary { background: var(--red); border-color: var(--red); color: var(--red-ink); }
button.primary:hover { filter: brightness(1.08); }
button.icon { padding: 0; justify-content: center; font: 700 1.4rem var(--head); }
button.link { border: 0; background: none; color: var(--red); padding: .3rem 0; min-height: 44px; text-decoration: underline; font-weight: 500; }
button svg, .btn svg { width: 18px; height: 18px; flex: none; }

/* Result card: the one elevated element */
.result { background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 1.1rem 1.1rem 1.4rem; min-width: 0; box-shadow: 0 1px 0 var(--line), 0 10px 30px -18px rgba(0,0,0,.35); }
.result h2 { margin: 0 0 .2rem; font-size: 1.45rem; }
.summary { margin: 0 0 .7rem; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; padding: 0; list-style: none; }
.badges li { font-size: .92rem; padding: .3rem .6rem; border-radius: 4px; background: var(--soft); color: var(--ink); }
.badges li.good { background: var(--good-soft); color: var(--good); }
.badges li.good::before { content: "✓ "; font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 1.1rem; }
.printmenu { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem 0 0; border-top: 1px solid var(--line); margin-bottom: 1rem; }
.printmenu .lbl { font-weight: 600; margin-right: .2rem; }
.error { color: var(--red); font-weight: 600; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .7rem 1rem; border-radius: var(--r); font-size: .98rem; z-index: 50; max-width: calc(100% - 32px); }

/* Player lookup */
.lookup { display: grid; gap: .4rem; margin: 0 0 1.2rem; padding: .8rem; background: var(--soft); border-radius: var(--r); }
.lookup label { font-weight: 600; }
.night { margin: .4rem 0 0; padding: 0; list-style: none; display: grid; gap: .25rem; }
.night li { padding: .25rem 0; border-bottom: 1px solid var(--line); }
.night li b { display: inline-block; min-width: 5.2rem; }
.night .against { display: block; color: var(--muted); font-size: .95rem; padding-left: 5.2rem; }
.night li.out { color: var(--muted); }

/* Round blocks */
.rounds { display: grid; gap: 1rem 1.6rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.round h3 { margin: 0 0 .35rem; font-size: 1rem; color: var(--red); }
.tables { list-style: none; margin: 0; padding: 0; display: grid; gap: .2rem; }
.tables li { display: grid; grid-template-columns: 1.8rem 1fr auto; gap: .5rem; align-items: baseline; padding: .2rem 0; border-bottom: 1px solid var(--soft); }
.tno { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border: 1.5px solid var(--red); color: var(--red); border-radius: 3px; font: 700 .9rem var(--head); }
.line { overflow-wrap: anywhere; }
.vs { color: var(--muted); font-size: .9em; padding: 0 .15em; }
.seats { font-size: .82rem; color: var(--muted); }
.sit { margin: .3rem 0 0; font-size: .95rem; color: var(--muted); }

/* Static chart pages */
.scroll-x { overflow-x: auto; max-width: 100%; }
table.chart { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.chart th, table.chart td { border: 1px solid var(--line); padding: .4rem .5rem; text-align: left; vertical-align: top; }
table.chart thead th { background: var(--soft); font-weight: 600; white-space: nowrap; }
table.chart tbody th { color: var(--red); font: 700 1rem var(--head); text-align: center; width: 3.2rem; }
table.chart td.so { color: var(--muted); }
.crib .next-block { margin-top: 1rem; }
.mvchart td .pr { display: block; font-weight: 600; white-space: nowrap; }
.mvchart td .bd { display: block; font-size: .88rem; color: var(--muted); white-space: nowrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem 1.2rem; margin: 1rem 0 1.2rem; padding: 0; list-style: none; }
.facts li { border-left: 3px solid var(--red); padding: .1rem 0 .1rem .7rem; }
.facts b { display: block; font: 700 1.5rem var(--head); }
.counts { display: grid; gap: .5rem; padding: 0; list-style: none; }
.counts li { display: flex; flex-wrap: wrap; gap: .2rem .55rem; align-items: baseline; }
.counts li > span { font-weight: 600; min-width: 9.5rem; }
.counts a { padding: .35rem .2rem; min-width: 1.9rem; text-align: center; }
.counts a[aria-current="page"] { color: var(--ink); font-weight: 700; text-decoration: none; }

/* Content */
main section.text { margin-top: 2.6rem; }
.faq h3 { font-family: var(--body); font-size: 1.05rem; font-weight: 650; letter-spacing: 0; margin: 1.3rem 0 .3rem; }
.faq p { margin: 0; }
.sources { font-size: .95rem; color: var(--muted); }
.scorebox { display: grid; gap: .8rem; }

/* Bridge + cribbage forms */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: .3rem; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg label { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .3rem .75rem; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer; font-size: .98rem; }
.seg input { accent-color: var(--red); width: 18px; height: 18px; margin: 0; }
.seg label:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.check { display: flex; align-items: center; gap: .55rem; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--red); }
.note { padding: .7rem .9rem; border-left: 3px solid var(--red); background: var(--soft); margin: 0 0 1rem; }
.games { display: grid; gap: .5rem; }
.game { display: grid; grid-template-columns: 2.4rem 1fr; gap: .3rem .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.game .bno { font: 700 .95rem var(--head); color: var(--muted); }
.game .who { display: flex; flex-wrap: wrap; gap: .4rem; }
.game .who label { flex: 1 1 8rem; }
.game .lose { grid-column: 2; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.game .lose input { width: 6.5rem; }
.game .res { font-size: .92rem; color: var(--good); }
table.standings, table.scores { border-collapse: collapse; width: 100%; font-size: .95rem; }
table.standings th, table.standings td, table.scores th, table.scores td { padding: .4rem .45rem; border-bottom: 1px solid var(--line); text-align: right; }
table.standings th:nth-child(2), table.standings td:nth-child(2), table.scores th:nth-child(-n+3), table.scores td:nth-child(-n+3) { text-align: left; }
table.scores th { white-space: nowrap; }
table.scores input { width: 4.3rem; min-height: 42px; text-align: right; padding: .35rem .45rem; }
.boardnav { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .3rem 0 .6rem; }
.boardnav select { width: auto; }
.calc { display: grid; gap: .6rem; padding: .8rem; background: var(--soft); border-radius: var(--r); margin: .6rem 0; }
.calc .row { display: flex; flex-wrap: wrap; gap: .5rem; }
.calc select { width: auto; min-width: 5rem; }

/* Live view (night mode): felt green, big type */
.live { position: fixed; inset: 0; z-index: 40; background: #0c2a20; color: #f3efe2; display: flex; flex-direction: column; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
.live[hidden] { display: none; }
.live header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.live h2 { margin: 0; font-size: clamp(1.6rem, 6vw, 2.6rem); color: #fff; }
.live .of { font-size: 1rem; color: #b9cbbf; font-family: var(--body); font-weight: 400; }
.live .body { flex: 1; overflow-y: auto; padding: 1rem 0; }
.live-tables { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.live-tables li { display: grid; grid-template-columns: 2.6rem 1fr; gap: .8rem; align-items: center; font-size: clamp(1.25rem, 4.6vw, 1.9rem); line-height: 1.25; }
.live-tables .tno { width: 2.4rem; height: 2.4rem; border-color: #ff9a9a; color: #ff9a9a; font-size: 1.3rem; }
.live .vs { color: #9fb8aa; }
.live-sit { font-size: 1.2rem; color: #c9d8cf; }
.live nav { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.live button { background: #173e31; color: #fff; border-color: #2f6150; min-height: 60px; font-size: 1.15rem; justify-content: center; }
.live button.primary { background: #ff9a9a; border-color: #ff9a9a; color: #2a0a0f; }
.live button.close { min-height: 46px; font-size: 1rem; }

#print-area { display: none; }

/* Footer */
footer.site { margin-top: 3.5rem; padding: 1.6rem 0 2.4rem; border-top: 1px solid var(--line); font-size: .95rem; color: var(--muted); }
footer.site a { color: var(--muted); }
.sb-footer p { margin: .4rem 0; max-width: none; }

@media (max-width: 420px) {
  .wrap { padding: 0 14px; }
  .result { padding: .9rem .8rem 1.2rem; margin: 0 -6px; }
  .night .against { padding-left: 0; }
  .counts li > span { min-width: 100%; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ------------------------------------------------------------------ print */
@page { margin: 11mm; }
@media print {
  :root { --ink: #000; --muted: #333; --line: #888; --red: #a3102a; --soft: #eee; }
  body { background: #fff; color: #000; font: 10pt/1.35 var(--body); }
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  body:not(.printing) .lattice, body:not(.printing) .top nav, body:not(.printing) footer.site, body:not(.printing) .noprint { display: none !important; }
  .p-head { margin: 0 0 3mm; border-bottom: 1.5pt solid #000; padding-bottom: 1.5mm; }
  .p-head h2 { font-size: 15pt; margin: 0; }
  .p-head p { margin: .5mm 0 0; font-size: 9.5pt; max-width: none; }
  .p-note { font-size: 9pt; margin: 2mm 0 0; max-width: none; }
  table { border-collapse: collapse; width: 100%; }
  table.chart { font-size: 10.5pt; }
  table.chart th, table.chart td { border: .6pt solid #555; padding: 2mm 1.8mm; }
  table.chart thead th { background: #e8e8e8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.chart tbody th { color: #000; font-size: 10.5pt; width: 11mm; }
  table.chart tr { break-inside: avoid; }
  .wide table.chart { font-size: 9pt; }
  .wide table.chart th, .wide table.chart td { padding: 1.4mm 1.2mm; }
  .scroll-x { overflow: visible; }
  .vs { color: #444; }
  .sheet { break-after: page; }
  .sheet:last-child { break-after: auto; }
  .sheet-grid { display: grid; gap: 5mm; }
  .per4 .sheet-grid { grid-template-columns: 1fr 1fr; }
  .per2.scards .sheet-grid { grid-template-columns: 1fr 1fr; }
  .scard, .tcard, .gcard, .pcard, .trav { border: 1pt solid #000; border-radius: 2mm; padding: 3mm; break-inside: avoid; }
  .per4 .scard { min-height: 112mm; }
  .per2.scards .scard { min-height: 232mm; }
  .scard h3, .tcard h3, .gcard h3, .pcard h3, .trav h3 { margin: 0 0 2mm; font-size: 13pt; display: flex; align-items: center; gap: 2mm; }
  .pno { display: inline-grid; place-items: center; min-width: 8mm; height: 8mm; border: 1.2pt solid #000; border-radius: 1mm; font-size: 12pt; }
  .scard table, .tcard table, .gcard table, .pcard table, .trav table { font-size: 9pt; }
  .scard th, .scard td, .tcard th, .tcard td, .gcard th, .gcard td, .pcard th, .pcard td, .trav th, .trav td { border: .5pt solid #777; padding: 1mm 1.2mm; text-align: left; vertical-align: top; }
  .scard thead th, .tcard thead th, .gcard thead th, .pcard thead th, .trav thead th { background: #e8e8e8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; font-weight: 600; }
  .scard td.box, .tcard td.box { width: 12mm; }
  table.fixed { table-layout: fixed; }
  table.fixed td { overflow-wrap: anywhere; }
  table.fixed thead th { font-size: 8pt; white-space: nowrap; overflow: hidden; }
  .p-chart .team { display: block; white-space: nowrap; }
  .p-chart .vs { display: block; font-size: 8pt; line-height: 1.1; }
  .p-chart.compact .team, .p-chart.compact .vs { display: inline; }
  .p-chart.xwide .team, .p-chart.xwide .vs { display: block; }
  .p-chart .mvchart .vs, .p-chart.crib .vs { display: inline; font-size: inherit; }
  .crib .next-block { break-before: page; }
  .scard tr.out td { color: #555; font-style: italic; }
  .scard tbody td { height: 6mm; }
  .rows-s .scard tbody td { height: 7.2mm; }
  .rows-m .scard tbody td { height: 6.6mm; }
  .rows-xs .scard tbody td, .rows-xs .tcard tbody td { height: 10mm; }
  .per2.scards .scard tbody td { height: 9mm; }
  .per2.fullw .sheet-grid { grid-template-columns: 1fr; }
  .per2.fullw .scard { min-height: 0; }
  .per2.fullw .scard tbody td { height: auto; padding-top: 1.6mm !important; padding-bottom: 1.6mm !important; }
  .tcards.per1 .tcard tbody td { height: 9.5mm; }
  .scard tfoot th, .scard tfoot td { height: 7mm; border: .5pt solid #777; font-weight: 700; text-align: right; padding: 1mm 1.2mm; }
  .final { margin: 2mm 0 0; text-align: right; font-weight: 600; max-width: none; }
  .final .box { display: inline-block; margin-right: 3mm; width: 16mm; height: 7mm; border: .8pt solid #000; vertical-align: middle; margin-left: 1mm; }
  .final .box.wide { width: 22mm; }
  .tcards.per2 .tcard { min-height: 112mm; }
  .tcards.per1 .tcard { min-height: 230mm; }
  .tcard tbody td { height: 7mm; }
  .big { display: inline-grid; place-items: center; min-width: 13mm; height: 13mm; border: 2pt solid #000; border-radius: 1.5mm; font-size: 22pt; }
  .gcards .sheet-grid, .travs .sheet-grid, .tcards.per2 .sheet-grid, .tcards.per1 .sheet-grid { display: block; }
  .gcards .gcard, .travs .trav, .tcards .tcard { margin-bottom: 5mm; }
  .gcard table { font-size: 9.5pt; }
  .gcard td, .gcard th { padding: .8mm 1.2mm !important; }
  .gcard .big { min-width: 10mm; height: 10mm; font-size: 17pt; }
  .gcard h3 { margin-bottom: 1.5mm; }
  .gcard td.next { font-size: 9pt; }
  .pcards .sheet-grid { grid-template-columns: 1fr 1fr; }
  .trav tbody td { height: 6.5mm; }
  .trav h3 small { font-size: 9.5pt; font-weight: 400; margin-left: 2mm; }
  .p-chart { break-after: page; }
  .p-chart:last-child { break-after: auto; }
  a { color: #000; text-decoration: none; }
  .mvchart td .bd { font-size: 8.5pt; }
  .wide .mvchart td .bd { font-size: 7.5pt; }
  .wide .mvchart td { padding: 1.2mm 1mm; }
}

/* screen-only tweaks for printable fragments shown on screen */
@media screen {
  .result .p-head { display: none; }
  table.scores, table.standings { max-width: 680px; }
  .faq .sources { margin-top: 1.4rem; }
}
#rounds h4 { margin: 1.1rem 0 .2rem; font: 700 1rem var(--head); color: var(--red); }
#rounds h4 small { color: var(--muted); font-family: var(--body); font-weight: 400; }
.standings td b { font-family: var(--head); }
.top nav a.here { border-bottom-color: var(--line); }
@media screen {
  .p-chart.compact table.chart td { white-space: nowrap; }
  table.chart tbody th[scope="row"] { position: sticky; left: 0; background: var(--surface); }
  .mvchart tbody th[scope="row"] { background: var(--surface); }
}
@media (max-width: 420px) { .top nav { gap: .2rem .9rem; font-size: .95rem; } }
@media (max-width: 420px) {
  table.scores th, table.scores td { padding: .35rem .25rem; font-size: .9rem; }
}
/* cribbage standings: on a phone, Played / Skunks / Plus fold under the name */
.crib-st .sub { display: none; }
@media screen and (max-width: 560px) {
  .crib-st .w { display: none; }
  .crib-st .sub { display: block; font-size: .85rem; color: var(--muted); }
  .crib-st th, .crib-st td { padding: .4rem .3rem; }
}
/* blank results / standings sheets to fill in by hand */
@media print {
  table.fill { font-size: 10.5pt; max-width: none; }
  table.fill th, table.fill td { border: .6pt solid #555; padding: 1.2mm 2mm; text-align: left; }
  table.fill thead th { background: #e8e8e8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  table.fill tbody td { height: 8.5mm; }
  table.fill tbody td:first-child { width: 34%; }
  table.fill tr { break-inside: avoid; }
  .blank h4 { margin: 4mm 0 1.5mm; font-size: 12pt; }
}
/* phone: let 2- and 3-table charts fit without sideways scrolling */
@media screen and (max-width: 480px) {
  table.chart { font-size: .9rem; }
  table.chart th, table.chart td { padding: .35rem .3rem; }
  table.chart tbody th { width: 2.2rem; }
  table.chart thead th:last-child { white-space: normal; }
}
@media screen and (max-width: 480px) {
  .p-chart.compact table.chart td { white-space: normal; }
  table.chart .team { display: block; white-space: nowrap; }
  table.chart .vs { font-size: .8rem; }
}
@media screen and (max-width: 480px) { .crib table.chart thead th { white-space: normal; } }
@media screen and (max-width: 480px) {
  table.chart .team + .vs { display: none; }
  table.chart .team + .vs + .team::before { content: "v "; color: var(--muted); font-size: .8rem; }
}
