/* Anchor bowling score calculator.
   Page chrome uses the Anchor marketing variables from ../styles.css.
   The tool surface (pin deck, frame strip, scoresheet, stats) uses the app's "House Style" tokens. */

:root {
  --t-paper: #EDE3D0;
  --t-surface: #F7F1E3;
  --t-sheet: #F3EBD8;
  --t-ink: #22324A;
  --t-ink-soft: #6B5F49;
  --t-line: #D7CBAF;
  --t-accent: #BE382D;
  --t-accent-rgb: 190, 56, 45;
  --t-readout: #22324A;
  --t-brass: #B07A2E;
  --t-mono: 'Space Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --t-serif: 'Fraunces', ui-serif, 'New York', Georgia, serif;
  --t-sans: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --t-paper: #17130D;
    --t-surface: #221C14;
    --t-sheet: #241D13;
    --t-ink: #EFE6D3;
    --t-ink-soft: #A6967B;
    --t-line: #372E20;
    --t-accent: #E1584B;
    --t-accent-rgb: 225, 88, 75;
    --t-readout: #E7A63C;
    --t-brass: #E7A63C;
  }
}

[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

body.calc-page { font-size: 1.0625rem; overflow-x: hidden; }
.calc-page .topbar .wrap, .calc-page .foot .wrap { padding-left: 16px; padding-right: 16px; }
.calc-page .topnav { gap: 14px; }
.calc-page .brand { min-height: 44px; }
.calc-page .topnav a { min-width: 44px; justify-content: center; display: inline-flex; align-items: center; min-height: 44px; }
.calc-page .foot a { display: inline-block; padding: 12px 0; }

.cwrap { max-width: 760px; margin: 0 auto; padding: 0 16px 56px; }

:where(button, input, a, summary):focus-visible { outline: 3px solid var(--t-accent); outline-offset: 2px; }
.cta :where(a):focus-visible { outline-color: #fff; }

/* ---------- intro ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; font-size: .88rem; color: var(--muted); padding-top: 6px; }
.crumbs a { min-width: 44px; display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
.crumbs a:hover { color: var(--red-deep); }
.crumbs [aria-current] { color: var(--text); }
.intro { padding: 4px 0 22px; }
.intro h1 { font-size: clamp(2.1rem, 8vw, 3.2rem); }
.intro .lede { margin: 12px 0 0; color: var(--muted); font-size: 1.04rem; line-height: 1.55; }

.eyebrow-t { font-family: var(--t-sans); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--t-ink-soft); }
.hint { margin: 8px 0 0; font-size: .85rem; color: var(--t-ink-soft); line-height: 1.45; }
.calc-page .hint { color: var(--muted); }
.tool .hint, .paper .hint, .stats-grid .hint { color: var(--t-ink-soft); }

/* ---------- buttons ---------- */
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 16px;
  font: 600 .98rem/1.1 var(--t-sans); color: var(--t-ink);
  background: var(--t-sheet); border: 1px solid var(--t-line); border-radius: 14px;
  cursor: pointer; text-decoration: none; -webkit-tap-highlight-color: transparent;
  transition: background-color .12s ease, transform .12s ease;
}
.t-btn:hover:not(:disabled) { background: var(--t-paper); }
.t-btn:active:not(:disabled) { transform: translateY(1px); }
.t-btn:disabled { opacity: .45; cursor: default; }
.t-btn--primary { background: var(--t-accent); border-color: var(--t-accent); color: #fff; font-weight: 700; }
.t-btn--primary:hover:not(:disabled) { background: var(--t-accent); filter: brightness(.94); }
.t-btn--quiet { background: transparent; border-color: transparent; color: var(--t-accent); padding: 0 12px; }
.t-btn--quiet:hover:not(:disabled) { background: rgba(var(--t-accent-rgb), .1); }
.t-btn--link:hover { text-decoration: none; }
.calc-page .t-btn--quiet { color: var(--red-deep); }
.tool .t-btn--quiet, .block .t-btn--quiet { color: var(--t-accent); }

/* ---------- tool ---------- */
.tool {
  background: var(--t-surface); color: var(--t-ink);
  border: 1px solid var(--t-line); border-radius: 14px;
  padding: 14px; font-family: var(--t-sans);
}
.tool-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-width: 0; max-width: 240px; }
.field input {
  min-height: 44px; width: 100%; padding: 0 12px;
  font: 700 1.1rem var(--t-serif); color: var(--t-ink);
  background: var(--t-sheet); border: 1px solid var(--t-line); border-radius: 8px;
}
.tool-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.score-so-far { display: flex; align-items: baseline; gap: 6px; }
.score-so-far strong { font: 600 1.9rem/1 var(--t-mono); color: var(--t-readout); min-width: 2ch; text-align: right; }

/* frame strip */
.strip {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--t-sheet); border: 1px solid var(--t-line); border-radius: 8px; overflow: hidden;
}
.fc {
  position: relative; display: flex; flex-direction: column; align-items: stretch;
  min-height: 66px; padding: 0; margin: 0;
  background: transparent; color: var(--t-ink); font: inherit; text-align: center;
  border: 0; border-left: 1px solid var(--t-line); border-top: 1px solid var(--t-line);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.fc:nth-child(5n+1) { border-left: 0; }
.fc:nth-child(-n+5) { border-top: 0; }
.fc:disabled { cursor: default; color: var(--t-ink); }
.fc:not(:disabled):hover { background: rgba(var(--t-accent-rgb), .05); }
.fc.is-current { background: rgba(var(--t-accent-rgb), .1); box-shadow: inset 0 2px 0 var(--t-accent); }
.fc:focus-visible { outline-offset: -3px; }
.fc-n { font: 600 .62rem/1 var(--t-mono); color: var(--t-ink-soft); padding: 5px 0 2px; }
.fc-boxes { display: flex; height: 20px; border-bottom: 1px solid var(--t-line); }
.bx { display: flex; align-items: center; justify-content: center; font: 700 .8rem/1 var(--t-mono); color: var(--t-ink); }
.bx.mk { color: var(--t-accent); }
.fc .bx { flex: 1 1 0; min-width: 0; border-left: 1px solid rgba(var(--t-accent-rgb), 0); border-left-color: var(--t-line); }
.fc .bx:first-child { border-left: 0; }
.fc-total { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 26px; font: 600 .95rem/1 var(--t-mono); color: var(--t-readout); }
@media (min-width: 560px) {
  .strip { grid-template-columns: repeat(9, 1fr) 1.4fr; }
  .fc { border-top: 0 !important; border-left: 1px solid var(--t-line) !important; }
  .fc:first-child { border-left: 0 !important; }
}

/* entry */
.entry-head { display: flex; align-items: center; justify-content: space-between; min-height: 44px; margin-top: 8px; }
.entry-title { font: 700 1.15rem var(--t-serif); color: var(--t-ink); letter-spacing: 0; }
.entry-title.is-edit { color: var(--t-accent); }
.deck { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 6px 0 2px; }
.deck-row { display: flex; justify-content: center; gap: 16px; }
.deck-cap { text-align: center; margin: 8px 0 14px; }

.pin {
  position: relative; display: block; width: 44px; height: 58px; padding: 0; margin: 0;
  background: none; border: 0; cursor: pointer; font: inherit; color: var(--t-ink);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.pin svg { display: block; overflow: visible; }
.pin-body { fill: var(--t-sheet); stroke: var(--t-ink); stroke-opacity: .45; stroke-width: 1.5; transition: fill .15s ease; }
.pin-stripe { fill: var(--t-accent); }
.pin-n { position: absolute; left: 0; right: 0; top: 30px; text-align: center; font: 700 .875rem/1 var(--t-mono); color: var(--t-ink); pointer-events: none; }
.pin.is-standing .pin-body { fill: var(--t-accent); stroke: var(--t-accent); stroke-opacity: 1; }
.pin.is-standing .pin-stripe { display: none; }
.pin.is-standing .pin-n { color: #fff; }
.pin.is-down { cursor: default; opacity: .22; }
.pin.is-down .pin-body { stroke: var(--t-line); stroke-opacity: 1; }
.pin.is-down .pin-n { color: var(--t-ink-soft); }
.pin:focus-visible { outline-offset: 0; border-radius: 12px; }

.actions { display: flex; flex-direction: column; gap: 10px; }
.actions .t-btn--primary { width: 100%; min-height: 56px; font-size: 1.15rem; }
.actions-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.keys { margin: 14px 0 0; font-size: .8rem; line-height: 1.6; color: var(--t-ink-soft); }
kbd { font: 700 .75rem var(--t-mono); padding: 1px 5px; border: 1px solid var(--t-line); border-bottom-width: 2px; border-radius: 5px; background: var(--t-sheet); color: var(--t-ink); }
@media (hover: none) and (pointer: coarse) { .keys { display: none; } }

.final { text-align: center; padding: 18px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.final-score { margin: 0; font: 600 4.5rem/1.05 var(--t-mono); color: var(--t-readout); }
.final .t-btn { margin-top: 14px; min-width: 220px; }

/* ---------- blocks ---------- */
.block { margin-top: 32px; }
.block-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.block-h { font-size: clamp(1.4rem, 5vw, 1.8rem); }
.block .hint { color: var(--muted); }

/* scoresheet */
.paper {
  background: var(--t-sheet); color: var(--t-ink); font-family: var(--t-sans);
  border: 1px solid var(--t-line); border-radius: 14px; padding: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .12);
}
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-name { margin: 2px 0 0; font: 700 1.75rem/1.1 var(--t-serif); color: var(--t-ink); overflow-wrap: anywhere; }
.sheet-date { margin: 4px 0 0; font-size: .85rem; color: var(--t-ink-soft); }
.stamp-box { flex: none; margin: 4px 4px 0 0; border: 2px solid var(--t-accent); border-radius: 8px; outline: 1px solid rgba(var(--t-accent-rgb), .3); outline-offset: 3px; padding: 6px 12px; text-align: center; }
.stamp-inner { display: flex; flex-direction: column; align-items: center; }
.stamp-label { color: var(--t-accent); }
.stamp-score { font: 700 2rem/1.1 var(--t-serif); color: var(--t-accent); min-width: 2ch; }

.league { border: 1px solid var(--t-line); border-radius: 8px; overflow: hidden; background: var(--t-sheet); }
.lg-row + .lg-row { border-top: 1px solid var(--t-line); }
.lg-nums { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--t-ink); }
.lg-nums span { padding: 4px 0; text-align: center; font: 600 .6875rem var(--t-mono); color: var(--t-paper); }
.lg-cells { display: grid; grid-template-columns: repeat(5, 1fr); }
.bf {
  display: flex; flex-direction: column; height: 124px; min-width: 0; padding: 6px 4px 8px; margin: 0;
  background: transparent; border: 0; border-left: 1px solid var(--t-line); color: var(--t-ink); font: inherit; text-align: center;
}
.bf:first-child { border-left: 0; }
button.bf { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button.bf:hover { background: rgba(var(--t-accent-rgb), .05); }
button.bf:focus-visible { outline-offset: -3px; }
.bf.is-current { background: rgba(var(--t-accent-rgb), .08); box-shadow: inset 0 2px 0 var(--t-accent); }
.bf-boxes { display: flex; justify-content: flex-end; gap: 3px; }
.bf .bx { flex: none; width: 15px; height: 15px; border: .75px solid var(--t-line); font-size: .8125rem; }
.bf-leave { flex: 1; display: flex; align-items: center; justify-content: center; }
.leave circle.on { fill: var(--t-accent); stroke: var(--t-accent); stroke-width: .75; }
.leave circle.off { fill: none; stroke: var(--t-line); stroke-width: .75; }
.bf-total { min-height: 28px; font: 600 1.375rem/1 var(--t-mono); color: var(--t-readout); }
@media (max-width: 400px) { .bf-total { font-size: 1.15rem; } .bf { padding-left: 2px; padding-right: 2px; } }

.share-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.share-row .t-btn { flex: 1 1 160px; }
#share-msg { min-height: 1.3em; overflow-wrap: anywhere; }

/* stats */
.seg { display: inline-flex; border: 1px solid var(--t-line); border-radius: 12px; overflow: hidden; background: var(--t-surface); }
.seg button { min-height: 44px; padding: 0 14px; border: 0; background: transparent; color: var(--t-ink); font: 600 .9rem var(--t-sans); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--t-line); }
.seg button.is-on { background: var(--t-accent); color: #fff; }
.seg button:focus-visible { outline-offset: -3px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 10px; }
.stat {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 14px;
  background: var(--t-surface); color: var(--t-ink); border: 1px solid var(--t-line); border-radius: 14px; font-family: var(--t-sans);
}
.stat strong { font: 600 1.7rem/1.1 var(--t-mono); color: var(--t-readout); }
.stat .sub, .totals .sub { font-size: .8rem; color: var(--t-ink-soft); line-height: 1.35; }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--t-line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--t-accent); border-radius: 3px; }
.stat--heat { grid-column: 1 / -1; align-items: center; text-align: center; }
.stat--heat .eyebrow-t { align-self: flex-start; }
.heat { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0; }
.heat-pin { position: relative; width: 44px; height: 58px; }
.heat-pin svg { display: block; }
.heat-pin .pin-body { fill: var(--t-sheet); }
.heat-pin .pin-heat { fill: var(--t-accent); stroke: none; }
.heat-pin .pin-n { top: 28px; left: 8px; right: 8px; background: var(--t-sheet); border-radius: 6px; padding: 2px 0; font-size: .75rem; }
.heat-n { position: absolute; left: 0; right: 0; top: 45px; text-align: center; font: 700 .625rem/1 var(--t-mono); color: var(--t-ink); }
.empty { grid-column: 1 / -1; margin: 0; padding: 18px; text-align: center; color: var(--t-ink-soft); background: var(--t-surface); border: 1px dashed var(--t-line); border-radius: 14px; font-size: .95rem; }

/* games */
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.totals > div { display: flex; flex-direction: column; gap: 3px; padding: 12px; min-width: 0; background: var(--t-surface); color: var(--t-ink); border: 1px solid var(--t-line); border-radius: 14px; }
.totals strong { font: 600 1.55rem/1.1 var(--t-mono); color: var(--t-readout); }
.games { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.game { display: flex; align-items: stretch; background: var(--t-surface); color: var(--t-ink); border: 1px solid var(--t-line); border-radius: 14px; overflow: hidden; }
.game.is-view { border-color: var(--t-accent); box-shadow: inset 0 0 0 1px var(--t-accent); }
.game-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 8px 12px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.game-open:hover { background: rgba(var(--t-accent-rgb), .05); }
.game-score { font: 600 1.9rem/1 var(--t-mono); color: var(--t-readout); min-width: 3.2ch; }
.game-info { display: flex; flex-direction: column; min-width: 0; font-size: .82rem; color: var(--t-ink-soft); line-height: 1.35; }
.game-info strong { color: var(--t-ink); font: 700 .95rem var(--t-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-del { flex: none; width: 52px; background: none; border: 0; border-left: 1px solid var(--t-line); color: var(--t-ink-soft); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.game-del:hover { color: var(--t-accent); background: rgba(var(--t-accent-rgb), .06); }
.game-open:focus-visible, .game-del:focus-visible { outline-offset: -3px; }

/* ---------- CTA ---------- */
.cta { margin-top: 32px; padding: 22px 20px; border-radius: 20px; background: var(--ink); color: #E8DCC6; }
.cta .eyebrow-t { color: var(--brass); }
.cta h2 { margin: 6px 0 10px; font-size: clamp(1.4rem, 5.5vw, 1.9rem); color: #fff; }
.cta p { margin: 0 0 16px; line-height: 1.55; font-size: 1rem; }
.cta .t-btn--primary { width: 100%; min-height: 52px; background: var(--red); border-color: var(--red); }
.cta .links { margin: 16px 0 0; font-size: .95rem; }
.cta .links a { color: #F0E7D8; display: inline-block; padding: 10px 0; }
.cta--foot { margin-top: 48px; }
@media (min-width: 560px) { .cta .t-btn--primary { width: auto; min-width: 280px; } }

/* ---------- prose ---------- */
.prose { margin-top: 48px; color: var(--text); font-size: 1.04rem; line-height: 1.65; }
.prose h2 { font-size: clamp(1.55rem, 5.5vw, 2.1rem); margin: 44px 0 12px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.2rem; margin: 24px 0 6px; }
.prose p { margin: 0 0 14px; }
.table-scroll { overflow-x: auto; margin: 14px 0 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.ex { width: 100%; border-collapse: collapse; font-size: .95rem; }
.ex caption { text-align: left; padding: 10px 12px 4px; font-size: .8rem; color: var(--muted); caption-side: top; }
.ex th, .ex td { padding: 9px 12px; text-align: left; border-top: 1px solid var(--line); vertical-align: top; }
.ex thead th { font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ex tbody td:last-child, .ex tbody td:nth-child(2) { font-family: var(--t-mono); font-weight: 700; color: var(--navy); }
.ex tbody th { font-family: var(--t-mono); width: 3.5rem; }

@media (prefers-reduced-motion: reduce) {
  .t-btn, .pin-body { transition: none !important; }
}
@media print {
  .topbar, .foot, .cta, .tool, .share-row, .prose, #stats, #games { display: none !important; }
}
