:root {
  --paper: #f7f1e8;
  --card: #fffaf2;
  --ink: #2b2118;
  --ink-soft: #6b5b4b;
  --rust: #a8461f;
  --rust-ink: #ffffff;
  --honey: #e0a03a;
  --rule: #e3d7c4;
  --tile-edge: #cdbca3;
  --radius: 8px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1712;
    --card: #26201a;
    --ink: #ede4d6;
    --ink-soft: #b3a593;
    --rust: #f0a37f;
    --rust-ink: #1c1712;
    --honey: #e0a03a;
    --rule: #3a3128;
    --tile-edge: #5a4c3e;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--sans);
}
a { color: var(--rust); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--honey); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; color: var(--ink); }
h1 { font-size: 36px; margin: 0 0 12px; }
h2 { font-size: 28px; margin: 48px 0 16px; }
h3 { font-size: 22px; margin: 32px 0 12px; }

.masthead { border-bottom: 1px solid var(--rule); }
.masthead-inner {
  max-width: 1120px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.wordmark {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
  font-family: var(--serif); font-weight: 700; font-size: 22px; color: var(--ink); text-decoration: none;
}
.wordmark img { width: 32px; height: 32px; border-radius: 6px; }
.masthead-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.masthead-nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  color: var(--ink-soft); text-decoration: none; font-weight: 600; font-size: 16px; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.masthead-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--rust); }
.masthead-nav a:hover { color: var(--ink); }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sheet { max-width: 760px; margin: 0 auto; padding: 32px 0 64px; }
.sheet-head { text-align: left; }
.lede { font-size: 18px; color: var(--ink-soft); margin: 0 0 24px; max-width: 62ch; }
.lede-after { margin: 16px 0 0; }

.workbench {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 24px;
}
.ad-slot { min-height: 0; }

.prose { max-width: 70ch; }
.prose p, .prose li { font-size: 17px; }
.prose h2, .faq h2, .related h2 { position: relative; padding-left: 16px; }
.prose h2::before, .faq h2::before, .related h2::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 4px;
  border-radius: 2px; background: var(--honey);
}
.prose code { font-size: 15px; background: var(--card); border: 1px solid var(--rule); border-radius: 4px; padding: 1px 6px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 16px; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--rule); }

.faq { max-width: 70ch; margin-top: 48px; }
.faq details { border-bottom: 1px solid var(--rule); }
.faq summary {
  cursor: pointer; list-style: none; padding: 12px 32px 12px 0; min-height: 44px;
  font-weight: 600; position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 4px; top: 10px; font-size: 22px; color: var(--rust); }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0 0 16px; color: var(--ink-soft); }

.related { margin-top: 48px; border-top: 1px solid var(--rule); padding-top: 8px; }
.related ul { list-style: none; padding: 0; margin: 0; }
.related li { padding: 8px 0; }
.related a { font-weight: 600; }
.related span { color: var(--ink-soft); }

.sheet-text .prose { margin-top: 8px; }
.stamp { color: var(--ink-soft); font-size: 15px; margin: 0 0 24px; }

.colophon {
  border-top: 1px solid var(--rule); margin-top: 32px; padding: 24px 16px 32px;
  text-align: center; color: var(--ink-soft); font-size: 15px;
}
.colophon-note { max-width: 62ch; margin: 0 auto 12px; }
.colophon-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; }
.colophon-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 8px; color: var(--ink-soft); }
.colophon-copy { margin: 8px 0 0; }

/* the solver tools share these building blocks */
.field-label { display: block; font-weight: 600; margin: 0 0 8px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .word-input { flex: 1 1 160px; }
.word-input {
  min-height: 52px; padding: 0 14px; font: 600 22px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink); background: var(--paper); border: 2px solid var(--tile-edge); border-radius: var(--radius);
  width: 100%;
}
.word-input:focus { border-color: var(--rust); outline: none; }
.word-input::placeholder { color: var(--ink-soft); opacity: .55; font-weight: 400; letter-spacing: .05em; text-transform: none; }
.word-input[aria-invalid="true"] { border-color: #b3261e; }
.btn {
  min-height: 52px; padding: 0 24px; border: 0; border-radius: var(--radius); cursor: pointer;
  background: var(--rust); color: var(--rust-ink); font: 600 17px/1 var(--sans); white-space: nowrap;
  box-shadow: 0 3px 0 var(--tile-edge);
}
.btn:hover { filter: brightness(.94); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--tile-edge); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-quiet {
  min-height: 44px; padding: 0 16px; border: 2px solid var(--tile-edge); border-radius: var(--radius); cursor: pointer;
  background: transparent; color: var(--ink); font: 600 16px/1 var(--sans); white-space: nowrap;
}
.btn-quiet:hover { border-color: var(--rust); }
.tool-msg { margin: 12px 0 0; font-size: 16px; color: var(--ink-soft); }
.tool-msg.is-error { color: #b3261e; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .word-input[aria-invalid="true"] { border-color: var(--rust); }
  .tool-msg.is-error { color: var(--rust); }
}
.result { margin-top: 24px; border-top: 1px dashed var(--tile-edge); padding-top: 16px; }
.result-summary { font-size: 18px; margin: 0 0 16px; }
.ladder { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; }
.ladder li { display: flex; align-items: center; gap: 12px; }
.rung { color: var(--ink-soft); font-size: 14px; min-width: 56px; flex: none; white-space: nowrap; }
.tiles { display: inline-flex; gap: 6px; }
.tile {
  width: 44px; height: 48px; display: grid; place-items: center;
  font: 700 22px/1 var(--sans); text-transform: uppercase;
  background: var(--card); border: 2px solid var(--tile-edge); border-radius: 6px;
  box-shadow: 0 2px 0 var(--tile-edge);
}
.tile.is-changed { background: var(--honey); border-color: var(--honey); color: #2b2118; box-shadow: 0 2px 0 var(--rust); }
.tile.is-hidden { color: transparent; background: repeating-linear-gradient(45deg, var(--card), var(--card) 6px, var(--rule) 6px, var(--rule) 12px); }
.result-actions { display: flex; gap: 12px; flex-wrap: wrap; }

@media (max-width: 640px) {
  h1 { font-size: 30px; }
  h2 { font-size: 24px; }
  .sheet { padding-top: 20px; }
  .workbench { padding: 16px; }
  .field-row .btn { flex: 1 1 100%; }
  .tiles { gap: 4px; }
  .tile { width: 36px; height: 42px; font-size: 19px; }
  .rung { min-width: 52px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
