:root {
  color-scheme: dark;
  --ink: #151013;
  --cream: #f9edda;
  --gold: #edc492;
  --dim: #c3aa9f;
  --line: #e8bc8938;
  --serif: "Noto Serif SC", "Songti SC", SimSun, serif;
  --sans: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font: 15px/1.7 var(--sans);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 5px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; }
h2 { font-size: clamp(2.25rem, 6vw, 4.1rem); line-height: 1.2; letter-spacing: .05em; }

.topbar {
  position: sticky;
  z-index: 5;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 64px;
  padding: 0 clamp(18px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: #171114f5;
}
.wordmark, .topbar nav, .sound { display: flex; align-items: center; }
.wordmark { gap: 10px; width: fit-content; letter-spacing: .12em; }
.mark { color: var(--gold); font-size: 1.35rem; }
.topbar nav { gap: clamp(12px, 4vw, 40px); color: var(--dim); font-size: .84rem; }
.topbar nav a { display: grid; min-height: 44px; align-items: center; }
.topbar nav a:hover, .text-button:hover { color: var(--cream); }
.sound {
  justify-self: end;
  gap: 9px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 40px;
  background: transparent;
  font-size: .75rem;
  white-space: nowrap;
}
.sound-bars { display: inline-flex; align-items: center; gap: 2px; height: 12px; color: var(--gold); }
.sound-bars i { width: 2px; height: 6px; background: currentColor; }
.sound-bars i:nth-child(2) { height: 11px; }
.sound[aria-pressed="true"] i { animation: equalizer .8s alternate infinite; }
.sound[aria-pressed="true"] i:nth-child(2) { animation-delay: -.45s; }

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: max(590px, calc(100svh - 64px));
  overflow: hidden;
  padding: 60px 26px;
  background: #1b1118;
  text-align: center;
}
.projection, .hero-art, .hero-frame, .aperture { position: absolute; pointer-events: none; }
.projection {
  z-index: -3;
  inset: 0;
  background: radial-gradient(ellipse at 82% 40%, #a6613b 0%, #6d3930 18%, #2d191f 52%, #170f15 82%);
}
.projection::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(123deg, #bb785b00 35%, #e7a06448 76%, #ffe5a780);
  clip-path: polygon(100% 23%, 100% 38%, 7% 93%, 0 67%);
  mix-blend-mode: screen;
}
.hero-art {
  z-index: -2;
  inset: 0;
  background: linear-gradient(90deg, #140d16a0, #140d1625 76%, #140d1625), url("projection.jpg") center 47% / cover;
}
.hero::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: radial-gradient(ellipse at 50% 42%, transparent 20%, #150c15a8 100%);
  pointer-events: none;
}
.hero-frame {
  inset: clamp(14px, 3vw, 42px);
  border: 1px solid #f0c39357;
}
.hero-frame::before, .hero-frame::after {
  position: absolute;
  width: 25px;
  height: 25px;
  content: "";
  border-color: var(--gold);
  border-style: solid;
}
.hero-frame::before { inset: -1px auto auto -1px; border-width: 1px 0 0 1px; }
.hero-frame::after { inset: auto -1px -1px auto; border-width: 0 1px 1px 0; }
.aperture {
  z-index: 1;
  inset: 0;
  background: #1a1117;
  animation: projector-open 1.15s cubic-bezier(.34,.03,.23,1) both;
}
.hero-copy { padding-bottom: 10px; animation: arrive .9s .27s backwards ease-out; }
.kicker {
  color: var(--gold);
  font-size: .77rem;
  letter-spacing: .26em;
  font-weight: 600;
}
.hero .kicker { display: flex; justify-content: center; align-items: center; gap: 13px; }
.kicker span { width: 26px; height: 1px; background: var(--gold); opacity: .55; }
h1 {
  margin: 26px 0 20px;
  font-size: clamp(3.45rem, 9vw, 8.3rem);
  line-height: 1.03;
  letter-spacing: .095em;
  text-shadow: 0 6px 50px #10090e80;
}
h1 em { color: var(--gold); font-style: normal; }
.punctuation { position: absolute; font-size: .68em; }
.dedication { color: #f1d8c2; font-size: clamp(.9rem, 2vw, 1.03rem); letter-spacing: .16em; }
.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 0 26px;
  border: 1px solid #ffdbad8a;
  border-radius: 2px;
  background: var(--gold);
  color: #2b1720;
  font-weight: 700;
  letter-spacing: .085em;
  transition: background .2s, box-shadow .2s, transform .2s;
}
.button:hover { background: #ffe0b7; box-shadow: 0 0 28px #f0ad5945; }
.button:active { transform: translateY(2px); }
.primary { margin-top: 37px; }
.primary span { font-size: .7rem; }
.cue { position: absolute; bottom: clamp(25px, 5vw, 58px); color: var(--gold); font-size: 1.2rem; }

.chapter { padding: clamp(78px, 11vw, 150px) 0; }
.chapter-heading { margin: 0 auto 44px; padding-inline: 20px; text-align: center; }
.chapter-heading h2, .finale h2 { margin: 10px 0 15px; }
.muted { color: var(--dim); }
.memories { background: radial-gradient(ellipse at 50% 28%, #352127, #1a1418 70%); }
.film {
  padding: 25px 0;
  border-block: 1px solid #ddb88c28;
  background:
    linear-gradient(#1a1418, #1a1418) center / 100% calc(100% - 32px) no-repeat,
    repeating-linear-gradient(90deg, #161013 0 13px, #b68e67 13px 28px, #161013 28px 40px);
}
.frames {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  width: min(100%, 1090px);
  margin-inline: auto;
  padding: 0 max(16px, calc((100% - 1060px) / 2));
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.frames::-webkit-scrollbar { display: none; }
.frame {
  flex: 0 0 53%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  background: #24191f;
  text-align: left;
  scroll-snap-align: center;
}
.frame:hover { border-color: var(--gold); }
.frame:focus-visible { outline-offset: -3px; }
.frame-visual, .detail-visual {
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 1.59;
  background: radial-gradient(ellipse at 70% 35%, #895744, #483034 46%, #2e252b 90%);
  color: #f3d0a9;
}
.visual-1 { background: radial-gradient(ellipse at 26% 22%, #9f704b, #50353a 43%, #24202a 92%); }
.visual-2 { background: radial-gradient(ellipse at 78% 73%, #815048, #432e40 52%, #241e32 95%); }
.frame-visual img, .detail-visual img { display: block; width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.placeholder { display: grid; justify-items: center; gap: 8px; font-size: .74rem; letter-spacing: .15em; }
.placeholder i { font-family: Georgia, serif; font-style: normal; font-size: clamp(2rem, 6vw, 4rem); line-height: 1; opacity: .74; }
.frame-label { display: flex; justify-content: space-between; gap: 10px; padding: 10px 4px 0; color: var(--dim); font-size: .85rem; }
.film-tools { position: relative; max-width: 1070px; margin: 20px auto 0; padding-inline: 16px; }
.gallery-nav { display: flex; justify-content: center; align-items: center; gap: 17px; }
#frame-count { color: var(--dim); font: .85rem Georgia, serif; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.icon-button, .egg {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #1b141a;
  color: var(--gold);
}
.icon-button:hover, .egg:hover { border-color: var(--gold); }
.egg { position: absolute; right: 16px; top: 0; border-color: transparent; background: transparent; color: #b59076; }

.letter {
  border-block: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 70%, #57302e, #281920 61%, #1c151a);
}
.desk { display: grid; justify-items: center; padding-inline: 22px; }
.envelope {
  position: relative;
  isolation: isolate;
  display: grid;
  justify-items: center;
  align-content: end;
  width: min(100%, 380px);
  aspect-ratio: 1.63;
  padding: 0 16px 30px;
  border: 1px solid #d0927960;
  border-radius: 4px;
  background:
    linear-gradient(30deg, #6a352f 49.8%, #a26050 50%, transparent 50.3%) left bottom / 50% 100% no-repeat,
    linear-gradient(-30deg, #6a352f 49.8%, #a26050 50%, transparent 50.3%) right bottom / 50% 100% no-repeat,
    #794137;
  box-shadow: 0 16px 45px #140b0e90;
  transition: transform .25s;
}
.envelope:hover { transform: translateY(-5px); }
.envelope-flap {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(145deg, #a85e4b, #864238);
  clip-path: polygon(0 0, 100% 0, 50% 61%);
}
.seal {
  position: absolute;
  top: 47%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 53px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid #eda88275;
  border-radius: 48% 52% 45% 50%;
  background: radial-gradient(circle at 39% 37%, #a34d3e, #562929);
  box-shadow: 0 5px 12px #341619a0, inset 0 0 0 4px #572b2e4d;
  color: #f5c491;
  font-size: 1.35rem;
}
.envelope-label { color: #ffdfc2; font-size: .85rem; letter-spacing: .14em; }
.paper {
  max-width: 610px;
  width: 100%;
  padding: clamp(25px, 7vw, 63px);
  background: #f2dfc1;
  color: #412b31;
  box-shadow: 0 20px 48px #180d15a6;
  animation: arrive .55s both;
}
.paper h3 { margin-bottom: 15px; font-size: 1.45rem; }
.paper p + p { margin-top: 1em; }
.signature { margin-top: 2em; text-align: right; }

.finale {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  min-height: 570px;
  place-items: center;
  padding-inline: 20px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 57%, #342329, #1b131b 64%, #140f17);
}
.finale.lit { background: radial-gradient(ellipse at 50% 55%, #57372c, #241722 59%, #140f17); }
#fireworks { position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; }
.candle {
  position: relative;
  width: 12px;
  height: 42px;
  margin: 44px auto 25px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(90deg, #a3755d, #f5d6ac 42%, #b18764);
}
.flame {
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: 15px;
  height: 24px;
  transform: translateX(-50%);
  border-radius: 62% 38% 56% 44%;
  background: radial-gradient(ellipse at 49% 77%, #fff9db, #ffc360 50%, #f47d41 76%);
  box-shadow: 0 0 25px 8px #ff9b45ad;
  opacity: calc(.2 + var(--hold, 0) * .8);
}
.lit .flame { opacity: 1; animation: flicker 1.3s alternate infinite; }
.hold {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  margin-top: 20px;
  color: var(--gold);
  background: #281b22;
}
.hold:hover { background: #33212a; }
.hold::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  transform: scaleX(var(--hold, 0));
  transform-origin: left;
  background: #9c6350;
}
.wish { animation: arrive .65s both; }
#wish-message { color: var(--gold); font-family: var(--serif); font-size: clamp(1.2rem, 3vw, 1.75rem); }
.text-button { border: 0; background: none; color: var(--dim); padding: 10px 0; }
#replay { margin-top: 10px; }
footer { padding: 24px; border-top: 1px solid var(--line); text-align: center; }

dialog {
  width: min(510px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 0;
  border: 1px solid #b58b65;
  background: #261c22;
  color: var(--cream);
  box-shadow: 0 24px 90px #000a;
}
dialog::backdrop { background: #100a11ca; backdrop-filter: blur(5px); }
.close { position: absolute; right: 12px; top: 12px; font-size: 1.4rem; }
.detail-copy { padding: 34px clamp(22px, 7vw, 42px); }
.detail-copy h2 { margin: 8px 0 12px; font-size: 2rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@keyframes projector-open { from { clip-path: inset(0); } to { clip-path: inset(51% 0); visibility: hidden; } }
@keyframes arrive { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flicker { to { transform: translateX(-50%) rotate(6deg) scale(.92, 1.06); } }
@keyframes equalizer { to { transform: scaleY(.45); } }

@media (max-width: 700px) {
  .frames { scroll-padding-inline: 16px; }
  .frame { flex-basis: 81%; scroll-snap-align: start; }
}
@media (max-width: 440px) {
  .topbar { padding-inline: 10px; gap: 7px; min-height: 57px; }
  .wordmark { gap: 4px; font-size: .75rem; letter-spacing: .02em; white-space: nowrap; }
  .topbar nav { gap: 9px; font-size: .76rem; }
  .sound { padding-inline: 7px; gap: 5px; font-size: .69rem; }
  .hero { min-height: max(510px, calc(100svh - 57px)); }
  .hero-art { background-position: 65% center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .aperture { display: none; }
}

.icon-button:disabled { opacity: .45; cursor: default; }
.icon-button:disabled:hover { border-color: var(--line); }
