:root {
  --cream: #ded2c0;
  --paper: #e9dfcf;
  --paper-deep: #d8c5ac;
  --ink: #493629;
  --muted: #6b5545;
  --terracotta: #854e3b;
  --terracotta-dark: #713824;
  --caramel: #ac8058;
  --peach: #cdb296;
  --rose: #a16b60;
  --line: rgba(73, 54, 41, 0.16);
  --shadow: 0 24px 70px rgba(73, 54, 41, 0.14);
  --shadow-soft: 0 12px 34px rgba(73, 54, 41, 0.12);
  --radius: 8px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

.display-title em { white-space: nowrap; }
.brand-period { margin-left: -8px; }
.primary { gap: 12px; }
.cover-footnote { color: var(--muted); font-size: 13px; margin-top: 24px; }
.clue-photo { max-height: 280px; }
.clue-photo img { transform: scale(1.9); transform-origin: 52% 58%; }
.envelope-label { position: relative; z-index: 3; display: block; margin-top: 100px; font: 30px var(--serif); }
.envelope-label small { font: 12px var(--sans); }
.image-error { background: var(--peach); font: 14px var(--sans); }
.video-select { display: block; margin: 28px 0; color: var(--terracotta); }
.video-select input { display: block; max-width: 100%; margin-top: 12px; }
#personal-video { width: 100%; max-height: 55vh; background: var(--ink); border-radius: 8px; }
@media (max-width: 700px) {
  body .site-header { flex-direction: row; align-items: center; gap: 8px; }
  body .header-note { display: none; }
  body .header-actions { width: auto; margin-left: auto; }
  body .display-title { font-size: 52px; }
  body .cover { gap: 24px; }
  body .cover-actions { gap: 12px; }
  body .cover-copy .intro br { display: none; }
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 8%, rgba(205, 178, 150, 0.36), transparent 32%),
    radial-gradient(circle at 86% 18%, rgba(172, 128, 88, 0.16), transparent 28%),
    linear-gradient(135deg, rgba(233, 223, 207, 0.88), rgba(222, 210, 192, 0.94)),
    var(--cream);
  color: var(--ink);
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.5;
  background-image:
    linear-gradient(rgba(73, 54, 41, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(73, 54, 41, 0.025) 1px, transparent 1px);
  background-size: 32px 32px, 32px 32px;
}

img {
  display: block;
  max-width: 100%;
}

button,
a {
  color: inherit;
}

button {
  font: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

:focus-visible {
  outline: 3px solid rgba(147, 76, 54, 0.72);
  outline-offset: 4px;
}

[hidden],
.hidden {
  display: none !important;
}

.site-header,
.site-footer,
.scene {
  width: min(1120px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 0 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--terracotta-dark);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(147, 76, 54, 0.28);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow-soft);
  color: var(--terracotta);
}

.header-note {
  max-width: 34ch;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.header-actions,
.cover-actions,
.chapter-controls,
.choice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.header-actions {
  justify-content: flex-end;
}

#app {
  min-height: calc(100vh - 164px);
}

.scene {
  padding: 48px 0 56px;
}

.cover {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  align-items: center;
  gap: clamp(32px, 6vw, 88px);
  min-height: calc(100vh - 170px);
}

.cover-copy {
  position: relative;
  z-index: 1;
}

.eyebrow,
.chapter-number,
.chapter-meta,
.small-note,
.paper-tag,
.status,
.dialog-header,
.letter-footer {
  font-family: var(--mono);
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow,
.chapter-number,
.chapter-meta,
.small-note {
  color: var(--terracotta);
  font-size: 12px;
  line-height: 1.45;
}

.display-title {
  max-width: 9.5ch;
  margin: 18px 0 24px;
  font-family: var(--serif);
  font-size: clamp(64px, 8.2vw, 90px);
  font-weight: 400;
  line-height: 0.96;
  color: var(--ink);
}

.display-title em,
.chapter-heading h1 em {
  color: var(--terracotta);
  font-style: italic;
}

.intro {
  max-width: 58ch;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.75;
}

.primary,
.secondary,
.utility-button,
.text-button,
.close-button,
.choice-button,
.image-choice {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease,
    color 180ms ease;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 22px;
  background: var(--terracotta);
  box-shadow: 0 12px 28px rgba(147, 76, 54, 0.24);
  color: #e9dfcf;
  font-weight: 700;
  text-decoration: none;
}

.secondary,
.utility-button,
.close-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 18px;
  border: 1px solid rgba(147, 76, 54, 0.24);
  background: rgba(233, 223, 207, 0.72);
  color: var(--terracotta-dark);
}

.text-button {
  min-width: 44px;
  padding: 10px 6px;
  background: transparent;
  color: var(--terracotta);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}

.primary:not(:disabled):hover,
.secondary:not(:disabled):hover,
.utility-button:not(:disabled):hover,
.close-button:not(:disabled):hover,
.choice-button:not(:disabled):hover,
.image-choice:not(:disabled):hover {
  transform: translateY(-2px);
}

.primary:not(:disabled):active,
.secondary:not(:disabled):active,
.utility-button:not(:disabled):active,
.close-button:not(:disabled):active,
.choice-button:not(:disabled):active,
.image-choice:not(:disabled):active {
  transform: translateY(0);
}

.small-note {
  margin: 16px 0 0;
  color: var(--muted);
}

.cover-art {
  position: relative;
  min-height: 620px;
}

.orbit-text {
  position: absolute;
  top: 4%;
  right: 3%;
  z-index: 2;
  width: min(170px, 34vw);
  color: rgba(147, 76, 54, 0.72);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.25;
  transform: rotate(8deg);
}

figure.print,
.letter-paper,
.envelope,
.chapter-game,
.day-result,
.album-dialog {
  border: 1px solid rgba(73, 54, 41, 0.12);
  background: var(--paper);
  box-shadow: var(--shadow);
}

figure.print {
  margin: 0;
  padding: 14px 14px 18px;
  border-radius: var(--radius);
}

figure.print img,
.clue-photo img,
.image-choice img,
.memory-card img,
.album-grid figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--paper-deep);
}

figure.print figcaption,
.album-grid figure figcaption {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.photo-main {
  position: absolute;
  top: 64px;
  right: 54px;
  width: min(420px, 72vw);
  transform: rotate(3.5deg);
}

.photo-main img {
  aspect-ratio: 4 / 5;
}

.photo-small {
  position: absolute;
  left: 8px;
  bottom: 56px;
  z-index: 2;
  width: min(270px, 52vw);
  transform: rotate(-7deg);
}

.photo-small img {
  aspect-ratio: 1 / 1;
}

.sun-doodle {
  position: absolute;
  left: 20%;
  top: 14%;
  width: 92px;
  height: 92px;
  border: 2px solid rgba(172, 128, 88, 0.54);
  border-radius: 50%;
}

.sun-doodle::before,
.sun-doodle::after {
  position: absolute;
  inset: -14px;
  border: 1px dashed rgba(147, 76, 54, 0.36);
  border-radius: 50%;
  content: "";
}

.sun-doodle::after {
  inset: 15px;
  background: rgba(205, 178, 150, 0.34);
}

.paper-tag {
  position: absolute;
  right: 0;
  bottom: 116px;
  z-index: 3;
  max-width: 190px;
  padding: 13px 16px;
  border: 1px solid rgba(147, 76, 54, 0.2);
  border-radius: var(--radius);
  background: #d9bda0;
  box-shadow: var(--shadow-soft);
  color: var(--terracotta-dark);
  font-size: 12px;
  line-height: 1.45;
  transform: rotate(5deg);
}

.chapter-top {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.chapter-heading {
  max-width: 790px;
  margin-bottom: 32px;
}

.chapter-heading h1 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: clamp(40px, 6vw, 72px);
  font-weight: 400;
  line-height: 1;
}

.chapter-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.chapter-layout {
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.28fr);
  align-items: start;
  gap: 28px;
}

.chapter-aside {
  position: sticky;
  top: 20px;
  min-width: 0;
}

.clue-photo {
  overflow: hidden;
  margin: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.clue-photo img {
  aspect-ratio: 4 / 5;
}

.chapter-game {
  min-width: 0;
  padding: clamp(18px, 3vw, 30px);
  border-radius: var(--radius);
}

.image-options,
.memory-grid,
.album-grid {
  display: grid;
  gap: 14px;
}

.image-options {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.image-choice {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(73, 54, 41, 0.12);
  background: #e9dfcf;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.image-choice img {
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background: var(--paper-deep);
}

.image-choice span {
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.image-choice.selected,
.choice-button.selected,
.memory-card.is-open,
.memory-card.is-matched {
  border-color: rgba(147, 76, 54, 0.72);
  box-shadow: 0 0 0 3px rgba(147, 76, 54, 0.12), var(--shadow-soft);
}

.image-choice.correct,
.choice-button.correct,
.memory-card.is-matched {
  border-color: rgba(109, 126, 77, 0.82);
  background: #dedfc9;
}

.status {
  min-height: 24px;
  margin: 18px 0;
  color: var(--terracotta-dark);
  font-size: 12px;
  line-height: 1.5;
}

.choice-groups {
  display: grid;
  gap: 24px;
}

.choice-group h2 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  color: var(--terracotta-dark);
}

.choice-button {
  max-width: 100%;
  padding: 12px 18px;
  border: 1px solid rgba(73, 54, 41, 0.14);
  background: rgba(233, 223, 207, 0.78);
  color: var(--ink);
  text-align: left;
}

.day-result {
  margin-top: 22px;
  padding: 18px;
  border-radius: var(--radius);
  color: var(--muted);
  line-height: 1.65;
}

.memory-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.memory-card {
  position: relative;
  display: grid;
  min-height: 44px;
  overflow: hidden;
  border: 1px solid rgba(73, 54, 41, 0.14);
  border-radius: var(--radius);
  background: #e9dfcf;
  padding: 0;
  aspect-ratio: 1 / 1;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.memory-card img,
.memory-card .card-back {
  grid-area: 1 / 1;
}

.memory-card img {
  opacity: 0;
  transition: opacity 180ms ease;
}

.memory-card.is-open img,
.memory-card.is-matched img {
  opacity: 1;
}

.card-back {
  display: grid;
  place-items: center;
  padding: 10px;
  background:
    linear-gradient(135deg, rgba(205, 178, 150, 0.42), rgba(233, 223, 207, 0.88)),
    var(--paper);
  color: var(--terracotta);
  font-family: var(--serif);
  font-size: clamp(24px, 5vw, 40px);
  transition: opacity 180ms ease;
}

.memory-card.is-open .card-back,
.memory-card.is-matched .card-back {
  opacity: 0;
}

.envelope-stage {
  display: grid;
  justify-items: center;
  gap: 28px;
}

.envelope {
  position: relative;
  width: min(420px, 100%);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, transparent 49.5%, rgba(73, 54, 41, 0.12) 50%, transparent 50.5%),
    linear-gradient(215deg, transparent 49.5%, rgba(73, 54, 41, 0.1) 50%, transparent 50.5%),
    #d5b18f;
}

.envelope-flap {
  position: absolute;
  inset: 0 0 auto;
  height: 58%;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: #c8a17b;
  transform-origin: top;
  animation: flapFloat 4.8s ease-in-out infinite;
}

.envelope-heart {
  position: absolute;
  left: 50%;
  top: 51%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--terracotta);
  color: #e9dfcf;
  transform: translate(-50%, -50%) rotate(-8deg);
  box-shadow: 0 10px 22px rgba(147, 76, 54, 0.24);
}

.letter-paper {
  width: min(760px, 100%);
  padding: clamp(24px, 5vw, 56px);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(18px, 2.1vw, 22px);
  line-height: 1.78;
}

.letter-salutation,
.letter-signoff {
  color: var(--terracotta-dark);
  font-size: 1.1em;
}

.letter-footer {
  margin-top: 28px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.progress-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  justify-content: center;
  padding: 26px 0 0;
}

.dot {
  width: 11px;
  height: 11px;
  border: 1px solid rgba(147, 76, 54, 0.42);
  border-radius: 50%;
  background: transparent;
}

.dot.active {
  background: var(--terracotta);
  box-shadow: 0 0 0 5px rgba(147, 76, 54, 0.12);
}

.dot.done {
  background: var(--caramel);
  border-color: var(--caramel);
}

.album-dialog {
  width: min(920px, calc(100% - 32px));
  max-height: min(780px, calc(100vh - 40px));
  overflow: auto;
  border-radius: var(--radius);
  padding: 22px;
  color: var(--ink);
}

.album-dialog::backdrop {
  background: rgba(73, 54, 41, 0.44);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  color: var(--terracotta-dark);
  font-size: 12px;
}

.album-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.album-grid figure {
  min-width: 0;
  margin: 0;
  border-radius: var(--radius);
}

.album-grid figure img {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
}

.site-footer {
  padding: 22px 0 30px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

@keyframes flapFloat {
  0%,
  100% {
    transform: rotateX(0deg);
  }
  50% {
    transform: rotateX(8deg);
  }
}

@media (max-width: 900px) {
  .cover {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .cover-art {
    min-height: 540px;
  }

  .chapter-layout {
    grid-template-columns: 1fr;
  }

  .chapter-aside {
    position: static;
  }
}

@media (max-width: 700px) {
  .site-header,
  .site-footer,
  .scene {
    width: min(100% - 32px, 1120px);
  }

  .site-header {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 18px;
  }

  .header-actions,
  .cover-actions,
  .chapter-controls,
  .choice-row {
    width: 100%;
  }

  .header-actions > *,
  .cover-actions > *,
  .chapter-controls > * {
    flex: 1 1 auto;
  }

  .scene {
    padding: 32px 0 42px;
  }

  .display-title {
    max-width: 8.8ch;
    font-size: 56px;
  }

  .intro {
    font-size: 17px;
  }

  .cover-art {
    min-height: 440px;
  }

  .photo-main {
    top: 36px;
    right: 8px;
    width: min(310px, 76vw);
  }

  .photo-small {
    left: 0;
    bottom: 28px;
    width: min(210px, 56vw);
  }

  .orbit-text {
    right: 0;
    width: 130px;
    font-size: 15px;
  }

  .sun-doodle {
    left: 4%;
    top: 10%;
    width: 66px;
    height: 66px;
  }

  .paper-tag {
    right: 0;
    bottom: 62px;
    max-width: 150px;
  }

  .chapter-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .image-options,
  .album-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .memory-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .letter-paper {
    padding: 24px 20px;
  }
}

@media (max-width: 430px) {
  .site-header,
  .site-footer,
  .scene {
    width: min(100% - 24px, 1120px);
  }

  .brand {
    font-size: 18px;
  }

  .display-title {
    font-size: 56px;
  }

  .primary,
  .secondary,
  .utility-button,
  .close-button,
  .choice-button {
    width: 100%;
  }

  .cover-art {
    min-height: 390px;
  }

  .photo-main {
    width: min(268px, 78vw);
  }

  .photo-small {
    width: min(176px, 54vw);
  }

  .paper-tag {
    bottom: 34px;
    font-size: 11px;
  }

  .image-options,
  .memory-grid,
  .album-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-choice span {
    padding: 10px;
    font-size: 13px;
  }

  .chapter-game {
    padding: 16px 12px;
  }

  .dialog-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.music-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid currentColor;
  border-radius: 24px;
  background: #e9dfcf;
  color: #493629;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.music-toggle:focus-visible { outline: 3px solid #854e3b; outline-offset: 3px; }
