:root {
  /* Warm ivory rather than candlelit plum: the page now reads like the paper
     the letter is written on, not the room it's read in. */
  --bg-deep: #fbf6f0;
  --bg-warm: #f4e6dc;

  --ink: #2a1720;
  --muted: #6d5360;
  --faint: #9b8590;

  --rose: #d1456b;
  --rose-lit: #b12d55;     /* on a light page "lit" has to mean deeper, not brighter */
  --rose-deep: #8e2f4c;
  --gold: #c9911f;
  --gold-deep: #8a6218;

  --paper: #fffaf1;
  --paper-ink: #221419;
  --paper-rule: #e2d0b4;

  /* Surfaces are a wash of the ink colour, so everything tints together. */
  --tint: rgba(42, 23, 32, .035);
  --tint-strong: rgba(42, 23, 32, .08);
  --line: rgba(42, 23, 32, .13);
  --line-strong: rgba(42, 23, 32, .28);
  --shadow: rgba(104, 58, 80, .18);
  --shadow-deep: rgba(104, 58, 80, .3);

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Libre Franklin", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --header-h: 66px;
  --cols: 8;
  --gap: 6px;
  --heart-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 30'%3E%3Cpath d='M16 29S1 19.5 1 10.2A8.2 8.2 0 0 1 16 5.6 8.2 8.2 0 0 1 31 10.2C31 19.5 16 29 16 29z' fill='%23000'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

/* The `hidden` attribute is only a UA-stylesheet rule, and ANY author rule that
   sets `display` beats it — author origin outranks UA origin whatever the
   specificity. Every element this app hides from JS (#load-error, the letter
   buttons, .w-line-field, the builder) also matches a rule that sets display, so
   without this reset `hidden` silently does nothing. The full-screen
   "Couldn't load this" panel sat on top of every working game because of it. */
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* Candlelight pooling behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(120% 80% at 50% -10%, #fbe3e9 0%, rgba(251,227,233,0) 62%),
    radial-gradient(90% 60% at 12% 102%, #f8e7d6 0%, rgba(248,231,214,0) 58%),
    radial-gradient(80% 55% at 92% 88%, #f6e2ea 0%, rgba(246,226,234,0) 60%),
    var(--bg-deep);
}

#ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Header ---------- */

.topbar {
  height: var(--header-h);
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
}

.topbar-right { display: flex; justify-content: flex-end; gap: 2px; }

.brand { display: flex; flex-direction: column; align-items: center; gap: 5px; }

.wordmark {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(23px, 6.4vw, 34px);
  line-height: 1;
  letter-spacing: .005em;
  white-space: nowrap;
  color: var(--ink);
  text-shadow: 0 0 26px rgba(224, 86, 127, .45);
}

.pips { display: flex; gap: 5px; }

.pip {
  width: 9px; height: 9px;
  opacity: .28;
  background: var(--muted);
  transition: opacity .45s ease, background-color .45s ease, transform .45s cubic-bezier(.2,1.4,.4,1);
  -webkit-mask: var(--heart-mask) center / contain no-repeat;
          mask: var(--heart-mask) center / contain no-repeat;
}
.pip.lit {
  opacity: 1;
  background: var(--rose);
  transform: scale(1.18);
  filter: drop-shadow(0 2px 3px rgba(177, 45, 85, .45));
}

.icon-btn {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  touch-action: manipulation;
  padding: 0; border: 0; border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s ease, background-color .2s ease;
}
.icon-btn:hover { color: var(--ink); background: var(--tint-strong); }
.icon-btn:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.icon-btn svg { width: 21px; height: 21px; fill: currentColor; }
.icon-btn[aria-pressed="true"] { color: var(--rose); }

/* ---------- Board ---------- */

main.game {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 10px 0;
}

.board-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  min-height: 0;
  padding: 6px 0;
  scrollbar-width: thin;
}

.board {
  display: grid;
  grid-auto-rows: auto;
  gap: var(--gap);
  padding: 0 10px;
  width: min(100%, calc(var(--cols) * 68px), 566px);
}

.row { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: var(--gap); }

.tile {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(17px, calc(52vw / var(--cols)), 34px);
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
  transition: border-color .2s ease, transform .1s ease;
}

.tile[data-state="tbd"] {
  border-color: var(--line-strong);
  background: #fff;
  box-shadow: 0 2px 8px var(--shadow);
  animation: pop .12s ease;
}

/* Three clearly different lightnesses, so the states still read for anyone who
   can't separate rose from gold: correct is dark, present is mid, absent pale. */
.tile[data-state="correct"] {
  background: linear-gradient(160deg, var(--rose), var(--rose-deep));
  border-color: var(--rose-deep);
  color: #fff;
  box-shadow: 0 4px 14px rgba(177, 45, 85, .35);
}
.tile[data-state="present"] {
  background: linear-gradient(160deg, #f0c968, var(--gold));
  border-color: var(--gold);
  color: #3d2a05;
}
.tile[data-state="absent"] {
  background: #e7ded9;
  border-color: transparent;
  color: #6b5e64;
}

.tile.flip { animation: flip .55s ease forwards; }
.row.shake { animation: shake .55s ease; }
.row.dance .tile { animation: dance 1s cubic-bezier(.3,1.2,.4,1); }

@keyframes pop { from { transform: scale(.9); } 45% { transform: scale(1.05); } to { transform: scale(1); } }
@keyframes flip { 0% { transform: rotateX(0); } 49%,50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes shake {
  10%,90% { transform: translateX(-2px); } 20%,80% { transform: translateX(4px); }
  30%,50%,70% { transform: translateX(-7px); } 40%,60% { transform: translateX(7px); }
}
@keyframes dance {
  20% { transform: translateY(-16px) scale(1.06); } 40% { transform: translateY(7px); }
  60% { transform: translateY(-8px); } 80% { transform: translateY(3px); } 100% { transform: translateY(0); }
}

.hint {
  margin: 14px 18px 0;
  max-width: 460px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--muted);
  animation: fade-up .5s ease;
}

@keyframes fade-up { from { opacity: 0; transform: translateY(5px); } }

/* ---------- Keyboard ---------- */

.keyboard {
  flex: 0 0 auto;
  display: flex; flex-direction: column; gap: 7px;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 10px 8px calc(12px + env(safe-area-inset-bottom));
  touch-action: manipulation;
}

.kb-row { display: flex; gap: 6px; justify-content: center; }
.kb-spacer { flex: .5; }

.key {
  flex: 1; min-width: 0; height: 54px;
  display: grid; place-items: center;
  padding: 0 2px; border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 1px 3px var(--shadow);
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(11px, 3.3vw, 14px);
  font-weight: 600;
  text-transform: uppercase;
  cursor: pointer; user-select: none;
  transition: background-color .25s ease, color .25s ease, transform .07s ease, box-shadow .25s ease;
}
.key:active { transform: scale(.93); }
.key:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }
.key.wide { flex: 1.6; font-size: clamp(10px, 2.7vw, 12px); }
.key svg { width: 19px; height: 19px; fill: currentColor; }

.key[data-state="correct"] {
  background: linear-gradient(160deg, var(--rose), var(--rose-deep));
  border-color: var(--rose-deep); color: #fff;
  box-shadow: 0 2px 8px rgba(177, 45, 85, .3);
}
.key[data-state="present"] {
  background: linear-gradient(160deg, #f0c968, var(--gold));
  border-color: var(--gold); color: #3d2a05;
}
.key[data-state="absent"] {
  background: #e7ded9;
  border-color: transparent;
  box-shadow: none;
  color: #6b5e64;
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed; top: calc(var(--header-h) + 16px); left: 50%;
  transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}

/* Kept dark: a toast has to separate itself from the page, and on ivory that
   means going the other way. */
.toast {
  background: #32202a;
  border: 1px solid #32202a;
  color: #fdf6f0;
  padding: 12px 20px; border-radius: 999px;
  font-family: var(--serif); font-style: italic; font-size: 17px;
  box-shadow: 0 10px 30px var(--shadow-deep);
  animation: toast-in .2s ease;
  white-space: nowrap;
}
.toast.out { animation: toast-out .3s ease forwards; }

/* Inside an open <dialog> the toast is positioned against the dialog itself.
   left/right + margin rather than translateX, so the entry keyframe (which sets
   transform) can't knock it sideways. */
.toast-over {
  position: absolute; left: 16px; right: 16px; bottom: 14px;
  width: fit-content; margin-inline: auto;
  white-space: normal; text-align: center;
  pointer-events: none;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; } }

/* ---------- Modals ---------- */

.modal {
  width: min(93vw, 520px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 22px 22px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #fffdfa;
  color: var(--ink);
  box-shadow: 0 24px 70px var(--shadow-deep);
}
.modal::backdrop { background: rgba(58, 30, 44, .5); backdrop-filter: blur(3px); }
.modal[open] { animation: modal-in .28s cubic-bezier(.2,.9,.3,1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }

.modal h2 {
  margin: 0 0 16px;
  font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 28px;
}
/* Direct children only — this used to leak into the letter's paragraphs. */
.modal > p { margin: 0 0 13px; font-size: 15px; line-height: 1.6; color: var(--muted); }
.modal .fine {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}

.modal-close-form { position: absolute; top: 12px; right: 14px; margin: 0; }
.modal-close {
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer;
}
.modal-close:hover { color: var(--ink); background: var(--tint-strong); }

.examples { margin: 18px 0; display: flex; flex-direction: column; gap: 15px; }
.example p { margin: 9px 0 0; font-size: 14px; }
.mini-row {
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 4px;
  max-width: min(330px, calc(var(--cols) * 40px));
}
.tile-static {
  font-size: clamp(11px, calc(32vw / var(--cols)), 17px);
  border-radius: 7px; border-width: 1.5px;
}
.tile-static.correct {
  background: linear-gradient(160deg, var(--rose), var(--rose-deep)); border-color: var(--rose-deep); color: #fff;
}
.tile-static.present {
  background: linear-gradient(160deg, #f0c968, var(--gold)); border-color: var(--gold); color: #3d2a05;
}
.tile-static.absent {
  background: var(--tint); border-color: var(--tint-strong); color: var(--faint);
}

/* ---------- The letter ---------- */

/* The ruled lines and the text share one rhythm: --rule. Every line-height and
   every vertical margin is exactly --rule, so the text always sits ON a rule
   instead of drifting between them. */

.letter-modal { padding: 46px 18px 20px; overflow: hidden; }
.letter-modal[open] { display: flex; flex-direction: column; }   /* [open] only — plain
   .letter-modal{display:flex} would override the UA's display:none and leave it
   permanently visible. */

.paper {
  --rule: 34px;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;

  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 6px;
  padding: var(--rule) 24px var(--rule);
  border: 1px solid rgba(122, 59, 79, .14);
  box-shadow: 0 10px 28px var(--shadow), inset 0 0 60px rgba(180, 150, 120, .1);
  font-family: var(--serif);
  line-height: var(--rule);
}

.paper .paper-to,
.paper .paper-line,
.paper .paper-close {
  margin: 0 0 var(--rule);
  line-height: var(--rule);
}
.paper .paper-sign { margin: 0; line-height: var(--rule); }

.paper .paper-to {
  font-size: 21px;
  font-style: italic;
  font-weight: 600;
  color: #7a3b4f;
}

/* No padding of its own, so its top edge IS the first text line's top edge —
   which makes every rule land exactly on a baseline without any offset maths.
   It scrolls as ordinary content inside .paper, so no background-attachment
   trickery is needed. */
.paper-sheet {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--rule) - 1px),
    var(--paper-rule) calc(var(--rule) - 1px),
    var(--paper-rule) var(--rule)
  );
}

.paper-lines { display: block; }

.paper .paper-line {
  font-size: 20px;
  font-weight: 600;
  color: var(--paper-ink);
}
.paper .paper-line.fresh { animation: ink-in .8s ease both; }

/* The word that unlocked the line beneath it. One rule tall like everything
   else on the sheet, so the ruled rhythm still lands on the baselines. */
.paper .paper-word {
  margin: 0;
  line-height: var(--rule);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #a8496a;
}
.paper .paper-word.fresh { animation: ink-in .8s ease both; }
@keyframes ink-in { from { opacity: 0; filter: blur(3px); transform: translateY(6px); } }

.paper .paper-line.locked {
  display: flex;
  gap: 7px;
  align-items: center;
  height: var(--rule);
}
.paper .paper-line.locked span {
  height: 2px;
  border-radius: 2px;
  background: rgba(122, 59, 79, .22);
}

.paper .paper-close, .paper .paper-sign {
  font-size: 20px;
  font-style: italic;
  font-weight: 600;
  color: #7a3b4f;
}
.paper .paper-sign { text-align: right; font-size: 21px; }

.letter-modal .paper-meta {
  flex: 0 0 auto;
  margin: 14px 2px 0;
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--muted);
  text-align: center;
}

/* ---------- Buttons ---------- */

.modal-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.btn {
  flex: 1 1 140px;
  height: 50px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 999px;
  font-family: var(--sans); font-size: 14px; font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .2s ease, transform .07s ease, background-color .2s ease;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.1); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }

.btn-primary {
  background: linear-gradient(160deg, var(--rose), var(--rose-deep));
  color: #fff;
  box-shadow: 0 8px 26px rgba(224, 86, 127, .4);
}
.btn-ghost { background: var(--tint-strong); border-color: var(--line-strong); color: var(--ink); }
.btn-quiet { background: transparent; color: var(--muted); flex: 0 0 auto; }
.btn-quiet:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .tile.flip, .row.shake, .row.dance .tile, .modal[open],
  .toast, .hint, .paper .paper-line.fresh, .pip { animation: none !important; }
  * { transition-duration: .01ms !important; }
}

@media (max-width: 380px) {
  .key { height: 48px; }
  .paper { --rule: 30px; padding: var(--rule) 17px; }
  .paper .paper-line { font-size: 18px; }
  .paper .paper-to, .paper .paper-close, .paper .paper-sign { font-size: 18.5px; }
}

/* ---------- Nudge ---------- */

.nudge {
  margin: 12px auto 0;
  padding: 7px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}
.nudge:hover { color: var(--ink); border-color: var(--line-strong); background: var(--tint); }
.nudge:focus-visible { outline: 2px solid var(--rose); outline-offset: 2px; }

.btn-quiet.armed { color: var(--rose); }

/* The text copy is a fallback now that the image is the real keepsake. */
.linkish {
  display: block; margin: 12px auto 0; padding: 4px;
  background: none; border: 0; cursor: pointer;
  font-family: var(--serif); font-style: italic; font-size: 15px;
  color: var(--muted); text-decoration: underline; text-underline-offset: 3px;
}
.linkish:hover { color: var(--ink); }

/* ==========================================================================
   Site pages: landing and builder. The game keeps everything above.
   ========================================================================== */

.page { display: block; min-height: 100%; }
.page main, .page .done { position: relative; z-index: 1; }

.site-head {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 940px; margin: 0 auto; padding: 20px 20px 8px;
}
.site-mark {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  font-family: var(--serif); font-style: italic; font-size: 20px;
}
.site-heart {
  width: 16px; height: 15px; background: var(--rose);
  -webkit-mask: var(--heart-mask) center/contain no-repeat;
  mask: var(--heart-mask) center/contain no-repeat;
}
.site-heart.big { width: 34px; height: 32px; display: block; margin: 0 auto 18px; }

.btn-big { padding: 15px 30px; font-size: 17px; }

/* ---------- Landing ---------- */

.home { max-width: 940px; margin: 0 auto; padding: 0 20px 80px; }

.hero { padding: 48px 0 12px; text-align: center; }
.hero h1 {
  margin: 0 0 18px;
  font-family: var(--serif); font-weight: 600; font-size: clamp(38px, 8vw, 62px);
  line-height: 1.08; letter-spacing: -.01em;
}
.hero h1 em { font-style: italic; color: var(--rose-lit); }
.hero-sub {
  max-width: 34em; margin: 0 auto 30px;
  font-size: 17px; line-height: 1.65; color: var(--muted);
}
.hero-fine { margin: 14px 0 0; font-size: 13.5px; color: var(--faint); }

.demo { margin: 44px auto 0; text-align: center; }
.demo-row { display: flex; gap: var(--gap); justify-content: center; }
.demo-row .tile { width: 54px; height: 54px; font-size: 26px; }
.demo-caption {
  max-width: 30em; margin: 18px auto 0;
  font-family: var(--serif); font-style: italic; font-size: 19px; color: var(--muted);
}

.steps, .modes-home, .plain { margin-top: 76px; }
.steps h2, .modes-home h2, .plain h2 {
  margin: 0 0 26px;
  font-family: var(--serif); font-weight: 600; font-size: 30px; text-align: center;
}
.steps ol { counter-reset: step; list-style: none; margin: 0; padding: 0;
  display: grid; gap: 24px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.steps li { counter-increment: step; padding: 24px 22px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--tint); }
.steps li::before {
  content: counter(step);
  display: inline-grid; place-items: center; width: 30px; height: 30px; margin-bottom: 14px;
  border-radius: 50%; background: var(--rose-deep); color: var(--ink);
  font-family: var(--sans); font-size: 14px; font-weight: 700;
}
.steps h3, .modes-grid h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.steps p, .modes-grid p { margin: 0; font-size: 15px; line-height: 1.6; color: var(--muted); }

.modes-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.modes-grid article { padding: 24px 22px; border: 1px solid var(--line); border-radius: 14px; }
.modes-grid em { color: var(--rose-lit); font-style: italic; }

.plain ul { max-width: 40em; margin: 0 auto; padding-left: 20px; }
.plain li { margin-bottom: 14px; font-size: 15px; line-height: 1.65; color: var(--muted); }
.plain strong { color: var(--ink); font-weight: 600; }

.home-cta { margin-top: 64px; text-align: center; }

.site-foot {
  position: relative; z-index: 1;
  padding: 30px 20px 44px; text-align: center;
  font-size: 13px; color: var(--faint);
}
.site-foot p { margin: 0; }

/* ---------- Builder ---------- */

.builder { max-width: 720px; margin: 0 auto; padding: 24px 20px 90px; }
.builder-title { margin: 20px 0 8px; font-family: var(--serif); font-weight: 600; font-size: clamp(32px, 7vw, 46px); }
.builder-sub { margin: 0 0 8px; font-size: 16px; line-height: 1.6; color: var(--muted); }

.field-group { margin-top: 42px; }
.group-title {
  margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line);
  font-family: var(--sans); font-size: 13px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.group-note { margin: 0 0 14px; font-size: 13.5px; line-height: 1.55; color: var(--faint); }

.field { display: block; margin-bottom: 18px; position: relative; }
.field .label { display: block; margin-bottom: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.field .label em { font-style: normal; font-weight: 500; color: var(--faint); }
.field-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

input[type="text"], textarea {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.5;
}
textarea { resize: vertical; font-family: var(--serif); font-size: 18px; }
input[type="text"]:focus, textarea:focus {
  outline: none; border-color: var(--rose); box-shadow: 0 0 0 3px rgba(224, 86, 127, .2);
}
input::placeholder, textarea::placeholder { color: var(--faint); }

.counter { display: block; margin-top: 5px; font-size: 12px; color: var(--faint); text-align: right; }
.counter.bad { color: var(--rose-lit); }

.mode-picker { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.mode-card {
  display: block; padding: 20px 18px; text-align: left; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: var(--tint); color: var(--ink); font-family: var(--sans);
}
.mode-card:hover { border-color: var(--rose-deep); }
.mode-card.on { border-color: var(--rose); background: rgba(224, 86, 127, .12); }
.mode-name { display: block; margin-bottom: 7px; font-family: var(--serif); font-size: 21px; font-weight: 600; }
.mode-desc { display: block; font-size: 14px; line-height: 1.55; color: var(--muted); }

.word-row {
  margin-bottom: 16px; padding: 18px 16px 8px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--tint);
}
.word-head { display: flex; align-items: flex-start; gap: 12px; }
.word-num {
  flex: 0 0 auto; margin-top: 30px; width: 24px; height: 24px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--tint-strong); font-size: 12px; font-weight: 700; color: var(--muted);
}
.word-answer { flex: 1 1 auto; margin-bottom: 12px; }
.word-answer input { font-family: var(--sans); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
/* 44px and 8px apart: these were 32px with a 4px gap, which is under every
   touch-target guideline and puts a delete button a thumb-slip from a reorder. */
.word-tools { flex: 0 0 auto; display: flex; gap: 8px; margin-top: 22px; }
.word-tools .icon-btn {
  width: 44px; height: 44px; font-size: 17px;
  border: 1px solid var(--line);
  touch-action: manipulation;          /* no 300ms double-tap-zoom delay */
}
.word-tools .icon-btn:disabled { opacity: .25; cursor: default; }
.word-tools .w-del:hover:not(:disabled) { color: var(--rose-lit); border-color: var(--rose); }

.hints { margin: 0 0 12px; }
.hints summary {
  cursor: pointer; padding: 6px 0; font-size: 13.5px; font-weight: 600; color: var(--muted);
}
.hints summary:hover { color: var(--ink); }
.hint-badge { margin-left: 6px; font-weight: 500; color: var(--faint); }
.hints input { margin-bottom: 8px; font-size: 15px; }

.preview-shell { --rule: 30px; }
.preview-paper { max-height: 340px; font-size: 17px; }
.preview-paper .paper-line { font-size: 17px; }

.errors {
  margin-top: 28px; padding: 16px 18px;
  border: 1px solid var(--rose); border-radius: 12px; background: rgba(224, 86, 127, .12);
}
.errors-title { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--ink); }
.errors ul { margin: 0; padding-left: 20px; }
.errors li { margin-bottom: 5px; font-size: 14.5px; line-height: 1.5; color: var(--ink); }

.builder-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 34px; }
.builder-fine { margin: 14px 0 0; font-size: 13px; color: var(--faint); }
.btn-quiet.danger { color: var(--rose-lit); margin-left: auto; }

/* ---------- The finished link ---------- */

.done { max-width: 620px; margin: 0 auto; padding: 60px 20px 90px; text-align: center; }
.done h1 { margin: 0 0 10px; font-family: var(--serif); font-weight: 600; font-size: clamp(34px, 7vw, 48px); }
.done-sub { margin: 0 0 28px; font-size: 16px; line-height: 1.6; color: var(--muted); }
.done-actions { margin: 16px 0 0; }

.link-box { display: flex; gap: 8px; }
.link-box input {
  flex: 1 1 auto; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px;
}
.link-box .btn { flex: 0 0 auto; }

.keep-box {
  margin-top: 42px; padding: 22px 20px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: 14px; background: var(--tint);
}
.keep-box h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.keep-box p { margin: 0 0 14px; font-size: 14px; line-height: 1.6; color: var(--muted); }

/* ---------- Words mode: the message is the words ---------- */

.paper-lines.word-wall { display: flex; flex-wrap: wrap; gap: 10px 14px; justify-content: center; padding: 8px 0; }
.found-word {
  margin: 0; padding: 7px 16px; border-radius: 999px;
  background: rgba(122, 59, 79, .1); border: 1px solid rgba(122, 59, 79, .22);
  font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: .04em;
  color: var(--paper-ink); text-transform: uppercase;
}
.found-word.fresh { animation: ink-in .8s ease both; }
.found-word.locked { color: rgba(122, 59, 79, .3); letter-spacing: .3em; background: transparent; }

/* ---------- A link that leads nowhere ---------- */

.load-error {
  position: fixed; inset: 0; z-index: 90;
  display: grid; align-content: center; justify-items: center; gap: 10px;
  padding: 24px; text-align: center; background: var(--bg-deep);
}
.load-error h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 32px; }
.load-error p { margin: 0 0 12px; font-size: 15px; color: var(--muted); max-width: 26em; }
body.errored .topbar, body.errored main.game, body.errored .keyboard { display: none; }

@media (max-width: 560px) {
  .site-head { padding: 16px 16px 4px; }
  .hero { padding: 32px 0 6px; }
  .steps, .modes-home, .plain { margin-top: 56px; }
  .word-num, .word-tools { margin-top: 0; }
  .word-head { flex-wrap: wrap; }
  .word-answer { flex: 1 1 100%; order: 3; }
}

.make-own { display: block; margin-top: 6px; text-decoration-style: dotted; }

/* ---------- A single opt-in tick ---------- */

.tickbox {
  display: flex; gap: 12px; align-items: flex-start;
  margin-top: 22px; padding: 16px 18px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--tint);
  cursor: pointer;
}
.tickbox:hover { border-color: var(--line-strong); }
.tickbox input { flex: 0 0 auto; width: 19px; height: 19px; margin: 2px 0 0; accent-color: var(--rose); }
.tickbox strong { display: block; font-size: 14.5px; font-weight: 600; color: var(--ink); }
.tickbox em {
  display: block; margin-top: 5px;
  font-style: normal; font-size: 13px; line-height: 1.55; color: var(--muted);
}
.tickbox u { text-decoration-color: var(--rose); text-underline-offset: 2px; }

.legal-links { margin-top: 10px; font-size: 12.5px; }
.legal-links a { color: var(--muted); }
.legal-links a:hover { color: var(--ink); }
