/* Riddle Seekers styles (was Clue Trail) (v0.7 "adventure journal"). System fonts only (no web fonts, no network).
   Colors chosen for WCAG 2.2 AA contrast on their backgrounds (tests/contrast.js checks them). */
/* Theme: dark is the default (no setting needed); [data-theme="light"] gives the daylight look.
   The choice is never saved: reloading returns to dark. Print always uses the light set. */
:root {
  /* Dark (default): a lantern-lit night map. Deep inky paper, warm parchment text, brass accents,
     a sealing-wax red for the current step and a forest green for steps done. */
  --ink: #f1e6cf;
  --muted: #c4b69b;
  --bg: #11151f;
  --paper: #1a2030;
  --accent: #e3b35e;
  --accent-dark: #f2cb84;
  --accent-soft: #2e2a22;
  --on-accent: #17130b;
  --line: #9c917b;
  --line-soft: #2a3142;
  --line-card: #3b4357;
  --line-faint: #2a3142;
  --ok: #8fd19a;
  --ok-bg: #18291f;
  --on-ok: #11151f;
  --warn-bg: #3a2d12;
  --warn-ink: #f4d08a;
  --error: #ff9c8a;
  --error-bg: #3a1d1a;
  --focus: #86c5ff;
  --note-bg: #222a3b;
  --step-num-bg: #333b4f;
  --disabled-bg: #262d3c;
  --disabled-ink: #a39c8d;
  --shadow: rgba(0, 0, 0, 0.55);
  --shadow-soft: rgba(0, 0, 0, 0.4);
  --toggle-bg: #1a2030;
  --stamp: #b4412c;
  --on-stamp: #fff3e0;
  --tape: rgba(227, 179, 94, 0.22);
  --glow: rgba(227, 179, 94, 0.10);
  /* Paper grain: an inline SVG noise filter, light specks for the night map. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .93 0 0 0 0 .8 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
  color-scheme: dark;
  /* Printed paper sheets (printout preview, sample card): the same in both themes. */
  --sheet-bg: #fffdf8;
  --sheet-ink: #000000;
  --sheet-muted: #4a4033;
  --radius: 6px;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-hand: "Bradley Hand", "Segoe Print", "Chalkboard SE", "Marker Felt", "Comic Sans MS", cursive;
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.5;
}
:root[data-theme="light"] {
  /* Light: daylight parchment. Ink-navy text and buttons, map-red stamps, forest green for done. */
  --ink: #1d2638;
  --muted: #5a4a35;
  --bg: #ece1c8;
  --paper: #fbf5e6;
  --accent: #24406e;
  --accent-dark: #172d52;
  --accent-soft: #e4e2d6;
  --on-accent: #fffaf0;
  --line: #7c6f58;
  --line-soft: #dccfb2;
  --line-card: #d6c9ab;
  --line-faint: #e4d9c0;
  --ok: #2f6b34;
  --ok-bg: #e3efd9;
  --on-ok: #ffffff;
  --warn-bg: #f8e6b5;
  --warn-ink: #5c4300;
  --error: #a32a1a;
  --error-bg: #fbe9e2;
  --focus: #0b5fc4;
  --note-bg: #f3ead6;
  --step-num-bg: #e6dcc4;
  --disabled-bg: #e3d9c3;
  --disabled-ink: #5f5647;
  --shadow: rgba(60, 40, 10, 0.18);
  --shadow-soft: rgba(60, 40, 10, 0.10);
  --toggle-bg: #fbf5e6;
  --stamp: #a5321f;
  --on-stamp: #fff8ec;
  --tape: rgba(196, 160, 90, 0.38);
  --glow: rgba(255, 255, 255, 0.45);
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .1 0 0 0 .12 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 96px; } /* keeps focused fields clear of the sticky spot counter (WCAG 2.4.11) */
body {
  margin: 0; color: var(--ink); font-size: 1rem;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 90% 55% at 50% -8%, var(--glow), transparent 70%), var(--grain);
  background-attachment: fixed, scroll;
}
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3, h4 { line-height: 1.2; font-family: var(--font-display); font-weight: 700; }
a { color: var(--accent); text-underline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 8px; top: -60px; background: var(--paper); color: var(--accent); border: 2px solid var(--accent); padding: 8px 12px; border-radius: var(--radius); z-index: 10; }
.skip-link:focus { top: 8px; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input:focus-visible, select:focus-visible { outline-offset: 1px; }

/* Shared journal-page surface: warm paper, grain, a thin inner rule and a soft lift. */
.wizard, .toolbar, .after-sheets > section {
  background-color: var(--paper);
  background-image: var(--grain);
  border: 1px solid var(--line-card);
  box-shadow: inset 0 0 0 5px var(--paper), inset 0 0 0 6px var(--line-soft), 0 10px 24px -12px var(--shadow), 0 1px 2px var(--shadow-soft);
}
/* A strip of tape holding the page down. Decorative, screen only. */
.wizard, .toolbar { position: relative; }
.wizard::before, .toolbar::before {
  content: ""; position: absolute; top: -11px; left: 50%; width: 112px; height: 24px; margin-left: -56px;
  background: var(--tape); transform: rotate(-2deg); pointer-events: none;
  border-left: 1px dashed rgba(0, 0, 0, 0.08); border-right: 1px dashed rgba(0, 0, 0, 0.08);
}

/* ---------- header / footer ---------- */
.site-header { padding: 20px 0 4px; position: relative; }
.site-header .wrap { position: relative; }
.brand { padding-right: 150px; }
@media screen and (max-width: 520px) { .brand { padding-right: 0; } .theme-toggle { position: static; margin: 0 0 10px; } }
.theme-toggle { position: absolute; top: 0; right: 16px; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px; border-radius: var(--radius); border: 2px solid var(--accent); background: var(--toggle-bg); color: var(--accent); font: inherit; font-weight: 700; font-size: 0.92rem; cursor: pointer; }
.theme-toggle:hover { background: var(--accent-soft); }
.brand { display: flex; align-items: center; gap: 12px; font-family: var(--font-display); font-size: 2rem; font-weight: 700; margin: 0; letter-spacing: 0.01em; line-height: 1.1; }
.compass { flex: none; width: 46px; height: 46px; color: var(--accent); }
.compass .c-north { fill: var(--stamp); }
.compass .c-hub { fill: var(--paper); stroke: currentColor; }
/* Privacy line: a quiet ink note, not a loud pill (review finding: it outweighed the task). */
.privacy-pill { display: inline-block; margin: 0; background: transparent; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); padding: 4px 12px; font-size: 0.9rem; }
.site-footer { margin-top: 48px; padding: 22px 0 32px; border-top: 2px dashed var(--line-card); color: var(--muted); font-size: 0.8rem; line-height: 1.45; }
.site-footer strong { color: var(--ink); }
.byline { margin: 6px 0 0; font-size: 0.8rem; color: var(--muted); }
.byline a { color: inherit; }
.version { font-size: 0.85rem; font-family: var(--font-display); font-style: italic; }
/* v0.8: the footer is small and quiet (Ian: "can be much smaller"); muted text keeps AA on both themes. */
.footer-title { font-family: var(--font-body); font-size: 0.82rem; font-weight: 700; color: var(--muted); margin: 0 0 4px; letter-spacing: 0.02em; }
.footer-section { margin: 0 0 12px; }
.footer-list { margin: 0; padding-left: 1.2em; }
.footer-list li { margin: 2px 0; }
.footer-section p { margin: 0; }

/* ---------- hero (v0.12): who it's for, the moment, one call to action, value props ---------- */
.hero { margin: 18px 0 0; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px 32px; align-items: center; }
@media screen and (min-width: 760px) { .hero-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); } }
.hero-kicker { margin: 0 0 6px; font-family: var(--font-hand); font-size: 1.3rem; line-height: 1.3; color: var(--accent); }
.hero h1 { margin: 0 0 12px; font-size: 2.7rem; line-height: 1.08; letter-spacing: 0.002em; max-width: 15em; }
.hero-sub { margin: 0 0 18px; font-size: 1.12rem; color: var(--ink); max-width: 34em; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 0; }
.hero-note { margin: 0; color: var(--muted); font-size: 0.95rem; }
.btn-hero { display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 12px 26px; font-size: 1.12rem; text-decoration: none; }
.cta-arrow { display: inline-block; transition: transform 0.15s ease-out; }
.btn-hero:hover .cta-arrow, .btn-hero:focus-visible .cta-arrow { transform: translateX(3px); }
@media (prefers-reduced-motion: reduce) { .cta-arrow { transition: none; } .btn-hero:hover .cta-arrow, .btn-hero:focus-visible .cta-arrow { transform: none; } }
.btn-hero:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
/* Decorative treasure map: hidden on narrow screens so the call to action stays near the top. */
.hero-map { width: 100%; max-width: 320px; height: auto; justify-self: center; display: none; overflow: visible; }
@media screen and (min-width: 760px) { .hero-map { display: block; } }
.hero-map .map-paper { fill: var(--paper); stroke: var(--line-card); stroke-width: 1.5; filter: drop-shadow(0 8px 10px var(--shadow-soft)); }
.hero-map .map-fold { fill: none; stroke: var(--line-soft); stroke-width: 1.2; }
.hero-map .map-trail { fill: none; stroke: var(--line); stroke-width: 2.5; stroke-dasharray: 6 6; stroke-linecap: round; }
.hero-map .map-stop circle { fill: var(--stamp); }
.hero-map .map-stop text { fill: var(--on-stamp); font-family: var(--font-display); font-weight: 700; font-size: 13px; text-anchor: middle; }
.hero-map .map-x { fill: none; stroke: var(--stamp); stroke-width: 5; stroke-linecap: round; }
.hero-map .map-compass circle { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.hero-map .map-compass path { fill: var(--accent); opacity: 0.6; }
.hero-map .map-compass .map-north { fill: var(--stamp); opacity: 1; }
.hero .privacy-pill { display: block; margin: 4px 0 0; padding: 0; border: 0; font-size: 0.88rem; }
/* Value props: one strip of journal paper, five short items split by dashed rules. */
.value-props {
  list-style: none; margin: 18px 0 0; padding: 16px 18px; display: grid; gap: 14px 0;
  grid-template-columns: minmax(0, 1fr);
  background-color: var(--paper); background-image: var(--grain);
  border: 1px solid var(--line-card); border-radius: var(--radius);
  box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5px var(--line-soft), 0 8px 18px -12px var(--shadow);
}
@media screen and (min-width: 560px) { .value-props { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; } }
@media screen and (min-width: 880px) {
  .value-props { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; padding: 18px 6px; }
  .value-props li { padding: 0 14px; }
  .value-props li + li { border-left: 2px dashed var(--line-faint); }
}
.value-props li { display: flex; gap: 10px; align-items: flex-start; }
@media screen and (min-width: 880px) { .value-props li { flex-direction: column; gap: 8px; } }
.prop-icon { flex: none; width: 34px; height: 34px; color: var(--accent); }
.value-props p { margin: 0; font-size: 0.9rem; line-height: 1.38; color: var(--muted); }
.value-props strong { display: block; margin-bottom: 2px; color: var(--ink); font-family: var(--font-display); font-size: 1.02rem; line-height: 1.22; }

/* ---------- printout preview (step 1 only, never printed) ---------- */
/* v0.7: one real, readable sample clue card (review finding 23) plus short labels for the other pages. */
.preview { margin: 0 0 22px; }
.preview-title { font-size: 1.15rem; margin: 0 0 12px; }
.preview-layout { display: grid; grid-template-columns: 1fr; gap: 18px 28px; align-items: start; }
@media (min-width: 640px) { .preview-layout { grid-template-columns: minmax(0, 300px) minmax(0, 1fr); } }
.sample { margin: 0; max-width: 300px; }
.sample figcaption { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); line-height: 1.35; }
.mini-sample {
  position: relative; background: var(--sheet-bg); color: var(--sheet-ink); color-scheme: light;
  border: 2px dashed #000; border-radius: 4px; padding: 16px 16px 14px;
  display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; line-height: 1.35;
  transform: rotate(-1.2deg); box-shadow: 0 8px 18px -8px var(--shadow);
}
.mini-sample::before { content: ""; position: absolute; inset: 4px; border: 1px solid #8a7d66; border-radius: 2px; pointer-events: none; }
.mini-sample::after { content: ""; position: absolute; top: -12px; left: 50%; width: 84px; height: 22px; margin-left: -42px; background: var(--tape); transform: rotate(3deg); }
.mini-sample p { margin: 0; position: relative; }
.mini-sample .card-head { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid #000; padding-bottom: 6px; }
.mini-sample .card-title { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.mini-sample .turn { font-weight: 700; }
.mini-sample .flourish { font-style: italic; }
.mini-sample .riddle { font-weight: 600; font-size: 0.98rem; }
.mini-sample .corner { position: absolute; bottom: 6px; right: 10px; font-size: 0.75rem; font-weight: 700; color: #333; }
.mini-sample .cut { position: absolute; top: -0.75em; left: 10px; background: var(--sheet-bg); padding: 0 4px; line-height: 1; }
.preview-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.preview-list li { display: flex; gap: 12px; align-items: flex-start; }
.preview-icon { flex: none; width: 40px; height: 40px; color: var(--accent); }
.preview-cap { margin: 0; font-size: 0.95rem; color: var(--muted); line-height: 1.4; }
.preview-cap strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 1.05rem; }

/* ---------- wizard ---------- */
.wizard { border-radius: var(--radius); margin-top: 28px; padding: 28px; }
.wizard-title { margin: 0 0 8px; font-size: 1.9rem; letter-spacing: 0.005em; }
.lede { color: var(--muted); margin: 0 0 18px; max-width: 40em; }
.need-note { color: var(--muted); margin: -8px 0 18px; max-width: 40em; }

/* Step progress as a trail with five stops: dashed path, wax-seal current stop, green stops behind you. */
.progress { list-style: none; padding: 0; margin: 4px 0 24px; display: flex; gap: 0; counter-reset: none; }
.progress li { flex: 1 1 0; min-width: 0; position: relative; }
.progress li + li::before {
  content: ""; position: absolute; top: 25px; left: -50%; right: 50%; z-index: 0;
  border-top: 2px dashed var(--line); pointer-events: none;
}
.progress li.done + li::before { border-top-style: solid; border-color: var(--ok); }
.step-link { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; padding: 4px 2px 6px; border: 0; border-radius: var(--radius); background: transparent; font: inherit; font-size: 0.92rem; color: var(--muted); text-align: center; line-height: 1.2; }
button.step-link { cursor: pointer; }
button.step-link:hover > span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.progress .done .step-link, .progress .visited .step-link { color: var(--ink); }
.progress .done .step-num { background: var(--ok); color: var(--on-ok); border: 2px solid var(--ok); }
.progress .visited .step-num { border-style: solid; border-color: var(--accent); color: var(--ink); }
.progress .current .step-link { color: var(--ink); font-weight: 700; }
.progress .current .step-num { background: var(--stamp); color: var(--on-stamp); border: 2px solid var(--stamp); box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent); }
.step-num { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--step-num-bg); color: var(--ink); border: 2px dashed var(--line); font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
@media screen and (max-width: 420px) { .step-num { width: 36px; height: 36px; font-size: 0.95rem; } .progress li + li::before { top: 21px; } .step-link { font-size: 0.8rem; } }

.step-title { font-size: 1.6rem; margin: 4px 0 6px; }
.step-title:focus { outline: none; }
.step-title:focus-visible { outline: 3px solid var(--focus); }
.step-kicker { display: block; font-family: var(--font-hand); font-size: 1.05rem; font-weight: 400; color: var(--accent); letter-spacing: 0.01em; margin-bottom: 2px; }
.step-intro { color: var(--muted); margin-top: 0; }

fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
legend { font-family: var(--font-display); font-weight: 700; padding: 0; margin-bottom: 8px; font-size: 1.12rem; }
.field { margin-bottom: 14px; }
.field label, .label-row label { display: block; font-weight: 600; margin-bottom: 4px; }
.label-row { display: flex; align-items: center; gap: 8px; }
.label-row label { margin-bottom: 4px; }
input[type="text"], select {
  font: inherit; font-size: 1rem; width: 100%; max-width: 420px; min-height: 44px; padding: 8px 12px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink);
}
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--error); }
.code-input { max-width: 140px !important; font-size: 1.4rem !important; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin: 2px 0 0; }

.kid-row { border: 2px dashed var(--line-card); border-radius: var(--radius); padding: 14px 16px 6px; display: grid; grid-template-columns: 1fr; gap: 0 16px; }
.kid-row legend { padding: 0 6px; margin-left: -6px; }
@media (min-width: 640px) { .kid-row { grid-template-columns: 2fr 1fr; align-items: start; } .kid-row > .btn { grid-column: 1 / -1; justify-self: start; margin-bottom: 10px; } }
.band-hint { color: var(--muted); font-size: 0.9rem; margin: 4px 0 0; min-height: 1.2em; }

/* Tooltips: a round brass "?" and a pinned field note. */
.help-btn { width: 32px; height: 32px; flex: none; border-radius: 50%; border: 2px solid var(--accent); background: var(--paper); color: var(--accent); font-family: var(--font-display); font-weight: 700; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; margin-bottom: 4px; }
.help-btn[aria-expanded="true"] { background: var(--accent); color: var(--on-accent); }
.help-bubble { position: relative; background: var(--accent-soft); border: 1px solid var(--line-card); border-left: 4px solid var(--accent); border-radius: 2px var(--radius) var(--radius) 2px; padding: 10px 12px; margin: 10px 0 0; max-width: 480px; font-size: 0.93rem; box-shadow: 0 6px 14px -8px var(--shadow); }

.note { background: var(--note-bg); border: 1px dashed var(--line-card); border-radius: var(--radius); padding: 4px 14px; margin-top: 16px; font-size: 0.95rem; }
.hint { color: var(--muted); font-size: 0.92rem; margin: 4px 0 10px; }
.muted { color: var(--muted); font-weight: 400; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); padding: 8px 12px; font-size: 0.93rem; }

/* Theme choices: index cards that get a brass outline and an offset ink shadow when picked. */
.theme-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .theme-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 820px) { .theme-grid:not(.two) { grid-template-columns: 1fr 1fr 1fr; } }
.theme-group-title { grid-column: 1 / -1; margin: 10px 0 -4px; font-weight: 700; font-size: 0.95rem; color: var(--accent); }
.theme-group-title:first-of-type { margin-top: 0; }
.choice-pair { font-size: 0.82rem; color: var(--muted); }
.choice-card { position: relative; }
.choice-card input { position: absolute; top: 16px; left: 14px; }
.choice-card label { display: flex; flex-direction: column; gap: 2px; height: 100%; padding: 12px 14px 12px 46px; border: 2px solid var(--line-card); border-radius: var(--radius); cursor: pointer; background: var(--note-bg); }
.choice-card label:hover { border-color: var(--line); }
.choice-card input:checked + label { border-color: var(--accent); background: var(--accent-soft); box-shadow: 4px 4px 0 var(--accent); }
.choice-card input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice-emoji { font-size: 1.6rem; line-height: 1; }
.choice-name { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; }
.choice-blurb { color: var(--muted); font-size: 0.92rem; }
.choice-sample { font-style: italic; font-size: 0.88rem; color: var(--muted); }

.count-group .radio-inline, .check-line { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
/* v0.9: step 5 "Puzzle style" */
.puzzle-style { margin: 18px 0 16px; }
.puzzle-style .hint { margin: 0 0 8px; }
.puzzle-style .radio-inline { display: flex; align-items: center; gap: 10px; min-height: 32px; margin-bottom: 4px; }
/* v0.16 two trails: the choices on step 1, the moon and star marks (solid shapes, never emoji) and the trail sections on the host sheet. */
.trail-group { margin: 14px 0 6px; }
.trail-group .radio-inline { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.trail-choices .note, .trail-choices .hint { margin: 6px 0; }
.vp-svg.trail-mark { display: inline-block; vertical-align: middle; flex: 0 0 auto; margin: 0; }
.trail-corner { display: inline-flex; align-items: center; gap: 2px; }
.slip-badge.has-mark { display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.trail-heading { display: flex; align-items: center; gap: 8px; margin: 10px 0 2px; font-size: 1rem; line-height: 1.25; }
.trail-section + .trail-section, .trail-section + .prize-list { margin-top: 4px; }
.two-trails .card::after { display: none; }
.counter { font-weight: 700; padding: 10px 12px; border-radius: var(--radius); margin: 0 0 16px; }
.counter.ok { background: var(--ok-bg); color: var(--ok); }
.counter.short { background: var(--warn-bg); color: var(--warn-ink); }
/* Step 3 (v0.6): the Back / Next bar, with the spot counter between the buttons, stays pinned to the
   bottom of the screen while the rooms scroll, so the count and the way forward are always together. */
.nav-extra { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; }
.nav-extra .counter { margin: 0; align-self: center; border: 2px solid currentColor; }
.nav-buttons.is-sticky { position: sticky; bottom: 0; z-index: 5; background: var(--paper); margin-left: -28px; margin-right: -28px; padding: 12px 28px; border-top: 2px dashed var(--line-card); box-shadow: 0 -8px 16px -6px var(--shadow-soft); }
.starter-row { margin: 0 0 16px; }
.starter-row .hint { margin: 6px 0 0; }
.starter-status { margin: 8px 0 0; padding: 8px 12px; border-radius: var(--radius); background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.starter-status:focus { outline: none; }
.starter-status:focus-visible { outline: 3px solid var(--focus); }
/* Rooms are collapsed accordions, styled like journal tabs; the heading button shows how many spots are picked. */
.rooms { margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.room-heading { margin: 0; font-size: 1.05rem; }
.room-heading-static { padding: 10px 0 0; }
.room-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 12px; border: 2px solid var(--line-card); border-radius: var(--radius); background: var(--note-bg); color: var(--ink); font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; text-align: left; cursor: pointer; }
.room-toggle:hover { border-color: var(--line); }
.room-toggle[aria-expanded="true"] { border-color: var(--accent); border-bottom-style: dashed; border-radius: var(--radius) var(--radius) 0 0; }
.room-chevron { display: inline-block; width: 1em; color: var(--accent); transition: transform 0.15s; }
.room-toggle[aria-expanded="true"] .room-chevron { transform: rotate(90deg); }
.room-name { flex: 1 1 auto; }
.room-count { background: var(--stamp); color: var(--on-stamp); border-radius: 3px; padding: 1px 10px; font-family: var(--font-body); font-size: 0.85rem; white-space: nowrap; transform: rotate(-2deg); box-shadow: 0 0 0 1px var(--paper), 0 0 0 2px var(--stamp); }
.room-total { color: var(--muted); font-family: var(--font-body); font-weight: 400; font-size: 0.9rem; white-space: nowrap; }
.room-panel { padding: 8px 8px 6px; border: 2px solid var(--accent); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); }
.room-fieldset { margin: 0; }
@media (prefers-reduced-motion: reduce) { .room-chevron { transition: none; } }
.included { background: var(--note-bg); border-radius: var(--radius); padding: 10px 14px; }
.included-title { margin: 0 0 4px; }
.included ul { margin: 0; padding-left: 1.3em; }
.included li { margin: 2px 0; }
.room-group { margin: 0 0 8px; }
.custom-group { border-top: 2px dashed var(--line-faint); padding-top: 12px; margin-top: 16px; }
.spot-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 4px 16px; }
@media (min-width: 640px) { .spot-list { grid-template-columns: 1fr 1fr; } }
.spot-list li { display: flex; align-items: center; gap: 10px; margin: 0; }
.spot-list li .btn { margin-left: auto; }
/* The whole row is the label: a wide tap target at least 44px tall (v0.6). */
.spot-row { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-height: 44px; padding: 6px 8px; border-radius: var(--radius); cursor: pointer; }
.spot-row:hover { background: var(--accent-soft); }
.spot-row input { margin: 0; }
.spot-label { flex: 0 1 auto; }
.spot-list li.custom-spot { flex-wrap: wrap; }
.spot-list li.custom-spot .spot-row { flex: 1 1 10rem; min-width: 0; }
.suggest-list { list-style: none; padding: 0; margin: 8px 0 0; }
.suggest-item { padding: 8px 0; border-top: 1px dashed var(--line-faint); }
.suggest-spot { font-weight: 600; display: block; margin-bottom: 6px; }
.suggest-confirm { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; }
.suggest-confirm p { margin: 0 0 8px; font-size: 0.92rem; }
.suggest-buttons { display: flex; flex-wrap: wrap; gap: 12px; }
.suggest-status { margin: 4px 0 0; font-size: 0.92rem; }
.suggest-status:empty { display: none; }
.suggest-status:focus { outline: none; }
.suggest-status.is-ok { color: var(--ok); font-weight: 600; }
.suggest-status.is-error { color: var(--error); }
.spot-emoji { display: inline-block; width: 1.4em; text-align: center; }
.custom-toggle { width: 100%; text-align: left; margin-bottom: 8px; }
.custom-toggle-label { font-weight: 700; margin: 0 0 8px; }
.custom-panel[hidden] { display: none; }
.custom-row { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.custom-row label { display: block; font-weight: 600; margin-bottom: 4px; }
.custom-row .cr-label-word { margin-top: 14px; }
.custom-row .cr-help { margin: 4px 0 10px; }
.cr-add { margin: 4px 0 10px; }
@media (min-width: 600px) {
  /* rows: labels / inputs / help text. v0.13: the Add button sits below the picture picker. */
  .custom-row { grid-template-columns: 2fr 1fr; grid-template-rows: auto auto auto; align-items: start; }
  .custom-row .cr-label-where { grid-column: 1; grid-row: 1; }
  .custom-row .cr-label-word { grid-column: 2; grid-row: 1; margin-top: 0; }
  .custom-row .cr-input-where { grid-column: 1; grid-row: 2; }
  .custom-row .cr-input-word { grid-column: 2; grid-row: 2; }
  .custom-row .cr-help { grid-column: 2; grid-row: 3; }
}
.field-error { color: var(--error); font-weight: 600; margin: 0; min-height: 1px; }
/* v0.13: optional picture for the parent's own spot. Native radios (arrow keys move, Tab leaves the
   group), visually hidden but focusable; each tile shows its emoji and a visible name. */
.pic-picker { margin: 10px 0 8px; }
.pic-picker legend { font-weight: 600; }
.pic-picker .hint { margin: 2px 0 8px; }
.pic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.4rem, 1fr)); gap: 6px; }
.pic-choice { position: relative; }
.pic-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.pic-choice label { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; padding: 4px; border: 2px solid var(--line-card); border-radius: var(--radius); background: var(--note-bg); cursor: pointer; text-align: center; }
.pic-choice label:hover { border-color: var(--line); }
.pic-choice input:checked + label { border-color: var(--accent); background: var(--accent-soft); box-shadow: 3px 3px 0 var(--accent); }
.pic-choice input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.pic-emoji { font-size: 1.5rem; line-height: 1.1; }
.pic-name { font-size: 0.8rem; line-height: 1.2; }
.pic-choice.is-none label { min-height: 58px; font-weight: 600; }
/* v0.13: step 4 has three finale cards; their options sit below. */
@media (min-width: 820px) { .finale-grid { grid-template-columns: 1fr 1fr 1fr; } }
.map-options { margin: 16px 0 8px; }
.map-dig { margin: 8px 0 12px; }
.map-dig .hint { margin: 2px 0 0; }

.review { display: grid; grid-template-columns: max-content 1fr; gap: 0 16px; margin: 0 0 18px; align-items: center; }
.review dt { font-family: var(--font-display); font-weight: 700; padding: 8px 0; border-bottom: 1px dashed var(--line-card); align-self: stretch; display: flex; align-items: center; }
.review dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 8px 0; border-bottom: 1px dashed var(--line-card); align-self: stretch; }
.change-link { min-height: 32px; }
.inline-error { margin: 4px 0 6px; }
.error-step-link { font-weight: 700; }
.hunt-exists { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; background: var(--note-bg); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 8px 14px; margin: 0 0 16px; }
.hunt-exists p { margin: 0; flex: 1 1 20rem; }
.prune-note { margin-top: 16px; }
.save-setup-review { margin-top: 18px; }

.error-summary { border: 3px solid var(--error); border-radius: var(--radius); padding: 8px 16px; margin-bottom: 16px; background: var(--error-bg); }
.error-summary:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.error-title { color: var(--error); font-size: 1.1rem; margin: 6px 0; }
.error-summary a { color: var(--error); font-weight: 600; }

/* Buttons: solid ink (or brass) primary with a pressed-ink edge; outlined secondary; underlined quiet. */
.nav-buttons { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; border-top: 2px dashed var(--line-faint); padding-top: 16px; }
.nav-buttons #next-btn { margin-left: auto; }
.btn { font: inherit; font-weight: 700; min-height: 44px; padding: 10px 20px; border-radius: var(--radius); border: 2px solid var(--accent); cursor: pointer; letter-spacing: 0.01em; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 0 var(--shadow); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-primary:active { box-shadow: 0 1px 0 var(--shadow); transform: translateY(2px); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--disabled-bg); border-color: var(--disabled-bg); color: var(--disabled-ink); cursor: not-allowed; text-decoration: none; box-shadow: none; transform: none; }
.btn-secondary { background: var(--paper); color: var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; padding-left: 6px; padding-right: 6px; box-shadow: none; }
.btn-quiet:hover { text-decoration-thickness: 2px; }
.btn-small { min-height: 36px; padding: 4px 10px; font-size: 0.9rem; }
@media (prefers-reduced-motion: reduce) { .btn-primary:active { transform: none; } }
/* Touch screens get full 44px targets (WCAG 2.5.5 level, beyond AA's 24px); mouse users keep compact controls. */
@media (pointer: coarse) {
  .btn-small, .change-link { min-height: 44px; }
  .help-btn { width: 44px; height: 44px; }
  .photo-zoom input[type="range"] { min-height: 44px; }
  .puzzle-select { min-height: 44px; }
}

/* ---------- output preview ---------- */
.output { margin-top: 36px; }
.toolbar { border-radius: var(--radius); padding: 24px 28px; margin-bottom: 24px; }
.toolbar h2 { margin: 0 0 8px; font-size: 1.7rem; display: flex; align-items: center; gap: 12px; }
.toolbar h2:focus { outline: none; }
.x-mark { flex: none; width: 72px; height: 34px; color: var(--line); }
.x-mark .x { stroke: var(--stamp); }
.toolbar-buttons { display: flex; flex-wrap: wrap; gap: 12px; }
/* "Print, cut, hide" as three stamped stops. */
.next-steps { list-style: none; counter-reset: stop; margin: 10px 0 16px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.next-steps li { counter-increment: stop; position: relative; margin: 0; padding: 4px 0 4px 44px; min-height: 32px; }
.next-steps li::before { content: counter(stop); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--stamp); color: var(--on-stamp); font-family: var(--font-display); font-weight: 700; box-shadow: 0 0 0 2px var(--paper), 0 0 0 3px var(--stamp); }
.next-steps li + li::after { content: ""; position: absolute; left: 15px; top: -10px; height: 12px; border-left: 2px dashed var(--line); }
.print-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 10px; }
.print-row .hint { margin: 0; flex: 1 1 18rem; }
.leave-note { margin: 10px 0 0; }
.more-options { margin-top: 12px; border-top: 2px dashed var(--line-faint); padding-top: 8px; }
.more-options-panel { padding: 8px 0 0; }
.after-sheets { max-width: 8.5in; margin: 28px auto 0; display: flex; flex-direction: column; gap: 14px; }
.after-sheets > section { border-radius: var(--radius); padding: 16px 20px; }
.disclosure { width: 100%; text-align: left; }
.save-setup-panel, .help-improve-panel { margin-top: 12px; }
.sheets { display: flex; flex-direction: column; align-items: center; gap: 28px; }

.sheet { background: var(--sheet-bg); width: 100%; max-width: 8.5in; padding: 0.5in; box-shadow: 0 12px 28px -12px var(--shadow), 0 1px 3px var(--shadow-soft); outline: 1px solid #cfc4ad; color: var(--sheet-ink); color-scheme: light; position: relative; }
/* Screen only: two corners of tape hold each printed page to the desk. */
.sheet::before, .sheet::after { content: ""; position: absolute; top: -9px; width: 70px; height: 20px; background: var(--tape); pointer-events: none; }
.sheet::before { left: -14px; transform: rotate(-35deg); }
.sheet::after { right: -14px; transform: rotate(35deg); }
/* Printed paper sheets always use the light theme's tokens (v0.6), so focus rings and the
   screen-only card tools keep their contrast on paper in dark mode too. Same values as the light set;
   tests/contrast.js checks they match. */
.sheet {
  --ink: #1d2638;
  --muted: #5a4a35;
  --paper: #fbf5e6;
  --accent: #24406e;
  --accent-dark: #172d52;
  --accent-soft: #e4e2d6;
  --on-accent: #fffaf0;
  --line: #7c6f58;
  --line-card: #d6c9ab;
  --line-faint: #e4d9c0;
  --ok: #2f6b34;
  --ok-bg: #e3efd9;
  --warn-bg: #f8e6b5;
  --warn-ink: #5c4300;
  --error: #a32a1a;
  --error-bg: #fbe9e2;
  --focus: #0b5fc4;
  --note-bg: #f3ead6;
  --stamp: #a5321f;
  --on-stamp: #fff8ec;
}
.sheet a { color: #172d52; }
.sheet-brand { position: absolute; top: 0.18in; right: 0.5in; margin: 0; font-size: 0.75rem; color: var(--sheet-muted); font-family: var(--font-display); font-style: italic; }
.sheet-brand::before { content: "\2726\00a0"; }
.sheet-title { font-size: 1.45rem; margin: 0 0 6px; }
.sheet h4 { margin: 18px 0 6px; font-size: 1.05rem; }
.meta { color: #333; margin: 0 0 12px; }
.callout { border: 2px solid #000; border-radius: 8px; padding: 6px 14px; }
.callout p { margin: 6px 0; }
.sheet h4.callout-title { margin: 6px 0 2px; }
.setup-steps { margin: 4px 0 6px; padding-left: 1.4em; }
.setup-steps li { margin: 2px 0; }
.setup-tip { font-style: italic; }
/* v0.8: slip-number-first rows: badge (#N, same mark as the card corner) | where it goes. */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist > li { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 12px; align-items: start; padding: 6px 0; border-bottom: 1px dotted #999; }
.slip-badge { flex: 0 0 auto; min-width: 2.6em; padding: 2px 6px; border: 2px solid #000; border-radius: 6px; text-align: center; font-weight: 800; font-size: 1.15rem; line-height: 1.2; color: #000; }
.is-prize .slip-badge { font-size: 0.85rem; padding: 4px 6px; }
.place-text { flex: 1 1 auto; min-width: 0; }
.place-label { display: block; }
.place-who { color: #333; }
.stuck-label { margin: 4px 0 0; font-size: 0.9rem; font-weight: 700; }
/* v0.10: the three hints sit side by side (Nudge | Bigger nudge | Answer), each with a left rule.
   v0.11: the middle column is 1.5 times wider than the Answer (the Bigger nudge is usually the longest)
   and the Nudge a little narrower (it is usually the shortest). */
.hint-steps { list-style: none; margin: 4px 0 2px; padding: 0; display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.5fr) minmax(0, 1fr); gap: 2px 10px; font-size: 0.86rem; line-height: 1.3; }
.hint-steps li { margin: 0; padding-left: 6px; border-left: 2px solid #000; }
.hint-level { font-weight: 700; }
/* v0.11: "How to set up" beside the prize spot or lock code, the tip and a one-line safety reminder. */
.setup-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.setup-side p { margin: 4px 0; }
.safety-line { border-left: 3px solid #000; padding-left: 8px; }

/* v0.11: the puzzle answers follow the setup rows on the host pages: one short entry per slip with a
   puzzle, two columns on screen and four on paper (each entry kept whole when the page breaks). */
.answers { margin-top: 14px; padding-top: 6px; border-top: 2px solid #000; }
.sheet .answers-title { margin-top: 0; }
.answer-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2px 14px; font-size: 0.85rem; line-height: 1.3; }
.answer-list li { overflow-wrap: anywhere; }
.answer-badge { display: inline-block; min-width: 2em; }

.cut-note { margin: 0 0 10px; font-size: 0.85rem; color: #333; }
.card-grid { display: grid; grid-template-columns: 1fr; gap: 0.2in; }
@media (min-width: 640px) { .card-grid { grid-template-columns: 1fr 1fr; } }
.card { position: relative; border: 2px dashed #000; border-radius: 4px; padding: 16px 16px 12px; min-height: 3.6in; break-inside: avoid; page-break-inside: avoid; display: flex; flex-direction: column; gap: 6px; }
/* v0.7 journal touch: a thin inner rule and a small star in the top corner. Absolutely placed, so they
   never change the card's size (js/generator.js page fit is unchanged). Light ink on paper. */
.card::before { content: ""; position: absolute; inset: 4px; border: 1px solid #8a7d66; border-radius: 2px; pointer-events: none; }
.card::after { content: "\2726"; position: absolute; top: 6px; right: 9px; font-size: 0.75rem; line-height: 1; color: #6b604d; pointer-events: none; }
.card p { margin: 0; }
.cut { position: absolute; top: -0.75em; left: 10px; background: var(--sheet-bg); padding: 0 4px; font-size: 1rem; line-height: 1; z-index: 1; }
.corner { position: absolute; bottom: 6px; right: 8px; font-size: 0.75rem; font-weight: 400; color: #222; }
.card-head { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid #000; padding-bottom: 6px; }
.card-emoji { font-size: 1.4rem; }
.card-title { font-family: var(--font-display); font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; font-size: 0.95rem; }
.turn { font-weight: 700; }
.badge { display: inline-block; align-self: flex-start; border: 1.5px solid #000; border-radius: 999px; padding: 1px 10px; font-size: 0.82rem; font-weight: 700; }
.flourish { font-style: italic; font-size: 0.92rem; }
.riddle { font-size: 1.02rem; font-weight: 600; }
.band-young .riddle { font-size: 1.2rem; }
.picture { font-size: 3.4rem; text-align: center; line-height: 1.1; }
.puzzle { border: 1.5px solid #000; border-radius: 6px; padding: 6px 8px; }
.puzzle-name { font-weight: 800; font-size: 0.85rem; }
.puzzle-prompt { font-size: 0.82rem; }
.puzzle-coded { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.08em; margin: 4px 0 !important; }
.puzzle-write { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.95rem; }
.digit { border-top: 1px solid #000; border-bottom: 1px solid #000; padding: 3px 0; display: flex; flex-direction: column; gap: 2px; }
.digit-intro { font-weight: 800; font-size: 0.9rem; }
.digit-puzzle { font-weight: 700; }
.welcome { font-size: 0.9rem; border-bottom: 1px dotted #000; padding-bottom: 4px; }
.puzzle-coded { overflow-wrap: anywhere; }
.lock-line { font-weight: 700; }
.letter-greeting { font-family: var(--font-display); font-weight: 700; font-size: 1.1rem; }
.letter-body { font-size: 0.95rem; }
.letter-sign { font-style: italic; }
.big-emoji { font-size: 3rem; text-align: center; }
/* v0.13 treasure map: the slip line that says a map piece comes with it, and the piece cards. A piece
   card has no padding: its dashed border is the piece's edge, so the cut pieces fit together. */
.map-line { font-weight: 800; font-size: 0.9rem; border: 1.5px dashed #000; border-radius: 4px; padding: 2px 6px; }
/* v0.15: the whole map is one block that spans both columns; its dashed cut lines are drawn inside the picture. */
.map-block { grid-column: 1 / -1; justify-self: center; align-self: center; width: min(100%, 6.46in); display: flex; flex-direction: column; align-items: center; break-inside: avoid; page-break-inside: avoid; }
.map-block .map-svg { display: block; margin: 0; overflow: visible; }
/* v0.13.1 packing: short note and decoder cards are only as tall as their words; a stack shares one slot. */
.card.is-short { min-height: 0; align-self: start; }
.stack-cell { display: flex; flex-direction: column; gap: 0.22in; align-self: start; break-inside: avoid; page-break-inside: avoid; }
.cell-blank { min-height: 0; }
.map-card-note { font-size: 0.82rem; color: #333; padding: 4px 8px; border-top: 1px dashed #000; }

/* ---------- v0.9 picture puzzles ----------
   Black ink on white so they survive black-and-white printing. Sizes are in inches or pt and match
   js/generator.js (PUZZLES[...].height, 1 SVG unit = 0.01 in); keep the two in step. */
.vpuzzle { margin: 2px 0; }
.vp-svg { display: block; margin: 0 auto; max-width: 100%; height: auto; overflow: visible; }
.vp-maze, .vp-arrow { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.arrow-steps { font-weight: 800; font-size: 1.05rem; text-align: center; letter-spacing: 0.03em; }
.arrow-steps.is-arrows { font-size: 1.4rem; letter-spacing: 0.1em; line-height: 1.1; }
.vp-jigsaw { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 2px auto; }
.jigsaw-frame { position: relative; width: 1.5in; height: 1.5in; border: 2.5px dashed #000; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #fff; }
.jigsaw-emoji { font-size: 5.4rem; line-height: 1; }
.card-photo.is-jigsaw .jigsaw-frame .photo-img { display: block; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: cover; object-position: center; transform-origin: center; border: 0; border-radius: 0; }
/* Cut lines: black dashes on a thin white edge, so they show on a dark photo too. */
.jigsaw-cut { position: absolute; pointer-events: none; z-index: 1; }
.jigsaw-cut.is-down { left: 50%; top: 0; bottom: 0; margin-left: -1.25px; border-left: 2.5px dashed #000; box-shadow: 1.5px 0 0 #fff, -1.5px 0 0 #fff; }
.jigsaw-cut.is-across { top: 50%; left: 0; right: 0; margin-top: -1.25px; border-top: 2.5px dashed #000; box-shadow: 0 1.5px 0 #fff, 0 -1.5px 0 #fff; }
.jigsaw-scissors { position: absolute; top: 1px; left: 3px; z-index: 2; font-size: 0.9rem; line-height: 1; background: #fff; padding: 0 2px; }
.vp-rebus { border: 1.5px solid #000; border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.rebus-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; margin: 4px 0 !important; }
.rebus-term { display: inline-flex; align-items: center; gap: 4px; border: 1.5px solid #000; border-radius: 8px; padding: 0 6px; }
.rebus-pic { font-size: 2rem; line-height: 1.15; }
.rebus-letters, .rebus-minus { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 800; font-size: 1.3rem; }
.rebus-op { font-weight: 800; font-size: 1.2rem; }
/* Mirror writing: flipped on screen and on paper (no media query on purpose). */
.riddle.is-mirrored { transform: scaleX(-1); }
.mirror-note { font-weight: 800; font-size: 0.92rem; text-align: center; }
.vp-coords, .vp-oddone, .vp-spiral, .vp-pigpen, .vp-fold { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.vp-cipher, .vp-circled, .vp-pigpen { border: 1.5px solid #000; border-radius: 6px; padding: 6px 8px; }
.vp-cipher { display: flex; flex-direction: column; gap: 3px; }
.cipher-key { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px 8px; font-weight: 700; }
.cipher-sym, .cipher-code { font-family: "Segoe UI Symbol", "Apple Symbols", "DejaVu Sans", sans-serif; }
.cipher-sym { font-size: 1.15rem; }
.cipher-letter { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 800; }
.cipher-code { font-size: 1.6rem; text-align: center; letter-spacing: 0.18em; margin: 2px 0 !important; }
.circled-text { font-size: 1rem; line-height: 1.7; }
.cl-mark { display: inline-block; border: 2px solid #000; border-radius: 3px; padding: 0 2px; margin: 0 1px; font-weight: 800; line-height: 1.1; text-decoration: underline; text-underline-offset: 2px; }
/* v0.17: crossword, word search, spot the difference (one drawing carries everything) and the sudoku / picture sum that hides a lock digit (drawing left, words right). */
.vp-crossword, .vp-wordsearch, .vp-diff { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.digit-side { display: flex; align-items: center; gap: 0.1in; }
.digit-side .vp-svg { flex: 0 0 auto; margin: 0; max-width: none; }
.digit-side-text { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.digit-side-text .digit-puzzle { font-size: 0.9rem; font-weight: 600; margin: 0; }
.host-pigpen { margin-top: 10px; break-inside: avoid; page-break-inside: avoid; }
/* v0.11: the teen pigpen key sits beside the puzzle answers (two answer columns then). */
.answers.has-key { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 14px; align-items: start; }
.answers.has-key .host-pigpen { margin-top: 0; }
.sheet .host-pigpen h4 { margin-top: 0; }
.host-pigpen .vp-svg { margin: 4px 0 0; }

.decoder { border-collapse: collapse; margin: 4px 0; width: 100%; table-layout: fixed; }
/* v0.11: decoder charts print on cut-out decoder cards with the slips. */
.decoder-name { margin: 0; font-size: 0.85rem; }
.decoder-name { font-weight: 700; }
.decoder-chart + .decoder-chart { margin-top: 4px; }
.decoder th, .decoder td { border: 1px solid #000; text-align: center; padding: 4px 0; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 700; font-size: 0.9rem; }
.decoder th { width: 3.6em; font-family: inherit; font-size: 0.8rem; }
.decoder td.real { background: #f0f0f0; }

/* ---------- v0.5: welcome back, "Used last time", card tools, photos, save setup ---------- */
.welcome-back { background: var(--accent-soft); color: var(--ink); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 8px 14px; margin: 0 0 16px; }
.welcome-back p { margin: 6px 0; }
.used-badge { display: inline-block; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid currentColor; border-radius: 3px; padding: 0 8px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.used-note { padding: 8px 14px; }
.tip { background: var(--note-bg); color: var(--ink); border: 1px dashed var(--line-card); border-radius: var(--radius); padding: 8px 14px; margin: 10px 0 0; font-size: 0.93rem; }

/* Screen-only tools under each (paper) card: one quiet row of two small buttons that
   reveal their controls on demand (v0.6). Light tokens come from .sheet, in both themes. */
.card-tools { margin-top: 8px; color: var(--ink); border-top: 1px dashed var(--line-card); padding-top: 4px; display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; position: relative; z-index: 1; }
.card-tools p { margin: 0; }
.card-tools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.tool-btn { padding-left: 4px; padding-right: 4px; }
.edited-note { color: var(--muted); font-style: italic; }
.puzzle-pick { display: inline-flex; align-items: center; gap: 6px; }
.puzzle-pick label { font-weight: 600; }
.puzzle-select { font: inherit; font-size: 0.92rem; min-height: 32px; padding: 2px 6px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); }
.puzzle-select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* v0.12.1: custom select chevron (screen only), 14px from the right edge, drawn in --ink so it follows
   the theme (contrast.js checks ink on paper at 3:1). Text stops before it (padding-right). The focus ring
   is unchanged. Windows high contrast / forced colors gets the native control back. Print is untouched. */
@media screen {
  select, .puzzle-select {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    padding-right: 40px;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
  }
}
@media screen and (forced-colors: active) {
  select, .puzzle-select { -webkit-appearance: auto; -moz-appearance: auto; appearance: auto; background-image: none; padding-right: 12px; }
}
.fit-warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; padding: 4px 8px; }
.char-count { color: var(--muted); font-size: 0.85rem; margin: 2px 0 0 !important; }
.card-editor { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.edit-note { color: var(--muted); }
.edit-field label { display: block; font-weight: 600; margin-bottom: 2px; }
.card-tools textarea { font: inherit; font-size: 0.95rem; width: 100%; padding: 6px 8px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--paper); color: var(--ink); resize: vertical; }
.edit-warn:empty, .card-tools .field-error:empty { display: none; }
.edit-warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; padding: 4px 8px; }
.edit-buttons { display: flex; flex-wrap: wrap; gap: 12px; }
.card-tools-row .edit-warn, .card-tools-row .card-editor { flex: 1 1 100%; }
.photo-tools { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; border: 1px solid var(--line-card); border-radius: var(--radius); padding: 8px 10px; background: var(--paper); }
.photo-help { color: var(--ink); }
.photo-mode { margin: 0; }
.photo-mode legend { font-size: 0.92rem; margin-bottom: 4px; }
.photo-mode .radio-inline { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.photo-zoom { display: flex; align-items: center; gap: 8px; }
.photo-zoom label { font-weight: 600; }
.photo-zoom input[type="range"] { accent-color: var(--accent); width: 10rem; min-height: 24px; }

/* The photo itself prints on the card. Sized so a card with a photo still fits half a page. */
.card-photo { margin: 2px 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.card-photo figcaption { font-size: 0.8rem; font-weight: 700; }
.card-photo.is-hint .photo-img { display: block; max-width: 100%; max-height: 1.3in; object-fit: contain; border: 1.5px solid #000; border-radius: 4px; }
.photo-frame { width: 1.3in; height: 1.3in; overflow: hidden; border: 2px solid #000; border-radius: 50%; }
.photo-frame .photo-img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; transform-origin: center; }

.save-setup { border-top: 2px dashed var(--line-faint); margin-top: 16px; padding-top: 12px; }
.save-setup h3 { margin: 0 0 6px; font-size: 1.15rem; }
.save-setup p { margin: 0 0 8px; }
.save-setup-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.save-setup-row .hint { margin: 0; }
.setup-link-fallback input { max-width: 100%; }
.copy-status { font-weight: 600; }
.copy-status:empty { display: none; }

/* Screen only: a phone-width window must never shrink print sizes. */
@media screen and (max-width: 639px) {
  .wizard { padding: 22px 16px 18px; }
  .wizard-title { font-size: 1.6rem; }
  .hero h1 { font-size: 2rem; }
  .hero-kicker { font-size: 1.15rem; }
  .hero-sub { font-size: 1.04rem; }
  .btn-hero { width: 100%; justify-content: center; }
  .brand { font-size: 1.6rem; }
  .compass { width: 38px; height: 38px; }
  .toolbar { padding: 20px 16px; }
  .sheet { padding: 20px 16px; }
  .sheet::before, .sheet::after { display: none; }
  .sheet-brand { right: 16px; top: 4px; }
  .nav-buttons .btn { flex: 1; }
  .nav-buttons.is-sticky { flex-wrap: wrap; margin-left: -16px; margin-right: -16px; padding: 10px 16px; }
  .nav-buttons.is-sticky .nav-extra { order: -1; flex-basis: 100%; }
  .hint-steps, .setup-top, .answer-list, .answers.has-key { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- print: US Letter, black and white ---------- */
/* v0.11: the print rules below also apply inside one hidden 720 x 3 px frame that js/app.js
   (measurePrint) uses to count the real printed pages; no real window is ever exactly that size. */
@page { size: letter; margin: 0.5in; }
@media print, (width: 720px) and (height: 3px) {
  /* Print is always the light palette, whatever the screen mode. */
  :root, :root[data-theme] {
    --ink: #1d2638;
    --muted: #5a4a35;
    --bg: #ece1c8;
    --paper: #fbf5e6;
    --accent: #24406e;
    --accent-dark: #172d52;
    --accent-soft: #e4e2d6;
    --on-accent: #fffaf0;
    --line: #7c6f58;
    --line-soft: #dccfb2;
    --line-card: #d6c9ab;
    --line-faint: #e4d9c0;
    --ok: #2f6b34;
    --ok-bg: #e3efd9;
    --on-ok: #ffffff;
    --warn-bg: #f8e6b5;
    --warn-ink: #5c4300;
    --error: #a32a1a;
    --error-bg: #fbe9e2;
    --focus: #0b5fc4;
    --note-bg: #f3ead6;
    --step-num-bg: #e6dcc4;
    --disabled-bg: #e3d9c3;
    --disabled-ink: #5f5647;
    --shadow: rgba(60, 40, 10, 0.18);
    --shadow-soft: rgba(60, 40, 10, 0.10);
    --toggle-bg: #fbf5e6;
    --stamp: #a5321f;
    --on-stamp: #fff8ec;
    color-scheme: light;
  }
  .theme-toggle { display: none !important; }
  .sheet, .cut { background: #fff; }
  .sheet { outline: 0; }
  .sheet::before, .sheet::after { display: none; }
  body { background: #fff; background-image: none; font-size: 11pt; }
  .no-print, .site-header, .site-footer, .skip-link { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .output { margin: 0; display: block !important; }
  .sheets { display: block; }
  .sheet { box-shadow: none; padding: 0; max-width: none; width: 100%; break-after: page; page-break-after: always; }
  .sheet:last-child { break-after: auto; page-break-after: auto; }
  .sheet-brand { top: 0; right: 0; }
  .card-grid { grid-template-columns: 1fr 1fr; gap: 0.22in; }
  /* 2 x 2 cards per page. min-height (not height) so a long card grows instead of being cut off;
     break-inside: avoid keeps any card from splitting across pages. */
  .checklist li, .answer-list li, .card { break-inside: avoid; page-break-inside: avoid; }
  .decoder td.real { background: #fff !important; }
  .counter, .warn { background: none; }
  .nav-buttons.is-sticky { position: static; box-shadow: none; }
  /* With a photo the emoji picture and photo share the space, so both shrink a little (sizes below). */
  .card-photo img { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a, .sheet a { color: #000; text-decoration: none; }
  /* Journal touch on paper: hairline inner rule and corner star (decorative, almost no ink). */
  .card::before { inset: 3.5pt; border-width: 0.5pt; }
  .card::after { top: 5pt; right: 7pt; }

  /* Page-break polish (v0.6). */
  .sheet-title, .sheet h4 { break-after: avoid; page-break-after: avoid; }
  .setup-top, .decoder, .meta, .host-pigpen { break-inside: avoid; page-break-inside: avoid; }
  .answers-title, .sheet .hint { break-after: avoid; page-break-after: avoid; }

  /* Host page sizes (v0.11, condensed): js/generator.js HOST_FIT models these, keep them in step.
     Only the hunt host reads these pages: setup rows 9pt, hints 8.5pt, the answers and other
     secondary lines 8 to 8.5pt; the title and slip badges stay clearly larger. One flowing section:
     no forced page breaks, rows break at row boundaries. */
  .parent { font-size: 9pt; line-height: 1.25; }
  .parent .sheet-title { font-size: 13pt; margin: 0 0 1pt; }
  .parent h4 { font-size: 10pt; margin: 3pt 0 1pt; }   /* v0.15: 1pt tighter above, so a long host sheet does not spill a line or two onto a new page */
  .parent h4.callout-title { margin: 0 0 1pt; }
  .parent .meta { font-size: 8.5pt; margin: 0 0 3pt; }
  .parent .hint { font-size: 8.5pt; margin: 0 0 1pt; }
  .callout { border-width: 1.5pt; padding: 2pt 6pt 2pt; }
  .setup-steps { margin: 0; padding-left: 1.3em; }
  .setup-steps li { margin: 0; }
  .setup-top { gap: 8pt; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
  .setup-top.wide-steps { grid-template-columns: minmax(0, 2.3fr) minmax(0, 1fr); }   /* v0.16: two-trail steps are a little longer */   /* v0.15: wider steps box (the safety line is short), a line or two less height */
  .setup-side p { margin: 0 0 1.5pt; }
  .setup-tip { font-size: 8.5pt; }
  .safety-line { font-size: 8pt; line-height: 1.2; border-left-width: 1.5pt; padding-left: 4pt; }
  .checklist > li { font-size: 9pt; line-height: 1.2; padding: 0.75pt 0; column-gap: 6pt; }   /* v0.15: was 1.5pt */
  .slip-badge { font-size: 11pt; padding: 0 3pt; border-width: 1.5pt; }
  .is-prize .slip-badge { font-size: 8.5pt; padding: 1pt 3pt; }
  /* On paper the column labels (Nudge, Bigger nudge, Answer) say what the hints are; the
     "If they're stuck on slip #N" line stays for screen readers. */
  .stuck-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
  .hint-steps { font-size: 8.5pt; line-height: 1.15; margin: 0; gap: 1pt 6pt; }
  .hint-steps li { padding-left: 3pt; border-left-width: 1.5pt; }
  .answers { margin-top: 2pt; padding-top: 1.5pt; border-top-width: 1.5pt; }
  .answer-list { font-size: 8pt; line-height: 1.2; gap: 0 8pt; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .has-key .answer-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answers.has-key { column-gap: 10pt; break-inside: avoid; page-break-inside: avoid; }
  .host-pigpen h4 { font-size: 8.5pt; margin: 0 0 1pt; }

  /* Card print sizes (v0.6): js/generator.js estimateCardHeight models these, keep the two in step.
     Every kid-facing line is 9pt or larger. The slip number (.corner) is an organizer-only mark, 9pt bold. */
  .card { min-height: 4.3in; line-height: 1.3; gap: 4pt; padding: 10pt 12pt 16pt; }
  .card-head { padding-bottom: 4pt; }
  .card-emoji { font-size: 16pt; }
  .card-title { font-size: 10.5pt; }
  .turn { font-size: 11pt; }
  .badge { font-size: 9.5pt; }
  .flourish, .welcome { font-size: 10pt; }
  .riddle { font-size: 11.5pt; }
  .band-young .riddle { font-size: 13pt; }
  .picture { font-size: 44pt; }
  .card.has-photo .picture { font-size: 30pt; }
  .puzzle { padding: 4pt 6pt; }
  .puzzle-name, .puzzle-prompt, .digit-intro { font-size: 9.5pt; }
  .puzzle-coded { font-size: 12.5pt; letter-spacing: 0.06em; margin: 3pt 0 !important; }
  .puzzle-write { font-size: 10pt; }
  .digit { padding: 2pt 0; }
  .digit-puzzle { font-size: 10.5pt; }
  .digit-side-text .digit-puzzle { font-size: 10pt; line-height: 1.25; }
  .card-photo figcaption { font-size: 9pt; }
  .corner { font-size: 9pt; font-weight: 400; color: #000; bottom: 5pt; right: 9pt; }
  .card-photo.is-hint .photo-img { max-height: 1.1in; }
  .photo-frame { width: 1.1in; height: 1.1in; }
  .letter-greeting { font-size: 13pt; }
  /* v0.9 picture puzzles (heights in js/generator.js PUZZLES). SVGs print at their own inch size. */
  .arrow-steps { font-size: 12pt; }
  .arrow-steps.is-arrows { font-size: 15pt; }
  .jigsaw-frame { width: 1.5in; height: 1.5in; border-width: 2pt; }
  .jigsaw-emoji { font-size: 76pt; }
  .jigsaw-scissors { font-size: 10pt; }
  .rebus-pic { font-size: 24pt; }
  .rebus-letters, .rebus-minus { font-size: 14pt; }
  .rebus-op { font-size: 13pt; }
  .mirror-note { font-size: 10pt; }
  .cipher-key { font-size: 11pt; }
  .cipher-sym { font-size: 13pt; }
  .cipher-code { font-size: 18pt; }
  .circled-text { font-size: 11pt; line-height: 1.6; }
  .vp-svg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .letter-body { font-size: 11pt; }
  .map-line { font-size: 10pt; padding: 1pt 4pt; }
  .card.is-short { min-height: 0; }
  /* v0.15: the map block's cut lines are part of the drawing; keep the row exactly the picture's height. */
  .map-block { margin: 0; }
  .card.is-short .big-emoji { font-size: 22pt; line-height: 1.1; }
  .cut-note { font-size: 9.5pt; margin: 0 0 6pt; padding-right: 1.2in; }   /* v0.15: clear of the brand name in the corner, now that the map note is longer */
  /* v0.11 decoder cards: kid-facing, so 9pt and up. */
  .decoder-name { font-size: 9pt; line-height: 1.2; }
  .decoder th, .decoder td { font-size: 10pt; padding: 1.5pt 0; }
  .decoder th { font-size: 9pt; width: 3.4em; }
  .decoder-card { padding-bottom: 15pt; }
  .decoder-card .decoder th { width: 3.9em; white-space: nowrap; }
  /* v0.16 two trails: trail headings on the host sheet (9pt, bold) and the mark in the slip header. */
  .trail-heading { font-size: 9.5pt; margin: 3pt 0 1pt; break-after: avoid; page-break-after: avoid; }
  .trail-section + .trail-section, .trail-section + .prize-list { margin-top: 2pt; }
}
