@font-face {
  font-family: "Gift Serif";
  src: url("assets/gift-serif.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #f7fafb;
  --ink: #182d37;
  --muted: #455d68;
  --berry: #08738b;
  --line: #d7e5e9;
  --heading: "Gift Serif", "Noto Serif CJK SC", "Songti SC", SimSun, serif;
  --body: "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 280px;
  background:
    radial-gradient(ellipse at 84% 40%, #eaf4f6 0%, transparent 57%),
    var(--canvas);
  color: var(--ink);
  font: 15px/1.65 var(--body);
}
button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid #00627a; outline-offset: 4px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.page { width: min(1200px, calc(100% - 112px)); margin: auto; }
.masthead, .footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.masthead { height: 93px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; font-size: 15px; font-weight: 700; letter-spacing: .19em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid #afd0d8;
  border-radius: 50%;
  background: #e7f3f5;
  color: var(--berry);
  font: 24px/1 Georgia, serif;
  letter-spacing: 0;
}
.mast-note { color: var(--muted); font-size: 12px; letter-spacing: .18em; }
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: clamp(36px, 6.2vw, 90px);
  padding: clamp(42px, 6.5vh, 70px) 0;
}
.intro { padding-bottom: 4px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--berry);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .22em;
}
.eyebrow::before { content: ""; width: 26px; height: 1px; background: #72aeba; flex-shrink: 0; }
h1, h2 { font-family: var(--heading); font-weight: 700; }
h1 {
  font-size: clamp(41px, 4.35vw, 66px);
  line-height: 1.27;
  letter-spacing: -.075em;
  margin: 20px 0 24px;
}
h1 em { color: var(--berry); font-style: normal; }
.intro-copy { font-size: clamp(15px, 1.3vw, 18px); line-height: 1.95; color: var(--muted); margin: 0 0 30px; letter-spacing: .095em; }
.primary {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 19px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: 100px;
  background: #086b82;
  color: #fff;
  box-shadow: 0 8px 19px #0c536628;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .08em;
  white-space: nowrap;
  transition: background .2s, box-shadow .2s, transform .2s;
}
.primary:hover { background: #07566a; box-shadow: 0 10px 24px #0c53664b; transform: translateY(-2px); }
.primary:active { transform: translateY(1px); }
.intro .primary { min-width: 166px; min-height: 54px; }
.arrow { font-size: 17px; }
.hint { display: flex; align-items: center; gap: 7px; margin: 15px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .07em; }
.hint span { color: var(--berry); font-size: 17px; }

.scene {
  container-type: inline-size;
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 1.04;
  min-height: 0;
  margin: 0;
  border-radius: 25px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 13% 8%, #f1fbfc, transparent 62%),
    linear-gradient(142deg, #d9edf2 20%, #afd2df 100%);
  box-shadow: 0 22px 52px -24px #28596a64;
}
.scene::before {
  content: "";
  position: absolute;
  top: 12%;
  left: 17%;
  width: 66%;
  aspect-ratio: 1;
  border: 1px solid #fff8;
  border-radius: 50%;
  box-shadow: 0 0 0 17px #ffffff24, inset 0 0 42px #effcff59;
}
.scene-frame { position: absolute; z-index: 8; inset: 12px; pointer-events: none; border: 1px solid #f4fcffad; border-radius: 18px; }
.postal-mark {
  position: absolute;
  top: 9%;
  right: 9%;
  width: 12%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: #377185;
  border: 1px dashed #6598a6;
  border-radius: 50%;
  font: 27px/1 Georgia, serif;
  opacity: .66;
  transform: rotate(12deg);
}
.postal-mark::before {
  content: "";
  position: absolute;
  top: 30%;
  right: 100%;
  width: 62%;
  height: 35%;
  background: repeating-linear-gradient(to bottom, #6da0ad 0 1px, transparent 1px 39%);
}
.box-shadow, .puppy-shadow {
  position: absolute;
  filter: blur(10px);
  border-radius: 50%;
  bottom: 16%;
  left: 21%;
  width: 63%;
  height: 9%;
  background: #2151625c;
  transform: rotate(-3deg);
  transition: transform .85s, opacity .6s;
}
.puppy-shadow { left: 55%; bottom: 14%; width: 34%; height: 7%; opacity: 0; }
.gift-box {
  width: 67%;
  aspect-ratio: 700 / 615;
  position: absolute;
  left: 16.5%;
  bottom: 18%;
  pointer-events: none;
  transition: transform .95s cubic-bezier(.22,.77,.25,1);
}
.closed-box, .open-lid, .open-base { position: absolute; inset: 0; background-repeat: no-repeat; }
.closed-box { background-image: url("assets/box.webp"); background-size: 100% auto; background-position: bottom; }
.open-lid, .open-base {
  background-image: url("assets/box-open.webp");
  background-size: 100% 100%;
  opacity: 0;
}
.open-lid {
  clip-path: polygon(0 0, 100% 0, 100% 58.2%, 17% 54.5%, 0 54.5%);
  transform-origin: 58% 55.7%;
}
.open-base { clip-path: polygon(0 54%, 17% 54%, 100% 57.8%, 100% 100%, 0 100%); }
.box-button {
  border: 0;
  border-radius: 12px;
  background: transparent;
  position: absolute;
  z-index: 7;
  left: 16.5%;
  right: 16.5%;
  top: 45%;
  bottom: 18%;
}
.scene:has(.box-button:hover) .gift-box { transform: translateY(-6px) rotate(-1deg); }
.scene:has(.box-button:focus-visible) .gift-box { filter: brightness(1.06); }
.stage-caption, .play-controls {
  position: absolute;
  z-index: 8;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.stage-caption {
  border: 1px solid #f7fcff;
  border-radius: 100px;
  padding: 6px 13px;
  color: #325363;
  background: #f6fcffed;
  box-shadow: 0 5px 14px #2d788e25;
  font-size: 11px;
  letter-spacing: .1em;
  transition: opacity .25s;
}
.caption-dot { width: 5px; height: 5px; background: #eb831d; border-radius: 50%; }
.puppy {
  position: absolute;
  z-index: 5;
  width: 39%;
  left: 48%;
  bottom: 15%;
  background: none;
  border: 0;
  padding: 0;
  transform-origin: bottom center;
  filter: drop-shadow(5px 8px 7px #16394744);
}
.puppy img { display: block; width: 100%; }
.puppy:hover img { transform: rotate(3deg); }
.puppy img { transform-origin: bottom center; transition: transform .25s ease; }
[data-phase="opening"] .puppy { animation: jump 1s .15s both; }
[data-phase="opening"] .gift-box, [data-phase="unwrapped"] .gift-box {
  transform: translate(-19%, 11%) scale(.79);
}
[data-phase="opening"] .closed-box { animation: unwrap .26s both; }
[data-phase="opening"] .open-lid { animation: lid-open .64s .055s both; }
[data-phase="opening"] .open-base { animation: show-box .26s both; }
[data-phase="unwrapped"] .closed-box { opacity: 0; }
[data-phase="unwrapped"] .open-base, [data-phase="unwrapped"] .open-lid { opacity: 1; }
[data-phase="opening"] .box-shadow, [data-phase="unwrapped"] .box-shadow { transform: translate(-21%, 19%) scale(.83); }
[data-phase="unwrapped"] .puppy-shadow { opacity: .73; }
.sparkles span, .reaction-hearts span {
  position: absolute;
  z-index: 6;
  left: var(--x);
  top: var(--y);
  opacity: 0;
  pointer-events: none;
  color: #fefcf0;
  font: 28px/1 Georgia, serif;
  text-shadow: 0 1px 10px #6498a5;
}
[data-phase="opening"] .sparkles span { animation: twinkle .85s calc(.26s + var(--delay)) both; }
.reaction-hearts span { color: #de7309; text-shadow: 0 0 9px #fff; animation: float-heart .9s var(--delay) both; }
.puppy[data-reaction="pet"] img { animation: pet .55s ease; }
.puppy[data-reaction="hug"] img { animation: cuddle .65s ease; }
.play-controls { gap: 9px; }
.play-controls button {
  min-height: 36px;
  padding: 4px 12px;
  border: 1px solid #fff;
  border-radius: 100px;
  background: #f7fcffed;
  color: #235466;
  font-size: 12px;
  font-weight: 700;
  transition: background .2s, transform .2s;
}
.play-controls button:hover { background: #fff; transform: translateY(-2px); }
.footer { min-height: 72px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; letter-spacing: .09em; }
.footer p { margin: 0; }
.footer p span { color: var(--berry); font-size: 17px; margin-right: 6px; vertical-align: -1px; }

.conversation { min-width: 0; }
.conversation h2 { margin: 13px 0 17px; font-size: clamp(28px, 3.15vw, 48px); line-height: 1.35; letter-spacing: -.055em; overflow-wrap: anywhere; }
h2:focus { outline: none; }
.speech {
  position: relative;
  background: #ffffffa8;
  border: 1px solid #dbe8eb;
  border-radius: 18px;
  padding: 18px 21px;
  min-height: 100px;
  box-shadow: 0 8px 27px #3462760d;
  color: #2a4757;
  line-height: 1.9;
  font-size: clamp(14px, 1.18vw, 17px);
  letter-spacing: .035em;
  overflow-wrap: anywhere;
}
.speech::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 23px;
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  border-top: 1px solid #dbe8eb;
  border-right: 1px solid #dbe8eb;
  background: #fcfeff;
}
.speech p { margin: 0; }
.speech p + p { margin-top: .65em; }
.name-form, .letter-controls { margin-top: 20px; }
.name-field, .letter-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.name-field input {
  min-width: 0;
  flex: 1 1 150px;
  padding: 12px 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b3cbd2;
  border-radius: 50px;
  min-height: 49px;
}
.name-field input::placeholder { color: #57727e; font-size: 13px; }
.secondary { background: none; border: 0; border-radius: 4px; color: var(--berry); font-size: 12px; padding: 7px 4px; white-space: nowrap; }
.secondary:hover { text-decoration: underline; text-underline-offset: 4px; }
.progress { color: var(--muted); font-size: 12px; margin-left: auto; }
[data-phase="unwrapped"] .conversation { animation: show-dialog .48s both; }
.speech[data-animate="true"] { animation: show-dialog .32s both; }
@keyframes show-dialog { from { opacity: 0; transform: translateY(8px); } }
@keyframes unwrap { 0%, 28% { opacity: 1; } 100% { opacity: 0; } }
@keyframes show-box { 0%, 15% { opacity: 0; } 100% { opacity: 1; } }
@keyframes lid-open {
  0% { transform: perspective(600px) rotateX(-88deg); opacity: 0; }
  26% { opacity: 1; }
  74% { transform: perspective(600px) rotateX(8deg); }
  100% { transform: none; opacity: 1; }
}
@keyframes jump {
  0% { transform: translate(-55%, 42%) scale(.29, .16); opacity: 0; }
  20% { transform: translate(-49%, 15%) scale(.52, .54) rotate(-9deg); opacity: 1; }
  50% { transform: translate(-22%, -26%) scale(.85, .91) rotate(-9deg); opacity: 1; }
  76% { transform: translate(0, 1%) scale(1.06, .92) rotate(3deg); }
  90% { transform: translate(0, -3%) scale(.98, 1.02); }
  100% { transform: none; }
}
@keyframes twinkle {
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px) scale(.5) rotate(30deg); }
}
@keyframes float-heart {
  22% { opacity: 1; }
  82% { opacity: .75; }
  100% { opacity: 0; transform: translate(var(--drift), -60px) scale(1.3); }
}
@keyframes pet {
  30% { transform: rotate(7deg) scaleY(.97); }
  66% { transform: rotate(-5deg); }
}
@keyframes cuddle {
  40% { transform: scale(.93, .89) rotate(-3deg); }
  75% { transform: scale(1.03, 1.04); }
}

@media (max-width: 950px) {
  .page { width: calc(100% - 70px); }
  .layout { gap: 34px; }
  h1 { font-size: clamp(33px, 4.6vw, 51px); }
}
@media (max-width: 680px) {
  .page { width: min(480px, calc(100% - 36px)); }
  .masthead { height: 61px; }
  .brand { font-size: 13px; gap: 8px; }
  .brand-mark { width: 29px; height: 29px; font-size: 20px; }
  .mast-note { font-size: 10px; letter-spacing: .09em; }
  .layout { grid-template-columns: 1fr; gap: 23px; padding: 26px 0 21px; }
  .intro { padding: 0; }
  .eyebrow { font-size: 11px; }
  h1 { margin: 10px 0 10px; font-size: clamp(31px, 8.9vw, 50px); }
  .intro-copy { margin-bottom: 15px; font-size: 13px; line-height: 1.75; }
  .intro .primary { min-height: 46px; min-width: 137px; padding: 8px 15px; }
  .hint { display: inline-flex; margin: 0 0 0 5px; font-size: 10px; letter-spacing: 0; }
  .scene { aspect-ratio: 1.16; border-radius: 20px; }
  .scene-frame { inset: 9px; border-radius: 14px; }
  .box-button { top: 42%; }
  .stage-caption { font-size: 10px; padding: 4px 9px; }
  .footer { min-height: 55px; font-size: 11px; letter-spacing: 0; }
  [data-phase="unwrapped"] .scene { grid-row: 1; }
  [data-phase="unwrapped"] .layout { padding-top: 16px; }
  .conversation h2 { margin: 7px 0 12px; }
  .speech { padding: 14px 16px; min-height: 0; }
  .speech::after { top: -6px; right: 16%; }
  .name-form, .letter-controls { margin-top: 13px; }
  .play-controls button { min-height: 33px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
.reaction {
  position: absolute;
  z-index: 7;
  top: 9%;
  right: 8%;
  max-width: 68%;
  margin: 0;
  padding: 6px 11px;
  background: #fbfefff5;
  border-radius: 20px 20px 5px 20px;
  color: #235466;
  font-size: 12px;
  box-shadow: 0 5px 16px #23546624;
}
.reaction:empty { display: block; opacity: 0; pointer-events: none; padding: 0; }
@media (max-width: 680px) {
  .name-field input { font-size: 16px; }
  .play-controls button { min-height: 44px; }
}
