:root {
  color-scheme: light;
  font-family: 'Trebuchet MS', sans-serif;
  background: #50143f;
  color: #3c122d;
  --paper: #fff3d4;
  --berry: #a20f42;
  --gold: #ffda63;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; min-height: 100svh;
  display: grid; place-items: center; padding: clamp(.55rem, 2.5vw, 2rem);
  background: radial-gradient(circle, #ffb8a82c 1px, transparent 1.5px) 0 0 / 12px 12px, #50143f;
}
main {
  isolation: isolate; display: grid; grid-template-columns: minmax(0, 1fr);
  width: min(100%, 29rem); padding: .42rem; border: 1px solid #ffce8c;
  background: repeating-linear-gradient(-48deg, #b41549 0 12px, #ffe4ab 12px 24px, #00815e 24px 36px, #ffe4ab 36px 48px);
  box-shadow: 0 .45rem #300a29, 0 1.2rem 3rem #28041c99;
}
.postmark, .letter, footer { background: var(--paper); }
.postmark {
  display: flex; align-items: center; justify-content: space-between; gap: .35rem;
  padding: .65rem clamp(.65rem, 4vw, 1.35rem) .45rem;
  color: var(--berry); font-weight: 900; font-size: clamp(.62rem, 2.8vw, .75rem); letter-spacing: .11em;
}
.postmark p { margin: 0; }
.postmark span { border: 1px dashed currentColor; padding: .22rem .35rem; transform: rotate(3deg); white-space: nowrap; }
.illustration { position: relative; overflow: hidden; background: var(--paper); }
#scene { display: block; width: 100%; max-height: 48svh; }
.letter { min-width: 0; padding: .25rem clamp(.8rem, 5vw, 1.55rem) .95rem; }
h1, h2 { font-family: Georgia, serif; line-height: 1; overflow-wrap: anywhere; }
h1 { color: var(--berry); font-size: clamp(2rem, 9.8vw, 3.55rem); margin: 0 0 .17em; letter-spacing: -.065em; }
h2 { color: var(--berry); font-size: clamp(1.85rem, 7vw, 3.25rem); margin: .16em 0; }
p { line-height: 1.45; text-wrap: pretty; }
#intro { margin: .35rem 0 .75rem; }
button {
  display: flex; align-items: center; justify-content: space-between; gap: .5em;
  width: 100%; min-height: 56px; padding: .6rem .8rem .6rem 1rem;
  border: 2px solid #6e1334; border-radius: .35rem .55rem .38rem .52rem;
  background: var(--gold); color: #40172a; font: 900 1.07rem/1.2 'Trebuchet MS', sans-serif;
  text-align: left; cursor: pointer; box-shadow: 0 4px #6e1334;
}
button::after { content: '→' / ''; color: #fff6d2; background: var(--berry); border-radius: 50%; display: grid; place-items: center; width: 32px; height: 32px; flex: none; }
button:hover:enabled { background: #ffe897; }
button:active:enabled { transform: translateY(3px); box-shadow: 0 1px #6e1334; }
button:disabled { cursor: wait; }
button:focus-visible { outline: 3px solid #00604b; outline-offset: 4px; }
#status { margin: .72rem 0 0; }
#status:empty { margin: 0; }
#result { margin-top: .65rem; padding: .65rem .85rem; background: #fffaf0; border: 1px dashed #a20f42; box-shadow: 3px 4px #edc3a7; animation: unfold .45s steps(8, end) both; }
#result p { margin: 0; }
#result p:first-child { font-weight: 900; color: #00634c; }
footer { color: #00634c; text-align: center; padding: .35rem .25rem .65rem; font-size: .65rem; font-weight: 900; letter-spacing: .12em; }
footer { display: flex; justify-content: space-between; gap: .45rem; align-items: center; padding: 0 .8rem .2rem; }
#motion { width: auto; min-height: 44px; padding: .25rem .4rem; background: transparent; box-shadow: none; border: 0; color: #00634c; font-size: .79rem; text-decoration: underline; }
#motion::after { display: none; }
#motion[aria-pressed="true"] { background: #e7efd3; }
.no-motion *, .no-motion *::before, .no-motion *::after { animation: none !important; transition: none !important; }
#scene g, #scene .star, #scene .bow, #scene .smoke { transform-box: fill-box; transform-origin: center; }
#scene .tree { transform-origin: center 95%; animation: sway 2.2s steps(7, end) infinite alternate; }
.sparkle, .treetop { animation: stitch 1.6s steps(6, end) infinite alternate; }
.snow-a { animation: drift 3.1s steps(18, end) infinite alternate; }
.snow-b { opacity: .62; animation: drift 4.3s steps(22, end) infinite alternate-reverse; }
.snow-front { animation: drift-front 2.7s steps(16, end) infinite alternate; }
.side-gift, .hero-gift { animation: bob 2.5s steps(10, end) infinite; }
.hero-gift { animation-delay: -.65s; }
.later { animation-delay: -.45s; }
.smoke { animation: smoke 2.8s steps(12, end) infinite alternate; }
.festoon use, .baubles circle { animation: warm 2.5s ease-in-out infinite alternate; }
.festoon use:nth-child(3n), .baubles circle:nth-child(even) { animation-delay: -1.4s; }
.festoon use:nth-child(3n + 1) { animation-delay: -.7s; }
.parcel-stars { opacity: 0; }
main.is-open .hero-gift { transform: none; animation: gift-nudge .68s steps(8, end) both; }
main.is-open .bow { transform: scaleX(.25); opacity: 0; animation: unknot .4s steps(6, end) both; }
main.is-open #gift-lid { transform: translate(-78px, -45px) rotate(-28deg); animation: lift .7s .38s steps(10, end) both; }
main.is-open .gift-glow { opacity: .13; animation: glow .65s .65s steps(8, end) both; }
main.is-open .parcel-stars { opacity: 1; animation: scatter .65s .66s steps(9, end) both; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; top: 73%; left: 50%; width: 8px; height: 12px; background: var(--color); border-radius: 2px; opacity: 0; }
main.is-open .confetti i { animation: confetti 1.1s var(--delay) steps(16, end) both; }
@keyframes sway { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
@keyframes stitch { from { transform: rotate(-9deg) scale(.83); } to { transform: rotate(8deg); } }
@keyframes drift { from { transform: translate(-6px, -12px); } to { transform: translate(9px, 18px); } }
@keyframes drift-front { from { transform: translate(12px, -18px); } to { transform: translate(-12px, 18px); } }
@keyframes warm { from { opacity: .69; } to { opacity: 1; filter: drop-shadow(0 0 4px #ffda6570); } }
@keyframes smoke { from { transform: translateY(1px) scale(.85); opacity: .4; } to { transform: translate(-4px, -7px) scale(1.08); opacity: .85; } }
@keyframes bob { 0%, 100% { transform: none; } 60% { transform: translateY(-5px) rotate(-3deg); } }
@keyframes gift-nudge { 0%, 100% { transform: none; } 25% { transform: rotate(-7deg) scale(1.09, .91); } 55% { transform: rotate(7deg) translateY(-8px); } }
@keyframes unknot { 0%, 30% { transform: none; opacity: 1; } 70% { transform: translate(15px, -11px) scale(1.45, .6); opacity: .9; } 100% { transform: translate(27px, -15px) scale(.25); opacity: 0; } }
@keyframes lift { 0% { transform: none; } 62% { transform: translate(-38px, -112px) rotate(-18deg); } 100% { transform: translate(-78px, -45px) rotate(-28deg); } }
@keyframes glow { from { opacity: 0; } to { opacity: .13; } }
@keyframes scatter { from { opacity: 0; transform: translateY(38px) scale(.28); } to { opacity: 1; transform: none; } }
@keyframes confetti {
  0% { opacity: 0; transform: none; }
  14% { opacity: 1; }
  56% { opacity: 1; transform: translate(var(--x), var(--y)) rotate(var(--spin)); }
  100% { opacity: 0; transform: translate(var(--end-x), 16px) rotate(var(--tail)); }
}
@keyframes unfold { from { opacity: .45; transform: translateY(.55rem) rotate(-1deg); } to { opacity: 1; transform: none; } }
@media (min-width: 760px) {
  main { width: min(100%, 65rem); grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); background-color: var(--paper); }
  .postmark, footer { grid-column: 1 / -1; }
  #scene { max-height: none; }
  .letter { display: flex; flex-direction: column; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
