:root {
  color-scheme: dark;
  --ink: #30241f;
  --cream: #fbefd6;
  --gold: #f8d998;
  --wine: #872d36;
  --night: #101b2c;
  --display: Georgia, serif;
  font-family: system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; display: flex; flex-direction: column; background: var(--night); color: var(--cream); }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .72; }
:focus-visible { outline: 3px solid #a34a3e; outline-offset: 5px; }
.sound:focus-visible { outline-color: var(--gold); }
::selection { background: #f0bc76; color: var(--ink); }

.scene {
  position: fixed; inset: -12px; z-index: -2;
  background: linear-gradient(90deg,#080e1c65,#0a14222b 54%,#080e1c68), url('/postoffice.jpg') 40% center / cover;
  transform: translate(var(--scene-x, 0), var(--scene-y, 0));
  transition: transform .45s ease-out;
}
.scene::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 20% 25%, #ffb76021, transparent 48%);
  animation: glow 5s ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: .15; } to { opacity: .95; } }
#snow, #confetti { position: fixed; inset: 0; pointer-events: none; }
#snow { z-index: -1; }
#confetti { z-index: 3; overflow: hidden; }
.masthead, footer { width: min(100%, 1470px); padding-inline: clamp(1.1rem, 4vw, 4.5rem); margin-inline: auto; }
.masthead { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding-block: 1.35rem; }
.postmark { display: flex; gap: .65rem; align-items: center; font: 1.03rem var(--display); }
.postmark svg { width: 1.25rem; flex: none; fill: var(--gold); }
.sound {
  position: fixed; top: 1.3rem; right: clamp(1.1rem, 4vw, 4.5rem); z-index: 4;
  display: flex; gap: .55rem; align-items: center; border: 1px solid #f8d99870; padding: .65rem .85rem;
  border-radius: 2rem; background: #121b2ce8; color: var(--cream); font-size: .78rem;
}
.sound svg { fill: none; stroke: currentColor; stroke-width: 1.45; width: 1rem; flex: none; }
.sound[aria-pressed="true"] svg { color: var(--gold); }
main {
  width: min(100%, 1350px); flex: 1; margin-inline: auto; display: grid;
  align-items: center; grid-template-columns: 1.12fr 1fr; gap: clamp(2rem, 7vw, 7rem);
  padding: 3.4rem clamp(1.25rem, 6vw, 6rem);
}
.intro { align-self: end; padding-bottom: clamp(0rem, 7vh, 6rem); text-shadow: 0 4px 26px #050913, 0 2px 5px #050913; }
h1,h2,h3,p { margin: 0; }
h1,h2,h3 { font-family: var(--display); font-weight: 400; letter-spacing: -.035em; }
h1 { font-size: clamp(3.5rem, 7.65vw, 6rem); line-height: .93; }
h1 em { color: var(--gold); font-weight: 400; }
.intro p { margin-top: 1.5rem; font-size: .93rem; letter-spacing: .015em; }
.letter {
  position: relative; isolation: isolate; text-align: center; color: var(--ink);
  padding: 3.05rem clamp(1.5rem, 4.1vw, 3.5rem) 1.85rem; border-radius: 3px;
  background: radial-gradient(ellipse at 46% 20%, #fff7e5, #f2dfb8);
  box-shadow: 0 22px 65px #040711b0; min-width: 0;
  animation: arrive .85s cubic-bezier(.15,.75,.25,1) both;
}
.letter::before { content: ''; position: absolute; z-index: -1; inset: .56rem; border: 1px solid #ac784877; border-radius: 2px; pointer-events: none; }
@keyframes arrive { from { opacity: .72; transform: translateY(20px) rotate(1deg); } }
.seal {
  position: absolute; top: -1.77rem; left: calc(50% - 1.73rem); width: 3.46rem; aspect-ratio: 1;
  display: grid; place-items: center; border-radius: 48% 52% 49% 51% / 53% 49% 51% 47%;
  background: radial-gradient(circle at 40% 30%,#b94d4d,#8d2832 65%,#5b1b25);
  box-shadow: inset 0 0 0 4px #fccaa92b, 0 6px 12px #18110e50; color: #ffe0ae; transform: rotate(-9deg);
}
.seal svg { width: 1.7rem; fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: round; }
h2 { font-size: clamp(2.05rem, 3.7vw, 3.45rem); line-height: .98; }
.letter p { font-size: .94rem; line-height: 1.55; color: #594439; }
.letter section > p { margin: .95rem auto 0; max-width: 29ch; }
form { margin-top: 1.6rem; text-align: left; }
form label { display: block; margin-bottom: .5rem; font-size: .82rem; font-weight: 650; }
input { width: 100%; min-height: 3.05rem; border: 1px solid #a88a6b; border-radius: .25rem; padding: .75rem .9rem; background: #fffaf0; color: var(--ink); caret-color: var(--wine); }
input::placeholder { color: #775d50; }
.primary {
  position: relative; display: flex; justify-content: center; align-items: center; gap: .65em;
  min-height: 3.05rem; width: 100%; border: 0; border-radius: .25rem; padding: .7rem;
  background: var(--wine); color: #fff4de; font-weight: 650; font-size: .91rem;
  transition: background .2s, transform .2s;
}
form .primary { margin-top: .65rem; }
.primary:hover { background: #69232c; transform: translateY(-2px); }
.primary:active { transform: translateY(1px); }
#message { margin-top: .6rem; min-height: 1.5em; color: #792732; font-size: .82rem; }
.gift-scene { position: relative; height: 9.6rem; display: grid; place-items: center; isolation: isolate; }
.gift { position: absolute; bottom: 1.65rem; width: 7.15rem; height: 5.35rem; cursor: pointer; }
.gift-box, .gift-lid {
  position: absolute; background: linear-gradient(90deg,#992b38 12%,#c25054 43%,#e7ac65 43% 57%,#a63e43 57%,#792733);
  border-radius: 3px; box-shadow: 0 6px 12px #18110e4a;
}
.gift-box { inset: .65rem 0 0; }
.gift-lid { inset: 0 -.35rem auto; height: 1.5rem; z-index: 1; }
.gift-lid i::before, .gift-lid i::after {
  content: ''; position: absolute; bottom: 100%; width: 1.9rem; height: 1.2rem;
  border: .28rem solid #b07236; border-radius: 80% 55% 15% 50%; right: 50%; transform: rotate(18deg);
}
.gift-lid i::after { right: auto; left: 50%; transform: scaleX(-1) rotate(18deg); }
.opened .gift { pointer-events: none; animation: gift-vanish .8s both; }
.opened .gift-lid { animation: open-lid .7s cubic-bezier(.2,.85,.45,1) both; }
@keyframes open-lid { to { transform: translate(40px,-70px) rotate(25deg); opacity: 0; } }
@keyframes gift-vanish { 53% { opacity: 1; } to { transform: translateY(25px) scale(.85); opacity: 0; } }
.result { position: relative; animation: reveal .65s .28s both; }
@keyframes reveal { from { transform: translateY(22px) scale(.9); opacity: 0; } }
.result h3 { font-size: clamp(2.7rem, 5vw, 4.4rem); line-height: 1.04; color: var(--wine); overflow-wrap: anywhere; }
.close { border: 0; background: none; color: #792732; text-decoration: underline; text-underline-offset: .2em; min-height: 2.5rem; }
.piece { position: absolute; width: var(--size); height: calc(var(--size) * .72); background: var(--color); animation: burst 1s cubic-bezier(.12,.6,.35,1) both; }
@keyframes burst { to { transform: translate(var(--x),var(--y)) rotate(var(--spin)); opacity: 0; } }
footer { color: #ffe6b5; font-family: var(--display); font-size: .84rem; padding-block: 1.15rem; text-shadow: 0 2px 4px #050913; }
@media (max-width: 760px) {
  .scene { background-position: 32% center; }
  main { grid-template-columns: minmax(0,1fr); align-content: center; gap: 2.9rem; max-width: 31rem; padding-block: 2.2rem 1.5rem; }
  .intro { padding: 0; }
  h1 { font-size: clamp(3rem, 12vw, 5.5rem); }
  .intro p { margin-top: .75rem; font-size: .83rem; }
  .letter { padding-top: 2.65rem; padding-bottom: 1.15rem; }
  .masthead { padding-top: 1.55rem; }
  .postmark { max-width: calc(100% - 9.8rem); font-size: .77rem; }
  .sound { top: 1rem; font-size: .71rem; padding-inline: .65rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .scene { transform: none; }
  .opened .gift { opacity: 0; }
  #snow, #confetti { display: none; }
}
