:root {
  color-scheme: dark;
  --spruce: #111915;
  --panel: #1d2822;
  --raised: #29362e;
  --line: #39483a;
  --cream: #f4e8ce;
  --soft: #bfbea6;
  --gold: #dfb779;
  --paper: #f5e1b9;
  --serif: "STZhongsong", "华文中宋", "Noto Serif SC", "Songti SC", SimSun, serif;
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

html[lang="en"] {
  --serif: Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 270px;
  min-height: 100svh;
  background: var(--spruce);
  color: var(--cream);
  font: 15px/1.6 var(--sans);
}

button, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid #fbe1a8;
  outline-offset: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link {
  position: fixed;
  z-index: 30;
  top: 8px;
  left: 12px;
  padding: 8px 13px;
  border-radius: 6px;
  background: var(--cream);
  color: var(--spruce);
  transform: translateY(calc(-100% - 12px));
}
.skip-link:focus { transform: none; }

.page { width: min(1392px, calc(100% - clamp(28px, 6vw, 88px))); margin: auto; }
.masthead {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 18px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font: 700 21px/1 var(--serif);
  letter-spacing: .13em;
  white-space: nowrap;
}
html[lang="en"] .brand { letter-spacing: .018em; }
.ui-icon {
  display: inline-block;
  flex: none;
  width: var(--icon-size, 15px);
  height: var(--icon-size, 15px);
  vertical-align: -.13em;
  background: url("assets/ui-icons.png") var(--icon-position, 0%) 0 / 700% 100% no-repeat;
}
.ui-icon--music { --icon-position: 16.6667%; }
.ui-icon--snow { --icon-position: 33.3333%; }
.ui-icon--sparkle { --icon-position: 50%; }
.ui-icon--treetop { --icon-position: 66.6667%; }
.ui-icon--write { --icon-position: 83.3333%; }
.ui-icon--play { --icon-position: 100%; }
.brand-star { --icon-size: 23px; }
.settings { display: flex; align-items: center; gap: 5px; }
.setting {
  min-width: 44px;
  min-height: 44px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--soft);
  font-size: 13px;
}
.setting[aria-pressed="true"], .setting:hover { color: var(--cream); background: var(--panel); }
.language-control { display: inline-flex; align-items: stretch; }
.language-control select {
  min-height: 44px;
  padding: 3px 6px 3px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--cream);
  font-size: 13px;
  cursor: pointer;
}

.postcard { padding: 18px 0 40px; }
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(246px, 25vw, 346px);
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: "stage intro" "stage journey" "stage utility" "tools utility";
  column-gap: clamp(14px, 2vw, 25px);
  align-items: start;
}
.intro {
  grid-area: intro;
  background: var(--panel);
  border-radius: 12px 12px 0 0;
  padding: clamp(14px, 1.65vw, 24px) clamp(12px, 1.5vw, 20px) 0;
}
.intro h1 {
  margin: 0 0 8px;
  font: 700 clamp(27px, 2.8vw, 32px)/1.07 var(--serif);
  letter-spacing: -.038em;
}
.intro p {
  margin: 0;
  color: var(--soft);
  font-size: 14px;
  line-height: 1.5;
}
.scene-frame { min-width: 0; }
.stage-wrap { grid-area: stage; position: relative; min-width: 0; }
.journey-controls {
  grid-area: journey;
  display: grid;
  gap: 10px;
  background: var(--panel);
  border-radius: 0 0 12px 12px;
  padding: 14px clamp(10px, 1.5vw, 20px) 15px;
  min-width: 0;
}
.journey-controls .growth-readout { width: 100%; min-width: 0; }
.growth-labels { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; }
#constellations-found { color: var(--soft); }
.journey-controls:has(.star-finale:not([hidden])) #constellations-found { display: none; }
.scene-tools {
  grid-area: tools;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 10px;
  min-width: 0;
  padding: 4px 0;
}
.style-picker { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px; }
.style-picker button {
  min-height: 44px;
  padding: 4px 8px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: #c9bea2;
  font-size: 13px;
  white-space: nowrap;
}
.style-picker button:hover { background: var(--panel); color: var(--cream); }
.style-picker button[aria-pressed="true"] {
  background: var(--raised);
  color: var(--cream);
}
.score-picker {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 55%;
  gap: 6px;
  color: var(--gold);
}
.score-picker select {
  min-width: 0;
  min-height: 44px;
  max-width: min(100%, 235px);
  padding: 3px 5px;
  border: 1px solid #5a604d;
  border-radius: 6px;
  background: #1b261e;
  color: #e7d6ac;
  font-size: 12px;
  text-overflow: ellipsis;
  cursor: pointer;
}
#sky-view { scroll-margin-block: 10px 20px; }
.stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 12px;
  background: #263129;
  container-type: inline-size;
  touch-action: manipulation;
}
.stage-camera { position: absolute; inset: 0; transform-origin: 50% 51%; }
.stage, .scene-art, .branches { user-select: none; }
.scene-art, #light-textures, #scene-effects, .branches, .gifts { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-art { z-index: 0; object-fit: fill; opacity: 0; transition: opacity 590ms cubic-bezier(.2,.55,.25,1); pointer-events: none; }
.scene-art.is-active { opacity: 1; }
.stage[data-visual="cinema"] .stage-camera::after {
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 56% 46%, #c2a17d08 37%, #0717202b 96%), linear-gradient(148deg, #dc9b4924, transparent 53%, #13374923);
  box-shadow: inset 0 0 32px #050e1660;
  content: "";
}
.stage[data-visual="paper"] .scene-art { transition-timing-function: steps(8, end); }
.stage[data-visual="paper"] .branch .sprite { filter: drop-shadow(1px 3px 1px #142315e8); }
.stage[data-visual="paper"] .gift.is-opening .gift-lid { animation: paper-lid var(--open-time) steps(9, end) both; }
@keyframes paper-lid {
  0%, 18% { transform: none; }
  52% { transform: rotateX(80deg); }
  81% { transform: rotateX(148deg); }
  100% { transform: rotateX(142deg); }
}
.stage[data-visual="ink"] { background: #ac8760; }
.stage[data-visual="ink"] [data-plate="ink"].is-active { animation: ink-wash 730ms ease-out both; }
.stage[data-visual="ink"] .branch .sprite { filter: saturate(.76) sepia(.13) drop-shadow(0 3px 2px #2d241780); }
.stage[data-visual="ink"] .gift-texture { filter: saturate(.78) sepia(.11) brightness(.97) drop-shadow(0 3px 2px #3427185a); }
@keyframes ink-wash {
  0% { clip-path: ellipse(3% 6% at 51% 48%); opacity: .21; }
  75% { clip-path: ellipse(67% 79% at 51% 48%); opacity: .97; }
  100% { clip-path: ellipse(83% 86% at 51% 48%); opacity: 1; }
}
#light-textures { z-index: 1; pointer-events: none; mix-blend-mode: screen; }
#scene-effects { z-index: 2; pointer-events: none; }
.tree-composition {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  transform-origin: 50% 52%;
  transition: transform 590ms cubic-bezier(.25,.65,.29,1);
}
.tree-composition.makes-room-for-stars { transform: translate(-17.5%, 2%) scale(.82); }
.tree-composition .tree-star { pointer-events: auto; }
.tree-foreground, #tree-effects { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tree-foreground { display: block; z-index: 3; }
.tree-composition.has-tree-foreground::before {
  content: "";
  position: absolute;
  z-index: 3;
  left: 10%;
  width: 77%;
  height: 16%;
  bottom: 5.4%;
  background: radial-gradient(ellipse at center, #091312cb, #09131280 33%, transparent 68%);
  pointer-events: none;
}
.stage[data-visual="paper"] .tree-foreground { filter: saturate(.82) contrast(.93); }
.stage[data-visual="ink"] .tree-foreground { filter: saturate(.48) sepia(.23); }
.stage[data-visual="folio"] .tree-foreground { filter: saturate(.82) contrast(.96) brightness(.93); }
.stage[data-visual="cel"] .tree-composition.has-tree-foreground::before { opacity: .68; }
.tree-grade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: color;
}
.star-illustration {
  position: absolute;
  z-index: 4;
  top: 5.9%;
  left: 51.2%;
  width: 46.1%;
  height: 66.1%;
  pointer-events: none;
  border: 1px solid #ffdf9e67;
  border-radius: 44% 44% 2px 2px / 8% 8% 2px 2px;
  box-shadow: 0 8px 24px #030c1e55;
}
.star-illustration[data-paint="paper"] {
  border: 3px double #efdaac;
  border-radius: 1px;
  clip-path: polygon(0 0, 91% 0, 100% 9%, 100% 100%, 0 100%);
}
.star-illustration[data-paint="ink"] {
  border-color: #bda67a76;
  border-radius: 14% 20% 10% 13% / 12% 13% 11% 12%;
  mask-image: radial-gradient(ellipse 79% 82% at 50% 52%, #000 63%, transparent 94%);
}
.star-illustration[data-paint="folio"][data-figure="lyra"] {
  border-color: #ffd59899;
  border-radius: 15% 30% 2px 2px / 9% 13% 2px 2px;
}
.star-illustration[data-paint="folio"][data-figure="delphinus"] {
  border-color: #b9f4e078;
  border-radius: 25% 12% 13% 8% / 12% 8% 10% 9%;
}
.star-illustration[data-paint="folio"][data-figure="cepheus"] {
  border-radius: 2px;
  clip-path: polygon(0 0, 94% 0, 100% 6%, 100% 100%, 0 100%);
}
#tree-effects { z-index: 4; mix-blend-mode: screen; }
#star-lines { position: absolute; z-index: 5; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.branches { z-index: 5; pointer-events: none; }
.gifts { z-index: 4; pointer-events: none; }
.stage::after {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  border: 1px solid #e4c38235;
  box-shadow: inset 0 0 22px #0d110f4f;
  content: "";
}
.scene-foot {
  min-height: 59px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.scene-note { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; color: #ddd0ad; }
.scene-note p { margin: 0; font-size: 13px; }
.note-star { --icon-size: 19px; }
.small-count { color: #c3b593; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.growth-readout {
  flex: 0 0 116px;
  display: grid;
  gap: 4px;
  color: #e6cfa4;
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.growth-readout progress {
  appearance: none;
  display: block;
  width: 100%;
  height: 4px;
  border: 0;
  border-radius: 4px;
  background: #3c4536;
  color: #dfb577;
  overflow: hidden;
}
.growth-readout progress::-webkit-progress-bar { background: #3c4536; }
.growth-readout progress::-webkit-progress-value { background: linear-gradient(90deg, #a8734e, #e5bd77 62%, #f6dea5); }
.growth-readout progress::-moz-progress-bar { background: linear-gradient(90deg, #a8734e, #e5bd77 62%, #f6dea5); }
.ornament-anchors { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.ornament-anchor {
  position: absolute;
  width: clamp(28px, 7cqw, 68px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -43%);
  pointer-events: auto;
}
.ornament-anchor::before {
  content: "";
  position: absolute;
  inset: 7%;
  border: 1px solid #f3d5a76d;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--ornament-glow) 0%, transparent 100%);
  opacity: .49;
  box-shadow: 0 0 14px #e4c38c2c;
  transition: opacity 170ms ease, scale 170ms ease;
}
.ornament-anchor:hover::before, .ornament-anchor:focus-visible::before { opacity: .90; scale: 1.11; }
.ornament-anchor .sprite { position: relative; width: 82%; height: 82%; filter: drop-shadow(0 4px 5px #0a110be3); }
.ornament-anchor.is-on::before { opacity: .72; }
.ornament-anchor.is-on .sprite { filter: drop-shadow(0 0 5px var(--ornament-glow)) drop-shadow(0 4px 5px #0a110be3); }
.intro-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
}
.journey-links { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 8px; }
.journey-links a, .journey-links button { display: inline-flex; align-items: center; min-height: 44px; text-underline-offset: .24em; }
.start-stargazing, .watch-stargazing {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .38em;
  min-height: 44px;
  padding: 5px 7px;
  border: 0;
  border-radius: 6px;
  background: var(--cream);
  color: #22251d;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
}
.start-stargazing:hover { background: #fff3d8; }
.start-stargazing .ui-icon { filter: brightness(.24); }
.watch-stargazing, .star-subaction { background: var(--raised); color: var(--cream); }
.star-subaction {
  min-height: 44px;
  padding: 5px 6px;
  border: 0;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.2;
}
.watch-stargazing:hover, .star-subaction:hover, .star-subaction[aria-pressed="true"] { background: #37473d; }
.light-route { display: grid; gap: 7px; }
.route-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.route-slot {
  position: relative;
  display: grid;
  gap: 1px;
  align-content: center;
  min-width: 0;
  min-height: 53px;
  padding: 5px 6px;
  border-bottom: 2px solid #47584d;
  border-radius: 5px 5px 0 0;
  background: var(--spruce);
}
.route-role { color: var(--soft); font-size: 12px; line-height: 1.25; }
.route-slot-selection { display: flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 600; line-height: 1.22; }
.route-slot-mark { color: #8f9b83; font: 13px/1 Georgia, serif; }
.route-slot[data-state="next"] { border-bottom-color: var(--gold); }
.route-slot[data-state="next"] .route-role { color: var(--cream); }
.route-slot[data-choice] .route-slot-mark { color: var(--selection); }
.route-slot[data-choice] .route-slot-selection { animation: route-seat 165ms cubic-bezier(.2,.75,.3,1) both; }
.route-slot[data-state="queued"] { border-bottom-style: dotted; }
.route-slot[data-state="flowing"], .route-slot[data-state="lit"] { border-bottom-color: var(--selection); }
.route-slot[data-state="flowing"]::after {
  position: absolute;
  height: 2px;
  inset: auto 0 -2px;
  background: var(--cream);
  transform-origin: left;
  animation: mark-turn 235ms ease-out both;
  content: "";
}
@keyframes route-seat { from { opacity: .2; translate: 0 4px; } to { opacity: 1; translate: 0; } }
@keyframes mark-turn { from { opacity: .9; scale: 0 1; } to { opacity: 0; scale: 1 1; } }
.route-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.route-light {
  position: relative;
  display: grid;
  grid-template-rows: minmax(27px, 1fr) auto;
  min-width: 0;
  min-height: 56px;
  padding: 2px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--spruce);
  color: var(--cream);
  font-size: 12px;
  line-height: 1.6;
  touch-action: manipulation;
  transition: background 160ms ease, translate 140ms ease;
}
.route-light-art {
  background: var(--raised) var(--light-atlas) var(--light-tile) / 200% 200% no-repeat;
  border-radius: 3px;
}
.route-light:not([aria-disabled="true"]):hover { background: var(--raised); color: #fff8e8; }
.route-light:not([aria-disabled="true"]):active { translate: 0 2px; }
.route-light:focus-visible { outline-offset: 1px; }
.route-light[aria-pressed="true"] { background: var(--raised); border-color: var(--light-color); }
.route-light[aria-disabled="true"] { cursor: default; }
.route-light[data-rank]::after {
  content: attr(data-rank);
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 16px;
  min-height: 16px;
  top: 5px;
  right: 5px;
  background: var(--spruce);
  border-radius: 4px;
  color: var(--light-color);
  font-size: 11px;
}
#new-light-order { background: var(--cream); color: #22251d; font-weight: 650; }
#new-light-order:hover { background: #fff3d8; }
.ritual-controls { padding-top: 7px; border-top: 1px solid var(--line); }
.ritual-controls[data-mode="stars"] {
  display: grid;
  grid-template-areas: "actions" "readout" "finale";
  gap: 3px;
}
.ritual-readout { grid-area: readout; display: flex; align-items: center; gap: 7px; min-width: 0; }
.ritual-status { flex: 1; min-width: 0; }
.star-preview {
  min-height: 44px;
  padding: 0 5px;
  border: 0;
  background: transparent;
  color: var(--cream);
  white-space: nowrap;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: .25em;
}
.star-preview:hover { color: #fff5d8; }
.undo-light { min-width: 44px; text-decoration: none; color: var(--soft); }
.undo-light:hover { text-decoration: underline; }
.star-preview[aria-disabled="true"] { color: #b6b7ad; text-decoration: none; cursor: default; }
.star-actions { grid-area: actions; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); gap: 6px; }
.star-actions button { justify-content: center; padding-inline: 7px; font-size: 13px; line-height: 1.15; }
.star-actions button[aria-disabled="true"], .ritual-controls:has(.star-finale:not([hidden])) #star-step { background: var(--raised); color: var(--cream); }
.star-actions button[aria-disabled="true"] { cursor: default; }
.star-actions select {
  width: 100%;
  min-height: 44px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--spruce);
  color: var(--cream);
  text-overflow: ellipsis;
  cursor: pointer;
  font-size: 13px;
}
.star-finale { grid-area: finale; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.tree-ritual { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
.ritual-point {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: clamp(28px, 5.3cqw, 53px);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--ritual-color);
  color: var(--ritual-color);
  background: #142329e8;
  box-shadow: 0 0 14px color-mix(in srgb, var(--ritual-color) 48%, transparent);
  font: 600 clamp(17px, 2.6cqw, 26px)/1 var(--sans);
  pointer-events: auto;
  transition: background 180ms, color 180ms, scale 180ms;
  touch-action: manipulation;
}
.ritual-point:hover, .ritual-point.is-lit { background: var(--ritual-color); color: #18202a; }
.ritual-point:active { scale: .92; }
.ritual-point, .ornament-anchor { -webkit-tap-highlight-color: transparent; }
.ritual-symbol { display: inline-block; transform-origin: 50% 19%; pointer-events: none; }
.tree-ritual[data-ritual="bells"] .ritual-symbol {
  width: 82%;
  height: 82%;
  background: url("assets/ornaments.png") 0% 100% / 300% 200% no-repeat;
  filter: drop-shadow(0 1px 2px #101c19);
}
.tree-ritual[data-ritual="frost"] .ritual-point { touch-action: none; }
.star-key-progress { display: none; }
.tree-ritual[data-ritual="stars"] .ritual-point {
  width: clamp(54px, 7.6cqw, 64px);
  padding-bottom: 8px;
  border: 1px solid #e8c589;
  color: #ffe0a6;
  background: radial-gradient(ellipse at 50% 28%, #5d4533, #192834 72%);
  box-shadow: 0 2px 13px #071223ee, inset 0 0 0 3px #0e1c2f94, 0 0 18px #e5b87460;
}
.tree-ritual[data-ritual="stars"] .ritual-point:focus-visible { outline: 2px solid #fff1cf; outline-offset: 3px; }
.tree-ritual[data-ritual="stars"] .star-key-progress {
  display: flex;
  gap: 3px;
  position: absolute;
  bottom: 8px;
  pointer-events: none;
}
.star-key-progress span {
  width: clamp(6px, .86cqw, 9px);
  height: 4px;
  border-radius: 9px;
  background: #cdb78c35;
  box-shadow: inset 0 0 0 1px #e9ca8263;
  transition: background 120ms, box-shadow 120ms;
}
.star-key-progress span[data-state="queued"] { background: #dba66c; }
.star-key-progress span[data-state="flowing"] { background: #fff3cb; box-shadow: 0 0 8px #ffdca7; }
.star-key-progress span[data-state="lit"] { background: #ffda91; box-shadow: 0 0 6px #fed8969e; }
.ritual-hint { min-height: 20px; margin: 0; color: #f5d9a9; font-size: 13px; line-height: 1.5; }
.constellation-name {
  position: absolute;
  z-index: 8;
  top: 73%;
  right: 2.7%;
  width: 46.1%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 3px 10px;
  padding: 5px;
  border-bottom: 1px solid #ffdda657;
  color: #fff2cc;
  background: linear-gradient(90deg, transparent, #081323db 17% 83%, transparent);
  text-shadow: 0 2px 5px #10182e;
  pointer-events: none;
}
.constellation-name strong { font: 700 clamp(16px, 2.65cqw, 32px)/1.1 var(--serif); }
.constellation-name span { font: clamp(10px, 1.25cqw, 15px)/1 var(--serif); letter-spacing: .08em; }
.ritual-point:disabled { opacity: .65; }
.ornament-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 9px;
  padding: 7px 5px 8px;
  border-bottom: 1px solid #675944;
}
.ornament-dock { display: flex; flex-wrap: wrap; gap: 5px; }
.ornament-pick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 3px 8px 3px 5px;
  border: 1px solid #584b35;
  border-radius: 4px;
  background: #24271d;
  font-size: 12px;
  white-space: nowrap;
}
.ornament-pick .sprite { width: 28px; height: 28px; flex: none; }
.ornament-pick:hover, .ornament-pick[aria-pressed="true"] { border-color: #bda171; background: #4b4030; }
.ornament-view { min-height: 40px; white-space: nowrap; }
.ornament-scene {
  position: absolute;
  z-index: 8;
  left: 0;
  bottom: 0;
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 25px 4% 3.1%;
  background: linear-gradient(to top, #0a131dd9, #0a141c8c 42%, transparent 100%);
  text-shadow: 0 1px 5px #080c10;
  pointer-events: none;
}
.ornament-scene span { color: #f0cf9a; font-size: clamp(11px, 1.1vw, 15px); }
.ornament-scene strong { font: 700 clamp(21px, 3.2vw, 47px)/1.10 var(--serif); letter-spacing: .055em; }
html[lang="en"] .ornament-scene strong { font-size: clamp(18px, 4.5cqw, 38px); letter-spacing: -.016em; }
.ornament-scene.is-arriving { animation: arrive-world 520ms ease-out both; }
@keyframes arrive-world { from { opacity: 0; translate: 0 7px; } to { opacity: 1; translate: 0 0; } }

.stage[data-ornament-view="journey"] .gifts { visibility: hidden; }
.gift-controls {
  display: grid;
  gap: 5px;
  padding: 8px 5px;
  border-bottom: 1px solid #514b37;
}
.gift-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 12px;
}
.gift-guide { margin: 0; color: var(--soft); font-size: 13px; }
.gift-picker { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.gift-picker button {
  min-width: 0;
  min-height: 40px;
  padding: 2px 3px;
  border: 1px solid #776a4d;
  border-radius: 2px;
  background: #211f18;
  color: var(--gift-ink, #edcb8a);
  font-size: 12px;
}
.gift-picker button:hover { background: #e7bb7224; }
.gift-picker button:disabled { opacity: .49; }
.gift-view-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; white-space: nowrap; }
.gift-view-links .text-button { min-height: 38px; }
.gift-view-links a { display: grid; align-items: center; text-decoration: none; }
.gift-view-links :disabled { opacity: .48; }
.stage[data-gift-view="wide"] .gifts { visibility: hidden; }
.gift-route-readout { display: grid; justify-items: end; flex: none; gap: 2px; }
.gift-order { display: flex; gap: 3px; }
.gift-order span {
  display: grid;
  place-items: center;
  width: 19px;
  height: 18px;
  color: #a39676;
  border: 1px solid #575543;
  border-radius: 2px;
  background: #e7c48311;
  font-size: 11px;
  line-height: 1;
}
.gift-route-readout .wrap-gifts { min-height: 29px; padding-block: 0; }

.tree-star {
  --charge: 0%;
  position: absolute;
  z-index: 5;
  top: 8.6%;
  left: 49.25%;
  width: clamp(45px, 10.5cqw, 105px);
  aspect-ratio: 1;
  transform: translate(-50%, -45%);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  touch-action: none;
}
.star-jewel {
  width: 69%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  isolation: isolate;
  filter: drop-shadow(0 1px 2px #0f130b) drop-shadow(0 0 6px #f6c27752);
  transform: rotate(-7deg);
  transition: transform 250ms, filter 500ms;
}
.star-jewel::before, .star-jewel span {
  grid-area: 1 / 1;
  aspect-ratio: 1;
  clip-path: polygon(50% 1%, 61% 35%, 98% 36%, 69% 58%, 79% 94%, 50% 72%, 20% 94%, 30% 59%, 2% 36%, 39% 35%);
}
.star-jewel::before {
  content: "";
  width: 100%;
  background: linear-gradient(142deg, #fff2be, #9c642f 33%, #e0a86a 61%, #845328);
}
.star-jewel span {
  width: 89%;
  background: conic-gradient(from 7deg, #b67b39, #f8d893 8%, #c79553 9% 19%, #fff0c3 20%, #956233 21% 39%, #f1bf78 40%, #714620 41% 58%, #d5a05f 59%, #f2cd85 60% 77%, #a87336 78%, #fae3a6 80% 99%, #b67b39);
}
.star-halo, .star-ring { position: absolute; pointer-events: none; border-radius: 50%; }
.star-halo {
  inset: 16%;
  background: color-mix(in srgb, var(--star-light, #ffe3a8) 68%, transparent);
  filter: blur(clamp(8px, 1.25cqw, 15px));
  opacity: .27;
  transition: opacity 500ms;
}
.star-ring {
  inset: 4%;
  padding: 2px;
  background: conic-gradient(#fff2c5 var(--charge), #fff0bc26 0);
  mask: linear-gradient(white 0 0) content-box exclude, linear-gradient(white 0 0);
  opacity: 0;
}
.tree-star.charging .star-ring { opacity: 1; }
.tree-star.charging .star-jewel { transform: scale(1.12) rotate(0); }
.tree-star.charging .star-halo, .tree-star.lit .star-halo { opacity: 1; }
.tree-star.lit .star-jewel { filter: drop-shadow(0 0 8px var(--star-light, #ffe1a9)) drop-shadow(0 0 18px color-mix(in srgb, var(--star-light, #fac471) 62%, transparent)); }
.tree-star:hover .star-jewel { transform: rotate(0) scale(1.07); }

.branch {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(30px, 8cqw, 76px);
  min-height: 34px;
  aspect-ratio: 1;
  padding: 0;
  transform: translate(-50%, -12%);
  border: 0;
  border-radius: 50%;
  background: none;
}
.branch.is-ready, .branch.is-occupied { pointer-events: auto; }
.branch.is-ready { cursor: copy; }
.branch.is-ready::before {
  position: absolute;
  z-index: -1;
  inset: 24%;
  content: "";
  transform: translateY(-13%);
  border: 1px solid #edd49d9c;
  border-radius: 50%;
  background: radial-gradient(circle, #fff1c4be 0 9%, #dcab4c40 11% 42%, #1423176b 44% 100%);
  box-shadow: 0 0 15px #edbd7a47;
}
.branch.is-ready:hover::before, .branch.is-target::before {
  background: radial-gradient(circle, #ffefc1 0 13%, #fff1ba9c 15% 40%, #72572ed9 42% 100%);
  box-shadow: 0 0 16px #ffd285b8;
}
.branch .sprite {
  width: 97%;
  transform-origin: 50% 10%;
  filter: drop-shadow(0 4px 4px #0a100bd6);
}
.branch.is-occupied:hover .sprite { filter: drop-shadow(0 0 6px #fde3a474) drop-shadow(0 3px 4px #10180ce3); }
.branch.new-hang .sprite { animation: hang-swing 760ms linear both; }
@keyframes hang-swing {
  0% { transform: translate(var(--entry-x, 0px), var(--entry-y, -13%)) rotate(var(--entry-angle, -16deg)) scale(var(--entry-scale, .91)); animation-timing-function: cubic-bezier(.35,.15,.24,1); }
  16% { transform: rotate(8deg) scale(1.025); animation-timing-function: ease-in-out; }
  37% { transform: rotate(-10deg); animation-timing-function: ease-in-out; }
  58% { transform: rotate(5deg); animation-timing-function: ease-in-out; }
  80% { transform: rotate(-2deg); }
  100% { transform: rotate(0); }
}

.gift {
  --box-ratio: 1;
  --open-time: 710ms;
  --stock: #9e6a3c;
  --stock-rim: #dcab73;
  --cel-glow: #ffd38a;
  --floor-angle: -2deg;
  position: absolute;
  bottom: 5.2%;
  left: 53%;
  width: clamp(47px, 13.1cqw, 133px);
  aspect-ratio: var(--box-ratio);
  padding: 0;
  transform: translateX(-50%) rotate(var(--floor-angle));
  transform-origin: 50% 100%;
  border: 0;
  border-radius: 5px;
  background: none;
  perspective: clamp(170px, 39cqw, 460px);
  perspective-origin: 58% 25%;
  pointer-events: auto;
}
.gift--spruce {
  --stock: #51563e;
  --stock-rim: #a69b68;
  --floor-angle: 3deg;
  bottom: 6.7%;
  left: 34%;
  width: clamp(39px, 8.9cqw, 98px);
}
.gift--wine {
  --stock: #753b35;
  --stock-rim: #bc8461;
  --floor-angle: 2deg;
  bottom: 6.3%;
  left: 63%;
  width: clamp(37px, 8.15cqw, 88px);
}
.gift--frost {
  --stock: #53616d;
  --stock-rim: #a5c8db;
  --cel-glow: #d9f1ff;
  --floor-angle: -4deg;
  bottom: 7.3%;
  left: 76.6%;
  width: clamp(38px, 7.7cqw, 82px);
}
.gift.gift--frost .gift-texture { filter: saturate(.29) sepia(.46) hue-rotate(154deg) brightness(1.31) drop-shadow(0 2px 2px #080b0dcc); }
.gift--cloud, .gift--tide, .gift--rose, .gift--moon { width: clamp(36px, 7.0cqw, 72px); }
.gift--cloud { --stock: #694e73; --stock-rim: #d8addf; --floor-angle: -4deg; bottom: 4.8%; left: 13.8%; }
.gift--tide { --stock: #3d6970; --stock-rim: #a8d1ce; --floor-angle: 3deg; bottom: 8%; left: 23.8%; }
.gift--rose { --stock: #88546a; --stock-rim: #eda7c2; --floor-angle: 2deg; bottom: 3%; left: 43.3%; }
.gift--moon { --stock: #9e895a; --stock-rim: #e7dfbd; --floor-angle: -4deg; bottom: 4.8%; left: 87.0%; }
.gift.gift--cloud .gift-texture { filter: hue-rotate(271deg) saturate(.52) brightness(1.2) drop-shadow(0 2px 2px #101011bb); }
.gift.gift--tide .gift-texture { filter: hue-rotate(151deg) saturate(.54) brightness(1.19) drop-shadow(0 2px 2px #101011bb); }
.gift.gift--rose .gift-texture { filter: hue-rotate(340deg) saturate(.68) brightness(1.29) drop-shadow(0 2px 2px #101011bb); }
.gift.gift--moon .gift-texture { filter: sepia(.62) saturate(.45) brightness(1.36) drop-shadow(0 2px 2px #101011bb); }
.gift::after {
  position: absolute;
  inset: -13% -4% -4%;
  z-index: 3;
  border-radius: inherit;
  content: "";
}
.gift-shadow, .gift-body, .gift-inside, .gift-lid, .gift-lid-top, .gift-lid-back {
  position: absolute;
  display: block;
  pointer-events: none;
}
.gift-shadow {
  bottom: -10%;
  left: -17%;
  width: 139%;
  height: 32%;
  transform: rotate(-3deg);
  background:
    radial-gradient(ellipse at 50% 43%, #090907d9 0%, #170f09a1 29%, transparent 68%),
    radial-gradient(ellipse at 50% 38%, #100e0b8f 0%, transparent 65%);
  filter: blur(1px);
}
.gift-body {
  inset: 0;
  filter: brightness(.87) saturate(.85) drop-shadow(0 2px 1px #0c0907a6);
}
.gift-texture {
  background-image: url("assets/gift-parts.webp");
  background-size: var(--texture-width) var(--texture-height);
  background-position: var(--texture-x) var(--texture-y);
  background-repeat: no-repeat;
}
.gift-inside {
  z-index: 1;
  inset: 0;
  clip-path: var(--mouth);
  opacity: 0;
  background:
    radial-gradient(ellipse at 56% 49%, #fff5d5 0%, var(--cel-glow) 17%, transparent 39%),
    linear-gradient(113deg, #2b140be0 2%, #e7994960 45%, transparent 81%);
  mix-blend-mode: screen;
}
.gift-lid {
  z-index: 2;
  top: var(--lid-y);
  left: var(--lid-x);
  width: var(--lid-width);
  height: var(--lid-height);
  transform-style: preserve-3d;
  transform-origin: 58% var(--hinge-y);
  transition: transform 180ms ease;
}
.gift-lid-top, .gift-lid-back {
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.gift-lid-top {
  filter: brightness(.89) saturate(.93) drop-shadow(0 3px 1px #1d120a86);
}
.gift-lid-back {
  transform: rotateX(180deg);
  clip-path: polygon(2% 7%, 92% 7%, 94% 16%, 99% var(--back-hinge), 16% var(--back-hinge), 3% 17%);
  background-color: var(--stock);
  background-image:
    linear-gradient(177deg, #241a0dde 0 7%, #d6ad6e10 9% 22%, transparent 26% 64%, #211c0e3d 79%, #1e1a13b0 95%),
    linear-gradient(95deg, var(--stock-rim), transparent 14% 86%, #201b12b3 97%),
    radial-gradient(ellipse at 48% 72%, #ffd38a49, transparent 70%),
    url("assets/gift-parts.webp");
  background-size: 100% 100%, 100% 100%, 100% 100%, var(--texture-width) var(--texture-height);
  background-position: center, center, center, var(--texture-x) var(--texture-y);
  background-repeat: no-repeat;
}
.gift:hover:not([aria-disabled="true"]) .gift-lid {
  transform: translateY(-1.5%) rotateX(5deg);
}
.gift.is-opening .gift-lid { animation: unwrap var(--open-time) linear both; }
.gift.is-open .gift-lid { transform: rotateX(142deg); }
.gift.is-opening .gift-inside { animation: box-glow var(--open-time) ease both; }
.gift.is-open .gift-inside { opacity: .27; }
@keyframes unwrap {
  0% { transform: none; animation-timing-function: cubic-bezier(.25,.55,.4,1); }
  18% { transform: translateY(1%) rotateX(-3deg); animation-timing-function: cubic-bezier(.4,.05,.45,1); }
  51% { transform: rotateX(78deg); animation-timing-function: cubic-bezier(.16,.66,.51,1); }
  79% { transform: rotateX(149deg); animation-timing-function: ease-out; }
  92% { transform: rotateX(139deg); }
  100% { transform: rotateX(142deg); }
}
@keyframes box-glow {
  0%, 26% { opacity: 0; }
  58% { opacity: .84; }
  100% { opacity: .27; }
}
.gift[aria-disabled="true"] { cursor: default; }

.cabin-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 5px 20px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
}
.cabin-tools .scene-foot { grid-column: 1 / -1; }
.controls {
  grid-area: utility;
  display: grid;
  align-items: start;
  gap: 0 16px;
  min-width: 0;
  margin-top: 12px;
}
.controls .reset { grid-column: 1 / -1; justify-self: start; }
.shelf {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--panel);
}
.shelf-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shelf-head h2 { margin: 0; font: 700 18px/1.16 var(--serif); }
.drawn {
  min-height: 54px;
  display: grid;
  grid-template-columns: 49px 1fr;
  align-items: center;
  gap: 12px;
  margin: 6px 0 8px;
}
.held-ornament {
  position: relative;
  display: grid;
  place-items: center;
  width: 49px;
  height: 49px;
  padding: 0;
  border: 1px dashed #a68a5b88;
  border-radius: 50%;
  background: radial-gradient(circle, #19261bc2, #4051447a);
  touch-action: none;
  user-select: none;
}
.held-ornament.has-item { cursor: grab; border: 1px solid #ac8c61; box-shadow: inset 0 0 15px #e8b87024; }
.held-ornament.is-dragging { cursor: grabbing; }
.held-ornament.is-dragging > .sprite { opacity: .36; }
.empty-star { --icon-size: 27px; }
.held-ornament.has-item .empty-star, .held-ornament:not(.has-item) .sprite { display: none; }
.drawn-copy strong { display: block; font-size: 15px; font-weight: 600; color: var(--cream); }
.drawn-copy p { margin: 3px 0 0; color: #c0bda5; font-size: 12px; line-height: 1.55; }
.sprite {
  --sx: 0%;
  --sy: 0%;
  display: block;
  width: 93%;
  aspect-ratio: 1;
  background-image: url("assets/ornaments.png");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  background-position: var(--sx) var(--sy);
  pointer-events: none;
}
.sprite[data-icon="gold"] { --sx: 50%; }
.sprite[data-icon="emerald"] { --sx: 100%; }
.sprite[data-icon="bell"] { --sy: 100%; }
.sprite[data-icon="paper"] { --sx: 50%; --sy: 100%; }
.sprite[data-icon="frost"] { --sx: 100%; --sy: 100%; }
.stage[data-visual="cel"] .sprite {
  width: 65%;
  height: 65%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 32% 27%, #fff5d7 0 7%, transparent 8%),
    linear-gradient(146deg, var(--ornament-rim, #f2a19a) 0 27%, var(--ornament-middle, #b55260) 28% 62%, var(--ornament-shadow, #63334c) 63%);
  box-shadow: inset 0 0 0 1px #10233285, 0 2px 4px #0d202cb8;
}
.stage[data-visual="cel"] .sprite[data-icon="gold"] { --ornament-rim: #ffe3a0; --ornament-middle: #d5a551; --ornament-shadow: #805a3b; }
.stage[data-visual="cel"] .sprite[data-icon="emerald"] { --ornament-rim: #d8ffb9; --ornament-middle: #5ea677; --ornament-shadow: #286268; }
.stage[data-visual="cel"] .sprite[data-icon="bell"] {
  border-radius: 0;
  clip-path: polygon(41% 1%, 59% 1%, 59% 13%, 74% 24%, 83% 62%, 98% 78%, 61% 81%, 55% 96%, 43% 96%, 36% 81%, 2% 78%, 17% 59%, 24% 25%, 41% 13%);
  background: linear-gradient(148deg, #f5d18c 0 31%, #cc8f46 32% 65%, #895756 66%);
}
.stage[data-visual="cel"] .sprite[data-icon="paper"] {
  border-radius: 0;
  clip-path: polygon(50% 0, 61% 34%, 99% 37%, 69% 60%, 81% 97%, 50% 74%, 19% 97%, 31% 60%, 1% 37%, 39% 34%);
  background: conic-gradient(from 26deg, #ffdfa4 0 15%, #c38749 15% 29%, #f9c571 29% 46%, #a87453 46% 63%, #ffefbb 63% 85%, #d39d5d 85%);
}
.stage[data-visual="cel"] .sprite[data-icon="frost"] {
  border-radius: 0;
  clip-path: polygon(50% 0, 57% 36%, 93% 18%, 66% 43%, 100% 54%, 63% 59%, 77% 93%, 54% 67%, 40% 100%, 43% 65%, 8% 78%, 36% 55%, 0 42%, 40% 43%, 30% 9%, 47% 38%);
  background: linear-gradient(145deg, #f8f9dd 0 32%, #acdfe6 33% 61%, #6b9fc0 62%);
}
.drag-ornament {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 15;
  width: clamp(54px, 5.5vw, 78px);
  margin: -29px 0 0 -30px;
  filter: drop-shadow(0 8px 9px #0b120eb3);
}
.shelf-actions { display: flex; gap: 9px; align-items: center; }
.draw-button {
  min-height: 45px;
  padding: 8px 14px;
  border: 1px solid #edcf98;
  border-radius: 2px;
  color: #2b2118;
  background: linear-gradient(120deg, #efd098, #d4a466);
  font-size: 14px;
  font-weight: 700;
  box-shadow: inset 0 0 0 2px #faf1c737, 0 3px 12px #0a120d45;
}
.draw-button:hover:not(:disabled) { background: #f5d7a1; }
.draw-button:disabled { background: #3f4d3d; color: #c9c0a4; border-color: #687059; box-shadow: none; }
.draw-button span { margin-right: 4px; font-size: 16px; }
.shelf-actions .draw-button { flex: 1; min-width: 0; }
.shelf-actions .draw-button:not(:disabled) { background: var(--raised); color: var(--cream); border: 0; box-shadow: none; border-radius: 6px; }
.shelf-actions .draw-button:hover:not(:disabled) { background: #37473d; }
.text-button {
  min-height: 40px;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: #e1c795;
  font-size: 13px;
}
.text-button:hover { color: #fff1bd; }
.hang-button { padding-inline: 5px; white-space: nowrap; }
.extra-actions { margin: 4px 0 2px; }
.action-row {
  display: grid;
  grid-template-columns: 26px 1fr 16px;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 3px 3px;
  border: 0;
  border-bottom: 1px solid #43513f;
  background: none;
  color: #e5d9ba;
  text-align: left;
  font-size: 14px;
}
.action-row:hover { color: #fff5d3; background: #e2c38b0b; }
.action-mark { --icon-size: 21px; justify-self: center; }
.action-next { text-align: right; color: #c7a675; font: 24px/1 Georgia, serif; }
.reset { color: #bdb69d; min-height: 37px; }
.reset span { margin-right: 3px; }
.wrap-gifts { flex: none; }

.letter {
  position: absolute;
  z-index: 8;
  right: 3.8%;
  bottom: 22%;
  width: min(285px, 39%);
  display: grid;
  grid-template-columns: 28% 1fr;
  align-items: stretch;
  min-height: 104px;
  border: 1px solid #c7a76b;
  border-radius: 3px;
  color: #382d21;
  background: var(--paper-fibres, none) 50% 50% / 340px 177px, radial-gradient(ellipse at 22% 0, #fff0cd, #e9c892 120%);
  box-shadow: 0 2px 0 #7b5636, 0 3px 0 #c59864, 0 15px 36px #090b09b3, 0 0 28px #f0c88620;
  transform-origin: 14% 91%;
  animation: letter-rise 495ms cubic-bezier(.2,.62,.34,1) both;
}
@keyframes letter-rise {
  0% { transform: perspective(620px) translate(-18px, 23px) rotateZ(-4deg) rotateX(34deg) scale(.80); opacity: 0; }
  58% { transform: perspective(620px) translate(-1px, -1px) rotateZ(.7deg) rotateX(-5deg); opacity: 1; }
  to { transform: none; opacity: 1; }
}
.letter-paper { align-self: center; padding: 13px 43px 13px 11px; }
.letter h2 { margin: 0 0 7px; font: 700 clamp(16px, 1.6vw, 23px)/1.18 var(--serif); }
.letter p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; font-size: clamp(11px, 1.05vw, 14px); line-height: 1.5; }
.letter-close {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: #62482e;
  font: 24px/1 Georgia, serif;
}
html[lang="en"] .letter { width: min(370px, 58%); }
.letter-close:focus-visible { outline-color: #785029; outline-offset: -3px; }
.letter-art {
  min-width: 0;
  background: radial-gradient(circle at 45% 44%, #8c663b, #21352d 72%);
  display: grid;
  place-items: center;
  border-right: 1px solid #b18a56;
  color: #fff1bd;
  font: 31px/1 Georgia, serif;
}
.letter-art[data-theme="comet"], .letter-art[data-theme="snow"] { background-image: radial-gradient(circle, #6a8cb0, #273c50 79%); }
.letter-art[data-theme="heart"] { background-image: radial-gradient(circle, #a3545a, #562d3b 79%); }
.letter-art[data-theme="aurora"] { background-image: linear-gradient(145deg, #182d3b, #4b876b 48%, #4e426d); }
.letter-art[data-illustrated="true"] { background-image: url("assets/gift-stories.webp"); background-size: 390% 205%; background-position: var(--art-x) var(--art-y); }
.letter-art[data-realm="true"] { background-image: var(--realm-source); background-size: 290% 200%; background-position: var(--realm-x) var(--realm-y); }
.letter-art[data-illustrated="true"] span { visibility: hidden; }
.letter-art[data-realm="true"] span { visibility: hidden; }

.wish-dialog {
  width: min(415px, 100% - 30px);
  max-width: none;
  padding: 24px;
  border: 1px solid #947a50;
  border-radius: 3px;
  color: var(--cream);
  background: #26362b;
  box-shadow: 0 22px 70px #0b100ce6;
}
.wish-dialog::backdrop { background: #0a100bc9; }
.wish-dialog h2 { margin: 0 0 12px; font: 700 28px/1.2 var(--serif); }
.wish-dialog label { display: block; margin-bottom: 8px; color: #e3d8b9; }
.wish-dialog textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid #827b5b;
  border-radius: 2px;
  background: #15221a;
  color: var(--cream);
  resize: vertical;
}
.wish-dialog textarea::placeholder { color: #b7a789; }
.wish-actions { display: flex; justify-content: flex-end; align-items: center; gap: 16px; margin-top: 13px; }

@media (min-width: 731px) and (max-width: 1050px) {
  .play-layout { grid-template: "stage intro" auto "stage journey" 1fr "tools journey" auto "utility utility" auto / minmax(0, 1fr) clamp(246px, 25vw, 346px); }
  .controls { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 730px) {
  .page { width: calc(100% - 24px); }
  .masthead { min-height: 56px; flex-wrap: wrap; gap: 3px 8px; padding-block: 3px; }
  .brand { font-size: 17px; gap: 4px; }
  .brand-star { --icon-size: 18px; }
  .settings { gap: 2px; }
  .setting { padding-inline: 5px; }
  #snow-toggle .setting-label { position: absolute; overflow: hidden; width: 1px; height: 1px; clip-path: inset(50%); }
  .language-control select { font-size: 12px; padding-inline: 5px; }
  .postcard { padding-block: 10px 24px; }
  .play-layout { grid-template: "intro" auto "stage" auto "journey" auto "tools" auto "utility" auto / minmax(0, 1fr); }
  .intro { padding: 0 4px 8px; background: transparent; }
  .intro h1 { margin-bottom: 4px; font-size: clamp(27px, 8.8vw, 32px); }
  .intro p { max-width: 36em; font-size: 13px; }
  .journey-controls { margin-top: 8px; padding: 8px 8px 10px; gap: 6px; border-radius: 8px; }
  .route-slot { min-height: 47px; }
  .route-light { min-height: 51px; }
  .scene-tools { padding: 5px 0 2px; gap: 0 7px; }
  .style-picker button { padding-inline: 7px; font-size: 12px; }
  .score-picker { gap: 6px; flex-basis: 100%; max-width: 100%; }
  .score-picker select { flex: 1; max-width: 100%; font-size: 13px; }
  .cabin-tools, .controls { grid-template-columns: minmax(0, 1fr); }
  .scene-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; min-height: 50px; padding: 6px 5px; gap: 6px; }
  .scene-note { grid-column: 1 / -1; }
  .growth-readout { width: min(132px, 100%); white-space: normal; }
  .gift-controls { padding-inline: 4px; }
  .gift-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
  .gift-picker button { min-height: 44px; }
  .gift-view-links { gap: 11px; }
  .scene-note { gap: 5px; }
  .scene-note p { font-size: 11px; }
  .growth-readout { flex-basis: 94px; font-size: 11px; }
  .gift-route-readout .wrap-gifts { min-height: 29px; }
  .gift-order span { width: 16px; height: 16px; }
  .small-count, .wrap-gifts { font-size: 11px; }
  .shelf { padding: 13px; }
  .shelf-head h2 { font-size: 21px; }
  .drawn { min-height: 52px; grid-template-columns: 55px 1fr; margin: 7px 0 9px; }
  .held-ornament { width: 55px; height: 55px; }
  .draw-button { min-height: 44px; }
  .extra-actions { margin-top: 8px; }
  .letter, html[lang="en"] .letter { position: relative; inset: auto; width: 100%; min-height: 85px; margin-bottom: 5px; grid-template-columns: 25% 1fr; }
  .letter-paper { padding: 12px 43px 12px 9px; }
}
@media (max-width: 450px) {
  .ritual-controls:has(.star-finale:not([hidden])) { padding-top: 5px; }
  .stage:has(.tree-ritual[data-ritual="stars"]:not([hidden])) .ornament-scene {
    justify-items: end;
    padding-bottom: max(3px, 1.45%);
  }
  .stage:has(.tree-ritual[data-ritual="stars"]:not([hidden])) .ornament-scene strong {
    font-size: clamp(14px, 4.1cqw, 19px);
    line-height: 1.15;
  }
  .constellation-name { gap: 1px 6px; padding: 3px; }
}
@media (min-width: 731px) and (max-width: 960px) {
  .gift-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 330px) {
  .brand-star { --icon-size: 15px; }
  .brand { font-size: 15px; gap: 3px; }
  #sound-toggle .setting-label { position: absolute; overflow: hidden; width: 1px; height: 1px; clip-path: inset(50%); }
  .scene-foot { padding-inline: 1px; }
  .scene-note p { line-height: 1.4; }
  .scene-tools { flex-wrap: wrap; }
  .score-picker { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ornament-anchor::before, .ornament-scene.is-arriving, .ritual-point { transition: none; animation: none; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.surprise-title, #open-surprise, #surprise-caption, .collection-meter { display: none; }
.surprise-dock { display: contents; }
.surprise-links { display: flex; align-items: center; justify-content: center; gap: 8px; order: 4; }
#toggle-studio, #armor-gallery-open {
  order: 3;
  min-height: 44px;
  padding: 5px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #d1c6af;
  font: 500 13px/1.4 var(--sans);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: #8a8068;
}
.surprise-links button:hover, .surprise-links button:focus-visible { color: #ffedca; text-decoration-color: currentColor; }
.armor-gallery {
  width: min(435px, calc(100% - 20px));
  max-height: calc(100svh - 20px);
  padding: 15px clamp(14px, 3vw, 24px) 19px;
  border: 1px solid #a28959; border-radius: 12px;
  background: #18241f; color: #f1e5c9;
}
.armor-gallery::backdrop { background: #09100de0; }
.armor-gallery header { display:flex; justify-content:space-between; align-items:center; margin-bottom:8px; }
.armor-gallery h2 { margin:0; font: 500 27px/1.1 var(--serif); }
.armor-gallery button, .armor-gallery select { min-height:44px; }
#armor-close, #armor-previous, #armor-next {
  min-width:44px; border:0; border-radius:6px; background:transparent; color:#e5d4b0; font:27px/1 var(--serif);
}
.armor-display { position:relative; display:grid; place-items:center; width:100%; height:min(50svh,415px); background:#101a1d; }
#armor-preview { display:block; width:100%; height:100%; min-height:0; object-fit:contain; }
#armor-motion { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
.atlas-plaque {
  display:grid; grid-template-columns:minmax(0,1fr) 87px; align-items:center; gap:9px;
  padding-block:8px 0;
}
.atlas-plaque strong, .atlas-plaque span { display:block; }
.atlas-plaque strong { font: 500 16px/1.2 var(--serif); color:#f0d9a8; }
.atlas-plaque span { margin-top:3px; font-size:11px; color:#c0c0ac; }
#atlas-sky-chart { width:87px; height:auto; border:1px solid #55615c; border-radius:5px; background:#101b29; }
#armor-error { position:absolute; margin:0; text-align:center; }
.armor-navigation { display:grid; grid-template-columns:44px minmax(0,1fr) 44px; gap:7px; align-items:center; margin:12px 0; }
#armor-choice { width:100%; border:1px solid #625a45; border-radius:5px; padding-inline:8px; background:#202e27; color:#f4e7c9; font:17px var(--serif); }
.atlas-actions { display:grid; grid-template-columns:minmax(0,1fr); gap:7px; }
.atlas-actions:has(#armor-replay-finale:not([hidden])) { grid-template-columns:repeat(2,minmax(0,1fr)); }
.atlas-actions button { padding:4px 7px; border:1px solid #e9c991; border-radius:6px; font:600 16px/1.12 var(--serif); }
#armor-play { background:#e4c48c; color:#30251b; }
#armor-replay-finale { border-color:#9b8057; background:#222c24; color:#f0d4a2; }
@media (min-aspect-ratio: 3/2) and (max-height: 500px) {
  .armor-gallery[open] {
    width:min(650px, calc(100% - 20px));
    padding:8px 12px 12px;
    display:grid;
    grid-template:
      "heading heading" auto
      "portrait detail" auto
      "portrait navigation" auto
      "portrait actions" 1fr / minmax(0,1.07fr) minmax(0,1fr);
    align-items:center;
    gap:7px 14px;
  }
  .armor-gallery header { grid-area:heading; margin:0; }
  .armor-display { grid-area:portrait; height:clamp(130px,calc(100svh - 98px),360px); }
  .atlas-plaque { grid-area:detail; padding:0; }
  .armor-navigation { grid-area:navigation; margin:0; }
  .atlas-actions { grid-area:actions; align-self:start; }
}
body[data-play-mode="gift"] {
  background: radial-gradient(ellipse at 50% 46%, #23372e 0, #16251f 47%, #101b17 80%);
}
body[data-play-mode="gift"] :is(#jump-to-lights, .studio-title, .intro p, .journey-controls, .controls, .cabin-tools,
  .style-picker, .score-picker, #snow-toggle, #reveal, #tree-ritual, #gifts) { display: none; }
body[data-play-mode="gift"] .stage :is(button, .branches, .ornament-anchors) { pointer-events: none; }
body[data-play-mode="gift"] .ornament-anchor::before { opacity: .13; }
body[data-play-mode="gift"] .branch:not(.is-occupied) { visibility: hidden; }
body[data-play-mode="gift"] .page { width: min(1240px, calc(100% - clamp(24px, 7vw, 104px))); }
body[data-play-mode="gift"] .masthead { border-color: #ab97622d; }
body[data-play-mode="gift"] .language-control select { background: transparent; border: 0; color: var(--soft); }
body[data-play-mode="gift"] .language-control option { background: var(--spruce); }
body[data-play-mode="gift"] .postcard { padding-block: clamp(11px, 2.7svh, 27px) 18px; }
body[data-play-mode="gift"] .play-layout {
  width: min(100%, 980px, max(340px, calc(133.333svh - 394px)));
  margin-inline: auto;
  grid-template: "intro" auto "stage" auto "tools" auto / minmax(0, 1fr);
}
body[data-play-mode="gift"] .intro {
  padding: 0 0 clamp(9px, 1.7svh, 18px);
  background: transparent;
  text-align: center;
}
body[data-play-mode="gift"] .intro h1 {
  margin: 0;
  font: 500 clamp(28px, 3.3vw, 49px)/1.10 var(--serif);
  letter-spacing: -.044em;
  color: #f1e1c0;
}
body[data-play-mode="gift"] .surprise-title { display: inline; }
body[data-play-mode="gift"] .stage {
  border-radius: clamp(10px, 1.5vw, 18px);
  outline: 1px solid #cab68957;
  box-shadow: 0 11px 40px -21px #070e0adb;
}
body[data-play-mode="gift"] .scene-tools {
  display: block;
  padding: clamp(12px, 2svh, 21px) 0 0;
}
body[data-play-mode="gift"] .surprise-dock {
  display: grid;
  justify-items: center;
  row-gap: 3px;
}
body[data-play-mode="gift"] #open-surprise {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  min-width: min(235px, 100%);
  max-width: 100%;
  min-height: 56px;
  padding: 9px 27px 9px 21px;
  border: 1px solid #f2d89d;
  border-radius: 9px;
  color: #33261e;
  background: linear-gradient(110deg, #e4c58e, #f2deb0 51%, #e3bf83);
  box-shadow: inset 0 -2px #b48f59, 0 4px 9px #09120d54;
  font: 600 20px/1.12 var(--serif);
  text-align: start;
  touch-action: manipulation;
  transition: transform 160ms ease, background-color 160ms ease;
}
body[data-play-mode="gift"] #open-surprise::after {
  position: absolute;
  pointer-events: none;
  inset: 3px;
  border: 1px solid #81623f55;
  border-radius: 6px;
  content: "";
}
body[data-play-mode="gift"] #open-surprise:active { transform: translateY(1px); }
body[data-play-mode="gift"] #open-surprise:focus-visible { outline-offset: 5px; }
.surprise-parcel {
  position: relative;
  flex: 0 0 35px;
  height: 36px;
  filter: drop-shadow(1px 2px 1px #70573760);
  transform: rotate(-6deg);
}
.surprise-parcel::before, .surprise-parcel::after {
  position: absolute;
  background-image: url("assets/gift-parts.webp");
  background-repeat: no-repeat;
  content: "";
}
.surprise-parcel::before {
  inset: 0;
  background-size: 478.5% 312.2%;
  background-position: 94% 88.1%;
}
.surprise-parcel::after {
  left: -2.2%;
  top: -9.1%;
  width: 105%;
  height: 63.1%;
  background-size: 455.8% 494.7%;
  background-position: 95% 29%;
  transform-origin: 80% 24%;
  transition: transform 200ms ease;
}
@media (hover: hover) {
  body[data-play-mode="gift"] #open-surprise:hover .surprise-parcel::after { transform: translateY(-2px) rotate(-5deg); }
}
body[data-play-mode="gift"][data-gift-state="opening"] #open-surprise .surprise-parcel::after {
  transform: translate(-2px, -5px) rotate(-13deg);
}
#surprise-parcel-prop {
  display: none;
  position: absolute;
  z-index: 5;
  left: 61.5%;
  bottom: 6.3%;
  width: 12.2%;
  min-width: 44px;
  aspect-ratio: 321 / 328;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  perspective: 340px;
  --mouth: polygon(20% 4%, 96% 4%, 85% 51%, 4% 51%);
  --cel-glow: #ffcc83;
  --stock: #854739;
  --stock-rim: #b98957;
  --back-hinge: 84%;
  --hinge-y: 16%;
  --lid-x: -2.2%;
  --lid-y: -9.1%;
  --lid-width: 105%;
  --lid-height: 63.1%;
}
body[data-play-mode="gift"]:is([data-gift-state="ready"], [data-gift-state="opening"]) #surprise-parcel-prop { display: block; }
#surprise-parcel-prop:disabled { pointer-events: none; }
#surprise-parcel-prop:focus-visible { outline-offset: 2px; }
#surprise-parcel-prop .gift-body {
  --texture-width: 478.5%;
  --texture-height: 312.2%;
  --texture-x: 94%;
  --texture-y: 88.1%;
  filter: saturate(.98) brightness(.98);
}
#surprise-parcel-prop .gift-lid-top {
  --texture-width: 455.8%;
  --texture-height: 494.7%;
  --texture-x: 95%;
  --texture-y: 29%;
  filter: drop-shadow(0 1px 1px #381c1a91);
}
#surprise-parcel-prop .gift-lid-back {
  --texture-width: 1491%;
  --texture-height: 975.2%;
  --texture-x: 81.4%;
  --texture-y: 87.5%;
}
#surprise-parcel-prop::before {
  position: absolute;
  inset: -72% -56% -13%;
  opacity: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 56%, #ffda91a0, #ffd48742 24%, #ecaf5514 45%, transparent 63%);
  content: "";
}
.stage[data-gift-tempo="quick"] {
  --parcel-departure: 190ms;
  --parcel-unlatch: 162ms;
  --parcel-light: 178ms;
}
body[data-gift-state="opening"] #surprise-parcel-prop { animation: parcel-depart var(--parcel-departure, 370ms) linear both; }
body[data-gift-state="opening"] #surprise-parcel-prop .gift-lid { animation: parcel-lid var(--parcel-unlatch, 325ms) cubic-bezier(.18,.62,.24,1) both; }
body[data-gift-state="opening"] #surprise-parcel-prop .gift-inside,
body[data-gift-state="opening"] #surprise-parcel-prop::before { animation: parcel-warmth var(--parcel-light, 345ms) ease-out both; }
@keyframes parcel-depart { 0%, 65% { opacity: 1; } 100% { opacity: 0; } }
@keyframes parcel-lid {
  0% { transform: rotateX(0); }
  14% { transform: rotateX(-5deg); }
  68% { transform: rotateX(116deg); }
  100% { transform: rotateX(132deg); }
}
@keyframes parcel-warmth { 0%, 12% { opacity: 0; } 52% { opacity: .97; } 100% { opacity: .70; } }
@media (prefers-reduced-motion: reduce) {
  body[data-gift-state="opening"] #surprise-parcel-prop { visibility: hidden; }
}
body[data-play-mode="gift"] #surprise-caption {
  display: block;
  grid-row: 2;
  margin: 3px 0 0;
  max-width: 39em;
  color: #e2d2af;
  font: 400 14px/1.45 var(--sans);
  text-align: center;
  overflow-wrap: anywhere;
}
body[data-play-mode="gift"] #surprise-caption:empty { display: none; }
body[data-play-mode="gift"] .collection-meter {
  display: flex;
  order: 2;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 10px;
  margin-top: 7px;
  color: #d8c7a5;
  font: 500 12px/1.35 var(--sans);
  font-variant-numeric: tabular-nums;
}
#collection-stars { display: flex; align-items: center; gap: 4px; }
#collection-stars span {
  display: block;
  width: 5px;
  height: 5px;
  transform: rotate(45deg);
  border: 1px solid #8c7960;
  border-radius: 1px;
}
#collection-stars .is-found { border-color: #f6d495; background: #e7b973; }
.collection-meter[data-complete="true"] { color: #ffdda0; }
.collection-meter[data-complete="true"] .is-found { box-shadow: 0 0 6px #f4cb83a6; }
body[data-play-mode="gift"] #toggle-studio { padding-inline: 12px; }
@media (max-width: 730px) {
  body[data-play-mode="gift"] .page { width: calc(100% - 20px); }
  body[data-play-mode="gift"] .postcard { padding-top: clamp(18px, 4.2svh, 38px); }
  body[data-play-mode="gift"] .play-layout { width: 100%; }
  body[data-play-mode="gift"] .intro { padding-bottom: clamp(12px, 2.5svh, 20px); }
  body[data-play-mode="gift"] .intro h1 { font-size: clamp(28px, 7.5vw, 36px); }
  body[data-play-mode="gift"] .scene-tools { padding-top: 18px; }
  body[data-play-mode="gift"] #open-surprise { min-width: min(225px, 100%); }
}
@media (min-aspect-ratio: 3/2) and (max-height: 550px) {
  body[data-play-mode="gift"] .masthead { min-height: 46px; }
  body[data-play-mode="gift"] .postcard { padding-block: 10px; }
  body[data-play-mode="gift"] .play-layout {
    width: min(100%, calc(133.333svh + 200px));
    grid-template: "stage intro" 1fr "stage tools" 1.3fr / minmax(0, 1.5fr) minmax(0, 1fr);
    column-gap: clamp(8px, 2vw, 20px);
  }
  body[data-play-mode="gift"] .intro { align-self: end; padding-bottom: 8px; }
  body[data-play-mode="gift"] .intro h1 { font-size: clamp(24px, 3.9vw, 34px); }
  body[data-play-mode="gift"] .scene-tools { padding-top: 5px; }
  body[data-play-mode="gift"] #open-surprise { min-width: 0; padding-inline: 12px; }
}
