:root {
  color-scheme: dark;
  --background: #0c2119;
  --cream: #fff1d6;
  --gold: #f7ce80;
  --muted: #c2c7b2;
  --line: #e8d8ac31;
  font-family: system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 250px;
  min-height: 100vh;
  color: var(--cream);
  background: radial-gradient(ellipse at 84% 20%, #1a3929, transparent 59%), var(--background);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button, .button { cursor: pointer; }
:focus-visible { outline: 3px solid #fff6ab; outline-offset: 5px; }

.page { width: min(100% - 96px, 1320px); margin-inline: auto; }
.masthead {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; font-size: .92rem; font-weight: 650; letter-spacing: .11em; }
.brand img { border-radius: 50%; object-fit: cover; border: 1px solid #f7ce8070; }
.preferences { display: flex; gap: 8px; }
.preference {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--cream);
  background: #122d22;
  font-size: .875rem;
}
.preference > span:first-child { font-size: 1.12rem; color: var(--gold); }
.switch { display: inline-flex; align-items: center; width: 27px; height: 16px; padding: 2px; background: #66746a; border-radius: 16px; }
.switch::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: #fff8e5; transition: transform .2s ease; }
.preference[aria-pressed="true"] .switch { background: #a96a32; }
.preference[aria-pressed="true"] .switch::before { transform: translateX(11px); }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, .73fr) minmax(0, 1.27fr);
  align-items: center;
  gap: clamp(26px, 5.5vw, 86px);
  min-height: calc(100svh - 86px);
  padding-block: clamp(22px, 4vh, 44px);
}
.intro { padding-left: clamp(0px, 1vw, 16px); }
h1 {
  margin: 0;
  font-family: "Songti SC", STSong, SimSun, "Noto Serif CJK SC", serif;
  font-size: clamp(4.25rem, 7.2vw, 7.35rem);
  line-height: 1.03;
  font-weight: 800;
  letter-spacing: -.09em;
}
h1 em { color: var(--gold); font-style: normal; }
.intro-copy { color: var(--muted); margin: 1.7rem 0; line-height: 1.65; }
.actions, .viewer-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: .6rem 1rem;
  border: 1px solid transparent;
  border-radius: 100px;
  font-size: .92rem;
  font-weight: 660;
  text-decoration: none;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.button:hover { transform: translateY(-2px); }
.gold { background: var(--gold); color: #213021; }
.gold:hover { background: #ffe1a0; }
.quiet { background: #ffffff0a; color: var(--cream); border-color: #ebdeb850; }
.quiet:hover { background: #ebdeb825; border-color: #ebdeb882; }
.progress-wrap { max-width: 290px; margin-top: 38px; }
.progress-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .875rem; color: var(--muted); }
#progress-number { color: var(--gold); font-variant-numeric: tabular-nums; }
progress { display: block; appearance: none; width: 100%; height: 4px; margin-top: 10px; border: 0; border-radius: 20px; background: #fff1d629; }
progress::-webkit-progress-bar { border-radius: inherit; background: #fff1d629; }
progress::-webkit-progress-value { border-radius: inherit; background: var(--gold); }
progress::-moz-progress-bar { border-radius: inherit; background: var(--gold); }

.stage {
  isolation: isolate;
  position: relative;
  overflow: clip;
  height: clamp(495px, 74svh, 680px);
  border: 1px solid #d3d1a737;
  border-radius: 32px;
  background: radial-gradient(ellipse at 50% 41%, #274e37 2%, #173528 52%, #0d251c 82%);
  box-shadow: 0 26px 64px #020b0738, inset 0 0 48px #030e0899;
}
.stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 10px;
  border: 1px solid #d3d1a71e;
  border-radius: 23px;
  pointer-events: none;
}
.stage::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 89%;
  height: 19%;
  left: 5.5%;
  bottom: 8%;
  background: radial-gradient(ellipse, #010b068a 6%, #b3a26032 32%, transparent 70%);
  transition: opacity .4s ease;
  opacity: .47;
}
.stage.lit::after { opacity: 1; }
.sky, .snow { position: absolute; inset: 0; pointer-events: none; z-index: -1; }
.star, .flake { position: absolute; left: var(--x); top: var(--y); color: #f4d394; opacity: var(--opacity); }
.star { font-size: var(--size); line-height: 1; }
.flake {
  top: -12px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: #fff1d7;
  animation: snowfall var(--duration) linear var(--delay) infinite;
}
.snow[hidden] { display: none; }
@keyframes snowfall {
  to { transform: translate(var(--drift), 780px); }
}

.tree { position: absolute; inset: 0; z-index: 0; touch-action: pan-y; cursor: grab; }
.tree.dragging, .tree.dragging button { cursor: grabbing; }
.stage-controls {
  position: absolute;
  z-index: 1;
  inset: auto 25px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .875rem;
  pointer-events: none;
}
.stage-controls .button { min-height: 38px; padding: .42rem .8rem; pointer-events: auto; background: #142d23; }
.stage-controls .button:hover { background: #254236; }
.ornament {
  --frame: #f7d991;
  position: absolute;
  top: calc(50% - 14px);
  left: 50%;
  width: 84px;
  height: 78px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  transform: translate3d(-50%, -50%, 0);
  user-select: none;
}
.ornament-face {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  padding: 2px;
  border-radius: inherit;
  background: var(--frame);
  filter: brightness(var(--shade, 1));
  box-shadow: 0 5px 13px #030f0880;
  transition: transform .22s cubic-bezier(.2,.7,.25,1.4), box-shadow .24s;
}
.ornament img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
  object-position: 50% var(--crop, 28%);
  background: #e1c584;
}
.ornament:hover .ornament-face, .ornament:focus-visible .ornament-face { transform: translateY(-3px) scale(1.12); filter: none; }
.ornament:focus-visible { z-index: 1000 !important; }
.ornament[data-seen="true"] { --frame: #ffebae; }
.lit .ornament-face { box-shadow: 0 0 8px var(--glow), 0 0 20px color-mix(in srgb, var(--glow) 65%, transparent), 0 5px 13px #030f0880; }
.ornament.topper {
  --shape: polygon(50% 0%, 64% 31%, 98% 37%, 74% 61%, 80% 98%, 50% 81%, 20% 98%, 26% 61%, 2% 37%, 36% 31%);
  width: 91px;
  height: 91px;
  border-radius: 50%;
  filter: drop-shadow(0 0 10px #f9c35677);
}
.ornament.topper::before { content: ""; position: absolute; inset: -17px; clip-path: var(--shape); background: #ffe4a1; }
.ornament.topper .ornament-face { --frame: #ffe4a1; padding: 3px; }
.ornament.topper img { object-position: center 33%; }
.topper-label {
  position: absolute;
  left: calc(100% + 19px);
  top: 34%;
  padding: 5px 10px;
  border: 1px solid #ffe4a16e;
  border-radius: 30px;
  background: #193c2e;
  color: var(--gold);
  white-space: nowrap;
  font-size: 18px;
  font-weight: 650;
}
.lit .ornament.topper { filter: drop-shadow(0 0 17px #ffdb73); }

.viewer {
  width: min(92vw, 510px);
  max-height: 92vh;
  padding: clamp(15px, 4vw, 25px);
  border: 1px solid #e4cc838a;
  border-radius: 24px;
  background: #18372a;
  color: var(--cream);
  box-shadow: 0 24px 100px #0008;
}
.viewer::backdrop { background: #030e0bd4; backdrop-filter: blur(5px); }
.viewer-heading, .viewer-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.viewer-kind { margin: 0 0 3px; color: var(--gold); font-size: .875rem; }
.viewer h2 { margin: 0; font-size: clamp(1.2rem, 5vw, 1.6rem); }
.close-button { width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #ffffff0c; color: var(--cream); font-size: 1.65rem; line-height: 1; }
.image-frame { display: grid; place-items: center; min-height: 132px; margin-block: 17px; border-radius: 16px; overflow: hidden; background: #0c2119; }
.image-frame img { display: block; width: 100%; max-height: min(53vh, 430px); object-fit: contain; }
.viewer-actions { justify-content: flex-start; }
.viewer-actions a { margin-left: auto; }

@media (max-width: 930px) {
  .page { width: calc(100% - 46px); }
  .layout { grid-template-columns: minmax(245px, .70fr) minmax(0, 1.30fr); gap: 25px; }
  h1 { font-size: clamp(3.45rem, 8.2vw, 5.3rem); }
}
@media (max-width: 670px) {
  .page { width: calc(100% - 32px); }
  .masthead { min-height: 63px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 21px; padding-block: 25px; min-height: 0; }
  .intro { padding-left: 2px; }
  h1 { font-size: clamp(2.8rem, 9.8vw, 4rem); letter-spacing: -.08em; }
  h1 br { display: none; }
  h1 em { margin-left: .12em; }
  .intro-copy { margin-block: .75rem 1rem; }
  .progress-wrap { margin-top: 18px; }
  .stage { height: clamp(350px, 112vw, 520px); border-radius: 23px; }
  .stage::before { inset: 6px; border-radius: 18px; }
  .stage-controls { inset: auto 14px 13px; }
  .stage-controls .button { min-height: 34px; }
  .ornament { top: 50%; }
  .keyboard-tip { display: none; }
}
@media (max-width: 350px) {
  h1 { font-size: clamp(2rem, 11vw, 2.55rem); }
  .button { padding-inline: .7rem; }
  .viewer-actions a { margin-left: 0; }
  .preferences { gap: 4px; }
  .preference { padding-inline: 7px; gap: 4px; }
  .brand { font-size: .8rem; gap: 5px; letter-spacing: 0; }
  .brand img { width: 26px; height: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; }
  .flake { animation-duration: calc(var(--duration) * 2); }
}
