:root {
  --zine-ink: #222832;
  --zine-paper: #f1ebdd;
  --zine-accent: #3e5774;
  --zine-edge: #344256;
  --zine-blue: #5d7694;
  --zine-yellow: #e4ba59;
  --zine-heading: "Arial Narrow", "Avenir Next Condensed", "PingFang HK", sans-serif;
  --zine-note: "Bradley Hand", "Chalkboard SE", cursive;
}

body[data-chapter]:not([data-chapter="9"]) {
  background-color: var(--zine-paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.71' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.19'/%3E%3C/svg%3E");
  color: var(--zine-ink);
}

body[data-chapter="1"] {
  --zine-paper: #242833;
  --zine-ink: #ebe1cf;
  --zine-edge: #6d7482;
  --zine-accent: #e1ba78;
  background: radial-gradient(ellipse at 50% 43%, #393630, #23252b 75%) !important;
}
body[data-chapter="2"] { --zine-paper: #e9e6dd; }
body[data-chapter="3"] { --zine-paper: #f1ebdd; }
body[data-chapter="4"] { --zine-paper: #d0deea; }
body[data-chapter="5"] { --zine-paper: #f2d99c; --zine-accent: #604832; }
body[data-chapter="6"] {
  --zine-paper: #222832;
  --zine-ink: #f1ebdd;
  --zine-edge: #8292a4;
  --zine-accent: #f0ce7a;
}
body[data-chapter="7"] { --zine-paper: #dbe4ec; }
body[data-chapter="8"] { --zine-paper: #f6edda; --rose: #385880; }

body[data-chapter]:not([data-chapter="9"]) header,
body[data-chapter]:not([data-chapter="9"]) footer {
  border-color: var(--zine-edge);
}
body[data-chapter]:not([data-chapter="9"]) > header, body[data-chapter]:not([data-chapter="9"]) .opening-header {
  box-sizing: border-box;
  margin: 0 auto;
  width: min(100%, 1320px);
}
body[data-chapter]:not([data-chapter="9"]):not([data-chapter="1"]) h1 {
  max-width: 23ch;
  margin-inline: auto;
  padding-inline: 9px;
}
body[data-chapter]:not([data-chapter="9"]) .eyebrow { font-family: "Courier New", monospace; }
body[data-chapter]:not([data-chapter="9"]) main > .eyebrow,
body[data-chapter]:not([data-chapter="9"]) :is(.caption, .page-heading, .post-intro, .wish) > .eyebrow,
body[data-chapter]:not([data-chapter="9"]) .caption > p:first-child {
  display: table;
  width: fit-content;
  margin-inline: auto;
  padding: 5px 9px;
  background: #f4df9e;
  color: #2a303a;
  rotate: -1.5deg;
}
body[data-chapter]:not([data-chapter="9"]) header a,
body[data-chapter]:not([data-chapter="9"]) .opening-brand {
  font: 700 clamp(20px, 2.2vw, 28px)/1 var(--zine-heading);
  letter-spacing: -.035em;
}
body[data-chapter]:not([data-chapter="9"]) h1 {
  color: var(--zine-ink);
  font: 800 clamp(34px, 5.2vw, 76px)/.99 var(--zine-heading);
  letter-spacing: -.045em;
  text-wrap: balance;
}
body[data-chapter]:not([data-chapter="9"]) :is(.eyebrow, .caption > p, header span:not(.opening-brand), footer, .opening-sub) {
  color: var(--zine-accent);
}
body[data-chapter]:not([data-chapter="9"]) :is(.intro, .help, .post-status, .wish-intro, .selection-status) {
  color: var(--zine-ink);
}
body[data-chapter]:not([data-chapter="9"]) :is(.paper-button, .continue-letter, .finish-button, .action, .read-side button, .actions button) {
  background: #fff7e7;
  border: 1.5px solid var(--zine-edge);
  border-radius: 1px 3px 2px 1px;
  box-shadow: 2px 3px var(--zine-edge);
  color: #222832;
}
body[data-chapter]:not([data-chapter="9"]) :is(.paper-button, .continue-letter, .finish-button, .action, .read-side button, .actions button):hover:not(:disabled) {
  background: #f6df9e;
  box-shadow: 1px 1px var(--zine-edge);
}
body[data-chapter]:not([data-chapter="9"]) .wish-mic { color: #222832; background: #e4ba59; }
body[data-chapter]:not([data-chapter="9"]) .wish-mic:hover:not(:disabled) { color: #222832; }
body[data-chapter]:not([data-chapter="9"]) :is(button, a, input, textarea):focus-visible {
  outline: 2px dashed currentColor;
  outline-offset: 4px;
}

[data-chapter="2"] .machine img {
  filter: brightness(.79) saturate(.9) drop-shadow(0 7px 6px #34425638);
}
[data-chapter="2"] .paper { background: #fff9ea; box-shadow: 3px 3px #34425644; }
[data-chapter="2"] .actions { background: #cddce7; border-color: #344256; box-shadow: 4px 4px #34425644; }
[data-chapter="2"] :is(.status, .paper small, .paper input::placeholder) { color: #535c68; }
[data-chapter="2"] .result:not(:empty) {
  width: fit-content;
  min-height: 0;
  margin: 10px auto;
  padding: 5px 16px;
  border: 3px double #385880;
  color: #385880;
  rotate: -5deg;
  animation: zine-stamp .28s ease-out both;
}
[data-chapter="2"] .result span { color: #385880; }
@keyframes zine-stamp { from { opacity: 0; scale: 1.36; } to { opacity: 1; scale: 1; } }
[data-chapter="3"] .paper {
  background: repeating-linear-gradient(#fbf8ef 0 30px, #e5e2d7 30px 31px);
  box-shadow: 4px 6px #34425642;
}
[data-chapter="3"] .read-side { color: #3e5774; }
[data-chapter="4"] .globe-wrap {
  background: repeating-radial-gradient(circle, transparent 0 37px, #3e577420 38px 39px);
  border-radius: 50%;
}
[data-chapter="4"] .routes { margin: 16px auto; gap: clamp(6px, 2vw, 14px); }
[data-chapter="4"] .routes button {
  min-height: 44px;
  background: #fff5d6;
  color: #222832;
  border: 1px solid #35566d;
  box-shadow: 2px 2px #35566d;
  white-space: nowrap;
}
[data-chapter="4"] .routes button:hover { background: #f0ce7a; }
[data-chapter="4"] .plane { background: #f0ce7a; color: #222832; box-shadow: 2px 2px #344256; }
[data-chapter="4"] .flag { background: #faf3dc; border-color: #35566d; border-style: dashed; }
[data-chapter="4"] .flag::after { background: #e4ba59; }
[data-chapter="4"] .flag h2 { color: #385880; }
.zine-next {
  display: inline-block;
  padding: 12px 22px;
  text-decoration: none;
  font: 20px var(--zine-note);
}
[data-chapter="5"] .ingredients {
  padding: clamp(10px, 2vw, 22px);
  background: #f8f0db;
  border: 2px solid #604832;
  box-shadow: 4px 5px #60483245;
}
[data-chapter="5"] .ingredient {
  border-color: #a08a67;
  border-style: dashed;
  background: #e6eaf0;
  color: #302b27;
}
[data-chapter="5"] :is(.ingredient small, .recipe, .stir-note, .result) { color: #604832; }
[data-chapter="5"] .ingredient b { color: #385880; }
[data-chapter="6"] .filmstrip {
  background: #171b23;
  border-color: #91a2b7;
  box-shadow: 5px 6px #111723;
}
[data-chapter="6"] .frame:not(.revealed) img { filter: grayscale(1) contrast(1.24); }
[data-chapter="6"] :is(.film-can, .progress, .reset) { color: #f1ebdd; }
[data-chapter="6"] .reset { background: #303a4a; border-color: #9fb1c6; }
[data-chapter="6"] .reset:hover { background: #3e5774; }
[data-chapter="6"] :is(.frame-label, .full-button) { color: #f0ce7a; }
[data-chapter="7"] .closet {
  background: #bacddf;
  border-color: #536c88;
  box-shadow: inset 0 0 0 5px #ede8dd, 5px 5px #536c8845;
}
[data-chapter="7"] .display {
  background: radial-gradient(ellipse at 50% 48%, #f4dda3 0 45%, transparent 45.4%);
}
[data-chapter="7"] #james { filter: drop-shadow(3px 3px 0 #faf3df); }
[data-chapter="7"] :is(.outfit-choice, .accessory)[aria-pressed="true"] {
  border-color: #44658a;
  background: #f4dda3;
}
[data-chapter="7"] :is(.outfit-choice, .accessory)[aria-pressed="true"]::after {
  color: #385880;
  border: 1px solid currentColor;
  border-radius: 45% 54% 47% 55%;
  padding: 1px 4px;
  rotate: -12deg;
}
[data-chapter="7"] :is(.look-label h2, .look-label p, .category span, .category small, .display-note, .small-button) { color: #344256; }
[data-chapter="8"] .postcard {
  background: #fff5d9;
  border: 2px solid #536c88;
  box-shadow: 5px 6px #536c8845;
}
[data-chapter="8"] .post-station { border-top: 5px double #536c88; }
[data-chapter="8"] .stamp-print { outline-color: #536c88; }
[data-chapter="8"] .stamp-print.balloon { background: #f1d386; }
[data-chapter="8"] .stamp-print.key { background: #d7e0ec; }
[data-chapter="8"] .postmark { stroke-width: 2; }

.story-navigation {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px clamp(12px, 2vw, 25px);
  border-top: 1px solid var(--zine-edge);
  padding: 16px 20px 20px;
  background: var(--zine-paper);
}
.story-navigation a {
  color: var(--zine-ink);
  font: 11px/1.6 monospace;
  text-decoration: none;
  padding: 5px 2px;
}
.story-navigation a:hover,
.story-navigation a[aria-current="page"] {
  color: var(--zine-accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}
body.candle-dark .story-navigation { visibility: hidden; }

/* The opening plays out on the same paper as the record and invitation. */
body[data-chapter="1"] .s1 {
  background: transparent !important;
  color: var(--zine-ink);
  --paper: var(--zine-paper);
}
.s1 .opening-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; min-height: 0; }
.s1 .opening-header {
  display: block;
  text-align: center;
  padding: 5px 0 18px;
  max-width: 800px;
  border-color: #999b9c40;
}
body[data-chapter="1"] .s1 .opening-brand {
  margin: 0 0 7px;
  font: 700 clamp(32px, 4vw, 52px)/1 Georgia, serif;
  letter-spacing: -.065em;
  color: #f2e5cc;
}
.s1 .opening-header .header-note { color: #d5bf98; }
.s1 .invitation-column { text-align: center; padding: 4px 0 28px; }
.s1 .music-settings { margin: 14px auto 0; }
.s1 .opening-footer { max-width: 800px; width: 100%; margin: auto; color: #d9cbb6; border-color: #999b9c40; }
.s1 .letter-frame {
  max-width: 520px;
  margin: 8px auto 22px !important;
  background: #f7f0dd !important;
  color: #382e2c !important;
  border-color: var(--zine-edge) !important;
  box-shadow: 4px 5px #342d2840 !important;
}
.s1 .letter-caption { background: #f4dda3; color: #37475a; }
.s1 .letter-signoff span { color: #385880; }
.s1 .letter-frame[hidden] { display: none !important; }
.s1 .sketch-btn {
  background: #253955 !important;
  color: #fff7e7 !important;
  border-color: var(--zine-edge) !important;
  box-shadow: 3px 4px var(--zine-edge) !important;
}
.s1 .sketch-btn:hover { background: #2c4568 !important; }
.s1 .track-line,
.s1 .side-label,
.s1 .needle-control,
.s1 .player-help,
.s1 .music-settings,
.s1 .audio-file { color: #e4d8c3; }
.s1.music-on .status-dot { background: #e4ba59; box-shadow: 0 0 0 3px #b8863355; }

.s1 .player-art {
  max-width: 540px;
  margin: clamp(8px, 2vw, 20px) auto 0;
  isolation: isolate;
}
.s1 .player-art img { filter: brightness(.94) saturate(.7); }
.s1 .player-parts { z-index: 1; pointer-events: none; }
.s1 .moving-needle { pointer-events: auto; transition-duration: .45s; }
.s1 .track-line { margin-top: 8px; }

.player-james, .player-puppy {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  transform-origin: center bottom;
}
.player-james {
  left: 1%;
  bottom: 3%;
  width: 25%;
  height: 43%;
  background: url("assets/retro/opening-james-narrow-shoulders.png") left center / 200% 100% no-repeat;
}
.player-puppy {
  right: 0;
  bottom: 3%;
  width: 25%;
  aspect-ratio: 1;
  background: url("assets/retro/opening-room307-puppy.png") center / contain no-repeat;
}
.playing :is(.player-james, .player-puppy) {
  animation: turntable-hop .62s ease-in-out both;
}

@keyframes turntable-hop {
  0%, 100% { transform: none; }
  14% { transform: scaleY(.96); }
  48% { transform: translateY(-13%); }
  80% { transform: scaleY(.95); }
}

@media (max-width: 800px) {
  .s1 .player-column { grid-row: 2; }
  .s1 .invitation-column { grid-row: 3; }
}
@media (prefers-reduced-motion: reduce) {
  .s1 :is(.player-james, .player-puppy, .record-surface) { animation: none !important; }
  .s1 .moving-needle { transition-duration: .15s; transition-delay: 0s; }
  [data-chapter="2"] .result:not(:empty) { animation: none; }
}
