/* Settled. The look, plan section 7. A results sheet: warm paper, black ink,
   wide heavy numerals, ruled lines, one yellow for the one thing in play. */

@font-face {
  font-family: 'Archivo';
  src: url('../fonts/archivo.woff2') format('woff2');
  font-weight: 400 900;
  font-stretch: 100% 125%;
  font-display: swap;
}
/* A stand-in scaled to Archivo's measure, so nothing moves when the font arrives. */
@font-face {
  font-family: 'Archivo Fallback';
  src: local('Helvetica Neue'), local('Arial'), local('Roboto');
  size-adjust: 104%;
  ascent-override: 88%;
  descent-override: 21%;
}

/* ---------- Colours (7.4) ---------- */
:root {
  --paper: #f5f3ec;
  --surface: #fbfaf6;
  --ink: #141414;
  --ink-2: #5f5c55;
  --hairline: #d9d5ca;
  --bib: #ffd21f;
  --fixed-ink: #141414;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #131311;
    --surface: #1d1d1a;
    --ink: #f1efe8;
    --ink-2: #a6a299;
    --hairline: #34332e;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --paper: #131311;
  --surface: #1d1d1a;
  --ink: #f1efe8;
  --ink-2: #a6a299;
  --hairline: #34332e;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Archivo', 'Archivo Fallback', system-ui, sans-serif;
  font-stretch: 100%;
  font-size: 1.0625rem;
  line-height: 1.5rem;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
h1, h2, h3, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
[tabindex='-1']:focus-visible { outline: none; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---------- Type styles (7.3), sizes in rem so they follow the browser's text setting ---------- */
.t-wordmark { font-stretch: 125%; font-weight: 800; font-size: 1.25rem; line-height: 1.5rem; letter-spacing: -0.01em; }
.t-numeral { font-stretch: 125%; font-weight: 900; font-size: 1.625rem; line-height: 1.75rem; font-variant-numeric: tabular-nums lining-nums; }
.t-score { font-stretch: 125%; font-weight: 900; font-size: 4.5rem; line-height: 4.5rem; font-variant-numeric: tabular-nums lining-nums; letter-spacing: -0.02em; }
.t-title { font-weight: 700; font-size: 1.5rem; line-height: 1.75rem; letter-spacing: -0.005em; }
.t-headline { font-weight: 700; font-size: 1.25rem; line-height: 1.5625rem; }
.t-card { font-weight: 700; font-size: 1.375rem; line-height: 1.625rem; }
.t-row { font-weight: 500; font-size: 1.125rem; line-height: 1.375rem; }
.t-body { font-weight: 400; font-size: 1.0625rem; line-height: 1.5rem; }
.t-value { font-weight: 500; font-size: 0.9375rem; line-height: 1.25rem; font-variant-numeric: tabular-nums lining-nums; }
.t-caption { font-weight: 400; font-size: 0.8125rem; line-height: 1.125rem; }
.t-label { font-weight: 600; font-size: 0.6875rem; line-height: 0.875rem; text-transform: uppercase; letter-spacing: 0.06em; }
.t-button { font-weight: 700; font-size: 1.0625rem; line-height: 1.375rem; }
.ink-2 { color: var(--ink-2); }

/* ---------- Parts (7.5) ---------- */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 52px; padding: 0 16px;
  border-radius: 4px; border: 1.5px solid var(--fixed-ink);
  background: var(--bib); color: var(--fixed-ink);
  font-weight: 700; font-size: 1.0625rem; line-height: 1.375rem; text-align: center;
  transition: transform 150ms ease-out;
  user-select: none; -webkit-user-select: none;
}
.btn:active:not(:disabled) { transform: scale(0.97); transition-duration: 80ms; }
.btn:disabled { background: var(--surface); border-color: var(--hairline); color: var(--ink-2); cursor: default; }
.btn.secondary { background: var(--paper); border-color: var(--ink); color: var(--ink); }
.tbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px;
  font-weight: 600; font-size: 0.9375rem; line-height: 1.25rem;
  color: var(--ink);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.tbtn.quiet { color: var(--ink-2); }
.notice {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 4px;
  padding: 12px; font-size: 0.8125rem; line-height: 1.125rem;
}
.rule { height: 1px; background: var(--hairline); border: 0; margin: 0; }

/* ---------- The frame (3.1) ---------- */
.col { max-width: 440px; margin: 0 auto; padding: 0 20px; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.hdr { height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hdr a.wordmark { color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; }
.hdr nav { display: flex; gap: 12px; }
.hdr nav .tbtn { padding: 0 2px; }
.hdr-num { display: none; margin-left: auto; }
.menu-wrap { position: relative; display: none; }
.menu-list {
  position: absolute; right: 0; top: 40px; z-index: 30;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 4px;
  padding: 4px 16px; display: flex; flex-direction: column; min-width: 140px;
}
.menu-list .tbtn { justify-content: flex-start; }

main { flex: 1; padding-bottom: calc(var(--bar-h, 0px) + 24px); }
.bar-inline main { padding-bottom: 24px; }
.meta { color: var(--ink-2); margin-top: 6px; }
.notices { display: flex; flex-direction: column; gap: 8px; }
.notices:not(:empty) { margin-top: 10px; }
.question { margin-top: 8px; }
.direction { margin-top: 4px; color: var(--ink-2); }

/* ---------- The board (3.3) ---------- */
.board { margin-top: 12px; border-top: 1px solid var(--hairline); }
.row {
  position: relative;
  display: flex; align-items: center;
  min-height: 44px;
  border-bottom: 1px solid var(--hairline);
}
.row > .hit {
  position: absolute; inset: 0 0 -1px 0; width: 100%; z-index: 1; /* covers the rule too: 44 tall */
  border-radius: 0;
}
.row .num { width: 36px; flex: none; text-align: right; color: var(--ink-2); transition: color 160ms; }
.row .area {
  flex: 1; min-width: 0; margin-left: 12px; padding: 8px 0;
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; row-gap: 2px;
}
.row .name { overflow-wrap: anywhere; }
.row .value { margin-left: auto; text-align: right; white-space: nowrap; }
.row.wrapped .value { margin-left: 0; flex-basis: 100%; text-align: left; }
.row .end { margin-left: auto; color: var(--ink-2); padding-left: 8px; white-space: nowrap; }
.row .verdict { flex: none; display: flex; align-items: center; gap: 6px; margin-left: 10px; padding-right: 4px; }
.row .verdict .word { white-space: nowrap; }

/* row states */
.row.can-take .hit { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .row.can-take .hit:hover { background: var(--surface); }
}
.row.locked .num, .row.holding .num, .row.revealed .num { color: var(--ink); }
.row .fill {
  position: absolute; inset: 0; z-index: 0;
  background: var(--bib); box-shadow: inset 0 0 0 1.5px var(--fixed-ink);
  transform-origin: right center; transform: scaleX(0); pointer-events: none;
}
.row.holding .fill { transform: scaleX(1); }
.row.wiping .fill { transform: scaleX(0); transition: transform 160ms ease-in-out; }
.row.holding .num, .row.holding .name { color: var(--fixed-ink); position: relative; z-index: 2; }
.row.holding .name { font-weight: 700; }
.row .num, .row .area, .row .verdict { position: relative; z-index: 2; pointer-events: none; }
.row.revealed .value, .row.revealed .verdict { animation: fade 150ms ease-out both; }
.row.revealed .cell.mark { animation: fade 120ms ease-out 60ms both; }
.row.revealed.instant .value, .row.revealed.instant .verdict, .row.revealed.instant .cell.mark { animation: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Cells: the strip and the marks (7.6) ---------- */
.strip { display: flex; gap: calc(var(--c) / 8); }
.cell {
  --c: 16px;
  width: var(--c); height: var(--c); flex: none; display: inline-block;
  border: 1.5px solid var(--ink);
}
.cell.s { background: var(--ink); }
.cell.h {
  background-image: repeating-linear-gradient(-45deg, var(--ink) 0 calc(var(--c) / 8), transparent calc(var(--c) / 8) calc(var(--c) / 4));
  background-position: center;
}
.strip .cell { --c: inherit; }
.strip.on .cell { animation: fade 100ms ease-out both; }

/* ---------- The bar (3.4) ---------- */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--paper); border-top: 1px solid var(--hairline);
}
.bar-in {
  max-width: 440px; margin: 0 auto;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
}
.bar-inline .bar { position: static; border-top: 1px solid var(--hairline); }
.bar .hint { margin-top: 8px; color: var(--ink-2); }
.bar .center { text-align: center; }
.bar .first .t-body { margin-top: 6px; }
.bar .first .price { margin-top: 10px; color: var(--ink-2); }
.bar .first .btn { margin-top: 12px; }
.bar .first .after { margin-top: 8px; text-align: center; color: var(--ink-2); }
.bar .truth { min-height: 52px; display: flex; align-items: center; justify-content: center; color: var(--ink-2); }
.card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; padding: 8px 16px; border-radius: 4px;
  background: var(--bib); border: 1.5px solid var(--fixed-ink); color: var(--fixed-ink);
}
.card .count { flex: none; color: var(--fixed-ink); }
.rise { animation: rise 220ms ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.fadeout { animation: fadeout 120ms ease-in both; }
@keyframes fadeout { to { opacity: 0; } }
.ghost {
  position: fixed; z-index: 40; pointer-events: none; margin: 0;
  display: flex; align-items: center; padding: 0 16px;
  background: var(--bib); box-shadow: inset 0 0 0 1.5px var(--fixed-ink); border-radius: 4px;
  color: var(--fixed-ink);
}

/* ---------- The result block (3.6) ---------- */
.result { margin-top: 24px; }
.stamp-wrap { margin-bottom: 18px; }
.stamp {
  display: inline-block; padding: 8px 14px; border-radius: 2px;
  background: var(--bib); border: 2px solid var(--fixed-ink); color: var(--fixed-ink);
  font-stretch: 125%; font-weight: 800; font-size: 1.875rem; line-height: 2.25rem;
  transform: rotate(-2deg);
}
.stamp.land { animation: land 140ms ease-out both; }
@keyframes land { from { opacity: 0; transform: rotate(-2deg) scale(1.04); } to { opacity: 1; transform: rotate(-2deg) scale(1); } }
.score-line { display: flex; align-items: baseline; gap: 10px; }
.result .offby { margin-top: 4px; }
.result .explain { margin-top: 4px; color: var(--ink-2); }
.result .strip { margin-top: 16px; --c: 28px; }
.result .pair { margin-top: 20px; display: flex; gap: 12px; }
.result .pair .btn { flex: 1; }
.result .next { margin-top: 20px; color: var(--ink-2); min-height: 18px; }
.result .rule { margin: 20px 0 16px; }
.result .sources { color: var(--ink-2); }
.result .links { display: flex; gap: 20px; margin-top: 2px; }

/* ---------- Footer (3.1) ---------- */
footer { padding: 24px 0 calc(var(--bar-h, 0px) + 24px); }
.has-result footer, .bar-inline footer { padding-bottom: 24px; }
.in-play footer { display: none; }
footer .links { display: flex; flex-wrap: wrap; column-gap: 16px; }
footer .links a { min-width: 44px; justify-content: center; color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; }
footer .appearance { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
footer .appearance .tbtn { font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }
footer .appearance .tbtn[aria-pressed='true'] { color: var(--ink); }
footer .made { color: var(--ink-2); margin-top: 4px; }

/* ---------- Panels (3.7 to 3.9) ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 50; display: flex; justify-content: center; align-items: flex-end;
  background: transparent;
}
.sheet-in {
  width: 100%; max-width: 440px; height: calc(100% - 12px);
  background: var(--surface); border-radius: 12px 12px 0 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 20px calc(32px + env(safe-area-inset-bottom, 0px));
  animation: slideup 240ms ease-out both;
}
@media (min-width: 480px) { .sheet-in { border: 1px solid var(--hairline); border-bottom: 0; } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }
.sheet-top { display: flex; justify-content: flex-end; }
.sheet h2 { margin-bottom: 16px; }
.how-list li { display: flex; gap: 12px; align-items: baseline; margin-bottom: 16px; }
.how-list .n { font-stretch: 125%; font-weight: 900; font-size: 1.125rem; line-height: 1.375rem; width: 22px; flex: none; }
.sheet .rule { margin: 20px 0; }
.sheet .gap { margin-top: 12px; }
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 16px; }
.figures .fig .t-label { margin-top: 4px; color: var(--ink-2); }
.figures .of { font-weight: 400; font-size: 0.8125rem; color: var(--ink); margin-left: 4px; }
.chart { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.chart .crow { display: flex; align-items: center; gap: 12px; min-height: 22px; }
.chart .cnum { width: 24px; text-align: right; font-stretch: 125%; font-weight: 900; font-size: 1.125rem; line-height: 1.375rem; }
.chart .track { flex: 1; display: flex; align-items: center; gap: 8px; }
.chart .barfill { height: 18px; background: var(--ink); min-width: 3px; }
.chart .barfill.today { background: var(--bib); box-shadow: inset 0 0 0 1.5px var(--fixed-ink); }
.chart .barfill.zero { min-width: 0; width: 0; }
.tlist { margin-top: 10px; }
.trow { display: flex; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--hairline); }
.trow:first-child { border-top: 1px solid var(--hairline); }
.trow .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .who.you { font-weight: 700; }
.trow .strip { --c: 12px; }
.trow .res { text-align: right; white-space: nowrap; }
.trow .res .t-caption { color: var(--ink-2); margin-left: 4px; }

/* ---------- Messages ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bar-h, 0px) + 16px); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px;
  font-size: 0.8125rem; line-height: 1.125rem; opacity: 0; transition: opacity 150ms; pointer-events: none;
}
.toast.on { opacity: 1; }
.stop { padding: 40px 0; }
.stop .btn { margin-top: 16px; }

/* ---------- Compact layout: short screens (3.1) ---------- */
.compact .hdr { height: 40px; }
.compact .hdr nav { display: none; }
.compact .menu-wrap { display: block; }
.compact .hdr-num { display: block; }
.compact .meta { display: none; }
.compact .question { margin-top: 4px; font-weight: 500; font-size: 1.125rem; line-height: 1.375rem; }

/* ---------- Reduce Motion (8) ---------- */
@media (prefers-reduced-motion: reduce) {
  .rise, .sheet-in { animation: fade 200ms ease-out both; }
  .stamp.land { animation: fade 200ms ease-out both; }
  .btn, .btn:active:not(:disabled) { transform: none; transition: none; }
  .row.wiping .fill { transition: opacity 200ms; transform: scaleX(1); opacity: 0; }
}

/* Pages beside the game (3.12 to 3.15) */
.page .t-title { margin-top: 8px; }
.page-h { margin-top: 28px; }
.page-p { margin-top: 8px; max-width: 36em; }
.page .links { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; }
.page a:not(.tbtn):not(.btn) { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.srclist, .corrlist { list-style: none; margin: 8px 0 0; padding: 0; }
.srclist li, .corrlist li { padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.board.static .row { pointer-events: none; }

/* The comparison and naming (3.10) */
.compare { margin-top: 24px; }
.compare .trow .strip { --c: 20px; }
.compare .see { min-height: 44px; }
.theirs { width: 100%; border-collapse: collapse; margin: 4px 0 12px; }
.theirs th { text-align: right; color: var(--ink-2); padding: 4px 0 4px 12px; }
.theirs th:first-child { text-align: left; padding-left: 0; }
.theirs td { padding: 6px 0; border-top: 1px solid var(--hairline); }
.theirs td.n { text-align: right; font-variant-numeric: tabular-nums; padding-left: 12px; width: 3.5em; }
.ask { margin-top: 12px; }
.ask input, .trow input { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--ink); border-radius: 4px; padding: 8px 10px; min-height: 44px; width: 100%; max-width: 16em; margin-top: 8px; }
.trow input { margin-top: 0; flex: 1; }
.ask-row { display: flex; gap: 20px; margin-top: 4px; }
