:root {
  --ink: #1c1915;
  --muted: #5c564c;
  --paper: #f3efe6;
  --paper-2: #e7e1d4;
  --cell: #fffdf8;
  --red: #c23b22;
  --rule: rgba(28, 25, 21, 0.14);
  --font-display: "Literata", Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8125rem);
  --text-sm: clamp(0.875rem, 0.82rem + 0.3vw, 0.9375rem);
  --text-base: clamp(1rem, 0.95rem + 0.35vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1rem + 0.5vw, 1.25rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.25rem + 1.25vw, 2rem);
  --text-hero: clamp(2.15rem, 1.4rem + 2.6vw, 3.35rem);
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
  --space-2xl: clamp(3.5rem, 6vw, 5.5rem);
  --space-3xl: clamp(4.5rem, 8vw, 7rem);
  --measure: 42rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
}
main { flex: 1 0 auto; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 600; }
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-hero);
  line-height: 1.12;
  letter-spacing: -0.025em;
  margin: 0 0 var(--space-md);
}
h2 {
  font-size: var(--text-2xl);
  line-height: 1.22;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-md);
}
h3 { font-size: var(--text-lg); margin: 0 0 var(--space-xs); line-height: 1.3; }
p { margin: 0 0 var(--space-sm); }
:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

.skip {
  position: absolute;
  left: var(--space-sm);
  top: -4rem;
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-xs) var(--space-sm);
  z-index: 5;
}
.skip:focus { top: var(--space-sm); }

.mast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  border-bottom: 1px solid var(--ink);
  position: sticky;
  top: 0;
  flex-wrap: wrap;
  background: var(--paper);
  z-index: 4;
}
.brand { display: flex; align-items: center; gap: var(--space-sm); text-decoration: none; font-weight: 600; }
.brand img { width: 36px; height: 36px; }
.site-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 1.05rem; }
.site-nav a { text-decoration: none; font-size: var(--text-sm); white-space: nowrap; }
.site-nav a.btn { font-size: var(--text-sm); }
.site-nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--red); }
.nav-toggle { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.6rem;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--ink);
  background: transparent;
  text-decoration: none;
  cursor: pointer;
  border-radius: 2px;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.btn:hover { background: rgba(28, 25, 21, 0.05); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fffdf8; }
.btn-primary:hover { background: #a8321d; }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: #000; }
.btn[disabled], .btn.is-disabled { opacity: 0.45; pointer-events: none; }

.wrap { width: min(var(--measure), calc(100% - 2.5rem)); margin: 0 auto; }
.hero { padding: var(--space-3xl) 0 var(--space-2xl); }
.hero-grid, .split, .dict-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  align-items: start;
}
.kicker {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--red);
  margin-bottom: var(--space-sm);
}
.lead { font-size: var(--text-lg); max-width: 38rem; color: var(--ink); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-lg); }
.board-frame { position: relative; padding: 0 0 12px 12px; }
.board-frame::before {
  content: "";
  position: absolute;
  inset: 12px 0 0 0;
  border: 2px solid var(--red);
  transform: translate(8px, 8px);
}
.demo-board {
  position: relative;
  z-index: 1;
  background: var(--paper);
  border: 2px solid var(--ink);
  padding: var(--space-md);
}
.demo-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  margin-bottom: var(--space-sm);
}
.cells {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
}
.hero-cell {
  aspect-ratio: 1;
  border: 1px solid var(--ink);
  background: var(--cell);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: clamp(0.85rem, 2vw, 1.15rem);
  position: relative;
  color: transparent;
}
.hero-cell span {
  position: absolute;
  top: 2px;
  left: 3px;
  color: var(--red);
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
}
.hero-cell.fill-1 { animation: fill-cell 0.35s ease forwards; animation-delay: 0.45s; }
.hero-cell.fill-4 { animation: fill-cell 0.35s ease forwards; animation-delay: 1.15s; }
.hero-cell.fill-9 { animation: fill-cell 0.35s ease forwards; animation-delay: 1.85s; }
.hero-caption {
  margin: var(--space-md) 0 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  opacity: 0;
  animation: caption-in 0.4s ease forwards;
  animation-delay: 2.35s;
}
@keyframes fill-cell {
  from { background: var(--cell); color: transparent; }
  to { background: var(--ink); color: var(--paper); }
}
@keyframes caption-in { to { opacity: 1; } }

.section { padding: 0 0 var(--space-2xl); }
.rule { border: 0; border-top: 1px solid var(--ink); margin: 0 0 var(--space-2xl); }
.split { align-items: start; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-lg); }
.steps li { display: grid; grid-template-columns: auto 1fr; gap: var(--space-sm) var(--space-md); }
.num {
  font-family: var(--font-mono);
  color: var(--red);
  font-size: var(--text-sm);
  padding-top: 0.2rem;
}
.finder {
  border: 1px solid var(--ink);
  background: var(--cell);
  padding: var(--space-md);
}
.finder-bar, .finder-tools { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; }
.finder-bar { justify-content: space-between; margin-bottom: var(--space-md); }
.seg { display: inline-flex; border: 1px solid var(--ink); }
.seg button { border: 0; background: transparent; padding: 0.4rem 0.75rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.len-ctrl { display: inline-flex; align-items: center; gap: var(--space-xs); }
.len-ctrl button { width: 2rem; height: 2rem; border: 1px solid var(--ink); background: transparent; cursor: pointer; }
.len-ctrl strong { font-family: var(--font-mono); font-variant-numeric: tabular-nums; min-width: 1.5rem; text-align: center; }
.hint { color: var(--muted); font-size: var(--text-sm); margin: 0 0 var(--space-sm); }
.count-line { font-family: var(--font-mono); font-size: var(--text-sm); font-variant-numeric: tabular-nums; margin: var(--space-sm) 0; }
.grid-scroll { overflow-x: auto; max-width: 100%; padding-bottom: var(--space-xs); }
.letter-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem 0.8rem; width: max-content; max-width: 100%; }
.letter-group { display: inline-flex; gap: 4px; }
.cell {
  width: 2.9rem;
  height: 2.9rem;
  border: 1px solid var(--ink);
  background: var(--cell);
  position: relative;
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
}
.cell .idx { position: absolute; top: 1px; left: 3px; font-family: var(--font-body); font-size: 0.62rem; color: var(--red); font-weight: 600; }
.cell.is-on { background: var(--ink); color: var(--paper); }
.cell.is-on .idx { color: #f3c1b6; }
.cell.is-active { outline: 2px solid var(--red); outline-offset: 2px; }
.sheet { margin-top: var(--space-md); border-top: 1px solid var(--rule); padding-top: var(--space-sm); }
.sheet h3 { font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 500; }
.letter-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.letter-pick button, .sheet .clear-cell {
  min-width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
  font-family: var(--font-mono);
}
.letter-pick button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.words { list-style: none; margin: var(--space-sm) 0 0; padding: 0; }
.words button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--rule);
  padding: 0.7rem 0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  align-items: baseline;
}
.words button strong { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; }
.words button span { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--muted); }
.words button:hover strong { color: var(--red); }
.picked {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 2px solid var(--ink);
}
.picked em { font-style: normal; font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.06em; color: var(--red); }
.picked strong { display: block; font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 700; }
.finder-error { color: var(--red); font-size: var(--text-sm); }
.show-row, .suggest-row { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-md); }
.show-row select, .suggest-row input, .field input, .field textarea, .field select {
  border: 1px solid var(--ink);
  background: var(--cell);
  border-radius: 2px;
  padding: 0.55rem 0.7rem;
  width: 100%;
}
.suggest-row input { max-width: 18rem; }

.dict-grid { grid-template-columns: 1fr; gap: var(--space-lg); }
.dict-side { border-top: 2px solid var(--red); padding-top: var(--space-md); }
.note {
  margin-top: var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--rule);
  color: var(--muted);
  max-width: 42rem;
}
.privacy-box {
  border: 2px solid var(--ink);
  padding: var(--space-md);
  background: var(--paper-2);
  margin: var(--space-md) 0 var(--space-lg);
}
.privacy-box h2 { font-size: var(--text-xl); }
.stores { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin: var(--space-md) 0; }
.faq { max-width: 42rem; }
.faq details { border-top: 1px solid var(--rule); }
.faq details:last-of-type { border-bottom: 1px solid var(--rule); }
.faq summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 1rem; padding: 0.85rem 0; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--font-mono); color: var(--red); flex: none; }
.faq details[open] summary::after { content: "–"; }
.faq-answer { color: var(--muted); padding-bottom: 0.9rem; }
.faq-answer p { margin: 0.35rem 0; }
.faq-answer a { color: inherit; }
.prose { max-width: 40rem; }
.prose p { margin-bottom: var(--space-md); }
.page-head { padding: var(--space-2xl) 0 var(--space-lg); }
.shots { display: flex; flex-wrap: wrap; gap: var(--space-md); }
.shots img { width: min(100%, 12rem); border: 1px solid var(--ink); background: var(--cell); }
.video-frame { max-width: 48rem; border: 1px solid var(--ink); background: #000; }
.video-frame video { width: 100%; display: block; }
.form { max-width: 32rem; display: flex; flex-direction: column; gap: var(--space-sm); }
.field label { display: block; font-size: var(--text-sm); margin-bottom: 0.25rem; }
.colophon {
  margin-top: auto;
  background: var(--ink);
  color: #f3efe6;
  padding: var(--space-xl) 0 var(--space-md);
}
.colophon-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg);
}
.colophon-brand, .colophon-links { flex: 1 1 12rem; }
.colophon-brand { display: flex; gap: var(--space-sm); align-items: flex-start; }
.colophon-brand img { width: 36px; height: 36px; background: #f3efe6; }
.colophon-brand p, .colophon-label { margin: 0; }
.colophon-brand p { color: #d9cfc2; font-size: var(--text-sm); max-width: 22rem; }
.colophon-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #b7aa9a;
  margin-bottom: var(--space-sm);
}
.colophon-links { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
.colophon-links a { color: #f3efe6; text-decoration: none; }
.colophon-links a:hover { color: #fff; }
.colophon-credit {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 1px solid rgba(243, 239, 230, 0.18);
  color: #d9cfc2;
  font-size: var(--text-xs);
}
.colophon-credit a { color: #f3efe6; }
.colophon-credit .heart { color: #e24b38; }
.cookie {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  display: flex;
  gap: var(--space-md);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--ink);
  color: var(--paper);
  border-top: 3px solid var(--red);
}
.cookie[hidden] { display: none; }
.cookie .btn { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.cookie p { margin: 0; font-size: var(--text-sm); }
body:has(.cookie:not([hidden])) { padding-bottom: 4.5rem; }
body:has(.cookie:not([hidden])) .xw-keys { bottom: 4.5rem; }
.toast {
  position: fixed;
  right: var(--space-md);
  bottom: var(--space-md);
  background: var(--ink);
  color: var(--paper);
  padding: var(--space-sm) var(--space-md);
  max-width: 22rem;
  z-index: 8;
  border-left: 4px solid var(--red);
}
.toast[data-variant="err"] { border-left-color: var(--red); }

.stack { display: flex; flex-direction: column; gap: var(--space-sm); max-width: 36rem; }
.account-card {
  border: 1px solid var(--ink);
  background: var(--cell);
  padding: var(--space-lg) var(--space-md);
  max-width: none;
}
.account-card input, .account-card select { min-height: 2.9rem; }
.account-now { margin: 0; }
.legal-links { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin-top: var(--space-sm); }
.legal-links button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 0.16em;
  font-size: var(--text-sm);
}
dialog.legal {
  width: min(36rem, calc(100% - 1.5rem));
  max-height: min(80vh, 40rem);
  overflow: auto;
  border: 1px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  padding: var(--space-md);
}
dialog.legal::backdrop { background: rgba(28, 25, 21, 0.45); }
dialog.legal h2 { margin-top: 0; }
.stack label { display: flex; flex-direction: column; gap: 0.25rem; font-size: var(--text-sm); }
.stack input, .stack select, .stack textarea {
  border: 1px solid var(--ink);
  background: var(--cell);
  padding: 0.55rem 0.7rem;
}
.row { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin: var(--space-md) 0; }
.cipher-board { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 0.7rem; margin-bottom: var(--space-md); }
.cipher-word { display: inline-flex; gap: 4px; }
.cell.is-lock { cursor: default; }
.result-line { font-family: var(--font-display); font-size: var(--text-2xl); line-height: 1.3; }
.xw { --xw: 2.75rem; display: grid; gap: 3px; width: max-content; margin: var(--space-md) 0; }
.xw-slot { position: relative; width: var(--xw); height: var(--xw); }
.xw-slot.is-empty { background: var(--ink); }
.xw-slot .idx { position: absolute; top: 1px; left: 3px; z-index: 1; pointer-events: none; font-family: var(--font-body); font-size: 0.58rem; color: var(--red); font-weight: 600; }
.xw-cell {
  width: 100%;
  height: 100%;
  border: 1px solid var(--ink);
  background: var(--cell);
  position: relative;
  padding: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: var(--xw);
  text-transform: uppercase;
}
.xw-current { font-family: var(--font-display); font-size: var(--text-lg); margin: 0 0 var(--space-sm); }
.xw-keys, .xw-words { display: flex; flex-wrap: wrap; gap: 6px; }
.xw-keys {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--paper);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-sm);
}
.xw-keys[hidden], .xw-assist[hidden] { display: none; }
.xw-keys button, .xw-words button {
  min-width: 2.15rem;
  min-height: 2.45rem;
  border: 1px solid var(--ink);
  background: var(--cell);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 600;
}
.xw-keys button.is-wide { min-width: 4.2rem; font-family: var(--font-body); font-weight: 500; }
.xw-words button { font-family: var(--font-display); font-size: var(--text-lg); padding: 0.2rem 0.65rem; }
.xw-assist { border-top: 1px solid var(--rule); padding-top: var(--space-sm); margin: var(--space-sm) 0 var(--space-md); }
.xw-cell .idx { position: absolute; top: 0; left: 2px; font-family: var(--font-body); font-size: 0.58rem; color: var(--red); font-weight: 600; }
.xw-cell.is-on { outline: 2px solid var(--red); outline-offset: 1px; }
.xw-cell.is-bad { background: #f3d2cb; }
.xw-cell.is-ok { background: #e4efe4; }
.clue-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-lg); margin-top: var(--space-md); }
.cipher-word.is-current { outline: 2px solid var(--red); outline-offset: 4px; }
.clue-list { list-style: none; margin: 0; padding: 0; }
.clue-list li { margin: 0 0 0.7rem; }
.clue-list button { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.clue-src { display: block; color: var(--muted); font-size: var(--text-xs); }
.legal-note { border-left: 3px solid var(--red); padding-left: 0.8rem; color: var(--muted); font-size: var(--text-sm); max-width: 40rem; }
.board-table { width: 100%; border-collapse: collapse; margin: var(--space-sm) 0 var(--space-lg); }
.board-table th, .board-table td { text-align: left; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.board-table th { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 500; }
.note-card { border-left: 4px solid var(--red); padding-left: 0.8rem; margin-bottom: var(--space-md); }
.note-card h3 { margin: 0 0 0.2rem; font-size: var(--text-lg); }
.note-card p { margin: 0; }

@media (max-width: 880px) {
  .mast { flex-wrap: wrap; }
  .hero { padding-top: var(--space-xl); }
}

@media (max-width: 520px) {
  .cell { width: 1.75rem; height: 1.75rem; font-size: 0.9rem; }
  .letter-group { gap: 3px; }
  .clue-grid { grid-template-columns: 1fr; }
  .xw { --xw: 2.15rem; }
  .xw-cell { font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  .hero-cell.fill-1, .hero-cell.fill-4, .hero-cell.fill-9 {
    background: var(--ink);
    color: var(--paper);
  }
  .hero-caption { opacity: 1; }
}
