/* Cam Across — a game page: the grid first, few controls, readable type. System fonts only.
   Colour comes in two layers: the neutral page tokens below (per theme), and the palette of the
   day (js/palette.js writes --accent, --a1…--a4 and the --hl-* tints into <style id="ca-palette">).
   A fallback palette follows the theme tokens. */
:root {
  color-scheme: light;
  --bg: #fffdf8;
  --fg: #202124;
  --muted: #5f6368;
  --line: #e7e0d2;
  --soft: #f5f0e6;
  --glyph: #8a8172;
  --paper: #ffffff;      /* a crossword tile: board cells, logo tiles, number tiles */
  --ink: #202124;
  --tline: #d8cfbd;      /* the hairline around a tile */
  --block: #24211d;      /* a black square */
  --block-line: #24211d;
  --wrong: #c5221f;
  --shadow: rgb(60 50 30 / 0.16);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* the logo's tile grid: the header, its buttons and the toolbar inset all sit on it */
  --t: 26px;
  --g: 2px;
  --bar-pad: 11px;
  --bar-h: calc(3 * var(--t) + 2 * var(--g) + 2 * var(--bar-pad));
  --bar-drop: 28px;      /* how far a band scene's glyph field reaches below the header (a full-page scene has no such edge) */
  --gutter: 16px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1f1d1a;
  --fg: #ede8df;
  --muted: #b0a898;
  --line: #3b3731;
  --soft: #2a2723;
  --glyph: #8c8476;
  --paper: #2d2a26;
  --ink: #ede8df;
  --tline: #48433b;
  --block: #0f0e0c;
  --block-line: #2e2b27;
  --wrong: #f28b82;
  --shadow: rgb(0 0 0 / 0.5);

}
/* The fallback palette, with no specificity (:where): the palette of the day in
   <style id="ca-palette"> wins wherever that element sits in the document, also when js/boot.js
   puts it in before this file loads. */
:where(:root) {
  --accent: #397593; --on-accent: #ffffff; --go: #397593; --on-go: #ffffff;
  --a1: #397593; --a2: #a67d4e; --a3: #b15964; --a4: #639245;
  --hl-cell: #cddfe8; --hl-word: #e6eff4; --hl-bar: #f5f9fa; --hl-done: #cde8da; --on-hl: #202124; --ok: #22774d;
}
:where(:root[data-theme="dark"]) {
  --accent: #6fa0b8; --on-accent: #1f1d1a; --go: #6fa0b8; --on-go: #1f1d1a;
  --a1: #6fa0b8; --a2: #ab875f; --a3: #ba7d85; --a4: #7dab5f;
  --hl-cell: #364c5f; --hl-word: #2f3f4d; --hl-bar: #27343e; --hl-done: #2b493a; --on-hl: #ede8df; --ok: #59c08c;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { color: var(--fg); font: 17px/1.5 var(--sans); } /* the page colour is the root's (css/transitions.css), so the header's glyph field can sit behind the page */
body.game { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* text for assistive technology only */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ── crossword tiles: the logo, and the look every square on the site shares ── */
.xw {
  display: inline-grid; grid-template-columns: repeat(var(--cols), var(--t)); grid-template-rows: repeat(var(--rows), var(--t));
  gap: var(--g); vertical-align: middle;
}
.xw > b {
  grid-row: var(--r); grid-column: var(--c); position: relative; display: grid; place-items: center;
  background: var(--paper); color: var(--ink); border-radius: calc(var(--t) * 0.15); box-shadow: inset 0 0 0 1px var(--tline);
  font: 750 calc(var(--t) * 0.58) / 1 var(--sans); padding-top: calc(var(--t) * 0.1);
  transition: background-color 300ms, color 300ms;
}
/* the square numbers show where the tiles are large enough to read them */
.logo > b[data-n]::before, .card-mark > b[data-n]::before { display: none; }
.xw > b[data-n]::before { content: attr(data-n); position: absolute; top: calc(var(--t) * 0.09); left: calc(var(--t) * 0.13); font-size: calc(var(--t) * 0.23); font-weight: 600; opacity: 0.8; }
.xw > b.k { background: var(--block); box-shadow: inset 0 0 0 1px var(--block-line); }
.xw > b.s { background: var(--hl-cell); color: var(--on-hl); box-shadow: none; }
.xw > b.y { background: var(--accent); color: var(--on-accent); box-shadow: none; }

/* ── header: one row of squares on the logo's grid (logo, timer, menus, buttons), the glyph field behind ── */
.bar {
  position: relative; flex: none; height: var(--bar-h); padding: var(--bar-pad) var(--gutter);
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: repeat(3, var(--t)); gap: var(--g) 0;
}
.bar > :not(.ascii-ambient), .toolbar > :is(.tl, .tr) { position: relative; z-index: 10; }
/* the scene: one canvas fixed behind the whole page, under every page's content */
.ascii-ambient { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.bar .name { grid-area: 1 / 1 / 4 / 2; align-self: start; display: block; line-height: 0; text-decoration: none; border-radius: calc(var(--t) * 0.15); }
.nav { grid-area: 1 / 3; display: grid; grid-auto-flow: column; grid-auto-columns: var(--t); gap: var(--g); }
.icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; background: none; border-radius: 50%; cursor: pointer; color: var(--fg); text-decoration: none; }
.icon:hover { background: var(--soft); }
.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon circle[r="1.3"] { fill: currentColor; }
.nav .icon {
  position: relative; width: var(--t); height: var(--t); border-radius: calc(var(--t) * 0.15);
  background: var(--paper); box-shadow: inset 0 0 0 1px var(--tline); transition: background-color 140ms;
}
.nav .icon::after { content: ""; position: absolute; inset: -9px calc(var(--g) / -2); } /* the touch target reaches past the square */
.nav .icon:hover { background: var(--hl-word); color: var(--on-hl); }
.nav .icon svg { width: calc(var(--t) * 0.62); height: calc(var(--t) * 0.62); stroke-width: 1.9; }

/* ── toolbar: timer and pause after the logo, the menus before the buttons, all on the top row ── */
.toolbar { grid-area: 1 / 2; min-width: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 calc(var(--t) + 2 * var(--g)); white-space: nowrap; }
.tl, .tr { display: flex; align-items: center; gap: var(--g); }
.timer { min-width: calc(2 * var(--t) + var(--g)); font-size: 17px; font-weight: 600; line-height: var(--t); font-variant-numeric: tabular-nums; }
.toolbar .icon { width: var(--t); height: var(--t); border-radius: calc(var(--t) * 0.15); }
/* the day before and the day after: a pair of chevrons beside Pause; one without a link marks the end of the open puzzles */
.days { display: flex; }
.days .icon { width: calc(var(--t) * 0.72); }
.days .icon:not([href]) { opacity: 0.28; pointer-events: none; }
.days .dayof { display: none; min-width: 0; padding: 0 4px; font-size: 15px; font-weight: 600; line-height: var(--t); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
body.touch .days .dayof { display: block; } /* the date line is hidden on a touch screen, so the date shows here */
body.touch .days .icon { position: relative; }
body.touch .days .icon::after { content: ""; position: absolute; inset: -6px 0; }
.toolbar .icon svg { width: calc(var(--t) * 0.62); height: calc(var(--t) * 0.62); }
.text { background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 16px; }
.text:hover { background: var(--soft); }
.toolbar .text { height: var(--t); padding: 0 10px; border-radius: calc(var(--t) * 0.15); }
.menu { position: relative; display: flex; }
.menu > div {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 170px; display: none;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px; box-shadow: 0 6px 24px var(--shadow);
}
.menu.open > div { display: grid; }
.menu > div button { white-space: nowrap; background: none; border: 0; text-align: left; padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: 16px; }
.menu > div button:hover { background: var(--soft); }
.menu-days { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; align-items: center; margin-bottom: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.menu-days span { text-align: center; font-size: 16px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.step-day { display: grid; place-items: center; height: 36px; border-radius: 6px; color: var(--fg); cursor: pointer; }
.step-day:hover { background: var(--soft); }
.step-day:not([href]) { opacity: 0.28; pointer-events: none; }
.step-day svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.made { margin: 6px 12px 4px; font-size: 12.5px; color: var(--muted); line-height: 1.4; border-top: 1px solid var(--line); padding-top: 8px; width: 0; min-width: calc(100% - 24px); white-space: normal; overflow-wrap: anywhere; } /* wraps to the width of the menu */

/* ── play area: the board, the clue bar under it, the clue list beside it ── */
.solver {
  --size: min(calc(100dvh - var(--bar-h) - 134px), 620px, max(560px, calc(100vw - 2 * var(--gutter) - var(--gap) - 460px))); --gap: 44px; --list: 520px;
  flex: 1; min-height: 0; width: 100%; padding: 0 var(--gutter) 16px; display: flex; flex-direction: column; align-items: center;
}
.dateline, .playarea { width: min(100%, calc(var(--size) + var(--gap) + var(--list))); }
.dateline { margin: 0 0 10px; font-size: 15px; line-height: 22px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dateline b { color: var(--fg); font-weight: 600; }
.playarea { flex: none; display: flex; gap: var(--gap); align-items: flex-start; }
.boardcol { width: var(--size); flex: none; display: flex; flex-direction: column; gap: 12px; }
.boardwrap { position: relative; container-type: inline-size; }
.line { display: contents; }
.board {
  --n: 5; --cell: calc(100cqw / var(--n)); width: 100%; aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); gap: max(3px, 0.9cqw);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.board:focus-visible { outline: none; } /* the cursor square's ring is the focus mark */
.cell { background: var(--paper); color: var(--ink); position: relative; cursor: pointer; overflow: hidden; border-radius: 7%; box-shadow: inset 0 0 0 1px var(--tline); }
.cell.black { background: var(--block); box-shadow: inset 0 0 0 1px var(--block-line); cursor: default; }
.cell .num { position: absolute; left: 8%; top: 6%; font: 600 calc(var(--cell) * 0.2) / 1 var(--sans); opacity: 0.75; }
.cell .ch { position: absolute; inset: 14% 0 0 0; display: grid; place-items: center; font: 600 calc(var(--cell) * 0.54) / 1 var(--sans); }
.cell.word { background: var(--hl-word); color: var(--on-hl); box-shadow: none; }
.cell.cur { background: var(--hl-cell); color: var(--on-hl); box-shadow: inset 0 0 0 2px var(--accent); }
.cell.pop .ch { animation: pop 180ms ease-out; }
@keyframes pop { 40% { transform: scale(1.16); } }
.solved .cell.wave .ch { animation: hop 420ms ease-out; }
@keyframes hop { 35% { transform: translateY(-12%) scale(1.1); } }
.solved .cell:not(.black) { background: var(--hl-done); color: var(--on-hl); box-shadow: none; }
.cell.wrong::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top right, transparent calc(50% - 1px), var(--wrong) calc(50% - 1px), var(--wrong) calc(50% + 1px), transparent calc(50% + 1px));
}
.cell.revealed::before { content: ""; position: absolute; right: 0; top: 0; border: calc(var(--cell) * 0.1) solid transparent; border-top-color: var(--wrong); border-right-color: var(--wrong); }
.pause { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--bg); text-align: center; }
.pause p { margin: 0; font-size: 20px; font-weight: 600; white-space: nowrap; }
/* a paused puzzle shows no clue: the board is covered, the clue texts fade out */
.cluelist .clue, .cluelist .pat, .cluebar .inner, .crossline { transition: opacity 160ms; }
body.paused :is(.cluelist .clue, .cluelist .pat, .cluebar .inner, .crossline) { opacity: 0; }

.cluebar { display: flex; align-items: center; gap: 4px; height: 56px; background: var(--hl-bar); color: var(--on-hl); border-radius: 10px; padding: 4px; }
.cluebar .text { flex: 1; min-width: 0; margin: 0; padding: 4px 6px; font-size: 18px; line-height: 1.35; cursor: pointer; white-space: nowrap; overflow: hidden; }
.cluebar .text .inner { display: inline-block; will-change: transform; }
.cluebar .text.marquee .inner { animation: marquee var(--mq-time, 8s) ease-in-out infinite alternate; }
@keyframes marquee { 0%, 18% { transform: translateX(0); } 82%, 100% { transform: translateX(var(--mq-shift, 0px)); } }
.cluebar .text:hover { background: none; }
.cluebar b { font-weight: 700; margin-right: 4px; }
.cluebar .step { flex: none; width: 40px; height: 44px; border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; border-radius: 6px; color: inherit; }
.cluebar .step:hover { background: var(--hl-word); }

/* ── clue list: Across then Down in one column, the rail beside it ── */
.clues { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; height: calc(var(--size) + 68px); }
.cluescroll {
  display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain;
  --fade-top: 0px; --fade-bottom: 0px;
  mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 var(--fade-top), #000 calc(100% - var(--fade-bottom)), transparent 100%);
}
.cluescroll::-webkit-scrollbar { display: none; }
.clues.more-top .cluescroll { --fade-top: 28px; }
.clues.more-bottom .cluescroll { --fade-bottom: 36px; }
.cluelist header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 8px 6px 4px; white-space: nowrap; }
.cluelist h2 { margin: 0; font-size: 13px; line-height: 20px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.cluelist ol { list-style: none; margin: 0; padding: 0; }
.prog { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.prog .meter { font-family: var(--mono); letter-spacing: 2px; color: var(--glyph); margin-right: 4px; }
.prog .meter i { font-style: normal; display: inline-block; transition: color 200ms; }
.prog .meter i.on { color: var(--accent); }
.prog .meter i.edge { color: var(--a2); }
.prog .meter i.pop { animation: progpop 320ms cubic-bezier(.3, 1.6, .5, 1); }
@keyframes progpop { 0% { transform: scale(0.4); } 100% { transform: scale(1); } }

.cluelist li {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; height: 44px;
  padding: 0 10px 0 6px; border-radius: 10px; cursor: pointer; white-space: nowrap; transition: background-color 120ms;
}
.cluelist li:hover { background: var(--soft); }
.cluelist li .n {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 4px;
  background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--tline); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.cluelist li .clue { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 16px; line-height: 1.3; }
.cluelist li .pat { display: flex; gap: 2px; }
.cluelist li .pat i {
  width: 14px; height: 14px; display: grid; place-items: center; border-radius: 2px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--tline);
  font: 700 9px/1 var(--sans); font-style: normal; color: var(--ink);
}
.cluelist li .pat i.on { box-shadow: inset 0 0 0 1px var(--glyph); }
.cluelist li.cross { background: var(--hl-bar); color: var(--on-hl); }
.cluelist li.active { background: var(--hl-word); color: var(--on-hl); }
.cluelist li.active .n { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.cluelist li.done:not(.active) .n { background: var(--hl-done); color: var(--on-hl); box-shadow: none; }
.cluelist li.done:not(.active) .clue { color: var(--muted); }
.cluelist li.done.cross:not(.active) .clue { color: inherit; }

/* ── solved card ── */
/* the backdrop leaves the top band clear, so the scene's solve moment plays above the card */
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: var(--bar-h) 16px 16px;
  background: linear-gradient(to bottom, rgb(0 0 0 / 0) var(--bar-h), rgb(0 0 0 / 0.35) calc(var(--bar-h) + 64px));
}
.card:focus { outline: none; }
.card { position: relative; width: min(380px, 100%); background: var(--bg); border-radius: 14px; padding: 28px 24px 22px; text-align: center; box-shadow: 0 10px 40px var(--shadow); }
.card-mark { --t: 18px; --g: 1.5px; margin: 0 auto 12px; display: grid; width: max-content; }
.card h2 { margin: 0; font-size: 26px; white-space: nowrap; }
.card .big { margin: 8px 0 2px; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .muted { margin: 0; white-space: nowrap; }
.card .best { margin: 6px 0 0; font-size: 15px; font-weight: 600; color: var(--ok); white-space: nowrap; }
.card .close { position: absolute; right: 8px; top: 8px; }
.actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.actions > :is(.primary, .secondary) { min-width: 0; flex: 1 1 auto; max-width: 150px; }
@media (max-width: 420px) {
  .card { padding-inline: 16px; }
  .actions { gap: 8px; }
  .actions > :is(.primary, .secondary) { padding: 0 10px; font-size: 15px; }
}
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; min-width: 120px; height: 46px; padding: 0 22px; border-radius: 999px; font-size: 16px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.primary { background: var(--go); color: var(--on-go); border: 0; }
.secondary { background: none; border: 1px solid var(--line); color: var(--fg); }

.toast { white-space: nowrap; position: fixed; left: 50%; top: calc(var(--bar-h) + 8px); transform: translateX(-50%); z-index: 70; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 15px; display: none; gap: 12px; align-items: center; max-width: calc(100vw - 24px); }
.toast.show { display: flex; }
/* a note that stays until it is dismissed: a new puzzle is out; a toast moves under it */
.fresh { position: fixed; left: 50%; top: calc(var(--bar-h) + 4px); transform: translateX(-50%); z-index: 65; max-width: calc(100vw - 24px); display: flex; align-items: center; gap: 12px; white-space: nowrap; padding: 3px 5px 3px 16px; border-radius: 8px; font-size: 15px; background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--tline), 0 6px 24px var(--shadow); }
.fresh span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.fresh a { font-weight: 600; text-underline-offset: 3px; }
.fresh .icon { width: 26px; height: 26px; flex: none; }
body:has(.fresh:not([hidden])) .toast { top: calc(var(--bar-h) + 48px); }
.toast button { background: none; border: 1px solid currentColor; border-radius: 6px; color: inherit; cursor: pointer; padding: 2px 10px; }

/* the crossing clue shows on phones only */
.crossline { margin: 0; }

/* ── on-screen keyboard (touch) ── */
.kbd { display: none; flex: none; gap: 6px; background: var(--soft); }
.kbd .row { display: flex; gap: 5px; justify-content: center; }
.kbd .row button {
  color: var(--fg); flex: 1 1 0; max-width: 42px; height: 50px; border: 0; background: var(--bg); border-radius: 6px; font-size: 18px; font-weight: 600;
  cursor: pointer; padding: 0; touch-action: manipulation; box-shadow: 0 1px 0 var(--shadow); transition: transform 60ms, background-color 60ms;
}
.kbd .row button:active { transform: scale(0.93); background: var(--hl-cell); color: var(--on-hl); }
.kbd .row button.wide { flex: 1.5 1 0; max-width: 64px; font-size: 14px; }
/* one column that cannot grow past the screen, however long the clue in the dock is */
body.touch .kbd { display: grid; grid-template-columns: minmax(0, 1fr); }

/* a desktop window: the block of dateline, board and clues sits centred in the space under the band, a touch above true centre (the spacers share the free height 1 to 1.1, and the page's bottom padding adds to the lower one); a window with no spare height keeps it under the band */
@media (min-width: 900px) {
  body:not(.touch) .solver::before, body:not(.touch) .solver::after { content: ""; flex: 1 1 0; }
  body:not(.touch) .solver::after { flex-grow: 1.1; }
}

/* ── narrow windows with a keyboard: the clue list goes under the board ── */
@media (max-width: 899px) {
  :root { --t: 20px; --bar-pad: 8px; --gutter: 12px; --bar-drop: 40px; }
  .solver { padding: 0 0 12px; }
  .dateline { margin: 0 0 8px; font-size: 14px; }
  .solver { --size: min(calc(100vw - 24px), 440px); }
  .dateline, .playarea { width: var(--size); }
  .playarea { flex-direction: column; align-items: center; gap: 16px; }
  .clues { width: var(--size); max-width: none; height: auto; flex: none; }
  body:not(.touch).game { overflow: auto; height: auto; min-height: 100dvh; }
  body.touch .clues { display: none; }
}

/* ── narrow phones: the timer stays on the top row, the menus move to the row of the logo's M ── */
@media (max-width: 479px) {
  .toolbar { display: contents; }
  .tl { grid-area: 1 / 2; justify-self: end; margin-right: calc(var(--t) + 2 * var(--g)); }
  /* a phone shows the date between the chevrons: the top row has no room for it, so the day control takes the row under the timer and Pause */
  body.touch .tl { grid-area: 1 / 2 / 3 / 3; justify-self: start; margin: 0 0 0 8px; display: grid; grid-template-columns: auto auto 1fr; grid-template-rows: var(--t) var(--t); align-content: start; }
  body.touch .tl .days { grid-area: 2 / 1 / 3 / 4; justify-self: start; }
  .tr { grid-area: 3 / 2 / 4 / 4; justify-self: end; }
  .toolbar .text { padding: 0 7px; font-size: 15px; }
  .timer { font-size: 15px; }
}

/* ── phones: the grid centred, one dock (crossing clue, clue, keys) ── */
body.touch { --dock-h: 262px; }
body.touch .toolbar :is(.tl > button, .menu > button) { position: relative; }
body.touch .toolbar :is(.tl > button, .menu > button)::after { content: ""; position: absolute; inset: -6px -2px; } /* touch targets reach past the squares */
body.touch .dateline { display: none; }
body.touch .solver { --size: min(calc(100vw - 24px), calc(100dvh - var(--bar-h) - var(--dock-h) - 20px)); justify-content: center; }
body.touch .playarea { flex: none; gap: 0; }
body.touch .kbd {
  border-radius: 18px 18px 0 0; padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); gap: 6px;
  box-shadow: 0 -6px 24px var(--shadow); border-top: 1px solid var(--line);
}
body.touch .kbd .crossline { margin: 0 12px; font-size: 13px; line-height: 18px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.touch .kbd .cluebar { height: 54px; margin: 0 4px 2px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); }
body.touch .kbd .cluebar .text { font-size: 17px; }

/* ── prose pages ── */
.page { max-width: 680px; margin: 0 auto; padding: 28px 18px 56px; width: 100%; }
.page h1 { font-size: 28px; line-height: 1.2; margin: 0 0 14px; }
.page h2 { font-size: 20px; margin: 30px 0 8px; }
.page p, .page li { font-size: 17px; line-height: 1.65; }
.page table { border-collapse: collapse; width: 100%; font-size: 16px; }
.page td, .page th { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
kbd { font: 13px var(--sans); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }

/* ── archive: each day is a small crossword square ── */
.page.wide { max-width: 1040px; }
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 28px; }
.month h2 { font-size: 17px; margin: 0 0 8px; white-space: nowrap; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { font-size: 12px; color: var(--muted); text-align: center; }
.day { aspect-ratio: 1; border-radius: 15%; display: grid; place-items: center; position: relative; text-decoration: none; font-size: 15px; font-variant-numeric: tabular-nums; }
a.day { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1px var(--tline); }
a.day:hover { background: var(--hl-word); color: var(--on-hl); }
.day.none { color: var(--muted); opacity: 0.35; }
.day.locked { color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.day.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.day.solved { background: var(--hl-cell); color: var(--on-hl); font-weight: 700; box-shadow: none; }
.day.started { background: linear-gradient(to top, var(--hl-word) 50%, var(--paper) 50%); color: var(--on-hl); }
.day.holiday::after { content: ""; position: absolute; right: 12%; top: 12%; width: 5px; height: 5px; border-radius: 50%; background: var(--dot, var(--accent)); }
.archive-key { white-space: nowrap; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 22px; font-size: 14px; color: var(--muted); }
.archive-key i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--tline); }
.archive-key .k-solved { background: var(--hl-cell); box-shadow: none; }
.archive-key .k-started { background: linear-gradient(to top, var(--hl-word) 50%, var(--paper) 50%); }
.archive-key .k-holiday { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); box-shadow: none; vertical-align: 2px; }

@media (prefers-reduced-motion: no-preference) { .cell { transition: background-color 60ms; } }
@media (prefers-reduced-motion: reduce) {
  .cluebar .text.marquee .inner, .cell.pop .ch, .solved .cell.wave .ch, .prog .meter i.pop { animation: none; }
  .xw > b { transition: none; }
}

/* Print: one sheet, black on white. The grid is empty, with its numbers, to solve on paper (typed
   letters stay on screen); then the two clue lists in full; no scene, controls, dock or rail. */
@page { margin: 0.6in; }
@media print {
  :root, :root[data-theme="dark"] { --bg: #fff; --fg: #000; --line: #999; --muted: #000; --paper: #fff; --ink: #000; --tline: #000; --block: #000; }
  html, body.game { background: #fff !important; color: #000; }
  body.game { display: block; height: auto; overflow: visible; font-size: 11pt; }
  .bar, .cluebar, .kbd, .toast, .fresh, .modal, .pause, .rail, .prog, .ascii-ambient, .ascii-overlay { display: none !important; }
  .solver { display: block; max-width: none; padding: 0; text-align: center; }
  .solver::before, .solver::after { display: none; }
  .sr.title { position: static; width: auto; height: auto; margin: 0 0 4pt; overflow: visible; clip-path: none; font: 800 22pt/1.1 var(--sans); letter-spacing: 0.04em; text-transform: uppercase; }
  .dateline, body.touch .dateline { display: block !important; width: auto; margin: 0 0 14pt; overflow: visible; white-space: normal; font-size: 12pt !important; line-height: 1.3; color: #000; }
  .dateline b { font-weight: 700; }
  .playarea { display: block; width: auto; }
  .boardcol { width: 4.6in; margin: 0 auto 20pt; }
  .board { print-color-adjust: exact; -webkit-print-color-adjust: exact; gap: 0; }
  .cell, .cell.word, .cell.cur, .solved .cell:not(.black) { background: #fff !important; border-radius: 0; box-shadow: inset 0 0 0 0.5pt #000; }
  .cell.black { background: #000 !important; }
  .cell .num { opacity: 1; color: #000; }
  .cell .ch { visibility: hidden; }
  .cell::after, .cell::before { display: none !important; }
  .clues { display: block !important; width: auto; height: auto; max-width: none; }
  .cluescroll { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28pt; align-items: start; overflow: visible; text-align: left; mask-image: none !important; -webkit-mask-image: none !important; }
  .cluelist header { padding: 0 0 4pt; }
  .cluelist li { display: flex; align-items: baseline; height: auto; padding: 2pt 0; border-radius: 0; background: none !important; color: #000 !important; break-inside: avoid; white-space: normal; }
  .cluelist li .pat { display: none; }
  .cluelist li .n { flex: none; width: 2em; height: auto; display: block; border-radius: 0; background: none !important; box-shadow: none; color: #000 !important; font-size: 11pt; }
  .cluelist li .clue { overflow: visible; text-overflow: clip; font-size: 11pt !important; color: #000 !important; }
}
