@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/atkinson-400.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-style: normal; font-weight: 700; font-display: swap; src: url("/fonts/atkinson-700.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("/fonts/bricolage.woff2") format("woff2"); }
/* Layout idea: the board is the page. Quiet paper around it, one column on a phone,
   board left and reference panel right on a wide screen. Colour never works alone:
   every patch also has an animal, a name and a heavy outline. */
:root {
  --paper: #F6F1E9;
  --surface: #FFFDF9;
  --ink: #23302A;
  --ink-soft: #4F5B54;
  --line: rgba(35, 48, 42, 0.3);
  --accent: #4C6B58;
  --on-accent: #FFFDF9;
  --warm: #86572A;
  --clash: #A3341F;
  --chip: #E6D9C3;
  --g0: #BFD3C1; --g1: #B9D3E6; --g2: #D2C3E3; --g3: #E6C3A5;
  --g4: #EBDD9A; --g5: #EDBFC4; --g6: #A9D6D0; --g7: #D5D0C6;
  --display: "Bricolage Grotesque", "Trebuchet MS", "Segoe UI", sans-serif;
  --body: "Atkinson Hyperlegible", Verdana, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #1D2420; --surface: #28322C; --ink: #F3EEE4; --ink-soft: #C3CBC4;
    --line: rgba(243, 238, 228, 0.32); --accent: #9DC0AA; --on-accent: #17201B;
    --warm: #E0B184; --clash: #FFB4A0;
    --g0: #3F5A49; --g1: #36566F; --g2: #57457A; --g3: #7A5234;
    --g4: #6E6220; --g5: #7A4049; --g6: #2C635D; --g7: #55524B;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #1D2420; --surface: #28322C; --ink: #F3EEE4; --ink-soft: #C3CBC4;
  --line: rgba(243, 238, 228, 0.32); --accent: #9DC0AA; --on-accent: #17201B;
  --warm: #E0B184; --clash: #FFB4A0;
  --g0: #3F5A49; --g1: #36566F; --g2: #57457A; --g3: #7A5234;
  --g4: #6E6220; --g5: #7A4049; --g6: #2C635D; --g7: #55524B;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); font-size: 1.0625rem; line-height: 1.55;
}
.wrap { max-width: 62rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; display: grid; gap: 1.25rem; }
header { display: grid; gap: 0.25rem; }
.eyebrow { margin: 0; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--warm); }
h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(2.1rem, 9vw, 3.25rem); line-height: 1; letter-spacing: -0.02em; text-wrap: balance; }
.lede { margin: 0.35rem 0 0; max-width: 38rem; color: var(--ink-soft); }
h2 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.1875rem; }
.layout { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 56rem) { .layout { grid-template-columns: minmax(0, 34rem) minmax(0, 1fr); gap: 2.5rem; } }
.play, .side { display: grid; gap: 1rem; min-width: 0; }

/* Board */
.frame { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr); grid-template-rows: 1.25rem auto; }
.colnums, .rownums { display: grid; color: var(--ink-soft); font-size: 0.75rem; font-variant-numeric: tabular-nums; text-align: center; }
.colnums { grid-column: 2; grid-template-columns: repeat(var(--n), 1fr); }
.rownums { grid-row: 2; grid-template-rows: repeat(var(--n), 1fr); align-items: center; }
.board {
  grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  border: 3px solid var(--ink); border-radius: 0.75rem; overflow: hidden;
  container-type: inline-size; --u: calc(100cqw / var(--n));
}
.board.solved { border-color: var(--accent); }
.rowline { display: contents; }
.cell {
  position: relative; aspect-ratio: 1; display: grid; place-items: center;
  background: var(--tint); color: var(--ink);
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.cell.er { border-right: 3px solid var(--ink); }
.cell.eb { border-bottom: 3px solid var(--ink); }
.cell.lastc { border-right: 0; }
.cell.lastr { border-bottom: 0; }
.cell:focus { outline: none; }
.cell:focus-visible { outline: 4px solid var(--ink); outline-offset: -4px; box-shadow: inset 0 0 0 6px var(--surface); z-index: 2; }
.cell svg { display: block; fill: currentColor; }
.label { position: absolute; top: 7%; left: 9%; font-weight: 700; font-size: max(0.6875rem, calc(var(--u) * 0.2)); line-height: 1; pointer-events: none; }
.label svg { width: 100%; height: auto; }
.token {
  width: 76%; aspect-ratio: 1; display: grid; place-items: center;
  background: var(--chip); border: 2px solid var(--ink); border-radius: 30%;
}
.token svg { width: 82%; height: auto; }
.cross { width: 34%; }
.cross svg { width: 100%; height: auto; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; opacity: 0.8; }
.dot { width: 12%; aspect-ratio: 1; border-radius: 50%; background: currentColor; opacity: 0.45; }
.cell.clash .token { border: 3px dashed var(--clash); }
.badge {
  position: absolute; top: 5%; right: 5%; width: calc(var(--u) * 0.3); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; background: var(--clash); color: var(--paper);
  font-weight: 700; font-size: calc(var(--u) * 0.2); line-height: 1;
}
.cell.h-show::after, .cell.h-target::after { content: ""; position: absolute; inset: 4px; border-radius: 0.5rem; pointer-events: none; }
.cell.h-show::after { border: 3px dotted var(--ink); }
.cell.h-target::after { border: 4px solid var(--warm); box-shadow: 0 0 0 2px var(--surface); }

/* Controls */
button, select { font: inherit; color: inherit; }
.btn {
  min-height: 2.75rem; padding: 0.5rem 0.9rem; border-radius: 0.625rem;
  border: 2px solid var(--ink); background: var(--surface); cursor: pointer; font-weight: 700;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn:focus-visible, select:focus-visible, summary:focus-visible, input:focus-visible + span {
  outline: 3px solid var(--ink); outline-offset: 3px;
}
.tools { display: grid; gap: 0.75rem; }
.toolpick { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.toolpick legend { padding: 0; margin-bottom: 0.35rem; font-weight: 700; }
.toolpick label { display: block; cursor: pointer; }
.toolpick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toolpick span {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 3rem;
  padding: 0.5rem; border: 2px solid var(--ink); border-radius: 0.625rem; background: var(--surface); font-weight: 700;
}
.toolpick span svg { width: 1.6rem; height: 1.6rem; fill: currentColor; }
.toolpick span svg.x { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.toolpick input:checked + span { background: var(--ink); color: var(--paper); }
.toolpick input:checked + span::before { content: "\2713"; font-weight: 700; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.row .btn { flex: 1 1 auto; }
.status { background: var(--surface); border: 1px solid var(--line); border-radius: 0.75rem; padding: 0.85rem 1rem; display: grid; gap: 0.5rem; }
.status p { margin: 0; }
#progress { color: var(--ink-soft); }
.state { display: inline-flex; align-items: center; gap: 0.5rem; justify-self: start; padding: 0.3rem 0.8rem 0.3rem 0.4rem; border: 2px solid var(--ink-soft); border-radius: 999px; font-weight: 700; }
.stateicon { width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; border: 2px dotted var(--ink-soft); font-size: 0.95rem; line-height: 1; }
.state[data-state="solved"] { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.state[data-state="solved"] .stateicon { border: 2px solid var(--on-accent); }
.state[data-state="error"] { border-color: var(--clash); }
.state[data-state="error"] .stateicon { border: 0; background: var(--clash); color: var(--paper); }
.optgroup { border: 0; margin: 0.4rem 0; padding: 0; min-width: 0; }
.optgroup legend { padding: 0; font-weight: 700; }
.cell.clash .cross { color: var(--clash); }
#msg:empty { display: none; }
.status .btn { justify-self: start; }

.setup { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; align-items: end; }
.setup label { display: grid; gap: 0.25rem; font-weight: 700; }
.setup select { min-height: 2.75rem; padding: 0.4rem 0.6rem; border: 2px solid var(--ink); border-radius: 0.625rem; background: var(--surface); }
.setup .btn { grid-column: 1 / -1; }
.key { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.5rem; }
.key li { display: flex; align-items: center; gap: 0.55rem; }
.swatch { flex: none; width: 2.1rem; height: 2.1rem; border-radius: 0.5rem; border: 2px solid var(--ink); display: grid; place-items: center; background: var(--tint); }
.swatch svg { width: 1.6rem; height: 1.6rem; padding: 1px; border-radius: 30%; background: var(--surface); }
.key small { display: block; font-size: 0.8125rem; color: var(--ink-soft); }
.key .name { font-weight: 700; line-height: 1.2; }
details { border-top: 1px solid var(--line); padding-top: 0.75rem; }
summary { cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 1.1875rem; border-radius: 0.25rem; }
details > :not(summary) { max-width: 36rem; }
details ol, details ul { padding-left: 1.25rem; margin: 0.6rem 0; }
details li + li { margin-top: 0.35rem; }
details p { margin: 0.6rem 0; }
.opt { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.4rem 0; cursor: pointer; }
.opt input { flex: none; width: 1.35rem; height: 1.35rem; margin: 0.15rem 0 0; accent-color: var(--accent); }
kbd { font: inherit; font-weight: 700; padding: 0 0.3rem; border: 1px solid var(--line); border-radius: 0.3rem; background: var(--surface); }
.note { color: var(--ink-soft); font-size: 0.9375rem; margin: 0; }
.swatch { font-weight: 700; }
.pick { border: 0; margin: 0.6rem 0 0; padding: 0; min-width: 0; }
.pick legend { padding: 0; margin-bottom: 0.35rem; font-weight: 700; }
.pickrow { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.pickrow label { cursor: pointer; }
.pickrow input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pickrow label > span { position: relative; display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 30%; border: 2px solid var(--ink-soft); background: var(--chip); }
.pickrow svg { width: 1.9rem; height: 1.9rem; }
.pickrow input:checked + span { border: 3px solid var(--ink); }
.pickrow input:checked + span::after { content: "\2713"; position: absolute; right: -0.3rem; bottom: -0.3rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-size: 0.7rem; font-weight: 700; line-height: 1; }
.beta { margin: 0; padding: 0.6rem 0.9rem; border: 2px solid var(--warm); border-radius: 0.75rem; background: var(--surface); font-size: 0.9375rem; }
.beta a, .foot a, details a { color: inherit; text-decoration: underline; }
.foot { border-top: 1px solid var(--line); padding-top: 1rem; color: var(--ink-soft); font-size: 0.9375rem; }
.foot p { margin: 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
