:root {
  --night: #14110f;
  --night-soft: #221c18;
  --ivory: #f4efe6;
  --ivory-deep: #efe6d8;
  --ink: #241c16;
  --muted: #6f6256;
  --gold: #b08958;
  --gold-soft: rgba(176, 137, 88, 0.72);
  --seal: #9c2f2c;
  --seal-deep: #6d1e1c;
  --paper-line: rgba(36, 28, 22, 0.08);
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", "PMingLiU", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --edge-left: 28px;
  --edge-right: 68px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--night);
  color: var(--ink);
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}

body.is-locked {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: rgba(176, 137, 88, 0.28);
}

.stage {
  width: min(100%, 480px);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ivory);
  position: relative;
}

.sheet {
  position: relative;
  z-index: 1;
  padding: calc(28px + var(--safe-top)) 0 0;
  background:
    radial-gradient(1200px 420px at 50% -10%, rgba(176, 137, 88, 0.08), transparent 60%),
    var(--ivory);
}

.sheet__inner {
  padding: 56px var(--edge-right) 12px var(--edge-left);
}

.ornament {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
  color: var(--gold);
}

.ornament svg {
  width: 132px;
  height: 16px;
  display: block;
}

.salutation {
  margin: 0 0 22px;
  font-size: 40px;
  font-weight: 500;
  letter-spacing: 0.14em;
  line-height: 1.2;
}

.letter {
  margin: 0;
}

.letter p,
.chapter__text,
.ending__line,
.sign p,
.album__title,
.chapter__title {
  margin: 0;
}

.letter p {
  font-size: 17px;
  line-height: 2;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.letter p + p {
  margin-top: 18px;
}

.stories {
  margin-top: 54px;
  padding-top: 8px;
}

.chapter {
  padding: 34px 0 8px;
  border-top: 1px solid var(--paper-line);
}

.chapter__index {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--gold);
}

.chapter__title {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.chapter__date {
  margin: 8px 0 0;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.chapter__text {
  margin-top: 16px;
  font-size: 16px;
  line-height: 1.95;
  letter-spacing: 0.04em;
}

.chapter__photo {
  margin: 22px 0 10px;
}

.chapter__photo img,
.album__card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chapter__photo img {
  height: auto;
  border-radius: 2px;
  box-shadow: 0 16px 40px rgba(36, 28, 22, 0.12);
}

.album {
  padding: 48px 0 12px;
}

.album__title {
  padding: 0 var(--edge-right) 0 var(--edge-left);
  font-size: 28px;
  letter-spacing: 0.14em;
  font-weight: 500;
}

.album__hint {
  margin: 8px 0 0;
  padding: 0 var(--edge-right) 0 var(--edge-left);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.album__row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 18px var(--edge-right) 28px var(--edge-left);
  -webkit-overflow-scrolling: touch;
}

.album__row::-webkit-scrollbar {
  display: none;
}

.album__card {
  flex: 0 0 78%;
  scroll-snap-align: center;
  aspect-ratio: 3 / 4;
  background: #e7dfd2;
  box-shadow: 0 18px 36px rgba(36, 28, 22, 0.12);
}

.album__card:only-child {
  flex-basis: 100%;
}

.ending {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  margin-top: 36px;
  padding: 72px var(--edge-right) calc(36px + var(--safe-bottom)) var(--edge-left);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    radial-gradient(520px 280px at 50% 42%, rgba(156, 47, 44, 0.08), transparent 70%),
    var(--ivory-deep);
}

.ending__kicker {
  margin: 0 0 18px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.32em;
  color: var(--gold);
}

.ending__line {
  font-size: 28px;
  line-height: 1.55;
  letter-spacing: 0.08em;
  font-weight: 500;
  text-wrap: balance;
}

.vow {
  position: relative;
  align-self: flex-start;
  margin: 36px 0 0;
  padding: 0 0 0 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.vow__ring {
  position: absolute;
  left: 0;
  top: 0.15em;
  width: 28px;
  height: 28px;
  border: 1px solid var(--seal);
  border-radius: 50%;
}

.vow__ring::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--seal);
}

.vow__label {
  display: block;
  font-size: 16px;
  letter-spacing: 0.14em;
  line-height: 1.7;
}

.vow.is-vowed {
  cursor: default;
  padding-left: 0;
}

.vow.is-vowed .vow__ring {
  animation: ring-out 1.1s ease forwards;
}

.vow.is-vowed .vow__label {
  font-size: 22px;
  letter-spacing: 0.08em;
  line-height: 1.7;
  max-width: 16em;
}

.sign {
  margin-top: 42px;
}

.sign__label,
.sign__name,
.sign__date,
.replay {
  margin: 0;
}

.sign__label {
  font-size: 14px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.sign__name {
  margin-top: 6px;
  font-size: 28px;
  letter-spacing: 0.18em;
}

.sign__date {
  margin-top: 14px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.replay {
  margin-top: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.2em;
  cursor: pointer;
}

.rise {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}

.rise.is-in {
  opacity: 1;
  transform: none;
}

.cover {
  position: fixed;
  z-index: 20;
  left: 50%;
  top: 0;
  width: min(100%, 480px);
  height: 100vh;
  height: 100dvh;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(28px + var(--safe-top)) 32px calc(28px + var(--safe-bottom));
  background:
    radial-gradient(420px 280px at 50% 58%, rgba(156, 47, 44, 0.18), transparent 70%),
    radial-gradient(900px 500px at 50% 100%, #2a221c, var(--night) 62%);
  color: #f6f0e6;
  overflow: hidden;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(176, 137, 88, 0.35);
  pointer-events: none;
}

.cover::after {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(176, 137, 88, 0.18);
  pointer-events: none;
}

.cover__side {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  writing-mode: vertical-rl;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.46em;
  color: var(--gold-soft);
}

.cover__kicker,
.cover__line,
.cover__hint {
  position: relative;
  z-index: 1;
  font-family: var(--sans);
}

.cover__kicker {
  margin: 0 0 18px;
  font-size: 12px;
  letter-spacing: 0.42em;
  color: var(--gold);
}

.cover__title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(46px, 14vw, 64px);
  font-weight: 500;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
}

.cover__line {
  margin: 16px 0 0;
  font-size: 14px;
  letter-spacing: 0.22em;
  color: rgba(246, 240, 230, 0.78);
}

.seal {
  position: relative;
  z-index: 1;
  width: 148px;
  height: 148px;
  margin: 40px 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.seal::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 196px;
  height: 196px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(156, 47, 44, 0.42), transparent 68%);
}

.seal__wax {
  position: absolute;
  inset: 16px;
  border-radius: 48% 52% 50% 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 220, 190, 0.28), transparent 36%),
    radial-gradient(circle at 50% 54%, #b23a34 0%, var(--seal) 46%, var(--seal-deep) 100%);
  box-shadow:
    inset 0 0 0 8px rgba(90, 18, 16, 0.18),
    inset 0 -10px 16px rgba(70, 12, 12, 0.25),
    0 14px 24px rgba(0, 0, 0, 0.28);
  display: grid;
  place-items: center;
}

.seal__wax::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid rgba(243, 230, 208, 0.7);
}

.seal__wax::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 50%;
  border: 1px dashed rgba(243, 230, 208, 0.35);
}

.seal__word {
  position: relative;
  z-index: 1;
  color: #f6efe4;
  font-size: 34px;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 0 rgba(80, 16, 14, 0.35);
}

.seal:active .seal__wax {
  transform: scale(0.96);
}

.seal.is-breaking .seal__wax {
  animation: seal-break 0.7s ease forwards;
}

.cover__hint {
  margin: 18px 0 0;
  font-size: 12px;
  letter-spacing: 0.38em;
  color: rgba(246, 240, 230, 0.62);
  animation: hint-in 1.4s ease 0.8s both;
}

.cover.is-open {
  pointer-events: none;
  animation: cover-away 1.05s ease forwards;
}

.sound {
  position: fixed;
  z-index: 30;
  top: calc(14px + var(--safe-top));
  right: max(14px, calc(50vw - 226px));
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(176, 137, 88, 0.85);
  background: rgba(20, 17, 15, 0.28);
  color: #f6f0e6;
  letter-spacing: 0.12em;
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
}

.stage.is-open .sound {
  color: var(--ink);
  background: rgba(244, 239, 230, 0.88);
}

.sound[hidden] {
  display: none;
}

.sound.is-muted {
  opacity: 0.55;
}

.petal {
  position: absolute;
  top: -12px;
  width: 9px;
  height: 13px;
  border-radius: 70% 10% 70% 10%;
  background: #c47876;
  opacity: 0;
  animation: fall 11s linear infinite;
  animation-play-state: paused;
}

.ending.is-vowed .petal {
  animation-play-state: running;
}

.noscript {
  color: #f6f0e6;
  padding: 48px 24px;
  text-align: center;
}

@keyframes hint-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes seal-break {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.08) rotate(-2deg);
  }
  100% {
    transform: scale(1.25) rotate(4deg);
    opacity: 0;
  }
}

@keyframes cover-away {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-6%);
    visibility: hidden;
  }
}

@keyframes ring-out {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

@keyframes fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 0.75;
  }
  100% {
    transform: translateY(78vh) rotate(200deg);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rise,
  .cover__hint,
  .seal.is-breaking .seal__wax,
  .cover.is-open,
  .petal,
  .vow.is-vowed .vow__ring {
    animation: none;
    transition: none;
    opacity: 1;
    transform: none;
  }

  .cover.is-open {
    opacity: 0;
    visibility: hidden;
  }

  .seal.is-breaking .seal__wax,
  .vow.is-vowed .vow__ring {
    opacity: 0;
  }
}

@media (max-width: 360px) {
  :root {
    --edge-left: 22px;
    --edge-right: 58px;
  }

  .salutation {
    font-size: 34px;
  }

  .ending__line {
    font-size: 26px;
  }
}
