:root {
  --paper: #FFF0F7; --ink: #542c43; --rose: #9f3264; --muted: #795069;
  --surface: #fffafde8; --surface-solid: #FFFAFD; --line: #ebc5d7; --soft: #ffe4ef; --gold: #E9C78B;
}
html { scroll-padding-top: 24px; }
body { isolation: isolate; background: radial-gradient(ellipse at 10% 0, #ffd6e8a8, transparent 48%), radial-gradient(ellipse at 95% 30%, #ffe7cf66, transparent 40%), var(--paper); }
.site-header, main, footer { position: relative; z-index: 1; }
body::before, body::after { content: ''; position: fixed; z-index: 0; pointer-events: none; width: 170px; height: 55px; top: 180px; border-radius: 100%; background: #fffafdb3; box-shadow: 35px -20px 0 5px #fffafd80, -30px 5px 0 4px #fffafd70; }
body::before { left: -60px; } body::after { right: 0; top: 55vh; transform: scale(.7); }
.header-actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.theme-toggle { min-height: 44px; padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); background: var(--surface); font: inherit; font-size: 12px; cursor: pointer; }
.world-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 22px; padding: 20px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.world-nav a { display: inline-flex; min-height: 44px; align-items: center; border-bottom: 1px solid transparent; }
.world-nav a:hover { color: var(--rose); border-color: var(--rose); }
.hero { padding-top: 56px; }
.world-card, .music-card, .chat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 28px; padding: 36px; margin-block: 0 30px; box-shadow: 0 12px 40px #90375d0c; }
@supports (backdrop-filter: blur(8px)) { .music-card, .theme-toggle { backdrop-filter: blur(8px); } }
.world-card .eyebrow { margin-bottom: 8px; }
.section-note { color: var(--muted); font-size: 14px; line-height: 1.8; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.secondary { background: var(--surface-solid); color: var(--rose); }
.secondary:hover { background: var(--rose); color: #fff; }
button, a, input, textarea { -webkit-tap-highlight-color: #f6a6c840; }
button, .button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--rose); outline-offset: 4px; }

/* All continuous decoration sits behind the readable/interactive content. */
.petals, .night-sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; contain: strict; }
.petal { position: absolute; left: var(--x); top: -40px; width: var(--size); height: calc(var(--size) * 1.4); border-radius: 80% 5% 70% 20%; background: #F6A6C899; animation: petal-fall var(--duration) var(--delay) linear infinite; }
@keyframes petal-fall {
  0% { transform: translate3d(0, -30px, 0) rotate(0); opacity: 0; }
  10% { opacity: .8; }
  40% { transform: translate3d(var(--drift), 42vh, 0) rotate(130deg); }
  70% { transform: translate3d(calc(var(--drift) * -1), 75vh, 0) rotate(250deg); opacity: .65; }
  100% { transform: translate3d(var(--drift), calc(100vh + 60px), 0) rotate(var(--turn)); opacity: 0; }
}
.tap-heart { position: fixed; pointer-events: none; z-index: 12; color: #d85b96; font-size: 17px; line-height: 1; opacity: 0; animation: tap-bloom 1s ease-out forwards; }
.tap-heart:nth-of-type(even) { color: #fffafd; text-shadow: 0 0 2px #a03468; }
@keyframes tap-bloom { 10% { opacity: .85; } 100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rotation)) scale(.5); opacity: 0; } }
.night-sky { display: none; }
.moon { position: absolute; top: 140px; right: 6%; color: #E9C78B; font-size: 85px; line-height: 1; }
.stars { position: absolute; top: 75px; left: 12%; font-size: 23px; color: #fff0d6; letter-spacing: 8vw; white-space: nowrap; animation: twinkle 6s ease-in-out infinite; }
.shooting-star { position: absolute; width: 65px; height: 1px; top: 12%; right: 30%; background: linear-gradient(90deg, transparent, #ffe9c1); animation: shooting 22s linear infinite; opacity: 0; }
@keyframes twinkle { 50% { opacity: .35; } }
@keyframes shooting { 0%, 85%, 100% { transform: translate(0, 0) rotate(-30deg); opacity: 0; } 88% { opacity: .8; } 93% { transform: translate(-180px, 110px) rotate(-30deg); opacity: 0; } }

/* Envelope remains a real keyboard-operable button; the full letter is real text. */
.letter { display: block; padding-block: 48px; }
.letter-intro { text-align: center; }
.letter-body { max-width: 720px; margin: 30px auto; font-size: 16px; }
.envelope { position: relative; display: block; width: min(310px, 80%); height: 190px; margin: 60px auto 20px; padding: 0; border: 0; border-radius: 12px; background: #efb2cc; cursor: pointer; perspective: 850px; transform-style: preserve-3d; box-shadow: 0 18px 32px #a03b6325; }
.envelope-front { position: absolute; inset: 0; z-index: 2; border-radius: 8px 8px 12px 12px; background: linear-gradient(32deg, #ffd6e8 49%, transparent 50%), linear-gradient(-32deg, #f4bdd5 49%, #efb2cc 50%); }
.envelope-flap { position: absolute; inset: -1px 0 auto; z-index: 3; height: 65%; background: #f8c8dd; clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: 50% 0; backface-visibility: hidden; transition: transform .65s ease; }
.envelope-paper { position: absolute; left: 8%; top: 12px; width: 84%; height: 150px; padding: 25px 12px; z-index: 1; background: #FFFAFD; color: #9f3264; border-radius: 8px; font-family: 'Songti SC', serif; transition: transform .85s .35s ease; }
.wax { position: absolute; z-index: 4; top: 50%; left: 50%; transform: translate(-50%, -30%); display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: #ffedf5; background: #b8477c; border: 3px double #eeb2cd; box-shadow: 0 3px 8px #82274e35; transition: opacity .25s; }
.envelope-ribbon { position: absolute; right: 15px; bottom: 5px; z-index: 4; font-size: 35px; color: #b8477c; }
.envelope-hint { font-size: 12px; color: var(--muted); }
.letter-open .envelope-flap { transform: rotateX(180deg); }
.letter-open .envelope-paper { transform: translateY(-70px); }
.letter-open .wax { opacity: 0; }
.envelope-ready .letter-body { padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.letter-open .letter-body { animation: letter-unfold 1.3s ease both; }
@keyframes letter-unfold { 0%, 30% { opacity: 0; transform: translateY(28px) rotateX(-5deg); } 100% { opacity: 1; transform: none; } }
#close-letter { display: flex; margin-top: 18px; }

.anniversary-card { display: flex; gap: 28px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.day-counter { text-align: center; flex: 1 1 200px; }
.day-counter strong { display: block; color: var(--rose); font: 500 clamp(45px, 6vw, 68px)/1.3 'Songti SC', serif; }
.day-counter span, #anniversary-status { color: var(--muted); font-size: 13px; }
.fireworks-section { text-align: center; background: radial-gradient(ellipse at 50% 100%, #f6a6c825, transparent 70%), var(--surface); }
#fireworks-status { font-size: 14px; color: var(--rose); min-height: 1.8em; }
.fireworks-stage { position: fixed; inset: 0; z-index: 30; pointer-events: none; background: #28162b8c; display: grid; place-items: center; overflow: hidden; }
.fireworks-stage canvas { position: absolute; width: 100%; height: 100%; }
.fireworks-stage p { color: #fff4e1; z-index: 1; font: 500 clamp(26px, 7vw, 60px)/1.5 'Songti SC', serif; text-shadow: 0 2px 10px #3e1c38; }
.static-fireworks canvas { display: none; }
.static-fireworks p::before, .static-fireworks p::after { content: ' ♡ ✧ '; display: block; text-align: center; color: #f6a6c8; }

.wish-garden { position: relative; min-height: 320px; padding: 45px 18px 95px; display: grid; align-items: center; }
.tree-art { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tree-crown { position: absolute; top: 12px; left: 12%; width: 76%; height: calc(100% - 90px); border-radius: 46% 50% 38% 40%; background: radial-gradient(ellipse at 50% 20%, #fff1f7b8, #f6a6c86b 65%, #e6a6c565); border: 1px solid #edb6d08c; }
.tree-trunk { position: absolute; bottom: 15px; left: calc(50% - 11px); width: 22px; height: 145px; background: #ba859b; border-radius: 100% 20% 4px 4px; z-index: -1; }
.tree-trunk::before, .tree-trunk::after { content: ''; position: absolute; width: 9px; height: 85px; background: #ba859b; bottom: 30px; transform-origin: bottom; transform: rotate(-43deg); }
.tree-trunk::after { transform: rotate(43deg); right: 0; }
.tree-stars { position: absolute; width: 100%; text-align: center; bottom: 5px; color: var(--rose); letter-spacing: 20px; }
.wish-hearts { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px; max-width: 750px; margin: auto; }
.wish-heart { position: relative; width: 112px; min-height: 87px; padding: 14px 10px 10px; border: 1px solid #e0a3bf; border-radius: 30px 30px 22px 22px; background: var(--surface-solid); color: var(--ink); box-shadow: 0 6px 12px #963b5f12; transform: rotate(var(--tilt)); cursor: pointer; font: inherit; }
.wish-heart::before { content: ''; position: absolute; width: 1px; height: 20px; background: #b99062; top: -20px; left: 50%; }
.wish-heart span:first-child { color: var(--rose); display: block; font-size: 28px; line-height: 1.1; }
.wish-heart span:last-child { display: block; font-size: 12px; overflow-wrap: anywhere; line-height: 1.5; }
#wish-status { color: var(--muted); font-size: 13px; text-align: center; }
.fairy-dialog { position: fixed; inset: 0; margin: auto; width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 40px); max-height: min(85vh, 850px); overflow-y: auto; overscroll-behavior: contain; padding: 44px 24px 24px; border-radius: 24px; border: 1px solid var(--line); background: var(--surface-solid); color: var(--ink); box-shadow: 0 20px 80px #2b112a45; }
.fairy-dialog::backdrop { background: #37213999; }
.fairy-dialog:not([open]) { display: none; }
.dialog-close { position: absolute; top: 3px; right: 8px; width: 44px; height: 44px; border: 0; background: none; font: 28px/1 system-ui; color: var(--rose); cursor: pointer; }
.fairy-dialog h2 { margin-block: 10px; font-size: 25px; }
.fairy-dialog p { overflow-wrap: anywhere; white-space: pre-wrap; }
textarea { width: 100%; font: inherit; font-size: 16px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; resize: vertical; background: var(--surface-solid); color: var(--ink); }
#wish-form label { margin-top: 16px; }
#wish-title { background: var(--surface-solid); color: var(--ink); }
.dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; }
#music-progress { width: 100%; height: 8px; accent-color: #D85B96; border-radius: 8px; overflow: hidden; }
#music-progress::-webkit-progress-bar { background: #f2d9e5; }
#music-progress::-webkit-progress-value { background: #D85B96; }
#music-progress::-moz-progress-bar { background: #D85B96; }
.volume-label { width: 100%; display: flex; justify-content: space-between; margin: 0; font-size: 12px; }
#music-volume { accent-color: #a43b70; padding: 0; border: 0; min-height: 44px; background: none; }
#volume-note { color: var(--muted); font-size: 11px; }
.record { animation: record-spin 12s linear infinite; animation-play-state: paused; }
.music-playing .record { animation-play-state: running; }
@keyframes record-spin { to { transform: rotate(360deg); } }
.no-script { margin: 30px; text-align: center; }

/* A brief CSS castle entrance, never coupled to the audio timer. */
.entrance { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px; background: radial-gradient(ellipse, #fff4cc 0, #ffe8f2 45%, #ffd6e8 100%); color: #8c345c; }
.entrance p { padding: 0 20px; text-align: center; font: 500 clamp(19px, 5vw, 30px)/1.7 'Songti SC', serif; }
.castle { position: relative; width: 250px; height: 210px; perspective: 600px; background: radial-gradient(ellipse at 50% 90%, #fff9da, transparent 65%); }
.tower { position: absolute; width: 52px; height: 165px; bottom: 0; background: linear-gradient(90deg, #f2b2cf, #ffdfed); border: 1px solid #e4a1bd; border-radius: 4px; }
.tower.left { left: 0; } .tower.right { right: 0; }
.tower::before { content: ''; position: absolute; top: -35px; left: -5px; border-left: 30px solid transparent; border-right: 30px solid transparent; border-bottom: 35px solid #d384ac; }
.tower::after { content: '୨୧'; position: absolute; top: 20px; width: 100%; text-align: center; font-size: 30px; color: #a43d70; }
.gate { position: absolute; bottom: 0; width: 75px; height: 145px; background: repeating-linear-gradient(90deg, #f6c4da 0 16px, #edb2cc 17px 18px); border: 2px solid #d8ab7c; }
.gate-left { left: 50px; transform-origin: left; border-radius: 65px 0 0 0; }
.gate-right { right: 50px; transform-origin: right; border-radius: 0 65px 0 0; }
.castle-heart { position: absolute; top: 0; left: 0; width: 100%; text-align: center; color: #a43d70; font-size: 40px; }
.opening .gate-left { animation: gate-left 1.2s .25s ease forwards; }
.opening .gate-right { animation: gate-right 1.2s .25s ease forwards; }
.opening { animation: entrance-out .4s 1.45s ease forwards; }
@keyframes gate-left { to { transform: rotateY(-105deg); } }
@keyframes gate-right { to { transform: rotateY(105deg); } }
@keyframes entrance-out { to { opacity: 0; } }

[data-theme="night"] { color-scheme: dark; --paper: #302239; --ink: #ffedf6; --rose: #ffb0d3; --muted: #dcc1d2; --surface: #443047ed; --surface-solid: #49354f; --line: #775469; --soft: #5b3b55; }
[data-theme="night"] body { background: radial-gradient(ellipse at 50% 0, #63446677, transparent 65%), var(--paper); }
[data-theme="night"] body::before, [data-theme="night"] body::after { display: none; }
[data-theme="night"] .night-sky { display: block; }
[data-theme="night"] .site-header, [data-theme="night"] footer, [data-theme="night"] .letter { border-color: var(--line); }
[data-theme="night"] .love-note { background: var(--surface-solid); border-color: var(--line); }
[data-theme="night"] .art { background: radial-gradient(ellipse, #a35d8b45, transparent 72%); }
[data-theme="night"] .chat-log { background: #302239; }
[data-theme="night"] .bubble { background: #49354f; border-color: #775469; }
[data-theme="night"] .bubble.user { background: #67425e; }
[data-theme="night"] #chat-input { background: #302239; color: var(--ink); border-color: var(--line); }
[data-theme="night"] input::placeholder { color: #c9a6bc; }
[data-theme="night"] .demo-badge { color: #ffdeee; background: #67425e; border-color: #98647f; }
[data-theme="night"] .tree-crown { background: radial-gradient(ellipse at top, #a2628b77, #754b6b66); }
[data-theme="night"] .surprise { border-color: var(--rose); }
[data-theme="night"] .surprise:hover { color: #302239; }
[data-theme="night"] .secondary:hover { color: #302239; }
.page-hidden *, .page-hidden *::before, .page-hidden *::after { animation-play-state: paused !important; }
@media (max-width: 700px) {
  .header-actions { justify-content: space-between; width: 100%; gap: 8px; }
  .world-nav { gap: 4px 18px; padding-top: 12px; }
  .hero { padding-top: 34px; }
  .world-card { padding: 26px 20px; border-radius: 24px; }
  .world-card h2 { font-size: 26px; }
  .anniversary-card { gap: 12px; }
  .envelope { width: min(280px, 84%); height: 175px; }
  .envelope-ready .letter-body { padding: 22px 18px; }
  .letter-intro h2 { font-size: 25px; }
  .wish-garden { padding-inline: 0; }
  .wish-heart { width: 92px; }
  .tree-crown { left: 1%; width: 98%; }
  .music-card, .chat-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .petals, .shooting-star, .entrance { display: none !important; }
}

.envelope-ribbon { right: 24px; bottom: 20px; width: 12px; height: 14px; border-radius: 4px; background: #b8477c; }
.envelope-ribbon::before, .envelope-ribbon::after { content: ''; position: absolute; top: -6px; width: 24px; height: 22px; border: 2px solid #b8477c; background: #fbe3ee; }
.envelope-ribbon::before { right: 9px; border-radius: 5px 14px 4px 5px; transform: rotate(12deg); }
.envelope-ribbon::after { left: 9px; border-radius: 14px 5px 5px 4px; transform: rotate(-12deg); }
.castle .castle-bow { top: 47px; transform: translateX(-50%) scale(.55); }
.tower::after { content: '♡'; }
.wish-heart { isolation: isolate; width: 112px; height: 112px; min-height: 112px; border: 0; border-radius: 0; background: none; box-shadow: none; padding: 16px 12px 25px; }
.wish-heart::after { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--surface-solid); clip-path: polygon(50% 14%, 63% 3%, 81% 0%, 96% 13%, 100% 34%, 92% 56%, 50% 100%, 8% 56%, 0% 34%, 4% 13%, 19% 0%, 37% 3%); }
.wish-heart span:first-child { font-size: 20px; }
.wish-heart span:last-child { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 11px; }
.wish-heart::before { top: -15px; height: 35px; z-index: -1; }
@media (max-width: 700px) { .wish-heart { width: 95px; height: 104px; min-height: 104px; padding-inline: 9px; } }

.fairy-dialog[open] { z-index: 50; }
[data-theme="night"] .tree-trunk, [data-theme="night"] .tree-trunk::before, [data-theme="night"] .tree-trunk::after { background: #c68eab; }

/* Marriage date is configured once; all labels and numbers are derived locally. */
.marriage-card { position: relative; display: block; text-align: center; background: radial-gradient(ellipse at 50% 0, #e9c78b22, transparent 65%), var(--surface); }
.marriage-heading { max-width: 700px; margin-inline: auto; }
#marriage-date { display: block; color: var(--rose); font: 500 clamp(22px, 4vw, 32px)/1.5 'Songti SC', serif; margin-top: 16px; }
#marriage-message { color: var(--muted); font-size: 15px; }
.marriage-counters { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 28px; }
.marriage-counters .day-counter { padding: 18px 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-solid); }
.marriage-counters strong { margin-block: 8px; font-size: clamp(32px, 5vw, 52px); }
.marriage-counters span { display: block; overflow-wrap: anywhere; }
.anniversary-celebration { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.anniversary-celebration h3 { color: var(--rose); font: 500 25px/1.5 'Songti SC', serif; margin-block: 12px; }
#anniversary-greeting { font-size: 15px; line-height: 1.9; }
.anniversary-sparkles { display: inline-block; color: var(--rose); letter-spacing: 15px; animation: anniversary-heart 4s ease-in-out 3; }
.is-anniversary { border-color: var(--gold); box-shadow: 0 12px 40px #d85b9628; }
.anniversary-today .hero .eyebrow::after { content: ' ♡ 周年快乐'; }
.anniversary-today .marriage-heading::before { content: '✧'; color: var(--gold); display: block; font-size: 28px; animation: twinkle 4s ease-in-out 3; }
@keyframes anniversary-heart { 50% { transform: scale(1.08); opacity: .6; } }
@media (max-width: 420px) { .marriage-counters { grid-template-columns: 1fr; gap: 12px; } }
@media (prefers-reduced-motion: reduce) { .anniversary-sparkles, .anniversary-today .marriage-heading::before { animation: none !important; } }
