:root {
  color-scheme: light;
  --bg: #f3f0e7; --paper: #ffffff; --raised: #eae6dc; --text: #23221f; --muted: #56534c;
  --accent: #62419a; --heading: #191916; --line: #b4b0a5; --grid-line: #c5c1b7;
  --ink: #172f4b; --mark: #315779; --active: #ffe3a0; --selection: #805900;
  --phrase: #e5e1ce; --success: #215b40; --error: #a11926;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Georgia, "Times New Roman", serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #22231f; --paper: #30322d; --raised: #393b34; --text: #f0eee3; --muted: #d2d0c4;
  --accent: #dfcef9; --heading: #f5f2e7; --line: #737569; --grid-line: #626558;
  --ink: #f0f6ff; --mark: #b6d5ff; --active: #705c2b; --selection: #f6d982;
  --phrase: #55594b; --success: #aed9ba; --error: #ffc2bc;
}
@font-face { font-family: "Patrick Hand"; src: url("fonts/PatrickHand-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); }
button, select { font: inherit; color: inherit; }
button { border: 1px solid var(--line); border-radius: 2px; background: var(--paper); cursor: pointer; padding: .5rem .8rem; min-height: 44px; touch-action: manipulation; }
button:hover { border-color: var(--accent); }
a { color: var(--accent); text-underline-offset: .2em; }
button, a, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1, h2 { color: var(--heading); }
h2 { font: 700 1.3rem/1.3 var(--serif); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; top: -100px; left: 12px; padding: 12px; background: var(--paper); z-index: 10; }
.skip:focus { top: 8px; }
.page { max-width: 1110px; margin: auto; padding: 0 36px; }
.masthead { border-bottom: 4px double var(--heading); padding-top: 18px; }
.topline, .title-row, .strapline, .preferences { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.vault-link { font-size: .78rem; text-decoration: none; font-weight: 650; }
.preferences { gap: 12px; }
.languages { display: flex; border: 1px solid var(--line); border-radius: 2px; overflow: hidden; }
.languages button { border: 0; border-radius: 0; font-size: .78rem; min-height: 36px; padding: .35rem .7rem; }
.languages button[aria-pressed="true"] { background: var(--heading); color: var(--bg); }
.theme-button { min-height: 38px; width: 40px; padding: 0; font-size: 24px; }
.title-row { padding: 15px 0 18px; align-items: end; }
.eyebrow { font-size: .65rem; letter-spacing: .12em; font-weight: 700; text-transform: uppercase; color: var(--muted); }
h1 { font: 700 clamp(42px, 6.5vw, 76px)/1.05 var(--serif); letter-spacing: -.04em; margin-top: 4px; }
.edition { text-align: right; color: var(--muted); font-size: .62rem; letter-spacing: .08em; }
.edition strong { display: block; font: italic 46px/1.2 var(--serif); color: var(--heading); }
.strapline { border-top: 1px solid var(--heading); padding: 4px 0; }
.strapline p { font: italic .94rem/1.5 var(--serif); color: var(--muted); }
.strapline button { font-size: .76rem; padding: .25rem 0 .25rem .5rem; min-height: 32px; border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.puzzle-nav { display: flex; gap: 8px; margin: 16px 0 14px; }
select { width: 100%; min-width: 0; min-height: 44px; background: var(--paper); border: 1px solid var(--line); border-radius: 2px; padding: .4rem .6rem; font-size: .92rem; }
.square-button { flex: 0 0 44px; width: 44px; padding: 0; font-size: 25px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 290px; grid-template-areas: "board words" "solution words"; align-items: start; gap: 22px 38px; }
.board-panel { grid-area: board; min-width: 0; }
.board-heading { display: flex; align-items: center; justify-content: space-between; min-height: 26px; gap: 8px; border-top: 2px solid var(--heading); }
#progress { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.directions { font-size: .78rem; color: var(--muted); padding: 2px 0 8px; }
.board { position: relative; background: var(--paper); border: 1px solid var(--line); }
#grid { display: grid; grid-template-columns: repeat(var(--columns), minmax(0, 1fr)); touch-action: none; user-select: none; -webkit-user-select: none; }
.grid-row { display: contents; }
.cell { position: relative; display: grid; place-items: center; padding: 0; border: 0; border-radius: 0; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); min-width: 0; min-height: 0; aspect-ratio: 1; background: transparent; color: var(--ink); touch-action: none; font: 400 32px/1 "Patrick Hand", cursive; }
.cell:last-child { border-right: 0; }
.grid-row:last-child .cell { border-bottom: 0; }
.cell.multi { font-size: 24px; letter-spacing: -.025em; }
.cell.preview { background: var(--active); }
.cell.anchor { box-shadow: inset 0 0 0 2px var(--selection); }
.cell:focus-visible { outline: 3px solid var(--selection); outline-offset: -3px; z-index: 2; }
.cell.phrase-letter { background: var(--phrase); }
.cell.phrase-letter.revealing { animation: reveal-letter .45s ease-out both; }
#marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.loop { fill: none; stroke: var(--mark); stroke-width: 1.7px; vector-effect: non-scaling-stroke; }
.loop.second { stroke-width: .7px; }
.gesture-hint { padding-top: 7px; font-size: .76rem; color: var(--muted); }
.word-panel { grid-area: words; border-top: 2px solid var(--heading); }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 10px 0 9px; border-bottom: 1px solid var(--line); }
.section-heading > span { color: var(--muted); }
.word-list { list-style: none; padding: 14px 0 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.word-list li { display: flex; align-items: baseline; gap: 5px; min-width: 0; font-size: .92rem; letter-spacing: .02em; }
.word-list .tick { width: 12px; flex-shrink: 0; color: var(--mark); font-size: .75rem; }
.word-list .found .word-text { text-decoration: line-through; text-decoration-color: var(--mark); text-decoration-thickness: 2px; }
.feedback { font: italic 1rem/1.45 var(--serif); min-height: 48px; margin-top: 18px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button { font-size: .77rem; padding: .45rem .6rem; }
.save-status { color: var(--muted); font-size: .72rem; padding-top: 8px; min-height: 28px; }
.save-status.error { color: var(--error); }
.pencil-note { font: italic 1.1rem/1.6 var(--serif); color: var(--muted); border-top: 1px solid var(--line); margin-top: 22px; padding: 18px 4px; max-width: 27ch; }
.solution-panel { grid-area: solution; border-top: 3px double var(--heading); }
.solution-panel > p { padding: 10px 0 0; font: .95rem/1.5 var(--serif); color: var(--muted); }
#solution-result { padding: 12px 0; }
#solution-result > p:first-child { font-size: .8rem; color: var(--success); }
#solution-phrase { font: 700 1.5rem/1.3 var(--serif); margin: 6px 0 14px; }
#another { font-size: .85rem; }
footer { display: flex; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; border-top: 3px double var(--heading); padding: 16px 0 24px; margin-top: 30px; font-size: .7rem; color: var(--muted); }
dialog { max-width: min(620px, calc(100% - 28px)); max-height: calc(100% - 32px); padding: 24px; border: 1px solid var(--heading); border-radius: 2px; background: var(--bg); color: var(--text); }
dialog::backdrop { background: #161711bb; }
.dialog-top { display: flex; gap: 16px; justify-content: space-between; align-items: center; }
.dialog-top button { font-size: .8rem; }
.instructions { padding-left: 22px; font-size: .93rem; }
.instructions li { margin: 12px 0; }
.help-callout { padding: 12px; background: var(--raised); border-left: 3px solid var(--accent); font-size: .88rem; }
.fine { font-size: .77rem; color: var(--muted); margin-top: 12px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 20px; }
#reset-dialog > p { margin-top: 12px; }
.primary { color: var(--bg); background: var(--heading); border-color: var(--heading); }
.noscript { padding: 20px; }
@keyframes reveal-letter { from { box-shadow: inset 0 0 0 3px var(--selection); } to { box-shadow: inset 0 0 0 0 transparent; } }
@media (max-width: 800px) {
  .page { max-width: 570px; padding: 0 16px; }
  .masthead { padding-top: 8px; }
  .topline { gap: 8px; }
  .preferences { gap: 6px; }
  .languages button { padding: .3rem .55rem; }
  .title-row { padding: 5px 0 7px; }
  .title-row .eyebrow { display: none; }
  h1 { font-size: 42px; margin-top: 1px; }
  .edition { font-size: .52rem; }
  .edition strong { font-size: 30px; }
  .strapline p { font-size: .8rem; }
  .strapline { padding: 2px 0; }
  .puzzle-nav { margin: 7px 0 7px; gap: 6px; }
  .workspace { grid-template-columns: 1fr; grid-template-areas: "board" "words" "solution"; gap: 12px; }
  .board-heading { min-height: 23px; }
  .directions { font-size: .73rem; padding: 0 0 6px; }
  .cell { font-size: 27px; }
  .cell.multi { font-size: 20px; }
  .gesture-hint { padding-top: 5px; font-size: .71rem; }
  .section-heading { padding: 7px 0; }
  h2 { font-size: 1.15rem; }
  .word-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 8px; padding-top: 9px; }
  .word-list li { font-size: .8rem; gap: 3px; letter-spacing: 0; }
  .word-list .tick { width: 10px; }
  .word-list li.long { grid-column: span 2; }
  .feedback { margin-top: 10px; min-height: 30px; font-size: .92rem; }
  .pencil-note { display: none; }
  footer { margin-top: 22px; }
}
@media (max-width: 374px) {
  .page { padding: 0 12px; }
  .vault-link { font-size: .72rem; }
  .languages button { font-size: .73rem; }
  h1 { font-size: 38px; }
  .edition { letter-spacing: 0; }
  .cell.multi { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { .cell.phrase-letter.revealing { animation: none; } }
