/* Game board template maker. Shop-drawing look: graphite ink on pale birch, walnut header, one orange "marking" accent. */
:root {
  --bg: #eceee9;
  --paper: #fbfbf8;
  --ink: #1d211e;
  --muted: #4f5650;
  --line: #c9cdc5;
  --walnut: #2c1e15;
  --walnut-ink: #f3e9de;
  --wood: #b8865b;
  --accent: #b93a0b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3d6;
  --err: #b42318;
  --focus: #1d6fb8;
  --hole: #2a2e2b;
  --home: #b93a0b;
  --base: #7d8a80;
  --sheet: #8c958e;
  --r: 6px;
  --head: "Rockwell", "Rockwell Nova", "Roboto Slab", "Zilla Slab", "DejaVu Serif", Georgia, serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171512;
    --paper: #211e1a;
    --ink: #ece6dd;
    --muted: #b5ada2;
    --line: #3d3832;
    --walnut: #0f0c0a;
    --walnut-ink: #efe4d6;
    --accent: #f08a4b;
    --accent-ink: #1a0f08;
    --accent-soft: #3a2418;
    --err: #ff8a7a;
    --focus: #79b8ff;
    --hole: #e7dfd3;
    --home: #f08a4b;
    --base: #8f9a91;
    --sheet: #7b746b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--body); }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--paper); color: var(--ink); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--walnut); color: var(--walnut-ink); }
.top-in { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--walnut-ink); text-decoration: none; font: 700 18px/1.2 var(--head); min-height: 44px; }
.games-nav { display: flex; flex-wrap: wrap; gap: 0 4px; font-size: 15px; }
.games-nav a { color: var(--walnut-ink); text-decoration: none; padding: 10px 8px; opacity: .85; }
.games-nav a:hover { opacity: 1; text-decoration: underline; }
.games-nav a[aria-current] { opacity: 1; box-shadow: inset 0 -3px 0 #e8590c; }

.crumb { font-size: 15px; color: var(--muted); padding-top: 14px; }
.crumb a { color: var(--muted); }
.intro { padding: 18px 0 14px; border-left: 4px solid var(--wood); padding-left: 14px; margin: 8px 0 18px; }
h1 { font: 700 clamp(26px, 5.2vw, 40px)/1.12 var(--head); margin: 0 0 8px; letter-spacing: -0.01em; }
.lede { margin: 0; max-width: 62ch; color: var(--muted); font-size: 17px; }
h2 { font: 700 24px/1.25 var(--head); margin: 0 0 10px; }
h3 { font: 700 19px/1.3 var(--head); margin: 18px 0 6px; }

/* the workbench: form left, result right */
.workbench { display: grid; gap: 18px; align-items: start; }
@media (min-width: 900px) {
  .workbench { grid-template-columns: minmax(300px, 360px) 1fr; grid-template-rows: auto 1fr; gap: 18px 28px; }
  .workbench .tool { grid-column: 1; grid-row: 1; }
  .workbench .prefs { grid-column: 1; grid-row: 2; align-self: start; }
  .workbench .result { grid-column: 2; grid-row: 1 / span 2; }
}
@media (max-width: 639px) { .games-nav { display: none; } }
.tool { display: grid; gap: 14px; min-width: 0; }
.fields { display: grid; gap: 14px; }
.field { margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { display: block; font-weight: 600; font-size: 15px; margin-bottom: 5px; padding: 0; }
select, .num input, .share-out input {
  font: 17px/1.3 var(--body); color: var(--ink); background: var(--paper); border: 1.5px solid var(--line);
  border-radius: var(--r); min-height: 46px; padding: 8px 10px; width: 100%;
}
select { appearance: auto; }
.num { display: flex; align-items: stretch; max-width: 220px; }
.num input { border-radius: var(--r) 0 0 var(--r); font-family: var(--mono); font-size: 17px; }
.unit { display: inline-flex; align-items: center; padding: 0 12px; border: 1.5px solid var(--line); border-left: 0; border-radius: 0 var(--r) var(--r) 0; color: var(--muted); font-size: 15px; background: var(--bg); }
.num input[aria-invalid="true"] { border-color: var(--err); }
.field-err { color: var(--err); font-size: 15px; margin: 4px 0 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; border: 1.5px solid var(--line); border-radius: var(--r); background: var(--paper); font-size: 15px; white-space: nowrap; cursor: pointer; }
.seg-opt input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 16px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.prefs { display: flex; flex-wrap: wrap; gap: 14px 22px; }
.more { border-top: 1px solid var(--line); padding-top: 4px; }
.more summary, .earlier summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; color: var(--accent); }
.more summary, .earlier summary { list-style: none; }
.more summary::-webkit-details-marker, .earlier summary::-webkit-details-marker { display: none; }
.more summary::after, .earlier summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: -4px 0 0 10px; }
.more[open] summary::after, .earlier[open] summary::after { transform: rotate(225deg); margin-top: 4px; }
.more .fields { padding: 8px 0 4px; }
.more-actions { margin: 0; }
.linkish { background: none; border: 0; padding: 10px 0; color: var(--accent); font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer; min-height: 44px; }

/* result card: the one card on the page */
.result { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; min-height: 320px; }
.result.is-error { min-height: 0; }
.res-wait { color: var(--muted); }
.res-title { font: 700 20px/1.3 var(--head); margin: 0 0 2px; }
.res-title:focus { outline: none; }
.res-big { font-size: 18px; margin: 0 0 10px; }
.res-big b { font-family: var(--mono); font-weight: 700; }
.res-error { color: var(--err); font-weight: 600; margin: 0; }
.preview { background: var(--bg); border-radius: 4px; padding: 8px; }
.preview svg { display: block; width: 100%; height: auto; max-height: 460px; }
.pv-board { fill: none; stroke: var(--wood); }
.pv-sheets rect { fill: none; stroke: var(--sheet); }
.pv-name { fill: var(--sheet); font-family: var(--body); font-weight: 700; }
.pv-h { fill: var(--hole); }
.pv-h.home, .pv-h.game { fill: var(--home); }
.pv-h.base, .pv-h.start { fill: var(--base); }
.pv-h.centre, .pv-h.corner { fill: var(--hole); stroke: var(--home); stroke-width: .6; }
.pv-mark { stroke: var(--home); }
.sheets { font-size: 15px; color: var(--muted); margin: 8px 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { font: 600 16px/1.2 var(--body); min-height: 46px; padding: 10px 16px; border-radius: var(--r); border: 1.5px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small { min-height: 44px; padding: 6px 12px; font-size: 15px; }
.btn:hover { filter: brightness(1.08); }
.share-out { margin: 10px 0 0; font-size: 15px; }
.counts { list-style: none; padding: 0; margin: 14px 0 8px; display: grid; gap: 2px; font-size: 16px; }
.counts b { font-family: var(--mono); }
.counts .why { color: var(--muted); font-size: 15px; }
.facts, .build-note { margin: 6px 0 0; font-size: 16px; }
.facts b { font-family: var(--mono); }
.build-note { color: var(--muted); }
.print-tip { margin: 10px 0 0; padding: 6px 0 6px 10px; border-left: 4px solid var(--ink); font-size: 16px; }
.warn { margin: 8px 0 0; padding: 8px 10px; border-left: 4px solid var(--accent); background: var(--accent-soft); font-size: 15px; }

.save-note { color: var(--muted); font-size: 15px; margin: 12px 0 0; }
.keep { margin: 10px 0 0; }
.earlier ul { list-style: none; padding: 0; margin: 4px 0 8px; display: grid; gap: 8px; max-width: 640px; }
.earlier li { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 15px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.earlier small { color: var(--muted); font-size: 14px; }
.forget { margin: 0; font-size: 15px; color: var(--muted); }

/* reading content */
.prose { max-width: 70ch; margin: 36px 0 0; }
.prose p, .prose li { margin: 0 0 12px; }
.games { padding-left: 20px; }
.example { border-left: 4px solid var(--wood); padding-left: 12px; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; font-weight: 600; padding: 12px 0; min-height: 44px; }
.faq details p { margin: 0 0 14px; }

.foot { margin-top: 48px; border-top: 1px solid var(--line); padding: 20px 0 32px; font-size: 15px; color: var(--muted); }
.foot a { color: var(--muted); }
.sb-footer p { margin: 0 0 8px; }
.nf { padding: 40px 0; }

#print-root { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* ------------------------------------------------------------------ print: only the template sheets */
@media print {
  html, body { background: #fff !important; color: #000; }
  body { font: 10pt/1.35 var(--body); }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  .sheet { width: var(--sheet-w); height: var(--sheet-h); overflow: hidden; break-after: page; page-break-after: always; break-inside: avoid; position: relative; color: #000; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
  .sheet svg { display: block; }
  .sheet-msg { font-size: 14pt; }

  .tl-head { height: 13mm; display: flex; align-items: center; gap: 4mm; border-bottom: 0.3mm solid #000; overflow: hidden; }
  .tl-name { font: 700 20pt/1 var(--body); min-width: 14mm; }
  .tl-info { flex: 1; font-size: 8.5pt; line-height: 1.3; }
  .tl-bar { display: flex; flex-direction: column; align-items: flex-end; font-size: 7.5pt; }

  .check-sheet { display: flex; flex-direction: column; gap: 3.5mm; }
  .ck-head h2 { font: 700 15pt/1.2 var(--body); margin: 0; }
  .ck-head p { margin: 1mm 0 0; font-size: 9pt; }
  .ck-warn { margin: 0; padding: 2mm 3mm; border: 0.5mm solid #000; font-weight: 700; font-size: 11pt; }
  .ck-cal { display: flex; gap: 5mm; align-items: flex-start; }
  .ck-cal svg { flex: none; }
  .ck-cal-text p { margin: 0 0 2mm; font-size: 10pt; }
  .ck-table { border-collapse: collapse; width: 100%; font-size: 9.5pt; }
  .ck-table th { text-align: left; width: 18mm; padding: 1mm 2mm 1mm 0; vertical-align: top; }
  .ck-table td { padding: 1mm 0; border-bottom: 0.2mm solid #999; }
  .ck-bottom { display: flex; gap: 6mm; align-items: flex-start; }
  .ck-map { flex: none; }
  .ck-steps { margin: 0; padding-left: 5mm; font-size: 9.5pt; }
  .ck-steps li { margin: 0 0 1.5mm; }
  #print-root[data-orientation="landscape"] .check-sheet { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "head head" "warn warn" "cal table" "cal bottom"; gap: 3mm 6mm; align-content: start; }
  #print-root[data-orientation="landscape"] .ck-head { grid-area: head; }
  #print-root[data-orientation="landscape"] .ck-warn { grid-area: warn; }
  #print-root[data-orientation="landscape"] .ck-cal { grid-area: cal; flex-direction: column; width: 105mm; }
  #print-root[data-orientation="landscape"] .ck-table { grid-area: table; }
  #print-root[data-orientation="landscape"] .ck-bottom { grid-area: bottom; flex-direction: column; }
}
