:root {
  --paper: #f5f1e8;
  --paper-deep: #e7ddcb;
  --ink: #2d2924;
  --chestnut: #753f2d;
  --chestnut-light: #a8654c;
  --forest: #20352e;
  --blue: #34566b;
  --muted: #766f65;
  --line: #c8bba7;
  --white: #fffdf8;
  --shadow: rgba(42, 32, 24, 0.18);
  font-family: "Hiragino Sans GB", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p,
blockquote,
figure {
  margin-top: 0;
}

h1,
h2,
h3 {
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 30px;
  font-size: 38px;
}

.reading-progress {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  pointer-events: none;
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--chestnut);
  transform-origin: left center;
}

.wide,
.narrow,
.letter-body {
  width: min(100% - 48px, 1120px);
  margin-inline: auto;
}

.narrow,
.letter-body {
  max-width: 760px;
}

.eyebrow {
  margin-bottom: 12px;
  color: var(--chestnut);
  font-size: 13px;
  font-weight: 700;
}

.opening {
  position: relative;
  min-height: 94svh;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.opening::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(117, 63, 45, 0.22);
  pointer-events: none;
}

.opening-copy {
  position: relative;
  z-index: 3;
  width: min(100% - 48px, 640px);
  margin-left: max(24px, calc((100vw - 1120px) / 2));
  padding: 10svh 0 110px;
}

.date-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.date-mark span {
  color: var(--muted);
  font-weight: 400;
}

.opening h1 {
  max-width: 580px;
  margin-bottom: 22px;
  color: var(--forest);
  font-size: 64px;
}

.opening-lead {
  margin-bottom: 36px;
  color: var(--muted);
  font-size: 18px;
}

.envelope {
  position: relative;
  display: block;
  width: 300px;
  height: 190px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  perspective: 900px;
}

.envelope:focus-visible,
.open-command:focus-visible,
.gallery-controls button:focus-visible,
.letter-gallery button:focus-visible,
.restart:focus-visible,
.lightbox button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 5px;
}

.envelope-back,
.envelope-paper,
.envelope-front,
.envelope-flap {
  position: absolute;
  left: 0;
  width: 300px;
}

.envelope-back {
  bottom: 0;
  height: 170px;
  border: 1px solid #af987b;
  background: #d9c39f;
  box-shadow: 0 22px 50px var(--shadow);
}

.envelope-paper {
  bottom: 16px;
  left: 22px;
  width: 256px;
  height: 140px;
  padding-top: 25px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--chestnut);
  text-align: center;
  transition: transform 900ms cubic-bezier(.2,.8,.2,1) 300ms;
}

.envelope-paper span {
  font-family: "Songti SC", "STSong", serif;
  font-size: 16px;
  font-weight: 700;
}

.envelope-front {
  bottom: 0;
  height: 170px;
  background: #cab18a;
  clip-path: polygon(0 0, 50% 60%, 100% 0, 100% 100%, 0 100%);
}

.envelope-flap {
  top: 20px;
  height: 118px;
  background: #e2cdaa;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 650ms cubic-bezier(.2,.8,.2,1);
  backface-visibility: hidden;
}

.envelope-seal {
  position: absolute;
  z-index: 3;
  top: 78px;
  left: 130px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  background: var(--chestnut);
  color: var(--paper);
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
  font-weight: 700;
  box-shadow: 0 4px 10px var(--shadow);
  transition: opacity 250ms ease;
}

.opening.is-opening .envelope-flap {
  transform: rotateX(180deg);
}

.opening.is-opening .envelope-seal {
  opacity: 0;
}

.opening.is-opening .envelope-paper {
  transform: translateY(-92px);
}

.open-command {
  margin-top: 18px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--chestnut);
  background: transparent;
  color: var(--chestnut);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.opening-photos {
  position: absolute;
  right: max(30px, calc((100vw - 1180px) / 2));
  bottom: -90px;
  width: 360px;
  height: 610px;
  opacity: 0.82;
}

.opening-photos img {
  position: absolute;
  width: 245px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 7px solid var(--white);
  box-shadow: 0 22px 45px var(--shadow);
}

.opening-photos img:nth-child(1) {
  z-index: 3;
  right: 34px;
  bottom: 50px;
  transform: rotate(3deg);
}

.opening-photos img:nth-child(2) {
  z-index: 2;
  right: 90px;
  bottom: 100px;
  transform: rotate(-7deg);
}

.opening-photos img:nth-child(3) {
  z-index: 1;
  right: 0;
  bottom: 118px;
  transform: rotate(11deg);
}

.next-hint {
  position: absolute;
  z-index: 4;
  bottom: 18px;
  left: 50%;
  width: 24px;
  height: 34px;
  transform: translateX(-50%);
}

.next-hint span {
  display: block;
  width: 1px;
  height: 28px;
  margin: auto;
  background: var(--chestnut);
  animation: hint 1.7s ease-in-out infinite;
}

@keyframes hint {
  0%, 100% { transform: scaleY(.45); transform-origin: top; opacity: .35; }
  50% { transform: scaleY(1); transform-origin: top; opacity: 1; }
}

.first-answer {
  padding: 130px 0 140px;
  background: var(--white);
}

.first-answer .lead-quote {
  margin-bottom: 34px;
  color: var(--forest);
  font-family: "Songti SC", "STSong", serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.6;
}

.first-answer .narrow > p:last-child {
  font-size: 18px;
}

.apology {
  padding: 95px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--paper-deep);
}

.apology-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 70px;
  align-items: center;
}

.gift-mark {
  position: relative;
  width: 170px;
  height: 160px;
  margin: auto;
}

.gift-box,
.gift-lid {
  position: absolute;
  left: 10px;
  width: 150px;
  border: 2px solid var(--chestnut);
  background: var(--paper);
}

.gift-box {
  bottom: 8px;
  height: 105px;
}

.gift-lid {
  z-index: 2;
  top: 28px;
  left: 0;
  width: 170px;
  height: 32px;
}

.gift-ribbon {
  position: absolute;
  z-index: 3;
  top: 28px;
  left: 73px;
  width: 24px;
  height: 129px;
  background: var(--chestnut);
}

.apology-text {
  max-width: 760px;
  margin-bottom: 18px;
  color: var(--forest);
  font-family: "Songti SC", "STSong", serif;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.55;
}

.five-reads {
  padding: 130px 0;
  background: var(--paper);
}

.section-heading {
  max-width: 760px;
  margin-bottom: 72px;
}

.read-list {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.read-list li {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 28px;
  padding: 34px 0;
  border-bottom: 1px solid var(--line);
}

.read-number {
  color: var(--chestnut-light);
  font-family: Georgia, serif;
  font-size: 40px;
  line-height: 1;
}

.read-list h3 {
  margin-bottom: 9px;
  color: var(--forest);
  font-size: 24px;
}

.read-list p {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--muted);
}

.original-letter {
  padding: 120px 0;
  overflow: hidden;
  background: var(--forest);
  color: var(--white);
}

.original-letter .eyebrow {
  color: #d4a38d;
}

.gallery-heading {
  display: flex;
  gap: 32px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 46px;
}

.gallery-heading h2 {
  margin-bottom: 0;
}

.gallery-controls {
  display: flex;
  flex: 0 0 auto;
  gap: 16px;
  align-items: center;
}

.gallery-controls button,
.lightbox button,
.restart {
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, 0.45);
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 21px;
  cursor: pointer;
}

.gallery-controls button:hover,
.lightbox button:hover,
.restart:hover {
  background: rgba(255, 253, 248, 0.12);
}

#galleryCount {
  min-width: 48px;
  color: #d9d3c9;
  font-size: 13px;
  text-align: center;
}

.letter-gallery {
  display: grid;
  grid-auto-columns: min(72vw, 520px);
  grid-auto-flow: column;
  gap: 26px;
  overflow-x: auto;
  padding: 4px 0 20px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.letter-gallery::-webkit-scrollbar {
  display: none;
}

.letter-gallery figure {
  position: relative;
  margin-bottom: 0;
  scroll-snap-align: start;
}

.letter-gallery figure button {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: zoom-in;
}

.letter-gallery img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  transition: transform 350ms ease;
}

.letter-gallery button:hover img {
  transform: scale(1.015);
}

.letter-gallery figcaption {
  position: absolute;
  right: 16px;
  bottom: 14px;
  padding: 3px 9px;
  border-radius: 4px;
  background: rgba(32, 53, 46, 0.8);
  color: var(--white);
  font-size: 12px;
}

.level-story {
  padding: 130px 0;
  background: var(--blue);
  color: var(--white);
}

.level-story .eyebrow {
  color: #f0b59e;
}

.level-track {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 54px;
  gap: 18px;
  align-items: center;
  margin: 68px 0 42px;
}

.level-start,
.level-end {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid rgba(255, 253, 248, 0.7);
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 20px;
}

.level-end {
  border-color: #f0b59e;
  background: #f0b59e;
  color: var(--forest);
  font-weight: 700;
}

.level-steps {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 4px;
  height: 16px;
}

.level-step {
  height: 100%;
  background: rgba(255, 253, 248, 0.2);
  transform: scaleY(.3);
  transition: transform 420ms ease, background 420ms ease;
}

.level-story.is-visible .level-step {
  background: #f0b59e;
  transform: scaleY(1);
}

.level-copy {
  max-width: 760px;
  margin-bottom: 0;
  font-family: "Songti SC", "STSong", serif;
  font-size: 23px;
  line-height: 1.65;
}

.milestones {
  padding: 130px 0;
  background: var(--paper);
}

.milestones-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, .95fr);
  column-gap: 80px;
  align-items: end;
  margin-bottom: 62px;
}

.milestones-heading .eyebrow {
  grid-column: 1 / -1;
}

.milestones-heading h2 {
  margin-bottom: 0;
  font-size: 36px;
}

.milestones-heading > p:last-child {
  margin-bottom: 2px;
  color: var(--muted);
}

.milestone-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.milestone-card {
  min-width: 0;
  margin-bottom: 0;
}

.milestone-card button {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101827;
  cursor: zoom-in;
  box-shadow: 0 16px 34px rgba(42, 32, 24, 0.12);
}

.milestone-card button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 5px;
}

.milestone-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 350ms ease;
}

.milestone-card button:hover img {
  transform: scale(1.02);
}

.milestone-card figcaption {
  padding: 16px 2px 0;
}

.milestone-card figcaption span,
.milestone-card figcaption small {
  display: block;
}

.milestone-card figcaption span {
  margin-bottom: 3px;
  color: var(--forest);
  font-family: "Songti SC", "STSong", serif;
  font-size: 19px;
  font-weight: 700;
}

.milestone-card figcaption small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.milestone-note {
  max-width: 700px;
  margin: 76px auto 0;
  padding: 34px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--chestnut);
  font-family: "Songti SC", "STSong", serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.65;
  text-align: center;
}

.reply {
  padding: 135px 0;
  background: var(--white);
}

.letter-body header {
  margin-bottom: 56px;
}

.letter-body p {
  margin-bottom: 34px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 19px;
  line-height: 2;
  text-align: justify;
}

.letter-body blockquote {
  margin: 65px 0;
  padding: 42px 0;
  border-top: 1px solid var(--chestnut);
  border-bottom: 1px solid var(--chestnut);
  color: var(--chestnut);
  font-family: "Songti SC", "STSong", serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.55;
  text-align: center;
}

.ending {
  min-height: 92svh;
  display: grid;
  place-items: center;
  padding: 110px 24px;
  background: var(--forest);
  color: var(--white);
  text-align: center;
}

.ending-inner {
  width: min(100%, 760px);
}

.ending .eyebrow {
  color: #d4a38d;
}

.ending h2 {
  margin-bottom: 18px;
  font-size: 46px;
}

.ending-main {
  margin-bottom: 52px;
  color: #f4d9cc;
  font-family: "Songti SC", "STSong", serif;
  font-size: 26px;
}

.ending-rule {
  width: 58px;
  height: 1px;
  margin: 0 auto 48px;
  background: #d4a38d;
}

.ending p {
  margin-bottom: 12px;
}

.ending .together {
  margin-top: 42px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 23px;
  font-weight: 700;
}

.signature {
  margin-top: 42px;
  color: #d4a38d;
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
}

.restart {
  margin: 50px auto 0;
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms ease, transform 700ms ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.lightbox {
  position: fixed;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 42px 76px 58px;
  border: 0;
  background: rgba(19, 27, 24, 0.97);
  color: var(--white);
}

.lightbox::backdrop {
  background: rgba(19, 27, 24, 0.88);
}

.lightbox[open] {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  grid-template-rows: minmax(0, 1fr) 30px;
  gap: 16px 24px;
  align-items: center;
}

.lightbox img {
  grid-column: 2;
  grid-row: 1;
  width: auto;
  max-width: 100%;
  height: 100%;
  max-height: calc(100dvh - 130px);
  margin: auto;
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
}

.lightbox-prev {
  grid-column: 1;
  grid-row: 1;
}

.lightbox-next {
  grid-column: 3;
  grid-row: 1;
}

.lightbox p {
  grid-column: 2;
  grid-row: 2;
  margin: 0;
  color: #d9d3c9;
  font-size: 13px;
  text-align: center;
}

@media (max-width: 900px) {
  .opening-copy {
    width: min(100% - 48px, 560px);
  }

  .opening h1 {
    font-size: 52px;
  }

  .opening-photos {
    right: -90px;
    opacity: 0.28;
  }
}

@media (max-width: 680px) {
  body {
    font-size: 15px;
  }

  h2 {
    margin-bottom: 24px;
    font-size: 30px;
  }

  .wide,
  .narrow,
  .letter-body {
    width: min(100% - 36px, 760px);
  }

  .opening {
    min-height: 92svh;
  }

  .opening::before {
    inset: 10px;
  }

  .opening-copy {
    width: calc(100% - 42px);
    margin-left: 21px;
    padding-top: 7svh;
  }

  .date-mark {
    margin-bottom: 18px;
  }

  .opening h1 {
    margin-bottom: 16px;
    font-size: 40px;
  }

  .opening-lead {
    margin-bottom: 28px;
    font-size: 16px;
  }

  .envelope {
    width: 260px;
    height: 170px;
  }

  .envelope-back,
  .envelope-front,
  .envelope-flap {
    width: 260px;
  }

  .envelope-back,
  .envelope-front {
    height: 148px;
  }

  .envelope-paper {
    left: 19px;
    width: 222px;
    height: 124px;
  }

  .envelope-flap {
    top: 22px;
    height: 102px;
  }

  .envelope-seal {
    top: 70px;
    left: 112px;
    width: 36px;
    height: 36px;
  }

  .opening-photos {
    right: -116px;
    bottom: -128px;
    width: 310px;
    opacity: 0.18;
  }

  .first-answer,
  .five-reads,
  .original-letter,
  .level-story,
  .milestones,
  .reply {
    padding: 88px 0;
  }

  .first-answer .lead-quote {
    font-size: 23px;
  }

  .first-answer .narrow > p:last-child {
    font-size: 16px;
  }

  .apology {
    padding: 78px 0;
  }

  .apology-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .gift-mark {
    width: 140px;
    height: 128px;
    margin-left: 0;
    transform: scale(.8);
    transform-origin: left center;
  }

  .apology-text {
    font-size: 21px;
  }

  .section-heading {
    margin-bottom: 45px;
  }

  .read-list li {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 16px;
    padding: 26px 0;
  }

  .read-number {
    font-size: 26px;
  }

  .read-list h3 {
    font-size: 21px;
  }

  .gallery-heading {
    display: block;
    margin-bottom: 32px;
  }

  .gallery-controls {
    justify-content: flex-end;
    margin-top: 22px;
  }

  .letter-gallery {
    grid-auto-columns: 84vw;
    gap: 16px;
  }

  .level-track {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
    gap: 10px;
    margin: 52px 0 36px;
  }

  .level-start,
  .level-end {
    width: 46px;
    height: 46px;
    font-size: 17px;
  }

  .level-steps {
    gap: 2px;
    height: 12px;
  }

  .level-copy {
    font-size: 20px;
  }

  .milestones-heading {
    display: block;
    margin-bottom: 38px;
  }

  .milestones-heading h2 {
    margin-bottom: 20px;
  }

  .milestone-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px 12px;
  }

  .milestone-card figcaption {
    padding-top: 12px;
  }

  .milestone-card figcaption span {
    font-size: 17px;
  }

  .milestone-card figcaption small {
    font-size: 12px;
  }

  .milestone-note {
    margin-top: 56px;
    padding: 28px 8px;
    font-size: 21px;
  }

  .letter-body header {
    margin-bottom: 38px;
  }

  .letter-body p {
    margin-bottom: 27px;
    font-size: 17px;
    line-height: 1.95;
    text-align: left;
  }

  .letter-body blockquote {
    margin: 48px 0;
    padding: 32px 0;
    font-size: 27px;
  }

  .ending {
    min-height: 88svh;
    padding: 88px 20px;
  }

  .ending h2 {
    font-size: 34px;
  }

  .ending-main {
    font-size: 22px;
  }

  .lightbox {
    padding: 68px 14px 40px;
  }

  .lightbox[open] {
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    gap: 12px 6px;
  }

  .lightbox button {
    width: 40px;
    height: 40px;
  }

  .lightbox-close {
    top: 14px;
    right: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
