:root {
  color-scheme: dark;
  --text: #f2f5ef;
  --mist: #b9c7cc;
  --gold: #f1cf9e;
  --line: rgba(215, 231, 228, .24);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #061020; color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, canvas:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid #ffdb9d; outline-offset: 4px; }
.world { --tree-layer: -100; isolation: isolate; position: relative; min-height: 550px; height: 100svh; overflow: hidden; background: #071223; }
.landscape, .vignette, #scene-input, canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.landscape { z-index: -204; background: #071223 url("winter-lake.webp") center 55% / cover no-repeat; }
#aurora-sky { z-index: -203; pointer-events: none; }
.vignette { z-index: -202; background: radial-gradient(ellipse at 69% 40%, transparent 15%, #04102045 57%, #030b19c4 100%), linear-gradient(90deg, #02091685, transparent 63%); }
canvas { z-index: -1; display: block; outline-offset: -4px; }
#scene { z-index: var(--tree-layer); pointer-events: none; }
#scene-input { z-index: -201; }
.world[data-state="open"] #scene-input, .photo-frame[data-behind] { cursor: grab; touch-action: none; }
.world[data-state="open"] #scene-input:active { cursor: grabbing; }
.top { position: absolute; inset: max(24px, env(safe-area-inset-top)) clamp(22px, 4vw, 67px) auto; display: flex; justify-content: space-between; align-items: center; z-index: 2; pointer-events: none; }
.brand { display: flex; align-items: center; gap: .72rem; font-size: .9rem; font-weight: 500; letter-spacing: .24em; color: #f5e4c6; }
.brand img { padding: 6px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: #0e1a2870; }
.top-actions, .scene-controls { display: flex; gap: 8px; pointer-events: auto; }
.icon-button, .spark-button, .text-button { color: var(--text); background: #0a1a2ca8; border: 1px solid var(--line); border-radius: 100px; display: inline-flex; align-items: center; justify-content: center; transition: background .2s, border-color .2s; }
.icon-button { width: 42px; height: 42px; padding: 10px; font-size: 1.18rem; line-height: 1; }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.icon-button[aria-pressed="true"], .icon-button:hover, .spark-button:hover, .text-button:hover { background: #20364b; border-color: #b1cbca91; }
.icon-button[aria-pressed="true"] { color: var(--gold); }
.greeting { position: absolute; left: clamp(24px, 6.4vw, 120px); top: 50%; width: min(44vw, 660px); transform: translateY(-49%); z-index: 1; pointer-events: none; }
.greeting::before { content: ""; position: absolute; z-index: -1; inset: -52px -45px; opacity: 0; background: radial-gradient(ellipse at center, #071223c9 12%, #07122394 49%, #07122300 74%); transition: opacity .28s ease-out; }
.world[data-scatter="spread"] .greeting::before { opacity: 1; }
.recipient { color: var(--gold); display: flex; align-items: center; gap: .65em; font-size: .9rem; letter-spacing: .17em; margin: 0 0 1.1rem; }
.recipient b { font-weight: 500; overflow-wrap: anywhere; }
.recipient span { width: clamp(16px, 2.2vw, 45px); flex: 0 0 auto; height: 1px; background: linear-gradient(90deg, #edc88f12, #edc88fb0); }
h1 { margin: 0; font-family: Baskerville, "Iowan Old Style", Georgia, serif; font-size: clamp(60px, 8.3vw, 156px); font-weight: 400; line-height: .85; letter-spacing: -.055em; color: #f6f0df; text-shadow: 0 0 38px #a5e8f124; }
h1 em { display: block; color: #e9d1ac; font-weight: 400; margin-left: -.033em; }
.wish { font-size: 1rem; line-height: 1.75; letter-spacing: .055em; color: var(--mist); margin: 1.55rem 0 1.28rem; overflow-wrap: anywhere; }
.primary { border: 1px solid #ffe3ae92; border-radius: 100px; padding: .76rem 1.28rem; display: inline-flex; align-items: center; gap: .53rem; min-height: 45px; background: #f2d4a7; color: #162131; font-size: .93rem; font-weight: 650; box-shadow: 0 4px 28px #eecf9238; transition: background .2s, transform .2s; pointer-events: auto; }
.primary:hover { background: #fff0ce; transform: translateY(-2px); }
.primary span { font-size: 1.25rem; line-height: 1; }
.opened { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem 1.05rem; }
.letter-button { gap: .58rem; }
.letter-button svg { width: 1.1rem; height: 1.1rem; }
.text-button { pointer-events: auto; font-size: .875rem; padding: .6rem .8rem; }
.scene-controls { position: absolute; z-index: 2; bottom: max(25px, env(safe-area-inset-bottom)); left: 66.5%; transform: translateX(-50%); align-items: center; }
.spark-button { color: #f7e2c0; padding: .57rem .8rem; min-height: 42px; gap: .35rem; font-size: .875rem; white-space: nowrap; }
.top-actions { align-items: center; }
.gesture-preview { position: absolute; z-index: 2; top: calc(max(24px, env(safe-area-inset-top)) + 56px); right: clamp(22px, 4vw, 67px); width: min(174px, 45vw); border: 1px solid #b9e4ff55; border-radius: 10px; background: #08182be8; overflow: hidden; }
.gesture-preview video { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; transform: scaleX(-1); background: #061020; }
.gesture-caption { display: flex; align-items: center; gap: .35rem; padding: .45rem .54rem; }
.gesture-caption p { flex: 1; margin: 0; color: #e0eef6; font-size: .74rem; line-height: 1.45; }
.gesture-caption .icon-button { padding: 0; width: 24px; height: 24px; flex: none; font-size: .9rem; }
#spark[aria-pressed="true"] { background: #25435a; border-color: #e9cf9ca2; }
.album-icon { width: 1.05rem; height: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.photo-orbit { position: absolute; inset: 0; pointer-events: none; }
.photo-frame { position: absolute; z-index: calc(var(--tree-layer) + var(--photo-depth, 1)); top: 0; left: 0; width: 68px; aspect-ratio: 4/5; padding: 0; border: 0; background: transparent; pointer-events: auto; }
.photo-frame-card, .viewer-card { border: 1px solid #f5d59c; background: linear-gradient(130deg, #f9e3b8, #9c6e42 50%, #ffe6aa); box-shadow: 0 0 16px #ffcb8282, 0 5px 15px #0208128c; }
.photo-frame-card { position: absolute; inset: 0; padding: 4px; display: block; pointer-events: none; border-radius: 3px; transform: perspective(570px) rotateY(var(--photo-heading,0deg)); transition: transform .44s cubic-bezier(.2,.8,.22,1), box-shadow .43s; }
.photo-frame[data-aloft] .photo-frame-card { transition-property: box-shadow; box-shadow: 0 0 19px #ffe1a95e, 0 6px 22px #020812c2; }
.photo-frame img, .album-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-frame:focus-visible:not([data-behind]) { z-index: 0; }
.photo-frame:focus-visible:not([data-behind]) .photo-frame-card { transform: perspective(570px) rotateY(0) scale(1.65); box-shadow: 0 0 28px #ffe5b4de, 0 6px 21px #020812aa; }
.photo-frame.photo-in-view { visibility: hidden; }
@media (hover: hover) and (pointer: fine) {
  .photo-frame:hover:not([data-behind]) { z-index: 0; }
  .photo-frame:hover:not([data-behind]) .photo-frame-card { transform: perspective(570px) rotateY(0) scale(1.65); animation: frame-glance .58s both; box-shadow: 0 0 28px #ffe5b4de, 0 6px 21px #020812aa; }
}
@keyframes frame-glance {
  0% { transform: perspective(570px) rotateY(var(--photo-heading,0deg)); }
  35% { transform: perspective(570px) translateY(-4px) rotateY(var(--photo-edge,-70deg)) scale(1.25); }
  100% { transform: perspective(570px) translateY(-8px) rotateY(0) scale(1.65); }
}
.featured-gifts { position: absolute; inset: 0; pointer-events: none; }
.featured-gift { position: absolute; z-index: 0; left: 0; top: 0; display: grid; justify-items: end; align-items: start; padding: 1px; pointer-events: auto; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #fff2cb; }
.featured-gift span { display: grid; place-items: center; width: 20px; height: 20px; margin: -6px -6px 0 0; border-radius: 50%; background: #122031db; border: 1px solid currentColor; box-shadow: 0 0 13px #ffc477a8; font-size: .72rem; }
#gift-rose { color: #ffe2e6; }
.featured-gift:hover, .featured-gift:focus-visible { border-color: currentColor; box-shadow: 0 0 24px #ffdba169, inset 0 0 12px #ffda8533; }
#gift-dialog { --gift-light: #ffdfa5; --gift-wrap: #a8753c; --gift-face: #eec480; }
#gift-dialog[data-gift="rose"] { --gift-light: #ffdae2; --gift-wrap: #913c58; --gift-face: #da8a9e; }
#gift-reading:not([hidden]), #gift-form:not([hidden]) { display: grid; gap: .8rem; }
#gift-reading .text-button { justify-self: start; }
.gift-opening { position: relative; width: 86px; height: 92px; margin: .75rem auto 0; filter: drop-shadow(0 0 18px color-mix(in srgb, var(--gift-light) 38%, transparent)); }
.gift-opening i { position: absolute; inset: 35px 6px 4px; border-radius: 4px; background: linear-gradient(90deg, transparent 43%, var(--gift-light) 43% 56%, transparent 56%), linear-gradient(130deg, var(--gift-face), var(--gift-wrap)); }
.gift-opening i:nth-child(2) { inset: 25px 0 auto; height: 19px; animation: open-gift-lid .65s cubic-bezier(.18,.72,.28,1) both; }
.gift-opening span { position: absolute; inset: 14px 0 auto; text-align: center; color: var(--gift-light); font-size: 1.55rem; animation: gift-spark .65s ease-out both; }
#gift-note { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.75; margin: 0; animation: gift-note .56s .16s both; }
.gift-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
@keyframes open-gift-lid { from { transform: translateY(5px); } to { transform: translateY(-15px) rotate(-12deg); } }
@keyframes gift-spark { from { opacity: 0; transform: translateY(10px) scale(.55); } to { opacity: 1; transform: translateY(-14px) scale(1); } }
@keyframes gift-note { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.album-note { color: var(--mist); font-size: .875rem; line-height: 1.5; }
.album-transfer { border-top: 1px solid var(--line); margin-top: .8rem; padding-top: .85rem; }
.album-transfer .album-note { margin: .48rem 0; }
.album-transfer .photo-status:empty { display: none; }
#album-link-panel { display: flex; flex-wrap: wrap; gap: .45rem; }
#album-link { flex: 1 1 12rem; min-width: 0; }
.album-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; }
.album-tile { position: relative; min-width: 0; aspect-ratio: 4/5; }
.album-image { width: 100%; height: 100%; padding: 3px; border: 1px solid #c6a471; border-radius: 6px; background: #1e2b3c; overflow: hidden; }
.photo-remove { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; padding: 0; background: #061020e0; }
.album-empty { border: 1px dashed #8e9cab58; padding: 1rem .6rem; text-align: center; border-radius: 8px; color: var(--mist); font-size: .9rem; }
.album-bottom, .viewer-header, .viewer-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.photo-status { color: #f3cc9b; margin: .75rem 0 0; font-size: .86rem; }
.photo-status:empty { display: none; }
.primary:disabled { cursor: default; opacity: .53; transform: none; }
#photo-viewer { width: max-content; max-width: calc(100% - 2.25rem); max-height: calc(100% - 1.4rem); border: 0; padding: 0; background: transparent; box-shadow: none; overflow: visible; }
#photo-viewer::backdrop { background: #030919a8; backdrop-filter: none; }
#photo-viewer[data-flight="opened"]::backdrop { animation: photo-night .82s both; }
#photo-viewer[data-flight="closing"]::backdrop { animation: photo-night .54s reverse both; }
#photo-viewer[data-flight="opened"] :is(.viewer-header,.viewer-nav) { animation: photo-chrome .36s .46s both; }
#photo-viewer[data-flight="closing"] :is(.viewer-header,.viewer-nav) { visibility: hidden; }
#photo-viewer :is(.viewer-header,.viewer-nav) { position: relative; z-index: 1; }
#photo-viewer .viewer-header { margin: 0 0 .55rem; min-width: 8.5rem; color: #efe0c5; text-shadow: 0 1px 8px #061020; }
.viewer-card { display: block; width: max-content; max-width: 100%; margin: 0 auto; padding: clamp(5px,1vw,11px); border-radius: 6px; box-shadow: 0 0 28px #ffcf969f, 0 0 64px #edbf6638, 0 18px 65px #000a; }
#viewed-photo { display: block; width: auto; height: auto; max-width: min(74vw,720px); max-height: min(67dvh,640px); object-fit: contain; border: 1px solid #724a32; border-radius: 2px; background: #061020; }
@keyframes photo-night { from { background-color: #03091900; } to { background-color: #030919a8; } }
@keyframes photo-chrome { from { opacity: 0; } to { opacity: 1; } }
.instructions { position: absolute; bottom: max(33px, env(safe-area-inset-bottom)); left: clamp(22px, 4vw, 67px); color: var(--mist); font-size: .86rem; letter-spacing: .04em; pointer-events: none; }
.mobile-instructions { display: none; }
.no-script { position: fixed; bottom: 30px; left: 24px; }
dialog { width: min(31rem, calc(100% - 2rem)); color: var(--text); background: #0e2036; border: 1px solid #76869c; border-radius: 20px; padding: 1.5rem; box-shadow: 0 24px 80px #0009; }
dialog::backdrop { background: #020811ae; backdrop-filter: blur(7px); }
dialog form { display: grid; gap: .7rem; }
dialog input, dialog textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: .63rem .7rem; color: inherit; background: #08172a; }
dialog textarea { resize: vertical; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: .4rem; }
.dialog-heading h2 { font-size: 1.3rem; font-weight: 600; margin: 0; color: #f5e4c6; }
dialog .primary { justify-self: start; margin-top: .25rem; }
.edit-note { margin: 0; color: var(--mist); font-size: .84rem; }
#winter-letter { width: min(37rem, calc(100% - 1.75rem)); max-height: calc(100% - 1.75rem); border: 0; padding: 0; overflow: visible; background: transparent; box-shadow: none; }
#winter-letter::backdrop { background: #030b1a9c; backdrop-filter: blur(2px); animation: letter-night .56s both; }
.letter-paper { position: relative; color: #2b3332; border-radius: 7px; border: 1px solid #e9d0a4; padding: clamp(1.25rem, 5vw, 3.4rem); max-height: calc(100dvh - 1.75rem); overflow: auto; background: radial-gradient(ellipse at 64% 22%,#fff5dfff,transparent 55%),linear-gradient(135deg,#fff2d4,#eedaba); box-shadow: 0 1rem 5rem #0009,0 0 2.3rem #ddac5f43; }
#winter-letter[open] .letter-paper { animation: letter-lift .90s cubic-bezier(.24,.72,.27,1) both; }
.letter-paper::before { content: ""; position: absolute; inset: 9px; border: 1px solid #a7804e61; border-radius: 3px; pointer-events: none; }
.letter-ink { position: relative; }
#winter-letter[open] .letter-ink { animation: letter-ink .39s .46s both; }
.letter-ink h2 { font-family: "Songti SC", "Noto Serif CJK SC", serif; font-weight: 650; font-size: clamp(1.6rem, 4.5vw, 2.62rem); letter-spacing: .11em; margin: 0 0 1.35rem; }
.letter-to { color: #714418; font-weight: 630; margin: 0 0 .6rem; }
.letter-text { margin: 0; white-space: pre-wrap; font-size: clamp(1rem,2.7vw,1.125rem); line-height: 2.02; overflow-wrap: anywhere; }
.letter-end { font-size: 1.4rem; color: #a66a2c; margin: 1.35rem 0 0; text-align: right; }
#close-letter { width: 35px; height: 35px; padding: 0; position: absolute; z-index: 1; top: 13px; right: 13px; color: #64421f; border-color: #ad81575c; background: #f2d9aeaa; }
.letter-envelope { position: absolute; z-index: 2; bottom: 13%; left: 13%; width: 74%; height: clamp(95px, 25vh, 164px); background: linear-gradient(146deg,#c9965c,#edc391); border-radius: 5px; border: 1px solid #f9dda9; perspective: 620px; pointer-events: none; box-shadow: 0 14px 32px #1e0c0e5a; }
.letter-envelope i { position: absolute; inset: 0; background: linear-gradient(152deg,#d5ac7b,#efd2a3); clip-path: polygon(0 0,100% 0,50% 66%); transform-origin: top; }
.letter-envelope span { position: absolute; top: 53%; left: 47%; line-height: 1.35; padding: .05rem .32rem; color: #ffddb3; border-radius: 50%; background: #825a42; }
#winter-letter[open] .letter-envelope { animation: letter-envelope .83s ease-out both; }
#winter-letter[open] .letter-envelope i { animation: letter-flap .58s cubic-bezier(.3,.55,.28,1) both; }
@keyframes letter-lift { 0%,20% { opacity: 0; transform: translateY(62px) scale(.87); clip-path: inset(84% 0 0); } 49% { opacity: 1; } 100% { opacity: 1; transform: none; clip-path: inset(0); } }
@keyframes letter-envelope { from { transform: translateY(22px) scale(.90); opacity: 0; } 27%,44% { transform: none; opacity: 1; } to { transform: translateY(32px) scale(.96); opacity: 0; } }
@keyframes letter-flap { 0%,25% { transform: rotateX(0); } to { transform: rotateX(164deg); } }
@keyframes letter-ink { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes letter-night { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 800px) and (orientation: portrait), (max-width: 585px) {
  .world { min-height: 610px; }
  .top { inset: max(16px, env(safe-area-inset-top)) 17px auto; }
  .brand { gap: .36rem; font-size: .75rem; letter-spacing: .055em; white-space: nowrap; }
  .brand img { width: 29px; height: 29px; padding: 5px; }
  .top-actions { gap: 6px; }
  .gesture-preview { top: auto; bottom: max(91px, calc(env(safe-area-inset-bottom) + 76px)); right: 11px; width: min(106px, 33vw); }
  .photo-frame { width: 47px; }
  .photo-frame-card { padding: 3px; }
  .greeting { top: clamp(76px, 10svh, 125px); left: 5%; width: 90%; transform: none; text-align: center; }
  .recipient { justify-content: center; margin-bottom: .65rem; font-size: .85rem; }
  h1 { font-size: clamp(47px, 10.4vw, 76px); line-height: .93; }
  h1 em { display: inline; margin: 0; }
  .wish { margin: .65rem auto .72rem; max-width: 35ch; font-size: .9rem; }
  .opened { justify-content: center; gap: .5rem; }
  .letter-button { padding: .53rem .76rem; min-height: 39px; font-size: .86rem; }
  .text-button { padding: .47rem .58rem; font-size: .8rem; }
  .scene-controls { left: 50%; bottom: max(40px, calc(env(safe-area-inset-bottom) + 25px)); }
  .instructions { bottom: max(15px, env(safe-area-inset-bottom)); left: 0; width: 100%; text-align: center; font-size: .76rem; }
  .desktop-instructions { display: none; }
  .mobile-instructions { display: inline; }
  .vignette { background: radial-gradient(ellipse at 48% 55%, transparent 25%, #0610222c 60%, #030b1977 100%); }
}
@media (max-width: 365px) {
  .top-actions { gap: 5px; }
  .top-actions .icon-button { width: 36px; height: 36px; padding: 8px; }
  #album-button { padding: .45rem .55rem; min-height: 36px; }
  .brand { font-size: .72rem; gap: .30rem; letter-spacing: .035em; }
  #album-button { font-size: .75rem; }
  #album-button .album-icon { display: none; }
}
@media (max-height: 510px) and (orientation: landscape) {
  .world { min-height: 350px; }
  .top { top: 13px; }
  .greeting { left: 5%; }
  h1 { font-size: clamp(44px, 11vh, 85px); }
  .recipient { margin-bottom: .55rem; }
  .wish { margin: .55rem 0 .65rem; }
  .instructions { bottom: 17px; font-size: .76rem; }
  .scene-controls { bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .gift-opening i, .gift-opening span, #gift-note { animation-duration: .01s; animation-delay: 0s; }
  *, *::before, *::after { transition: none !important; }
  .photo-frame .photo-frame-card, #photo-viewer::backdrop, #photo-viewer :is(.viewer-header,.viewer-nav) { animation: none !important; }
  #winter-letter::backdrop, #winter-letter[open] :is(.letter-paper,.letter-ink) { animation: none; }
  #winter-letter .letter-envelope { display: none; }
}
