:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  --cream: #ffefd3;
  --gold: #f5ca82;
  --ink: #3c2633;
  --display: Georgia, "URW Bookman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  --opened-box-width: clamp(9rem, 31vw, 13rem);
  margin: 0;
  min-width: 0;
  color: var(--cream);
  background: var(--backdrop);
  overflow-x: clip;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 47%, color-mix(in srgb, var(--backdrop), #d2d19b 23%), transparent 62%),
    radial-gradient(ellipse at 50% 40%, transparent 18%, color-mix(in srgb, var(--backdrop), #081522 58%) 100%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 5;
  background: url("/assets/paper-grain.png");
  opacity: 0.4;
  pointer-events: none;
}
::selection { background: #ffd18b; color: #302133; }

main {
  position: relative;
  min-height: 100svh;
  padding: 2.4rem 1.2rem 3.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
h1 {
  margin: 0;
  font: 700 clamp(2.5rem, 7.2vw, 5.65rem)/1.02 var(--display);
  letter-spacing: -0.066em;
  text-align: center;
  text-wrap: balance;
  text-shadow: 0 3px 0 #1e232b46, 0 9px 31px #12182240;
}
h1:focus { outline: none; }
h1 em {
  display: inline-block;
  transform: rotate(-5deg);
  color: var(--gold);
  font-weight: inherit;
  letter-spacing: -0.085em;
}

.winter {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.winter i {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--size);
  height: var(--size);
  color: color-mix(in srgb, var(--ribbon), #fff3d8 40%);
  transform: translate(-50%, -50%) rotate(-12deg);
  opacity: 0.62;
  font-style: normal;
}
.winter .speck {
  border-radius: 50%;
  background: #ffe5bd;
}
.winter .flake {
  width: auto;
  height: auto;
  color: #fae7be;
  font: var(--size)/1 "DejaVu Sans", sans-serif;
  opacity: 0.36;
  animation: flake-drift 10s ease-in-out var(--delay) infinite alternate;
}
.winter .falling-flake {
  top: -1rem;
  border-radius: 50%;
  background: #ffefd3;
  animation: snowfall var(--duration) linear var(--delay) infinite;
}
@keyframes flake-drift {
  from { transform: translate(-50%, -50%) rotate(-14deg); }
  to { transform: translate(calc(-50% + 22px), calc(-50% + 40px)) rotate(25deg); }
}
@keyframes snowfall {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(var(--sway), calc(100vh + 2rem), 0); }
}
.star, .line-star {
  --star-shape: polygon(50% 0%, 60% 38%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 38%);
  clip-path: var(--star-shape);
  background: currentColor;
}
.line-star::after {
  content: "";
  position: absolute;
  inset: 11%;
  background: color-mix(in srgb, var(--backdrop), #c0caab 10%);
  clip-path: var(--star-shape);
}

.stage {
  position: relative;
  width: min(100%, 35.5rem);
  margin-top: -0.35rem;
  isolation: isolate;
}
.stage.is-open {
  order: 1;
  z-index: 1;
  flex-shrink: 0;
  width: var(--opened-box-width);
  margin: auto 0 0;
  transform-origin: top left;
  pointer-events: none;
}
main:has(> .stage.is-open) {
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
}
.gift-button {
  display: block;
  position: relative;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 5rem;
  color: inherit;
  text-align: center;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.gift-button:focus-visible { outline: 2px dashed var(--gold); outline-offset: -1rem; }
.gift-button:disabled { cursor: default; }
.gift-art {
  position: relative;
  display: block;
  isolation: isolate;
  left: -2.6%;
  width: 100%;
  aspect-ratio: 500 / 415;
  pointer-events: none;
  transform-origin: 50% 92%;
}
.gift-art canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.gift-shadow {
  position: absolute;
  left: 23%;
  bottom: 5%;
  width: 64%;
  height: 12%;
  border-radius: 50%;
  background: #111222c7;
  filter: blur(clamp(9px, 1.2vw, 17px));
  transform: rotate(4deg);
  opacity: 0.8;
}
.gift-glow {
  position: absolute;
  left: 4%;
  top: 4%;
  width: 100%;
  height: 77%;
  background: radial-gradient(ellipse, #fff0b914 10%, #ffc67170 29%, transparent 65%);
  opacity: 0;
}
.box-lid { transform-origin: 54% 42%; }
.is-open .box-lid { visibility: hidden; }
.empty-gift {
  margin: 1.1rem 0 0;
  font-weight: 600;
  text-align: center;
}
.confetti {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: clip;
  pointer-events: none;
}
.confetti .box-lid { position: absolute; }
.confetti i {
  position: absolute;
  left: var(--burst-x);
  top: var(--burst-y);
  width: var(--size);
  height: var(--size);
  color: var(--color);
  background: currentColor;
  border-radius: 1px;
  animation: confetti 880ms cubic-bezier(.12,.66,.39,.97) var(--delay) both;
}
.confetti i:nth-child(even):not(.star) { height: calc(var(--size) * 0.5); }
@keyframes confetti {
  0% { transform: translate(0, 0) scale(0.3); opacity: 0; }
  14% { opacity: 1; }
  64% { transform: translate(calc(var(--x) * 0.78), calc(var(--y) - 45px)) rotate(calc(var(--angle) * 0.62)); opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--angle)); opacity: 0; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.has-surprises main {
  padding-top: 2.6rem;
  justify-content: flex-start;
}
.has-surprises h1 { font-size: clamp(2.5rem, 6.1vw, 4.55rem); }
.surprises {
  width: min(100%, 63rem);
  position: relative;
  z-index: 2;
  min-height: 43rem;
  margin-top: 0.5rem;
  margin-bottom: clamp(1.35rem, 3vw, 2.5rem);
  color: var(--ink);
  color-scheme: light;
}
.surprises.is-launching { visibility: hidden; }
.keepsake {
  position: absolute;
  margin: 0;
  border-radius: 0.8rem;
  box-shadow: 0 3px 0 #0d202549, 0 15px 26px #0c201e57;
  transform: rotate(var(--angle));
  transform-origin: 50% 50%;
}
.keepsake:focus-within { z-index: 2; }
.keepsake h2, .keepsake p { margin: 0; }
.keepsake h2 {
  font: 700 1.24rem/1.17 var(--display);
  letter-spacing: -0.037em;
}
.keepsake img, .keepsake video {
  display: block;
  width: 100%;
  height: auto;
}
.keepsake :is(button, input, summary, a):focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
.paper-button {
  display: inline-block;
  border: 0;
  border-radius: 100px;
  padding: 0.43rem 0.76rem;
  background: #563246;
  color: #fff4e8;
  font: 650 0.875rem/1.2 system-ui, sans-serif;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.paper-button:hover { background: #763954; }

.playlist {
  --angle: -7deg;
  left: 2.5%;
  top: 5.5rem;
  width: 27.8%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.05rem;
  background: #f9c7ce;
  border: 1px solid #ffe2d7;
}
.record {
  flex: 0 0 3.9rem;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, #352537 0 4%, #ee8f8e 5% 21%, transparent 23%),
    repeating-radial-gradient(circle, #452b41 0 2px, #68455a 3px, #452b41 4px 5px);
  box-shadow: 0 2px 3px #57344757;
}
.track { flex: 1; min-width: 0; }
.track p { font-size: 0.93rem; margin-top: 0.25rem; }
.track-controls { display: flex; align-items: center; gap: 0.55rem; margin-top: 0.58rem; }
.audio-toggle {
  display: grid;
  place-items: center;
  width: 1.95rem;
  height: 1.95rem;
  border-radius: 50%;
  padding: 0;
  border: 0;
  background: #563246;
  color: #fff4e8;
  cursor: pointer;
  flex: 0 0 auto;
}
.audio-toggle::before {
  content: "";
  width: 0.64rem;
  height: 0.72rem;
  background: currentColor;
  clip-path: polygon(12% 0, 100% 50%, 12% 100%);
}
.audio-toggle.is-playing::before {
  clip-path: polygon(0 0, 33% 0, 33% 100%, 0 100%, 0 0, 67% 0, 100% 0, 100% 100%, 67% 100%, 67% 0);
}
.scrubber { min-width: 0; width: 100%; margin: 0; accent-color: #62344c; cursor: pointer; }

.movie {
  --angle: 3deg;
  left: 34.5%;
  top: 2.25rem;
  width: 35%;
  padding: 0.57rem;
  background: #c7dae7;
  border: 1px solid #e0eef0;
}
.movie :is(video, iframe) { border-radius: 0.38rem; aspect-ratio: 16 / 9; background: #263c52; }
.movie iframe { display: block; width: 100%; min-height: 200px; border: 0; }
.movie h2 { margin: 0.45rem 0.38rem 0.24rem; }

.wallpaper {
  --angle: 8deg;
  left: 76%;
  top: 5.3rem;
  width: 20%;
  padding: 0.57rem 0.57rem 0.82rem;
  background: #e6d9f2;
  border: 1px solid #efe4fa;
  text-align: center;
}
.wallpaper img { aspect-ratio: 1 / 1.08; object-fit: cover; border-radius: 0.36rem; }
.wallpaper h2 { margin: 0.57rem 0 0.56rem; }

.note {
  --angle: 5deg;
  left: 7%;
  top: 16.5rem;
  width: 24%;
  padding: 1.35rem 1.28rem 1.2rem;
  border-radius: 0.3rem 0.4rem 1.35rem 0.33rem;
  background: repeating-linear-gradient(#f9e8b7 0 1.67rem, #ecce94 1.69rem 1.74rem);
}
.tape {
  position: absolute;
  top: -0.56rem;
  left: 35%;
  width: 36%;
  height: 1.12rem;
  background: repeating-linear-gradient(125deg, #eb9f6be8 0 0.29rem, #f8bb88e8 0.29rem 0.61rem);
  transform: rotate(-10deg);
  clip-path: polygon(3% 0, 100% 4%, 96% 97%, 0 100%);
}
.note p { margin-top: 0.57rem; font: italic 1.15rem/1.38 var(--display); }
.note-stamp { display: block; font: 700 1.8rem/1 var(--display); color: #a8464d; margin-top: 0.34rem; }

.fortune {
  --angle: -6deg;
  left: 39%;
  top: 19.3rem;
  width: 24%;
  padding: 1.02rem 0.8rem 1rem;
  background: #ffdbac;
  border: 1px solid #ffe9c6;
  text-align: center;
}
.cookie {
  position: relative;
  margin: 0.35rem auto 0;
  width: 5.5rem;
  height: 4.5rem;
  filter: drop-shadow(1px 3px 1px #af5a494f);
}
.cookie::before, .cookie::after, .cookie i {
  content: "";
  position: absolute;
  display: block;
}
.cookie::before, .cookie::after {
  width: 3.5rem;
  height: 2.1rem;
  border-radius: 75% 69% 69% 36%;
  background: linear-gradient(150deg, #ffe0a0 12%, #df9652 67%, #bc603e);
  border: 1px solid #b2694980;
  transition: transform 240ms ease;
}
.cookie::before { left: 0.2rem; top: 1rem; transform: rotate(41deg); }
.cookie::after { right: 0.1rem; top: 1.03rem; transform: rotate(-42deg) scaleX(-1); }
.cookie i {
  width: 2.7rem;
  height: 0.75rem;
  z-index: 1;
  border-radius: 50%;
  border-top: 0.27rem solid #e4a15c;
  left: 1.45rem;
  bottom: 1.1rem;
  transform: rotate(-3deg);
}
.is-cracked .cookie::before { transform: translateX(-0.5rem) rotate(29deg); }
.is-cracked .cookie::after { transform: translateX(0.5rem) rotate(-29deg) scaleX(-1); }
.is-cracked .cookie i { visibility: hidden; }
.fortune .fortune-slip {
  margin: 0 0.12rem 0.15rem;
  padding: 0.55rem 0.7rem;
  background: #fff3da;
  box-shadow: 0 2px 4px #955d3e38;
  font: italic 1rem/1.35 var(--display);
  transform: rotate(-2deg);
}
.fortune-trigger {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.fortune-trigger[aria-disabled="true"] { pointer-events: none; }

.meme {
  --angle: 5deg;
  left: 70%;
  top: 25.5rem;
  width: 25%;
  padding: 0.57rem 0.57rem 0.52rem;
  background: #fff2dc;
  border: 1px solid #fffaf0;
  text-align: center;
}
.meme span { display: block; padding: 0.3rem 0.4rem 0.46rem; font: 790 0.89rem/1.14 system-ui, sans-serif; }
.meme img { border-radius: 0.27rem; }
.meme figcaption { font-size: 0.87rem; margin-top: 0.35rem; color: #694455; }

.gif-card {
  --angle: -5deg;
  left: 12.5%;
  top: 30.7rem;
  width: 25%;
  padding: 0.56rem;
  background: #f9b7a9;
  border: 1px solid #ffd3be;
}
.gif-card :is(img, video) { border-radius: 0.35rem; }
.gif-card .gif-clip-still { display: none; }
.gif-card h2 {
  margin: 0.53rem 0.23rem 0.17rem;
  font-size: 1.04rem;
}

.extra {
  --angle: 8deg;
  left: 46%;
  top: 37rem;
  width: 22%;
  padding: 0.9rem 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.63rem;
  background: #cee2b5;
  border: 1px solid #e3edcb;
}
.extra-star { color: #b35959; font-size: 2.2rem; line-height: 1; }
.extra p { font-size: 0.92rem; margin-top: 0.3rem; }

.keepsake { overflow-wrap: anywhere; }
.card-message { white-space: pre-wrap; }
.card-link { margin-top: 0.55rem; }
.card-placeholder { padding: 0.6rem; font-size: 0.92rem; }
.movie .card-link { margin-left: 0.38rem; }
.movie img { border-radius: 0.38rem; }
.wallpaper .card-link { margin-top: 0; }
.wallpaper img + .card-link { margin-top: 0.55rem; }

@media (max-width: 57rem) {
  .surprises {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-around;
    min-height: auto;
    gap: 2.55rem 1.75rem;
    max-width: 43rem;
    margin-top: 2.65rem;
    padding: 0 0.7rem;
  }
  .keepsake { position: relative; top: auto; left: auto; }
  .playlist { width: 16.25rem; margin-top: 1.2rem; }
  .movie { width: 18rem; }
  .wallpaper { width: 12.5rem; }
  .note { width: 14.5rem; margin-top: 1.7rem; }
  .fortune { width: 13rem; }
  .meme { width: 15rem; }
  .gif-card { width: 14.5rem; }
  .extra { width: 13rem; margin-top: 1.1rem; }
}
@media (max-width: 39rem) {
  .winter .flake { font-size: calc(var(--size) * 0.73); }
  .winter .line-star, .winter .star { scale: 0.65; }
  .surprises { flex-direction: column; max-width: 26rem; align-items: flex-start; gap: 1.9rem; }
  .keepsake { max-width: 91%; margin-top: 0; }
  .keepsake:nth-child(even) { align-self: flex-end; }
  .playlist, .meme { margin-left: 0.25rem; }
  .movie { margin-right: 0.18rem; }
  .wallpaper, .gif-card { margin-left: 0.58rem; }
  .fortune { margin-left: 0.38rem; }
}
@media (max-width: 22rem) {
  main { padding-right: 0.8rem; padding-left: 0.8rem; }
  .surprises { padding-inline: 0.25rem; }
  .keepsake { max-width: 97%; }
}
.surprises.custom-collage {
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
  align-items: flex-start;
  min-height: 0;
  gap: clamp(1.4rem, 4vw, 3rem);
  max-width: 61rem;
  margin-top: 2.35rem;
  padding: 0.5rem;
}
.custom-collage .keepsake {
  position: relative;
  inset: auto;
  width: min(100%, var(--card-width, 15rem));
  max-width: 96%;
  margin: 0;
}
.custom-collage .keepsake:nth-child(even) { margin-top: 1.1rem; }
.custom-collage .playlist { --card-width: 18rem; }
.custom-collage .movie { --card-width: 20rem; }
.custom-collage .gif-card { --card-width: 17rem; }
.custom-collage .wallpaper { --card-width: 13rem; }
.custom-collage .fortune { --card-width: 14rem; }
@media (max-width: 39rem) {
  .surprises.custom-collage { max-width: 26rem; flex-direction: column; }
  .custom-collage .keepsake:nth-child(even) { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition: none !important; }
  .winter .flake, .winter .falling-flake { animation: none; }
  .gif-card .gif-no-still, .gif-card .gif-clip { display: none; }
  .gif-card .gif-clip-still { display: block; }
}
