/* Sundry Mill · the daily games (/games and /games/<slug>)
   Phone first on the site's own tokens. Each game brings a few colours of its
   app's look: Stepwise the printer's red, Lettercloth indigo floss and saffron,
   the number path a raspberry footpath. */

@font-face { font-family: 'Departure Mono'; src: url('/fonts/DepartureMono-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }

:root {
  --g-card: #FFFDF8;
  --g-good: #2D7A4B;
  --g-good-ink: #FFFFFF;
  --g-warn: #A8430B;
  --g-key: #EDE3D1;
  --g-shadow: 0 24px 60px -24px rgba(23, 32, 44, .45);
  /* Stepwise */
  --sw-accent: #B3261E;
  --sw-on: #FFFFFF;
  /* Lettercloth */
  --lc-cloth: #F3EBDC;
  --lc-hole: rgba(23, 32, 44, .1);
  --lc-indigo: #2E3F96;
  --lc-saffron: #E3A21A;
  --lc-madder: #B23A2A;
  /* the number path */
  --wf-path: #D2336A;
  --wf-on: rgba(210, 51, 106, .14);
  --wf-ground: #FFFDF8;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --g-card: #111A2E;
    --g-good: #5CC489;
    --g-good-ink: #0B1120;
    --g-warn: #FFB26B;
    --g-key: #1B2740;
    --g-shadow: 0 24px 60px -20px rgba(0, 0, 0, .7);
    --sw-accent: #FF8A78;
    --sw-on: #0B1120;
    --lc-cloth: #151F3A;
    --lc-hole: rgba(242, 234, 220, .12);
    --lc-indigo: #8C9DFF;
    --lc-saffron: #F2BD4B;
    --lc-madder: #FF7F6B;
    --wf-path: #FF6E9C;
    --wf-on: rgba(255, 110, 156, .16);
    --wf-ground: #111A2E;
  }
}
:root[data-theme="dark"] {
  --g-card: #111A2E;
  --g-good: #5CC489;
  --g-good-ink: #0B1120;
  --g-warn: #FFB26B;
  --g-key: #1B2740;
  --g-shadow: 0 24px 60px -20px rgba(0, 0, 0, .7);
  --sw-accent: #FF8A78;
  --sw-on: #0B1120;
  --lc-cloth: #151F3A;
  --lc-hole: rgba(242, 234, 220, .12);
  --lc-indigo: #8C9DFF;
  --lc-saffron: #F2BD4B;
  --lc-madder: #FF7F6B;
  --wf-path: #FF6E9C;
  --wf-on: rgba(255, 110, 156, .16);
  --wf-ground: #111A2E;
}

/* ------------------------------------------------------------------ the game page: one locked screen */
/* Built like Wordle, Connections and Strands on a phone: the site's header is
   not there, the game's own slim bar is, and the page never scrolls, so a drag
   on the board never moves it, the browser's bars stay put, and there is no pull
   to refresh or rubber band (ui.js stops the drags the browser would still turn
   into a page drag). Body is fixed to the window (inset 0 follows the phone's
   browser bars as they come and go) and the board takes what is left under the
   bar. Pinch zoom still works: touch-action: manipulation only stops the double
   tap zoom. */
html[data-shell="game"] { --bar-h: 52px; height: 100%; overflow: hidden; overscroll-behavior: none; }
html[data-shell="game"] body {
  position: fixed; inset: 0;
  overflow: hidden; overscroll-behavior: none;
  display: flex; flex-direction: column;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
html[data-shell="game"] main { flex: 1 1 auto; min-height: 0; display: flex; overflow: hidden; }

/* the slim top bar: the menu, the name (and the number where it fits), ? and Stats */
.gt {
  flex: none; position: relative; z-index: 2; display: flex; align-items: center; gap: 2px;
  height: calc(var(--bar-h) + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
  padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right));
  background: var(--paper); border-bottom: 1px solid var(--line); color: var(--text);
}
.gt-titles { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 8px; padding-left: 2px; white-space: nowrap; overflow: hidden; }
.gt-title {
  flex: none; font: 800 1.3125rem/1.1 var(--display);
  font-variation-settings: 'opsz' 96; letter-spacing: -.02em;
}
.gt-sub { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: .8125rem; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.gt-date { display: none; }
.gt-tools { display: flex; flex: none; }
.gt-icon {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer;
}
.gt-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .gt-icon:hover { background: color-mix(in srgb, currentColor 10%, transparent); } }
.gt-icon:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
/* a 320 wide phone: the number goes to the stats sheet, where it always is */
@media (max-width: 359px) { .gt-sub { display: none; } }
@media (min-width: 760px) {
  .gt { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .gt-date { display: inline; }
}

/* the play column: status, the board (all the space left), the message line, then the dock */
.gm {
  position: relative; flex: 1 1 auto; min-height: 0; width: 100%; max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: 8px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.gm-play { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.gm-stage { flex: 1 1 auto; min-height: 0; container-type: size; display: grid; place-items: center; }
.gm-dock { flex: none; padding: 8px 0 max(12px, env(safe-area-inset-bottom)); }
.gm-status {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 34px; padding: 4px 0; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: .9375rem; line-height: 1.3; color: var(--text-2);
}
.gm-status b { color: var(--text); font-variant-numeric: tabular-nums; }
.gm-status { flex-wrap: wrap; row-gap: 2px; }
.lc-cloth:focus { outline: none; }
.gm-msg { flex: none; min-height: 1.5em; margin: 6px 0 0; line-height: 1.5; text-align: center; font-weight: 600; font-size: .9375rem; color: var(--text-2); text-wrap: balance; }
.gm-msg[data-tone="warn"] { color: var(--g-warn); }
.gm-msg[data-tone="good"] { color: var(--g-good); }
/* once the day is done, the end bar says it */
.gm[data-done] .gm-msg { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gm-actions { display: flex; justify-content: center; gap: 10px; }
.gm-actions .btn { min-height: 46px; padding: 8px 18px; font-size: .9375rem; }
.gm .btn--line, .gm-dialog .btn--line { border-color: var(--line-strong); }
.gm-empty { padding: 48px 0; text-align: center; color: var(--text-2); font-weight: 600; }

/* the end bar, in place of the controls once the day's game is done */
.gm-end { display: grid; justify-items: center; gap: 2px; text-align: center; }
.gm-end-line { font-weight: 700; line-height: 1.35; text-wrap: balance; }
.gm-end-next { font-size: .875rem; color: var(--text-3); }
.gm-end-next time { font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.gm-end-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 8px; }
.gm-end-acts .btn { min-height: 46px; padding: 8px 18px; font-size: .9375rem; }
.gm-end-acts svg, .gm-share svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ Stepwise */
.sw-stage { display: block; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sw-ladder {
  --gap: 6px;
  --tile: clamp(30px, min((100cqw - 4 * var(--gap)) / 5, (100cqh - var(--rows, 4) * var(--gap)) / var(--rows, 4)), 58px);
  list-style: none; margin: 0; padding: 0; min-height: 100%;
  display: grid; justify-content: center; align-content: center; gap: var(--gap);
}
.sw-ladder:focus { outline: none; }
.sw-row { display: grid; grid-template-columns: repeat(5, var(--tile)); gap: 6px; }
.sw-tile {
  height: var(--tile); display: grid; place-items: center;
  border: 2px solid var(--line-strong); border-radius: 8px; background: var(--g-card);
  font: 700 calc(var(--tile) * .5)/1 var(--display); font-variation-settings: 'opsz' 72;
  color: var(--text);
}
.sw-row--start .sw-tile, .sw-row--goal .sw-tile { background: var(--text); border-color: var(--text); color: var(--paper); }
.sw-tile[data-mark="changed"] { background: var(--sw-accent); border-color: var(--sw-accent); color: var(--sw-on); }
.sw-row--done .sw-tile { background: var(--g-good); border-color: var(--g-good); color: var(--g-good-ink); }
.sw-row--done .sw-tile[data-mark="changed"] { box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .18); }
.sw-row--input .sw-tile { border-style: dashed; border-color: var(--text-3); background: transparent; }
.sw-row--input .sw-tile[data-mark="typed"], .sw-row--input .sw-tile[data-mark="typed-changed"] { border-style: solid; border-color: var(--line-strong); background: var(--g-card); }
.sw-row--input .sw-tile[data-mark="typed-changed"] { border-color: var(--sw-accent); color: var(--sw-accent); }
.sw-row--input .sw-tile[data-mark="cursor"] { border-color: var(--line-strong); }
.sw-row--input .sw-tile[data-mark="cursor"]::after { content: ''; width: 40%; height: 3px; border-radius: 2px; background: var(--text); margin-top: 45%; }
@media (prefers-reduced-motion: no-preference) {
  .sw-row--input .sw-tile[data-mark="cursor"]::after { animation: sw-blink 1.1s steps(2, start) infinite; }
  .sw-row.is-shaking { animation: sw-shake .4s var(--ease-io); }
}
@keyframes sw-blink { to { visibility: hidden; } }
@keyframes sw-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
[data-status="lost"] .sw-row--goal .sw-tile { opacity: .5; }
.sw-gap {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: calc(var(--tile) * .6);
  font-size: .8125rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3);
}
.sw-gap::before, .sw-gap::after { content: ''; flex: 1; max-width: 60px; border-top: 2px dotted var(--line-strong); opacity: .5; }

.sw-keys { display: grid; gap: 6px; margin: 0 -8px; user-select: none; -webkit-user-select: none; }
.sw-keys[data-done] { display: none; }
.sw-keyrow { display: flex; justify-content: center; gap: 5px; }
.sw-key {
  flex: 1 1 0; min-width: 0; max-width: 48px; height: clamp(42px, 6.6dvh, 58px);
  display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 8px; background: var(--g-key); color: var(--text);
  font: 700 1.0625rem/1 var(--sans); cursor: pointer; touch-action: manipulation;
}
.sw-key:active { background: var(--line-strong); color: var(--paper); }
.sw-key--wide { flex: 1.6 1 0; max-width: 72px; font-size: .8125rem; }
.sw-key svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sw-reveal p { font-weight: 700; margin-bottom: 6px; }
.sw-reveal ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.sw-reveal li { padding: 4px 8px; border-radius: 6px; background: var(--paper-2); font: 700 .9375rem/1.2 var(--display); letter-spacing: .06em; }
.sw-reveal li + li::before { content: ''; }

/* ------------------------------------------------------------------ Lettercloth */
.lc-clue {
  flex: none; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; margin-bottom: 4px; padding: 6px 12px;
  border-left: 4px solid var(--lc-indigo); border-radius: 4px 12px 12px 4px; background: var(--g-card);
}
.lc-clue-k { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.lc-clue-t { font: 600 italic 1.1875rem/1.25 var(--display); font-variation-settings: 'opsz' 48; }
.lc-loose { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.gm--lettercloth [data-status] { white-space: nowrap; }
.lc-loose-k { font-size: .8125rem; color: var(--text-3); }
.lc-knots { display: inline-flex; gap: 5px; }
.lc-knot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--lc-madder); position: relative; }
.lc-knot[data-used] { background: var(--lc-madder); }
.lc-knot[data-used]::after { content: ''; position: absolute; inset: 2px; background: linear-gradient(45deg, transparent 42%, var(--paper) 42% 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, var(--paper) 42% 58%, transparent 58%); }
.lc-trace {
  flex: none; height: 2.1rem; margin: 0 0 4px; text-align: center;
  font: 400 1.5rem/2.1rem 'Departure Mono', ui-monospace, monospace; letter-spacing: .12em; color: var(--lc-madder);
}
[data-status="won"] ~ .lc-trace, .lc-trace[data-empty="1"] { color: var(--text-3); font-size: 1.125rem; }
.lc-frame {
  position: relative; width: min(100cqw, 75cqh, 440px); aspect-ratio: 6 / 8; container-type: inline-size;
  border-radius: 14px; background: var(--lc-cloth);
  box-shadow: inset 0 0 0 2px var(--line-strong), inset 0 0 0 7px var(--lc-cloth), inset 0 0 0 8px var(--line);
}
.lc-cloth, .lc-threads { position: absolute; inset: 0; width: 100%; height: 100%; }
.lc-threads { z-index: 0; pointer-events: none; overflow: visible; }
.lc-cloth {
  z-index: 1; display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); grid-template-rows: repeat(var(--rows, 8), minmax(0, 1fr));
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.lc-cell {
  display: grid; place-items: center; padding: 0; border: 0; background: none; color: var(--text); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lc-cell span {
  width: 72%; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: transparent; border: 2px solid transparent;
  font: 400 clamp(.875rem, 8.4cqw, 1.75rem)/1 'Departure Mono', ui-monospace, monospace; text-transform: uppercase;
  transition: background-color .15s, color .15s, transform .25s var(--ease);
}
.lc-cell:disabled { cursor: default; color: var(--text); }
.lc-cell:focus-visible { outline: none; }
.lc-cell:focus-visible span { outline: 3px solid var(--focus); outline-offset: 2px; }
.lc-cell[data-kind="theme"] span { background: var(--lc-indigo); color: #fff; }
.lc-cell[data-kind="spangram"] span { background: var(--lc-saffron); color: #17202C; }
.lc-cell[data-trace] span { background: var(--lc-madder); color: #fff; }
.lc-cell[data-revealed] span { background: transparent; color: var(--text); border: 2px dashed currentColor; }
.lc-cell[data-revealed][data-kind="theme"] span { border-color: var(--lc-indigo); }
.lc-cell[data-revealed][data-kind="spangram"] span { border-color: var(--lc-saffron); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lc-cell[data-kind="theme"] span, :root:not([data-theme="light"]) .lc-cell[data-trace] span { color: #0B1120; }
}
:root[data-theme="dark"] .lc-cell[data-kind="theme"] span, :root[data-theme="dark"] .lc-cell[data-trace] span { color: #0B1120; }
@media (prefers-reduced-motion: no-preference) {
  .lc-cell[data-flash] span { transform: scale(1.14); }
}
.lc-line { fill: none; stroke-width: .3; stroke-linecap: round; stroke-linejoin: round; }
.lc-line--theme { stroke: var(--lc-indigo); }
.lc-line--span { stroke: var(--lc-saffron); }
.lc-line--trace { stroke: var(--lc-madder); stroke-width: .24; }
.lc-line--reveal { opacity: .45; stroke-dasharray: .18 .16; stroke-width: .16; }

/* ------------------------------------------------------------------ the number path */
.wf-time b { font: 700 1.125rem/1 var(--sans); font-variant-numeric: tabular-nums; }
.wf-time { display: inline-flex; align-items: baseline; gap: 10px; }
.wf-size { font-size: .8125rem; font-weight: 600; color: var(--text-3); }
.wf-frame { position: relative; width: min(100cqw, 100cqh, 520px); aspect-ratio: 1; }
.wf-map, .wf-paths { position: absolute; inset: 0; width: 100%; height: 100%; }
.wf-map {
  display: grid; grid-template-columns: repeat(var(--n, 6), minmax(0, 1fr)); grid-template-rows: repeat(var(--n, 6), minmax(0, 1fr));
  border-radius: 10px; overflow: hidden; outline: 2px solid var(--line-strong); outline-offset: 0;
  background: var(--line); gap: 1px;
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer;
}
.wf-map:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.wf-cell { background: var(--wf-ground); transition: background-color .12s; }
.wf-cell[data-on] { background: color-mix(in srgb, var(--wf-path) 14%, var(--wf-ground)); }
.wf-cell[data-hole] { background: repeating-linear-gradient(45deg, var(--paper) 0 6px, var(--paper-2) 6px 12px); }
.wf-paths { pointer-events: none; overflow: visible; }
.wf-wall { stroke: var(--text); stroke-width: .12; stroke-linecap: round; }
.wf-path { fill: none; stroke: var(--wf-path); stroke-width: .32; stroke-linecap: round; stroke-linejoin: round; }
.wf-headdot { fill: var(--paper); stroke: var(--wf-path); stroke-width: .08; }
.wf-num { fill: var(--text); }
.wf-num--on { fill: var(--wf-path); }
.wf-numt { fill: var(--paper); font: 700 .36px/1 var(--sans); text-anchor: middle; }
[data-status="won"] .wf-cell[data-on] { background: color-mix(in srgb, var(--g-good) 16%, var(--wf-ground)); }

/* ------------------------------------------------------------------ sheets: How to play, Your stats, the menu */
/* A card in the middle on wide screens, a sheet from the bottom on phones that
   can reach nearly the full height. The header row (the label and the close X)
   never scrolls and nothing sits over it; only the part under it scrolls. */
.gm-dialog {
  width: calc(100% - 32px); max-width: 460px; max-height: calc(100% - 48px);
  margin: auto; padding: 0; border: 0; border-radius: 20px;
  background: var(--paper); color: var(--text); box-shadow: var(--g-shadow);
  overflow: hidden; overscroll-behavior: contain;
}
.gm-dialog[open] { display: flex; flex-direction: column; }
.gm-dialog::backdrop { background: rgba(11, 17, 32, .5); }
@media (prefers-reduced-motion: no-preference) {
  .gm-dialog[open] { animation: gm-up .3s var(--ease); }
}
@keyframes gm-up { from { opacity: 0; transform: translateY(18px); } }
.gm-sheet-head {
  flex: none; position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 56px; margin: 0; padding: 6px 6px 0 20px; background: var(--paper);
}
.gm-dialog-in { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 20px 24px; }
.gm-dialog-in:focus { outline: none; }
.gm-close {
  flex: none; width: 48px; height: 48px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--text); cursor: pointer;
  touch-action: manipulation;
}
@media (hover: hover) { .gm-close:hover { background: var(--paper-2); } }
.gm-close:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.gm-close svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; pointer-events: none; }
@media (max-width: 599px) {
  .gm-dialog:not(.gm-drawer) {
    width: 100%; max-width: none; max-height: calc(100% - max(12px, env(safe-area-inset-top)));
    margin: auto 0 0; border-radius: 22px 22px 0 0;
  }
  .gm-dialog:not(.gm-drawer) .gm-sheet-head { border-radius: 22px 22px 0 0; }
  .gm-dialog-in { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
  @media (prefers-reduced-motion: no-preference) {
    .gm-dialog[open]:not(.gm-drawer) { animation: gm-sheet .32s var(--ease); }
  }
}
@keyframes gm-sheet { from { transform: translateY(100%); } }
.gm-kicker { min-width: 0; font-size: .8125rem; font-weight: 700; line-height: 1.35; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); text-wrap: balance; }
.gm-h2 { margin-top: 0; font: 800 1.75rem/1.1 var(--display); font-variation-settings: 'opsz' 96; letter-spacing: -.02em; }

/* the menu: a drawer from the left, the full height of the screen */
.gm-drawer {
  width: min(330px, calc(100% - 48px)); max-width: none; height: 100%; max-height: none;
  margin: 0 auto 0 0; border-radius: 0 20px 20px 0;
  padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left);
}
@media (prefers-reduced-motion: no-preference) {
  .gm-drawer[open] { animation: gm-drawer .3s var(--ease); }
}
@keyframes gm-drawer { from { transform: translateX(-100%); } }
.gm-drawer .gm-sheet-head { padding-left: 14px; }
.gm-drawer-home { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); text-decoration: none; font: 800 1.1875rem/1 var(--display); letter-spacing: -.01em; }
.gm-drawer-home .bar-mark { width: 34px; height: 34px; }
.gm-drawer-in { padding: 0 12px max(20px, env(safe-area-inset-bottom)); }
.gm-drawer-k { margin: 14px 10px 6px; font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.gm-drawer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.gm-drawer-list a {
  display: flex; flex-direction: column; justify-content: center; min-height: 48px; padding: 6px 10px; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.0625rem;
}
.gm-drawer-list a:hover { background: color-mix(in srgb, var(--text) 7%, transparent); text-decoration: none; }
.gm-drawer-list a[aria-current] { background: color-mix(in srgb, var(--sun-hot) 18%, transparent); }
.gm-drawer-kind { font-size: .8125rem; font-weight: 600; color: var(--text-3); }
.gm-drawer-theme {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; margin-top: 14px; padding: 0 10px;
  border: 0; border-top: 1px solid var(--line); border-radius: 0; background: none; color: var(--text); font: 700 1rem/1 var(--sans); cursor: pointer;
}
.gm-drawer-theme svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.gm-drawer-theme .t-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gm-drawer-theme .t-moon { display: block; }
  :root:not([data-theme="light"]) .gm-drawer-theme .t-sun { display: none; }
}
:root[data-theme="dark"] .gm-drawer-theme .t-moon { display: block; }
:root[data-theme="dark"] .gm-drawer-theme .t-sun { display: none; }
.gm-drawer .gm-foot { margin: 8px 10px 0; }
.gm-h3 { margin: 22px 0 10px; font: 700 1rem/1.3 var(--sans); }
.gm-line { margin-top: 8px; font-weight: 600; color: var(--text-2); }
.gm-reveal { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--g-card); border: 1px solid var(--line); }
.gm-rules { margin: 14px 0 0; padding-left: 1.2em; display: grid; gap: 8px; color: var(--text-2); }
.gm-rules li::marker { color: var(--accent-text); }
.gm-note { margin-top: 14px; font-size: .9375rem; color: var(--text-3); }
.gm-wide { width: 100%; margin-top: 18px; }
/* Under Play: one puzzle a day here, more in the app. One quiet line. */
.gm-app-line { margin-top: 10px; text-align: center; font-size: .875rem; line-height: 1.4; color: var(--text-3); }
.gm-app-line a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.gm-stats { margin: 18px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.gm-stats div { display: flex; flex-direction: column-reverse; gap: 4px; }
.gm-stats dt { font-size: .75rem; line-height: 1.2; color: var(--text-3); font-weight: 600; }
.gm-stats dd { margin: 0; font: 700 1.875rem/1 var(--display); font-variant-numeric: tabular-nums; }

.gm-dist { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.gm-dist li { display: grid; grid-template-columns: 4.6rem 1fr; align-items: center; gap: 8px; font-size: .875rem; }
.gm-dist-label { text-align: right; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.gm-dist-bar {
  width: var(--w); min-width: 26px; padding: 3px 8px; border-radius: 5px; background: var(--text-3); color: var(--paper);
  text-align: right; font-weight: 700; font-variant-numeric: tabular-nums;
}
.gm-dist li[data-today] .gm-dist-bar { background: var(--sun-hot); color: #17202C; }
.gm-after { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.gm-next { font-size: .9375rem; color: var(--text-2); }
.gm-next time { display: block; font: 700 1.5rem/1.1 var(--sans); color: var(--text); font-variant-numeric: tabular-nums; }

.gm-save { margin-top: 20px; padding: 16px; border-radius: 14px; background: var(--g-card); border: 1px solid var(--line); }
.gm-save .gm-h3 { margin-top: 0; margin-bottom: 4px; }
.gm-save-lede { font-size: .9375rem; color: var(--text-2); }
.gm-save-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.gm-input {
  flex: 1 1 200px; min-width: 0; min-height: 48px; padding: 10px 14px;
  border: 2px solid var(--line-strong); border-radius: 12px; background: var(--field); color: var(--text);
}
.gm-input:focus { outline: 3px solid var(--focus); outline-offset: 1px; }
.gm-save-row .btn { flex: 1 1 auto; }
.gm-consent { margin-top: 8px; font-size: .875rem; line-height: 1.45; color: var(--text-2); }
.gm-save-status { margin-top: 6px; font-size: .875rem; font-weight: 600; min-height: 1.2em; }
.gm-save-status[data-kind="error"] { color: var(--g-warn); }
.gm-save-status[data-kind="ok"] { color: var(--g-good); }

.gm-more { margin-top: 20px; padding-top: 4px; border-top: 2px solid var(--line-strong); }
.gm-more p { color: var(--text-2); }
.gm-stores { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.gm-stores svg { width: 20px; height: 20px; }
.gm-soon { margin-top: 10px; font-weight: 700; color: var(--text) !important; }

/* ------------------------------------------------------------------ About, in the How to play sheet */
.gm-about { margin-top: 24px; padding-top: 2px; border-top: 2px solid var(--line-strong); }
.gm-about .gm-h3 { margin-top: 18px; }
.gm-about p { margin-top: 10px; color: var(--text-2); }
.gm-more-games { margin-top: 14px !important; font-weight: 600; }
.gm-foot { margin-top: 20px; font-size: .875rem; color: var(--text-3); }

/* ------------------------------------------------------------------ phones on their side */
/* Too short for a board over a keyboard: the board on the left, the controls on the right. */
@media (orientation: landscape) and (max-height: 520px) {
  html[data-shell="game"] { --bar-h: 48px; }
  .gm {
    max-width: 980px; display: grid; column-gap: 24px;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 46%);
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    grid-template-areas: "stage clue" "stage status" "stage trace" "stage msg" "stage dock";
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .gm-play { display: contents; }
  .gm-stage { grid-area: stage; }
  .lc-clue { grid-area: clue; }
  .gm-status { grid-area: status; }
  .lc-trace { grid-area: trace; }
  .gm-msg { grid-area: msg; }
  .gm-dock { grid-area: dock; align-self: center; padding-top: 4px; }
  .sw-key { height: clamp(34px, 10.5dvh, 46px); }
}

/* ------------------------------------------------------------------ the hub */
.gh { padding: calc(var(--bar-h) + 28px) var(--gutter) clamp(56px, 8vw, 104px); background: linear-gradient(180deg, var(--paper) 0, var(--paper) 55%, var(--paper-2) 100%); }
.gh-in { max-width: 1120px; margin: 0 auto; }
.gh-title {
  font: 800 clamp(2.375rem, 1.3rem + 4.6vw, 4.75rem)/.98 var(--display);
  font-variation-settings: 'opsz' 144; letter-spacing: -.035em; text-wrap: balance; max-width: 15ch;
}
.gh-lede { margin-top: 16px; max-width: 40rem; font-size: clamp(1.0625rem, 1rem + .35vw, 1.3125rem); color: var(--text-2); text-wrap: pretty; }
.gh-list { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 760px) { .gh-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
.gh-card { min-width: 0; }
.gh-link {
  height: 100%; display: flex; flex-direction: column; text-decoration: none; color: var(--text);
  border: 2px solid var(--line-strong); border-radius: 20px; overflow: hidden; background: var(--g-card);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.gh-link:hover { text-decoration: none; transform: translateY(-3px); box-shadow: var(--g-shadow); }
.gh-pic { display: block; padding: 14px; border-bottom: 2px solid var(--line-strong); }
.gh-card--stepwise .gh-pic { background: color-mix(in srgb, var(--sw-accent) 12%, var(--g-card)); }
.gh-card--lettercloth .gh-pic { background: var(--lc-cloth); }
.gh-pic:has(> .gh-art--path) { background: color-mix(in srgb, var(--wf-path) 10%, var(--g-card)); }
.gh-art { width: 100%; height: auto; max-height: 170px; margin: 0 auto; }
.gh-body { display: flex; flex-direction: column; gap: 6px; padding: 18px 18px 20px; flex: 1; }
.gh-kind { font-size: .8125rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
.gh-name { font: 800 1.875rem/1 var(--display); font-variation-settings: 'opsz' 96; letter-spacing: -.02em; }
.gh-line { color: var(--text-2); }
.gh-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; font-size: .875rem; font-weight: 700; color: var(--text-3); }
[data-status="won"] .gh-status { color: var(--g-good); }
.gh-streak { color: var(--accent-text); }
.gh-cta { align-self: flex-start; margin-top: auto; translate: 0 6px; }
.gh-link:hover .gh-cta { transform: none; box-shadow: none; }
.gh-foot { margin-top: 28px; font-size: .9375rem; color: var(--text-3); max-width: 46rem; }

/* the hub pictures */
.gh-tile { fill: var(--g-card); stroke: var(--line-strong); stroke-width: 2; }
.gh-tile--ink { fill: var(--text); stroke: var(--text); }
.gh-tile--mark { fill: var(--sw-accent); stroke: var(--sw-accent); }
.gh-t { font: 700 14px/1 var(--display); text-anchor: middle; fill: var(--text); }
.gh-t--ink { fill: var(--paper); }
.gh-t--mark { fill: var(--sw-on); }
.gh-t--small { font: 400 12px/1 'Departure Mono', ui-monospace, monospace; }
.gh-t--on { fill: #fff; }
.gh-dot { fill: transparent; }
.gh-dot--theme { fill: var(--lc-indigo); }
.gh-dot--span { fill: var(--lc-saffron); }
.gh-dot--span + .gh-t--on { fill: #17202C; }
.gh-thread { fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.gh-thread--theme { stroke: var(--lc-indigo); }
.gh-thread--span { stroke: var(--lc-saffron); }
.gh-sq { fill: var(--wf-ground); stroke: var(--line); stroke-width: 1; }
.gh-route { fill: none; stroke: var(--wf-path); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.gh-num { fill: var(--text); }
.gh-t--num { font: 700 10px/1 var(--sans); fill: var(--paper); }

@media (min-width: 900px) {
  .gm { padding-top: 14px; }
  .gm-dialog:not(.gm-drawer) .gm-dialog-in { padding: 2px 26px 28px; }
  .gm-dialog:not(.gm-drawer) .gm-sheet-head { padding-left: 26px; }
}

/* ------------------------------------------------------------------ short phones (an SE, or any phone with its browser bars out) */
/* Every line above and below the board gives up a little height so the board keeps it. */
@media (max-height: 640px) and (orientation: portrait) {
  .gm { padding-top: 4px; }
  .gm-status { min-height: 0; margin-bottom: 4px; padding: 2px 0; font-size: .875rem; }
  .lc-clue { padding: 4px 10px; margin-bottom: 2px; }
  .lc-clue-k { font-size: .6875rem; }
  .lc-clue-t { font-size: 1.0625rem; }
  .lc-trace { height: 1.6rem; line-height: 1.6rem; font-size: 1.25rem; margin-bottom: 2px; }
  .gm-msg { min-height: 1.3em; margin-top: 2px; font-size: .875rem; line-height: 1.3; }
  .gm-dock { padding-top: 4px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .gm-actions .btn, .gm-end-acts .btn { min-height: 44px; padding: 6px 16px; }
  .gm-end-acts { margin-top: 4px; }
  .gm-end-next { font-size: .8125rem; }
}

/* ================================================================== phase 2 games (13 Oct 2026) */
/* Kept in a block of their own at the foot of the file. The names of games that
   are switched off never appear in deployed files, so these two are "the star
   battle" (nc-) and "the binary puzzle" (pw-) here. */

/* ------------------------------------------------------------------ the star battle */
/* The app's star atlas: navy ink, gold leaf stars, each region a pigment wash
   with a heavy ink border, so regions read by their outline and not by colour
   alone. In the dark the washes sink into the night sky, as the app's Night look does. */
:root {
  --nc-ink: #1D2742; --nc-night: #0F1528; --nc-sink: 0%; --nc-grid: #A5A6AD;
  --nc-gold: #C99A3E; --nc-starline: #1D2742; --nc-bad: #A23B2A;
  /* the binary puzzle: the app's Linen chart and its Madder yarn */
  --pw-chart: #FCFBF8; --pw-line: #BCCAD0; --pw-edge: #2D2832; --pw-printed: #E7E2D8; --pw-ink: #2D2832;
  --pw-knit: #B5452F; --pw-knit-edge: #6D291C; --pw-purl: #E7C3BC; --pw-purl-edge: #883423; --pw-bad: #B3261E;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --nc-ink: #EDE4D0; --nc-sink: 68%; --nc-grid: #40435A;
    --nc-gold: #E3BE6E; --nc-starline: #0F1528; --nc-bad: #E0806C;
    --pw-chart: #211E25; --pw-line: #3B4650; --pw-edge: #EFE9DF; --pw-printed: #302C35; --pw-ink: #EFE9DF;
    --pw-knit: #C56E5D; --pw-knit-edge: #762D1F; --pw-purl: #64302A; --pw-purl-edge: #D6998D; --pw-bad: #F08A7E;
  }
}
:root[data-theme="dark"] {
  --nc-ink: #EDE4D0; --nc-sink: 68%; --nc-grid: #40435A;
  --nc-gold: #E3BE6E; --nc-starline: #0F1528; --nc-bad: #E0806C;
  --pw-chart: #211E25; --pw-line: #3B4650; --pw-edge: #EFE9DF; --pw-printed: #302C35; --pw-ink: #EFE9DF;
  --pw-knit: #C56E5D; --pw-knit-edge: #762D1F; --pw-purl: #64302A; --pw-purl-edge: #D6998D; --pw-bad: #F08A7E;
}
/* the ten washes, picked in the app to stay apart for colour blind eyes too */
.nc-g0, .gh-sky--0 { --nc-w: #E3C89D; }
.nc-g1, .gh-sky--1 { --nc-w: #7E9DC9; }
.nc-g2, .gh-sky--2 { --nc-w: #F3DBF2; }
.nc-g3, .gh-sky--3 { --nc-w: #6BA793; }
.nc-g4, .gh-sky--4 { --nc-w: #ACDAF2; }
.nc-g5 { --nc-w: #95A073; }
.nc-g6 { --nc-w: #DDC0BA; }
.nc-g7 { --nc-w: #B2B5CA; }
.nc-g8 { --nc-w: #DDE7C4; }
.nc-g9 { --nc-w: #5DA6AE; }

.nc-shape, .pw-shape { margin-left: 6px; font-size: .8125rem; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.nc-wrong, .pw-dropped { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.nc-wrong-k, .pw-dropped-k { font-size: .8125rem; color: var(--text-3); }
.nc-pips, .pw-pips { display: inline-flex; gap: 5px; }
.nc-pip, .pw-pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--nc-bad); position: relative; }
.pw-pip { border-color: var(--pw-bad); }
.nc-pip[data-used] { background: var(--nc-bad); }
.pw-pip[data-used] { background: var(--pw-bad); }
.nc-pip[data-used]::after, .pw-pip[data-used]::after { content: ''; position: absolute; inset: 2px; background: linear-gradient(45deg, transparent 42%, var(--paper) 42% 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, var(--paper) 42% 58%, transparent 58%); }

.nc-frame { position: relative; width: min(100cqw, 100cqh, 520px); aspect-ratio: 1; border-radius: 6px; background: var(--nc-ink); }
.nc-chart, .nc-lines { position: absolute; inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px); }
.nc-chart {
  display: grid; grid-template-columns: repeat(var(--n, 7), minmax(0, 1fr)); grid-template-rows: repeat(var(--n, 7), minmax(0, 1fr)); gap: 1px;
  background: var(--nc-grid);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.nc-chart:focus { outline: none; }
.nc-cell {
  min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0; cursor: pointer;
  background-color: color-mix(in srgb, var(--nc-w) calc(100% - var(--nc-sink)), var(--nc-night));
  -webkit-tap-highlight-color: transparent;
}
.nc-cell:disabled { cursor: default; }
.nc-cell:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
/* a closed cell (a wrong star was tried there) is hatched as well as tinted */
.nc-cell[data-v="wrong"] { background-image: repeating-linear-gradient(45deg, transparent 0 5px, color-mix(in srgb, var(--nc-bad) 45%, transparent) 5px 7px); cursor: default; }
/* the lines and marks lie over the cells, a focused cell included */
.nc-lines { z-index: 2; pointer-events: none; overflow: visible; }
.nc-edge { fill: none; stroke: var(--nc-ink); stroke-width: 3px; vector-effect: non-scaling-stroke; stroke-linecap: square; }
.nc-star { fill: var(--nc-gold); stroke: var(--nc-starline); stroke-width: 1.5px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.nc-star--wrong { fill: var(--nc-bad); }
.nc-strike { stroke: var(--nc-ink); stroke-width: 2.5px; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.nc-star--reveal { fill: none; stroke: var(--nc-ink); stroke-dasharray: 3 2.5; }
.nc-x { fill: none; stroke: var(--nc-ink); stroke-width: 2px; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.nc-dot { fill: var(--nc-ink); opacity: .45; }

/* ------------------------------------------------------------------ the binary puzzle */
/* The knitting chart of the app: a knit is a V and a purl a short curved bar
   (shape and outline, never colour alone), printed stitches sit on shaded cells
   in print colour, and the stitches the player works are in yarn. */
.pw-frame { position: relative; width: min(100cqw, 100cqh, 520px); aspect-ratio: 1; border-radius: 9px; background: var(--pw-edge); }
.pw-chart, .pw-stitches { position: absolute; inset: 2px; width: calc(100% - 4px); height: calc(100% - 4px); }
.pw-chart {
  display: grid; grid-template-columns: repeat(var(--n, 8), minmax(0, 1fr)); grid-template-rows: repeat(var(--n, 8), minmax(0, 1fr)); gap: 1px;
  border-radius: 7px; overflow: hidden; background: var(--pw-line);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.pw-chart:focus { outline: none; }
.pw-cell { min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0; background: var(--pw-chart); cursor: default; -webkit-tap-highlight-color: transparent; }
.pw-cell[data-open]:not(:disabled) { cursor: pointer; }
.pw-cell[data-given] { background: var(--pw-printed); }
.pw-cell[data-dropped] { background: color-mix(in srgb, var(--pw-bad) 18%, var(--pw-chart)); }
.pw-cell:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.pw-stitches { z-index: 2; pointer-events: none; }
.pw-st { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pw-st-edge.pw-st--knit { stroke-width: .19; }
.pw-st-fill.pw-st--knit { stroke-width: .091; }
.pw-st-edge.pw-st--purl { stroke-width: .2; }
.pw-st-fill.pw-st--purl { stroke-width: .101; }
.pw-st--yarn.pw-st--knit.pw-st-edge { stroke: var(--pw-knit-edge); }
.pw-st--yarn.pw-st--knit.pw-st-fill { stroke: var(--pw-knit); }
.pw-st--yarn.pw-st--purl.pw-st-edge { stroke: var(--pw-purl-edge); }
.pw-st--yarn.pw-st--purl.pw-st-fill { stroke: var(--pw-purl); }
.pw-st--print.pw-st-edge, .pw-st--print.pw-st--knit.pw-st-fill { stroke: var(--pw-ink); }
.pw-st--print.pw-st--purl.pw-st-fill { stroke: var(--pw-printed); }
.pw-st--ghost.pw-st-edge { stroke: var(--pw-ink); stroke-width: .045; stroke-dasharray: .08 .07; opacity: .65; }
.pw-drop { fill: none; stroke: var(--pw-bad); stroke-width: .055; stroke-linecap: round; }

/* the stitch picker: which stitch a tap works */
.pw-tools { align-items: stretch; }
.pw-pick { display: inline-flex; border: 2px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.pw-pick-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px 0 8px;
  border: 0; border-radius: 0; background: none; color: var(--text); font: 700 .9375rem/1 var(--sans); cursor: pointer; touch-action: manipulation;
}
.pw-pick-btn + .pw-pick-btn { border-left: 2px solid var(--line-strong); }
.pw-pick-btn[aria-checked="true"] { background: var(--text); color: var(--paper); }
.pw-pick-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: -4px; }
.pw-pick-st { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--pw-chart); }
.gm-actions .btn:disabled { opacity: .45; cursor: default; }

/* ------------------------------------------------------------------ their pictures on the hub */
.gh-pic:has(> .gh-art--stars) { background: color-mix(in srgb, var(--nc-gold) 16%, var(--g-card)); }
.gh-sky { fill: color-mix(in srgb, var(--nc-w) calc(100% - var(--nc-sink)), var(--nc-night)); stroke: color-mix(in srgb, var(--nc-ink) 30%, transparent); stroke-width: .6; }
.gh-skyedge { fill: none; stroke: var(--nc-ink); stroke-width: 2.6; stroke-linecap: square; }
.gh-skydot { fill: var(--nc-ink); opacity: .45; }
.gh-star { fill: var(--nc-gold); stroke: var(--nc-starline); stroke-width: 5; stroke-linejoin: round; }
.gh-pic:has(> .gh-art--chart) { background: color-mix(in srgb, var(--pw-knit) 12%, var(--g-card)); }
.gh-ch { fill: var(--pw-chart); stroke: var(--pw-line); stroke-width: 1; }
.gh-ch--print { fill: var(--pw-printed); }
.gh-chedge { fill: none; stroke: var(--pw-edge); stroke-width: 2; }
.gh-st { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.gh-st--edge { stroke-width: 4.2; }
.gh-st--fill { stroke-width: 2; }
.gh-st--yarn.gh-st--knit.gh-st--edge { stroke: var(--pw-knit-edge); }
.gh-st--yarn.gh-st--knit.gh-st--fill { stroke: var(--pw-knit); }
.gh-st--yarn.gh-st--purl.gh-st--edge { stroke: var(--pw-purl-edge); }
.gh-st--yarn.gh-st--purl.gh-st--fill { stroke: var(--pw-purl); }
.gh-st--print.gh-st--edge, .gh-st--print.gh-st--knit.gh-st--fill { stroke: var(--pw-ink); }
.gh-st--print.gh-st--purl.gh-st--fill { stroke: var(--pw-printed); }
