:root {
  color-scheme: light;
  --ink: #172d23;
  --muted: #46564a;
  --green: #10543d;
  --hover: #e9eee4;
  --page: #f8f4eb;
  --panel: #fbf8f1;
  --paper: #fff;
  --edge: #d9cebc;
  --control-edge: #998f7d;
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Trebuchet MS", system-ui, sans-serif;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font: 1rem/1.45 var(--sans);
}
a { color: inherit; text-underline-offset: .2em; }
::selection { color: var(--ink); background: #dbe6ce; }
:focus-visible { outline: 3px solid #257153; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font: 700 1.8rem/1.12 var(--serif); letter-spacing: -.026em; }
h1 { font-size: clamp(2.1rem, 4vw, 2.85rem); }
.shell { width: min(100% - 72px, 1416px); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--edge); }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font: 700 1.75rem/1 var(--serif); }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 9px; background: var(--green); color: var(--paper); font-size: 1.5rem; }
nav { display: flex; gap: clamp(12px, 3vw, 38px); align-items: center; }
nav a { padding: 9px 0; text-decoration: none; font-family: var(--serif); }
nav a:hover, nav [aria-current] { text-decoration: underline; text-decoration-thickness: 2px; }
nav [aria-current] { font-weight: 700; }
.skip { position: fixed; z-index: 2; inset: 12px auto auto 12px; padding: 10px; transform: translateY(-160%); background: var(--paper); }
.skip:focus { transform: none; }
main { padding-block: 20px 44px; }
.quick-start {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: .925rem;
}
.quick-start h2 { color: var(--ink); font: 700 1em/1.45 var(--sans); letter-spacing: normal; }
.quick-start ol { display: flex; flex-wrap: wrap; gap: 3px 26px; margin: 0; padding-inline-start: 1.25em; }
.quick-start li::marker { color: var(--green); font-weight: 700; }
.workspace { display: grid; grid-template-columns: minmax(300px, .53fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { min-width: 0; padding: 17px 21px; border: 1px solid var(--edge); border-radius: var(--radius); background: var(--panel); }
.panel + .panel { margin-top: 14px; }
.workspace > .preview { margin-top: 0; }
.hint { color: var(--muted); font-size: .925rem; margin-top: 5px; }
.split { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
button, input, select, textarea { font: inherit; color: var(--ink); }
button, input:not([type="checkbox"]), select, textarea { min-height: 44px; border: 1px solid var(--control-edge); border-radius: 7px; background: var(--paper); }
button { cursor: pointer; font-weight: 700; padding: 7px 14px; }
button:hover:not(:disabled) { background: var(--hover); }
button:disabled { opacity: .45; cursor: default; }
button.primary, button[aria-pressed="true"] { background: var(--green); color: white; border-color: var(--green); }
button.primary:hover:not(:disabled), button[aria-pressed="true"]:hover { background: #173f31; }
button.text-button { background: transparent; border-color: transparent; color: var(--green); padding-inline: 7px; text-decoration: underline; text-underline-offset: .2em; }
input:not([type="checkbox"]), select, textarea { width: 100%; padding: 7px 10px; min-width: 0; }
input[type="checkbox"] { accent-color: var(--green); width: 16px; height: 16px; flex: 0 0 auto; }
.direction-pad {
  display: grid; grid-template-columns: repeat(3, minmax(50px, 74px)); justify-content: center;
  gap: 8px clamp(10px, 2vw, 25px); align-items: center; margin: 12px auto 15px;
}
.direction-pad button { display: grid; place-items: center; height: 48px; color: var(--green); border-color: var(--green); }
.direction-pad button[aria-pressed="true"] { color: white; }
.direction-pad svg { width: 26px; height: 26px; }
.direction-center { justify-self: center; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.presets { display: grid; grid-template-columns: repeat(3, 1fr); }
.presets button { border-radius: 0; }
.presets button:first-child { border-radius: 7px 0 0 7px; }
.presets button:last-child { border-radius: 0 7px 7px 0; }
.presets button + button { margin-left: -1px; }
.layout-heading { margin-top: 15px; font-size: 1.5rem; }
.layout-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 6px; align-items: center; margin-top: 6px; }
.dimensions {
  display: grid;
  grid-template-columns: minmax(44px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  inline-size: min(100%, 124px);
  border-radius: 7px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--edge);
  color: var(--muted);
}
.dimensions input[type="number"] {
  appearance: textfield;
  border: 0;
  padding-inline: 4px;
  background: transparent;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.dimensions input::-webkit-inner-spin-button { appearance: none; }
.dimensions input:hover { background: var(--hover); }
.dimensions input:focus-visible { outline-offset: -3px; }
.compact-select { position: relative; display: block; }
.compact-select::after {
  content: "";
  position: absolute;
  inset-inline-end: 13px;
  inset-block-start: 50%;
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.compact-select select {
  appearance: none;
  border: 0;
  padding-inline: 11px 31px;
  background: transparent;
  cursor: pointer;
  text-overflow: ellipsis;
}
.shape-select { inline-size: min(100%, 176px); }
.shape-select select { background: var(--paper); box-shadow: inset 0 0 0 1px var(--edge); }
.compact-select select:hover { background: var(--hover); }
.words textarea { resize: vertical; display: block; margin-top: 8px; line-height: 1.36; }
.title-label { display: block; margin: 11px 0 4px; }
.themes { margin: 5px 0 9px; padding: 10px; border: 1px solid var(--edge); border-radius: 7px; }
.theme-row { display: flex; gap: 8px; margin-top: 5px; }
.theme-row button { flex: 0 0 auto; }
.custom-editor { margin-top: 12px; }
.mask-actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0; }
.mask-grid { display: grid; grid-template-columns: repeat(var(--mask-columns, 20), minmax(0, 1fr)); gap: 1px; user-select: none; }
.mask-grid button { min-height: 0; aspect-ratio: 1; padding: 0; border-radius: 2px; border-color: var(--control-edge); cursor: crosshair; }
.mask-grid button:focus-visible { z-index: 1; outline-offset: 1px; }
.mask-grid button[aria-pressed="true"] { border-color: var(--panel); }
.preview { padding-inline: 20px; }
.actions, .preview-options { display: flex; gap: 9px; align-items: center; }
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--edge); margin-top: 5px; }
.tabs button { border: 0; border-radius: 0; background: transparent; font-weight: 400; position: relative; }
.tabs button[aria-selected="true"] { font-weight: 700; }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--green); }
.preview-options { margin-block: 8px 12px; gap: 12px; }
.paper-select { inline-size: 116px; }
.paper-select select { padding-inline-end: 26px; }
.large-label { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.feedback { margin: 9px 0; padding: 8px 10px; border-radius: 6px; background: #e9eee4; overflow-wrap: anywhere; }
.feedback:empty { margin: 0; padding: 0; }
.feedback.error { color: #7f2f25; background: #fae9df; }
.preview-pane { min-height: 274px; }
.preview-pane:empty { display: none; }
.worksheet {
  width: min(93%, 680px);
  margin-inline: auto;
  padding: 12px clamp(12px, 3vw, 35px) 16px;
  background: var(--paper);
  box-shadow: 0 4px 13px #40331b20;
  text-align: center;
  color: #142b22;
  overflow-wrap: anywhere;
}
.worksheet + .worksheet { margin-top: 14px; }
#view-print .worksheet { aspect-ratio: 612 / 792; padding-top: clamp(16px, 3vw, 36px); }
#view-print .worksheet[data-paper="a4"] { aspect-ratio: 210 / 297; }
.worksheet h3 { font-size: clamp(1.25rem, 3vw, 2.15rem); }
.sheet-caption { margin: 4px 0 8px; color: var(--muted); }
.puzzle-grid { display: block; width: 100%; height: auto; max-width: min(100%, 510px); max-height: clamp(255px, 42vh, 386px); margin-inline: auto; }
.puzzle-grid text { font: .65px "Courier New", monospace; fill: #142b22; }
.large .puzzle-grid text { font-size: .78px; }
.answer-line { stroke: #deebd1; stroke-width: .88; stroke-linecap: round; }
.word-bank { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; margin: 9px 0 0; padding: 0; font: 700 .9rem/1.6 var(--serif); letter-spacing: .055em; }
.large .word-bank { font-size: 1.05rem; }
.history { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: min(93%, 680px); margin: 13px auto 0; }
#layout-count { font-variant-numeric: tabular-nums; font-size: .9rem; white-space: nowrap; }
.practice { margin-top: 13px; padding-top: 10px; border-top: 1px solid var(--edge); }
.practice summary { width: fit-content; min-height: 36px; cursor: pointer; color: var(--green); text-decoration: underline; text-underline-offset: .2em; }
.practice button { margin-top: 9px; }
.mobile-only, #printed-pages { display: none; }

@media (max-width: 800px) {
  .shell { width: calc(100% - 32px); }
  .quick-start { display: block; }
  .quick-start ol { display: block; margin-top: 3px; }
  .quick-start li + li { margin-top: 2px; }
  .workspace { grid-template-columns: 1fr; gap: 16px; }
  .mobile-only { display: inline-block; margin-top: 5px; }
  .preview-pane { min-height: 0; }
}
@media (max-width: 500px) {
  .header-inner { align-items: start; flex-direction: column; gap: 6px; padding-top: 9px; }
  .brand { font-size: 1.4rem; }
  .brand-mark { width: 36px; height: 36px; }
  nav { gap: 15px; font-size: .92rem; }
  .panel, .preview { padding-inline: 12px; }
  .worksheet, .history { width: 100%; }
  .history { flex-wrap: wrap; justify-content: start; }
  .tabs button, .actions button { padding-inline: 9px; font-size: .91rem; }
  .preview-header h2 { font-size: 1.45rem; }
}
@media print {
  body { background: white; }
  body > :not(#printed-pages) { display: none !important; }
  #printed-pages { display: block; }
  #printed-pages .worksheet { width: 100%; box-shadow: none; padding: 13mm; margin: 0; break-after: page; }
  #printed-pages .worksheet:last-child { break-after: auto; }
  .answer-line { print-color-adjust: exact; }
  .puzzle-grid { max-height: 120mm; max-width: 140mm; }
}


.classic-link { margin-top: 12px; color: var(--muted); font-size: .9rem; }
.production-footer { padding: 18px 0; border-top: 1px solid var(--edge); }
.production-footer .shell { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 24px; }
.production-footer nav { flex-wrap: wrap; }
.maker-guide { margin-top: 30px; max-width: 74ch; }
.maker-guide section + section { margin-top: 23px; }
.maker-guide p { margin-top: 7px; }
.maker-guide button { margin-top: 10px; }
.maker-guide a { color: var(--green); }
@media print { .production-footer { display: none; } }
