:root {
  --ink: #16251f;
  --ink-soft: #58665f;
  --paper: #f4eddf;
  --paper-deep: #e9decb;
  --paper-light: #fbf7ee;
  --pine: #174b38;
  --pine-deep: #0a281f;
  --night: #071b18;
  --night-soft: #0d2a24;
  --red: #bf4038;
  --red-deep: #92312c;
  --gold: #d8a84f;
  --gold-light: #efd28a;
  --snow: #f8f3e8;
  --line: rgba(22, 37, 31, 0.14);
  --line-light: rgba(248, 243, 232, 0.14);
  --shadow-soft: 0 24px 70px rgba(2, 14, 11, 0.2);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --m-in: 150ms;
  --m-out: 120ms;
  --m-press: 90ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-enter: cubic-bezier(0.22, 1, 0.36, 1);
  --display: "Iowan Old Style", "Palatino Linotype", "Noto Serif SC", "Songti SC", SimSun, serif;
  --text: "Avenir Next", Avenir, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
}

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100svh;
  overflow: hidden;
  background: var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 100;
  min-height: 44px;
  padding: 12px 16px;
  color: var(--paper-light);
  background: var(--ink);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform var(--m-in) var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  height: 100svh;
  min-height: 540px;
  display: grid;
  grid-template-rows: 68px minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  color: var(--ink);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--gold);
  background: var(--pine);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.brand__mark svg {
  width: 25px;
  height: 25px;
}

.brand__copy {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.05;
}

.brand p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.tree-fact {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 14px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(251, 247, 238, 0.64);
  white-space: nowrap;
}

.tree-fact__count {
  color: var(--red);
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tree-fact__label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.tree-fact__divider {
  width: 1px;
  height: 15px;
  margin: 0 3px;
  background: var(--line);
}

.save-state {
  color: var(--pine);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.save-state[data-state="saving"] {
  color: var(--ink-soft);
}

.topbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.share-button {
  min-width: 112px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  color: #fffaf0;
  background: var(--pine);
  border: 1px solid var(--pine);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--m-in) var(--ease),
    border-color var(--m-in) var(--ease),
    transform var(--m-in) var(--ease);
}

.share-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.share-button:hover:not(:disabled) {
  background: #0f3d2e;
  border-color: #0f3d2e;
  transform: translateY(-1px);
}

.share-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.share-button:disabled {
  opacity: 0.42;
}

.save-button {
  min-width: 98px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  color: var(--ink);
  background: rgba(251, 247, 238, 0.66);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--m-in) var(--ease),
    border-color var(--m-in) var(--ease),
    transform var(--m-in) var(--ease);
}

.save-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.save-button:hover {
  background: var(--paper-light);
  border-color: rgba(22, 37, 31, 0.3);
  transform: translateY(-1px);
}

.save-button:active {
  transform: translateY(1px) scale(0.985);
}

.icon-button,
.tool-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition:
    color var(--m-in) var(--ease),
    background-color var(--m-in) var(--ease),
    border-color var(--m-in) var(--ease),
    transform var(--m-in) var(--ease);
}

.icon-button svg,
.tool-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover:not(:disabled),
.tool-button:hover:not(:disabled) {
  background: var(--paper-light);
  border-color: rgba(22, 37, 31, 0.3);
  transform: translateY(-1px);
}

.icon-button:active:not(:disabled),
.tool-button:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
}

.icon-button:disabled {
  opacity: 0.35;
}

.icon-button--danger:hover:not(:disabled),
.tool-button--danger:hover:not(:disabled) {
  color: var(--red-deep);
  background: rgba(191, 64, 56, 0.08);
  border-color: rgba(191, 64, 56, 0.35);
}

.sound-off {
  display: none;
}

[aria-pressed="false"] .sound-on {
  display: none;
}

[aria-pressed="false"] .sound-off {
  display: block;
}

.game-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: clamp(228px, 21vw, 300px) minmax(0, 1fr) clamp(238px, 21vw, 300px);
  overflow: hidden;
}

.palette-panel,
.detail-panel {
  position: relative;
  z-index: 5;
  min-height: 0;
  background: var(--paper-deep);
}

.palette-panel {
  display: flex;
  flex-direction: column;
  padding: 28px 22px 20px;
  border-right: 1px solid var(--line);
}

.detail-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.panel-heading--compact {
  margin-bottom: 22px;
}

.panel-step {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  margin-top: 2px;
  color: var(--paper-light);
  background: var(--pine);
  border-radius: 50%;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.panel-heading h2,
.records-heading h2,
.detail-section h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.panel-caption {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}

.palette-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 24px 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(22, 37, 31, 0.24) transparent;
}

.palette-item {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--ink);
  background: rgba(251, 247, 238, 0.54);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition:
    transform var(--m-in) var(--ease),
    background-color var(--m-in) var(--ease),
    border-color var(--m-in) var(--ease),
    box-shadow var(--m-in) var(--ease);
}

.palette-item:hover {
  z-index: 1;
  background: var(--paper-light);
  border-color: rgba(22, 37, 31, 0.15);
  transform: translateY(-2px);
}

.palette-item:active {
  transform: translateY(1px) scale(0.985);
}

.palette-item[aria-pressed="true"] {
  background: var(--paper-light);
  border-color: var(--pine);
  box-shadow:
    0 0 0 1px var(--pine),
    0 7px 20px rgba(23, 75, 56, 0.12);
}

.palette-item__name {
  position: absolute;
  right: 5px;
  bottom: 4px;
  left: 5px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette-selection {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.selection-swatch {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--red);
  box-shadow:
    inset -5px -7px 10px rgba(0, 0, 0, 0.22),
    inset 5px 6px 8px rgba(255, 255, 255, 0.24);
}

.selection-swatch::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: -12px;
  margin-left: -8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
}

.palette-selection__label {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-soft);
  font-size: 11px;
}

.palette-selection strong {
  display: block;
  overflow: hidden;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-scene {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  color: var(--snow);
  background: var(--night);
}

.tree-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: default;
  isolation: isolate;
  background:
    radial-gradient(circle at 18% 17%, rgba(229, 187, 98, 0.12) 0 1px, transparent 1.8px),
    radial-gradient(circle at 74% 29%, rgba(248, 243, 232, 0.17) 0 1px, transparent 1.8px),
    radial-gradient(circle at 43% 9%, rgba(248, 243, 232, 0.14) 0 1px, transparent 1.8px),
    radial-gradient(circle at 88% 62%, rgba(229, 187, 98, 0.1) 0 1px, transparent 1.8px),
    linear-gradient(180deg, #0a2420 0%, #071b18 54%, #03110f 100%);
  background-size: 173px 171px, 227px 211px, 281px 251px, 307px 263px, auto;
}

.tree-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 72%);
}

.tree-stage::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  height: 23%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(196, 156, 76, 0.18), transparent 58%),
    linear-gradient(to top, #03100d 4%, transparent 75%);
}

.tree-stage[data-tool-active="true"] {
  cursor: crosshair;
}

.world-art {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: none;
  animation: world-arrive 420ms var(--ease-enter) both;
}

.tree-stage[data-background="snow-night"] .world-art--night,
.tree-stage[data-background="cozy-room"] .world-art--room,
.tree-stage[data-background="day-lawn"] .world-art--lawn {
  display: block;
}

.tree-stage[data-background="cozy-room"]::before,
.tree-stage[data-background="day-lawn"]::before {
  display: none;
}

.tree-stage[data-background="cozy-room"]::after {
  background:
    radial-gradient(ellipse at 77% 73%, rgba(255, 173, 76, 0.16), transparent 30%),
    linear-gradient(to top, rgba(21, 11, 8, 0.48), transparent 56%);
}

.tree-stage[data-background="day-lawn"]::after {
  background: linear-gradient(to top, rgba(40, 72, 35, 0.18), transparent 42%);
}

.tree-scene[data-background="day-lawn"] .scene-heading p {
  color: #4b6a34;
}

.tree-scene[data-background="day-lawn"] .scene-heading h2 {
  color: #183a2d;
}

.tree-stage[data-background="day-lawn"] .stage-status {
  color: rgba(24, 58, 45, 0.72);
}

.tree-stage[data-background="day-lawn"] .stage-status__dot {
  background: #3f7d51;
  box-shadow: 0 0 0 3px rgba(63, 125, 81, 0.15);
}

@keyframes world-arrive {
  from {
    opacity: 0.35;
    transform: scale(1.015);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.scene-heading {
  position: absolute;
  top: 28px;
  left: 30px;
  z-index: 6;
  pointer-events: none;
}

.scene-heading p {
  margin: 0 0 8px;
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.13em;
}

.scene-heading h2 {
  margin: 0;
  max-width: 320px;
  color: rgba(248, 243, 232, 0.94);
  font-family: var(--display);
  font-size: clamp(24px, 2.5vw, 38px);
  font-weight: 500;
  line-height: 1.12;
}

.scene-switcher {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 8;
  display: flex;
  gap: 4px;
  padding: 5px;
  background: rgba(248, 243, 232, 0.9);
  border: 1px solid rgba(22, 37, 31, 0.12);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(2, 14, 11, 0.16);
}

.scene-switcher button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition:
    color var(--m-in) var(--ease),
    background-color var(--m-in) var(--ease),
    transform var(--m-in) var(--ease);
}

.scene-switcher button:hover {
  background: rgba(22, 37, 31, 0.08);
  transform: translateY(-1px);
}

.scene-switcher button:active {
  transform: translateY(1px) scale(0.985);
}

.scene-switcher button[aria-pressed="true"] {
  color: var(--paper-light);
  background: var(--pine);
}

.scene-switcher svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mobile-transform-bar {
  display: none;
}

.tree-canvas {
  position: absolute;
  left: 50%;
  bottom: 0.5%;
  z-index: 2;
  width: min(108%, 790px);
  aspect-ratio: 700 / 860;
  transform: translateX(-50%);
  filter: drop-shadow(0 18px 38px rgba(0, 0, 0, 0.32));
}

.tree-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ornament-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.ornament,
.placement-preview .ornament {
  position: absolute;
  width: var(--ornament-size, 46px);
  height: var(--ornament-size, 46px);
  display: grid;
  place-items: center;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  transform: translate(-50%, -50%) rotate(var(--rotation, 0deg)) scale(var(--scale, 1));
  transform-origin: 50% 50%;
  transition:
    filter var(--m-in) var(--ease),
    opacity var(--m-in) var(--ease);
}

.ornament:hover,
.ornament:focus-visible {
  filter: drop-shadow(0 0 8px rgba(239, 210, 138, 0.38));
}

.ornament:focus-visible {
  outline-color: var(--gold-light);
  outline-offset: 4px;
}

.ornament.is-selected::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px dashed rgba(239, 210, 138, 0.8);
  border-radius: 50%;
  pointer-events: none;
}

.ornament--light {
  width: var(--light-width, 46%);
  height: auto;
  aspect-ratio: 7 / 1;
  pointer-events: none;
}

.ornament--light .light-strand__svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.ornament--light .light-strand__hit {
  pointer-events: stroke;
  cursor: grab;
}

.ornament--light.is-dragging .light-strand__hit {
  cursor: grabbing;
}

.ornament--light.is-selected::after {
  inset: -5px -3px;
  border-radius: 9px;
}

.light-strand__wire {
  fill: none;
  stroke: rgba(31, 58, 45, 0.92);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.light-strand__bulb {
  filter: drop-shadow(0 0 3px rgba(255, 220, 136, 0.66));
}

.ornament-visual--light-warm,
.ornament-visual--light-multi {
  width: 94%;
  height: 50%;
}

.ornament-visual--light-warm svg,
.ornament-visual--light-multi svg {
  width: 100%;
  height: 100%;
}

.ornament-visual--topper-star {
  color: var(--gold-light);
  filter:
    drop-shadow(0 0 7px rgba(255, 221, 132, 0.62))
    drop-shadow(0 4px 5px rgba(0, 0, 0, 0.24));
}

.ornament.is-dragging {
  z-index: 999 !important;
  cursor: grabbing;
  transition: none;
  filter: drop-shadow(0 12px 13px rgba(0, 0, 0, 0.28));
}

.ornament.is-new {
  animation: ornament-arrive 420ms var(--ease-enter) both;
}

@keyframes ornament-arrive {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--rotation, 0deg)) scale(0.72);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(var(--rotation, 0deg)) scale(var(--scale, 1));
  }
}

.placement-preview {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
}

.placement-preview.is-visible {
  opacity: 0.56;
}

.placement-preview .ornament {
  cursor: crosshair;
  filter: saturate(0.9);
}

.ornament-visual {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.ornament-visual svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ornament-visual--bauble-red,
.ornament-visual--bauble-gold,
.ornament-visual--bauble-pearl {
  width: 77%;
  height: 77%;
  border-radius: 50%;
  box-shadow:
    inset -7px -9px 13px rgba(0, 0, 0, 0.27),
    inset 5px 5px 9px rgba(255, 255, 255, 0.26),
    0 4px 7px rgba(0, 0, 0, 0.28);
}

.ornament-visual--bauble-red {
  background: radial-gradient(circle at 32% 27%, #ef8271 0 4%, #cf4a40 33%, #9e2f2a 72%, #6b1d1a 100%);
}

.ornament-visual--bauble-gold {
  background: radial-gradient(circle at 32% 27%, #fff3b9 0 4%, #e8bd58 31%, #b77d22 72%, #765014 100%);
}

.ornament-visual--bauble-pearl {
  background: radial-gradient(circle at 32% 27%, #fffdf6 0 6%, #e8dfcd 34%, #b8aa91 73%, #857662 100%);
}

.ornament-visual--bauble-red::before,
.ornament-visual--bauble-gold::before,
.ornament-visual--bauble-pearl::before {
  content: "";
  position: absolute;
  top: -12%;
  left: 50%;
  width: 28%;
  height: 22%;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(90deg, #876022, #e4bc68 50%, #835b1f);
  transform: translateX(-50%);
}

.ornament-visual--bauble-red::after,
.ornament-visual--bauble-gold::after,
.ornament-visual--bauble-pearl::after {
  content: "";
  position: absolute;
  top: 12%;
  left: 18%;
  width: 25%;
  height: 14%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.62);
  transform: rotate(-27deg);
  filter: blur(0.4px);
}

.ornament-visual--star {
  color: var(--gold-light);
  filter: drop-shadow(0 0 6px rgba(239, 210, 138, 0.34));
}

.ornament-visual--snowflake {
  color: #d8eef0;
  filter: drop-shadow(0 0 4px rgba(216, 238, 240, 0.3));
}

.ornament-visual--bell,
.ornament-visual--pinecone {
  color: var(--gold);
}

.ornament-visual--candy {
  color: #f7eadb;
}

.ornament-visual--gingerbread {
  color: #b97843;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
}

.ornament-visual--gift {
  color: var(--red);
}

.ornament-visual--bow {
  color: #d94a42;
}

.stage-status {
  position: absolute;
  bottom: 18px;
  left: 24px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(248, 243, 232, 0.68);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.stage-status__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9bc9aa;
  box-shadow: 0 0 0 3px rgba(155, 201, 170, 0.12);
}

.toast {
  position: absolute;
  bottom: 24px;
  left: 50%;
  z-index: 30;
  max-width: calc(100% - 48px);
  padding: 10px 14px;
  color: var(--ink);
  background: var(--paper-light);
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition:
    opacity var(--m-in) var(--ease),
    transform var(--m-in) var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.detail-section {
  padding: 28px 22px;
}

.detail-section + .detail-section {
  border-top: 1px solid var(--line);
}

.detail-section--records {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.inspector-empty {
  min-height: 126px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--ink-soft);
  text-align: center;
  border: 1px dashed rgba(22, 37, 31, 0.18);
  border-radius: var(--r-md);
}

.inspector-empty p {
  margin: 0;
  font-size: 13px;
}

.empty-orbit {
  width: 47px;
  height: 47px;
  display: grid;
  place-items: center;
  color: var(--gold);
  border: 1px solid rgba(216, 168, 79, 0.48);
  border-radius: 50%;
}

.empty-orbit svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
}

.inspector-selected {
  padding: 16px;
  background: rgba(251, 247, 238, 0.58);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.selected-object {
  display: flex;
  align-items: center;
  gap: 14px;
}

.selected-object__visual {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--paper-light);
  border-radius: 50%;
}

.selected-object__visual .ornament-visual {
  width: 48px;
  height: 48px;
}

.selected-object h3 {
  margin: 0 0 5px;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
}

.selected-object p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.object-controls {
  display: grid;
  grid-template-columns: repeat(5, 44px);
  align-items: center;
  gap: 6px;
  margin-top: 14px;
}

.object-controls .tool-button {
  width: 44px;
  height: 44px;
  background: var(--paper-light);
}

.control-divider {
  display: none;
}

.records-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.records-heading span {
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tree-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 20px 0 24px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.tree-stats div {
  padding: 13px 0;
}

.tree-stats div + div {
  padding-left: 13px;
  border-left: 1px solid var(--line);
}

.tree-stats dt {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tree-stats dd {
  margin: 5px 0 0;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.recent-list-wrap {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}

.recent-list-wrap h3 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
}

.recent-list {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.recent-item {
  min-height: 46px;
  border-bottom: 1px solid var(--line);
}

.recent-item button {
  width: 100%;
  min-height: 46px;
  display: grid;
  grid-template-columns: 31px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.recent-item__icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}

.recent-item__icon .ornament-visual {
  width: 27px;
  height: 27px;
}

.recent-item__name {
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-item__time {
  color: var(--ink-soft);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.recent-empty {
  display: grid;
  flex: 1;
  place-items: center;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.confirm-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.save-dialog {
  width: min(540px, calc(100% - 32px));
  max-height: min(780px, calc(100svh - 32px));
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.save-dialog::backdrop {
  background: rgba(3, 16, 13, 0.66);
  backdrop-filter: blur(7px);
}

.save-dialog__panel {
  max-height: min(780px, calc(100svh - 32px));
  padding: 26px;
  overflow-y: auto;
  background: var(--paper-light);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.36);
}

.save-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.save-dialog__head h2 {
  margin: 3px 0 0;
  font-family: var(--display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
}

.save-dialog__kicker {
  margin: 0;
  color: var(--red-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.current-save {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 24px;
  padding: 14px 16px;
  background: var(--pine);
  border-radius: var(--r-md);
  color: var(--paper-light);
}

.current-save__label {
  flex: 0 0 auto;
  color: var(--gold-light);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.current-save strong {
  min-width: 0;
  overflow: hidden;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-save > span:last-child {
  flex: 0 0 auto;
  margin-left: auto;
  color: rgba(251, 247, 238, 0.68);
  font-size: 10px;
}

.save-list-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.save-list-heading h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

.text-button {
  min-height: 44px;
  padding: 0 4px;
  color: var(--pine);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.text-button:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button--danger {
  color: var(--red-deep);
}

.text-button--danger:hover {
  color: var(--red);
}

.save-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.save-item {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  text-align: left;
  cursor: pointer;
  transition:
    background-color var(--m-in) var(--ease),
    border-color var(--m-in) var(--ease),
    transform var(--m-in) var(--ease);
}

.save-item:hover {
  background: #f7f0e4;
  border-color: var(--line);
  transform: translateY(-1px);
}

.save-item[aria-current="true"] {
  background: rgba(23, 75, 56, 0.1);
  border-color: rgba(23, 75, 56, 0.4);
}

.save-item__icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--pine);
  background: var(--paper-light);
  border-radius: 50%;
}

.save-item__icon svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.save-item__copy {
  min-width: 0;
}

.save-item__copy strong,
.save-item__copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-item__copy strong {
  font-size: 13px;
  font-weight: 650;
}

.save-item__copy small {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 10px;
}

.save-item__open {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
}

.save-list-empty {
  margin: 8px 0 0;
  padding: 16px;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}

.new-save-form {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.new-save-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 650;
}

.new-save-form__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.new-save-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 16px;
}

.new-save-form input:focus {
  border-color: var(--pine);
  outline: 2px solid rgba(23, 75, 56, 0.18);
  outline-offset: 1px;
}

.save-dialog__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
}

.confirm-dialog::backdrop {
  background: rgba(3, 16, 13, 0.62);
  backdrop-filter: blur(6px);
}

.confirm-dialog__panel {
  padding: 28px;
  background: var(--paper-light);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.35);
}

.confirm-dialog__icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  color: var(--red);
  background: rgba(191, 64, 56, 0.08);
  border-radius: 50%;
}

.confirm-dialog__icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.confirm-dialog h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
}

.confirm-dialog p {
  margin: 10px 0 24px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition:
    transform var(--m-in) var(--ease),
    background-color var(--m-in) var(--ease),
    border-color var(--m-in) var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px) scale(0.985);
}

.btn--secondary {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.btn--primary {
  color: #fffaf0;
  background: var(--pine);
  border-color: var(--pine);
}

.btn--primary:hover {
  background: #0f3d2e;
  border-color: #0f3d2e;
}

.btn--secondary:hover {
  background: var(--paper);
  border-color: rgba(22, 37, 31, 0.3);
}

.btn--danger {
  color: #fff9f2;
  background: var(--red);
  border-color: var(--red);
}

.btn--danger:hover {
  background: var(--red-deep);
  border-color: var(--red-deep);
}

[hidden] {
  display: none !important;
}

.m-enter .brand,
.m-enter .tree-fact,
.m-enter .topbar__actions {
  opacity: 1;
  transform: translateY(-6px);
  animation: chrome-enter 600ms var(--ease-enter) forwards;
}

.m-enter .tree-fact {
  animation-delay: 70ms;
}

.m-enter .topbar__actions {
  animation-delay: 120ms;
}

.m-enter .palette-panel {
  opacity: 1;
  transform: translateX(-12px);
  animation: panel-enter-left 700ms 120ms var(--ease-enter) forwards;
}

.m-enter .detail-panel {
  opacity: 1;
  transform: translateX(12px);
  animation: panel-enter-right 700ms 160ms var(--ease-enter) forwards;
}

.m-enter .tree-canvas {
  opacity: 1;
  transform: translateX(-50%) scale(0.975);
  animation: tree-enter 900ms 100ms var(--ease-enter) forwards;
}

.m-enter .scene-heading {
  opacity: 1;
  transform: translateY(8px);
  animation: heading-enter 700ms 260ms var(--ease-enter) forwards;
}

@keyframes chrome-enter {
  to {
    transform: translateY(0);
  }
}

@keyframes panel-enter-left {
  to {
    transform: translateX(0);
  }
}

@keyframes panel-enter-right {
  to {
    transform: translateX(0);
  }
}

@keyframes tree-enter {
  to {
    transform: translateX(-50%) scale(1);
  }
}

@keyframes heading-enter {
  to {
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: 220px minmax(0, 1fr) 230px;
  }

  .palette-panel,
  .detail-section {
    padding-right: 18px;
    padding-left: 18px;
  }

  .palette-grid {
    gap: 8px;
  }

  .palette-item__name {
    font-size: 8px;
  }

  .object-controls {
    grid-template-columns: repeat(3, 44px);
  }
}

@media (max-width: 940px) {
  .game-layout {
    grid-template-columns: 216px minmax(0, 1fr);
  }

  .detail-panel {
    display: none;
  }

  .tree-fact {
    margin-left: auto;
  }

  .tree-canvas {
    width: min(108%, 720px);
  }

  .share-button {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .save-button {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .save-button span {
    display: none;
  }

  .share-button span {
    display: none;
  }
}

@media (max-width: 700px) {
  .app-shell {
    grid-template-rows: 58px minmax(0, 1fr);
    min-height: 500px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 0 12px 0 14px;
  }

  .brand {
    gap: 9px;
  }

  .brand__mark {
    width: 34px;
    height: 34px;
  }

  .brand__mark svg {
    width: 20px;
    height: 20px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .brand p {
    display: none;
  }

  .tree-fact {
    position: absolute;
    top: 64px;
    right: 14px;
    left: auto;
    z-index: 22;
    padding: 6px 10px;
    color: var(--snow);
    background: rgba(7, 27, 24, 0.72);
    border-color: rgba(248, 243, 232, 0.18);
    backdrop-filter: blur(10px);
  }

  .tree-fact__label,
  .tree-fact__divider {
    display: none;
  }

  .tree-fact__count {
    color: var(--gold-light);
    font-size: 18px;
  }

  .save-state {
    color: rgba(248, 243, 232, 0.75);
    font-size: 10px;
  }

  .topbar__actions {
    gap: 5px;
  }

  .topbar__actions .icon-button {
    width: 44px;
    height: 44px;
  }

  .share-button {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .save-button {
    min-width: 44px;
    width: 44px;
    padding: 0;
  }

  .save-button span {
    display: none;
  }

  .share-button span {
    display: none;
  }

  .icon-button svg {
    width: 17px;
    height: 17px;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .palette-panel {
    grid-row: 2;
    height: 282px;
    padding: 12px 14px max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .palette-panel .panel-heading {
    align-items: center;
  }

  .palette-panel .panel-step {
    width: 24px;
    height: 24px;
  }

  .palette-panel .panel-heading h2 {
    font-size: 18px;
  }

  .palette-panel .panel-caption {
    display: none;
  }

  .palette-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    margin: 10px 0;
    overflow: hidden;
  }

  .palette-item {
    min-height: 48px;
    aspect-ratio: auto;
    padding: 4px;
    border-radius: 9px;
  }

  .palette-item .ornament-visual {
    max-width: 31px;
    max-height: 31px;
  }

  .palette-item__name {
    display: none;
  }

  .palette-selection {
    display: none;
  }

  .tree-scene {
    grid-row: 1;
  }

  .scene-heading {
    top: 16px;
    left: 16px;
  }

  .scene-heading p {
    margin-bottom: 5px;
    font-size: 9px;
  }

  .scene-heading h2 {
    max-width: 240px;
    font-size: clamp(22px, 7vw, 28px);
  }

  .scene-switcher {
    top: 52px;
    right: 14px;
    bottom: auto;
    padding: 3px;
  }

  .scene-switcher button {
    width: 44px;
    height: 44px;
  }

  .tree-canvas {
    bottom: 0.5%;
    width: min(104%, 560px);
  }

  .stage-status {
    bottom: 10px;
    left: 14px;
    font-size: 10px;
  }

  .has-ornament-selected .stage-status {
    opacity: 0;
  }

  .mobile-transform-bar:not([hidden]) {
    position: absolute;
    right: 14px;
    bottom: 10px;
    left: 14px;
    z-index: 9;
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(5, 44px);
    align-items: center;
    gap: 4px;
    padding: 5px 6px 5px 12px;
    color: var(--ink);
    background: rgba(251, 247, 238, 0.94);
    border: 1px solid rgba(22, 37, 31, 0.12);
    border-radius: 999px;
    box-shadow: 0 12px 30px rgba(2, 14, 11, 0.2);
    backdrop-filter: blur(8px);
  }

  .mobile-transform-bar__name {
    overflow: hidden;
    font-family: var(--display);
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-transform-bar button {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    padding: 0;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
  }

  .mobile-transform-bar button:active {
    background: var(--paper);
    transform: scale(0.96);
  }

  .mobile-transform-bar button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-transform-bar .mobile-transform-bar__danger {
    color: var(--red-deep);
  }

  .has-ornament-selected .toast {
    bottom: 72px;
  }

  .toast {
    bottom: 62px;
    font-size: 12px;
  }
}

@media (max-width: 380px) {
  .palette-panel {
    height: 264px;
  }

  .palette-grid {
    gap: 5px;
  }

  .palette-item {
    min-height: 44px;
  }

  .topbar__actions .icon-button:last-child {
    display: none;
  }

  .tree-canvas {
    width: min(88%, 430px);
  }

  .save-dialog {
    width: calc(100% - 20px);
  }

  .save-dialog__panel {
    padding: 20px;
    border-radius: 16px;
  }

  .current-save {
    flex-wrap: wrap;
  }

  .current-save > span:last-child {
    width: 100%;
    margin-left: 0;
  }

  .new-save-form__row {
    grid-template-columns: 1fr;
  }

  .new-save-form .btn {
    width: 100%;
  }
}

@media (max-height: 660px) and (min-width: 701px) {
  .palette-panel {
    padding-top: 18px;
    padding-bottom: 14px;
  }

  .palette-grid {
    margin: 15px 0;
    gap: 7px;
  }

  .palette-item__name {
    display: none;
  }

  .detail-section {
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .inspector-empty {
    min-height: 92px;
  }

  .tree-stats {
    margin: 13px 0 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .m-enter .brand,
  .m-enter .tree-fact,
  .m-enter .topbar__actions,
  .m-enter .palette-panel,
  .m-enter .detail-panel,
  .m-enter .tree-canvas,
  .m-enter .scene-heading {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .m-enter .tree-canvas {
    transform: translateX(-50%);
  }
}

@media (hover: none), (pointer: coarse) {
  .palette-item:hover,
  .icon-button:hover:not(:disabled),
  .tool-button:hover:not(:disabled),
  .btn:hover {
    transform: none;
  }
}
