:root {
  --night: #080a17;
  --violet: #231636;
  --gold: #ffdaa1;
  --rose: #ffabc8;
  --text: #fff4ef;
  color-scheme: dark;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--night);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background: radial-gradient(ellipse at 55% 115%, var(--violet), transparent 72%),
    radial-gradient(ellipse at 12% 65%, #16223b, transparent 54%), var(--night);
  pointer-events: none;
}
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.toolbar {
  position: absolute;
  z-index: 2;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}
button, .scene-links a {
  color: var(--text);
  border: 1px solid #fff4ef38;
  border-radius: 100px;
  background: #101022da;
  padding: 0.62rem 1rem;
  font: inherit;
  font-size: .875rem;
  min-height: 44px;
  cursor: pointer;
}
button:hover, .scene-links a:hover { border-color: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
button:disabled { opacity: .6; cursor: default; }
.music-status { position: absolute; top: 100%; right: 0; width: max-content; max-width: 78vw; font-size: .875rem; }
.scene {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  position: relative;
  padding: 6rem max(16px, env(safe-area-inset-right)) 5rem max(16px, env(safe-area-inset-left));
  text-align: center;
}
.intro, .greeting { grid-area: 1 / 1; }
.intro { transition: opacity .75s; }
.eyebrow { margin: 0; color: var(--gold); letter-spacing: .26em; font-size: .875rem; }
.orbit {
  display: grid;
  place-items: center;
  width: clamp(8rem, 36vmin, 14rem);
  aspect-ratio: 1;
  border: 1px solid #ffdaa14a;
  border-radius: 50%;
  margin: 1.5rem auto;
  box-shadow: 0 0 44px #e7a67320, inset 0 0 40px #e7a67315;
}
#count { font: 400 clamp(3rem, 15vmin, 7rem)/1 Georgia, serif; color: var(--gold); text-shadow: 0 0 28px #ffc5809c; }
#count.tick { animation: tick 1s both; }
@keyframes tick { 0% { opacity: .15; transform: scale(.7); } 28% { opacity: 1; transform: scale(1.16); } 70% { opacity: 1; } 100% { opacity: .2; transform: scale(.94); } }
.intro-caption, .sky-hint { color: #f2dce5; font-size: .875rem; letter-spacing: .1em; }
body:not([data-phase="countdown"]) .intro { opacity: 0; visibility: hidden; transition: opacity .75s, visibility 0s .75s; }
.sky-hint { position: absolute; bottom: max(1.1rem, env(safe-area-inset-bottom)); margin: 0; pointer-events: none; }
.greeting {
  width: min(100%, 36rem);
  padding: clamp(1.15rem, 5vw, 2.6rem);
  border: 1px solid #ffe2b53b;
  border-radius: 1.75rem;
  background: linear-gradient(155deg, #151123f5, #101125ef);
  box-shadow: 0 20px 80px #06050e9c;
  animation: arrive 1.15s both;
}
@keyframes arrive { from { opacity: 0; transform: translateY(12px); } }
h1, h2 { font-family: "Songti SC", "SimSun", Georgia, serif; font-weight: 500; }
h1 { font-size: clamp(2rem, 8.5vw, 3.65rem); line-height: 1.18; margin: .65rem 0; }
.name { display: block; color: var(--rose); font-size: .72em; margin-top: .45rem; overflow-wrap: anywhere; animation: arrive 1.4s .55s both; }
.divider { color: var(--gold); margin: .45rem 0 .7rem; }
.message { line-height: 1.75; font-size: 1rem; overflow-wrap: anywhere; }
.message p { margin: .18rem 0; position: relative; }
.message .sizer { visibility: hidden; }
.message .typed { position: absolute; inset: 0; }
.scene-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .55rem; margin-top: 1.15rem; }
.scene-links a { display: inline-grid; place-items: center; text-decoration: none; }
.extras { width: min(100% - 2rem, 68rem); margin: auto; padding: 1rem 0 max(4rem, env(safe-area-inset-bottom)); display: grid; gap: 1rem; }
.panel { background: #101124ef; border: 1px solid #ffd9ad32; border-radius: 1.5rem; padding: clamp(1rem, 4vw, 2rem); text-align: center; min-width: 0; }
h2 { margin: 0 0 1.2rem; font-size: 1.7rem; }
.album { margin: 0; }
.photo-frame { aspect-ratio: 4 / 3; position: relative; overflow: hidden; border: 1px solid #ffe2c33b; border-radius: .85rem; display: grid; place-items: center; }
.photo-frame { background: radial-gradient(circle at 68% 22%, #ffbd866e, transparent 28%), linear-gradient(150deg, #342747, #75445e 52%, #151625 53%); }
.photo-frame[data-look="1"] { background: radial-gradient(circle at 30% 72%, #c8b2fe66, transparent 33%), linear-gradient(30deg, #151729, #412d58, #222d47); }
.photo-frame[data-look="2"] { background: radial-gradient(circle at 61% 35%, #ffc28b65, transparent 36%), linear-gradient(155deg, #201733, #6d3e55, #21142c); }
.photo-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--night); }
.photo-placeholder { background: #0e0d20bf; border: 1px solid #ffffff40; padding: .45rem .95rem; border-radius: 100px; font-size: .875rem; }
figcaption { margin: .65rem 0; min-height: 1.5em; overflow-wrap: anywhere; }
.album-controls { display: flex; gap: .75rem; align-items: center; justify-content: center; }
.cake { margin: 2.25rem auto 1rem; width: min(100%, 14rem); }
.candles { display: flex; justify-content: center; gap: 1.25rem; align-items: end; }
.candles i { display: block; position: relative; height: 1.9rem; width: .5rem; border-radius: 3px; background: repeating-linear-gradient(140deg, #fff1de 0 4px, #e396aa 4px 7px); }
.candles i:nth-child(2) { height: 2.3rem; }
.candles b { display: block; position: absolute; width: .64rem; height: 1rem; left: -.07rem; bottom: calc(100% + .12rem); border-radius: 65% 35% 60% 55%; background: radial-gradient(at 50% 70%, #fff9d2, #ffd78e 52%, #f58b61); box-shadow: 0 0 15px #ffb268a0; transform-origin: bottom; animation: flicker .7s ease-in-out infinite alternate; }
.candles i:nth-child(2) b { animation-delay: -.35s; }
.candles i:nth-child(3) b { animation-delay: -.19s; }
@keyframes flicker { to { transform: rotate(9deg) scale(.83, 1.08); } }
.cake.is-out b { animation: smoke .65s both; box-shadow: none; background: #e1c8eb; }
@keyframes smoke { to { opacity: 0; transform: translate(12px, -29px) scale(1.55); } }
.icing { width: 85%; margin: auto; height: 1.15rem; border-radius: .9rem .9rem .24rem .24rem; background: linear-gradient(#ffdec7, #f7a5b5); position: relative; z-index: 1; }
.cake-body { width: 82%; height: 3.3rem; margin: auto; border-radius: 0 0 .45rem .45rem; background: linear-gradient(#d68ea0 37%, #ffddc3 39% 52%, #b97691 54%); }
.plate { height: .45rem; background: linear-gradient(90deg, #7c6c97, #f4dfdf, #7c6c97); border-radius: 100%; }
.wish-status { min-height: 1.5em; color: var(--gold); }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.noscript { position: absolute; top: 30%; left: 1rem; right: 1rem; text-align: center; }
@media (min-width: 720px) { .extras { grid-template-columns: 1.15fr 1fr; align-items: start; } }
@media (orientation: landscape) and (max-height: 500px) {
  .scene { padding-top: 4.25rem; padding-bottom: 3rem; }
}
@media (orientation: landscape) and (max-height: 500px) and (min-width: 620px) {
  .greeting {
    width: min(100%, 40rem);
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    align-items: center;
    gap: .35rem clamp(1rem, 3vw, 2rem);
    padding: 1rem 1.25rem;
  }
  .greeting .eyebrow { grid-area: 1 / 1; }
  .greeting h1 { grid-area: 2 / 1; font-size: clamp(2rem, 5vw, 2.8rem); margin: 0; }
  .greeting .divider { grid-area: 3 / 1; margin: 0; }
  .greeting .message { grid-area: 1 / 2 / span 3; }
  .scene-links { grid-column: 1 / -1; margin-top: .35rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; transition-delay: 0ms !important; }
  #count.tick { animation: none; }
}
