@charset "UTF-8";

/* Locked style formula: Hand-painted storybook cartoon with crisp cel-shaded shapes, soft gouache texture, and cinematic family-animation polish. Use rounded, exaggerated silhouettes with clean dark cocoa outlines and tiny handcrafted imperfections. Set the workshop in deep pine, midnight teal, walnut, and brass; keep the elf bright in holly red, peppermint cream, warm skin tones, and emerald, with magical actions signaled by icy cyan and gold. Light everything with cozy amber pools, jewel-toned rim light, and gentle snowy sparkle. Maintain high contrast, readable layers, and a consistent flat-frontal perspective. */

:root {
  color-scheme: dark;
  --midnight: #071b1c;
  --midnight-2: #0b2929;
  --pine-950: #081b16;
  --pine-900: #0e2d24;
  --pine-800: #164534;
  --pine-700: #1d5b43;
  --emerald: #2f8655;
  --holly: #b52d2f;
  --holly-dark: #711b22;
  --berry: #e55343;
  --cream: #fff1cb;
  --cream-2: #f6dca7;
  --paper: #f8e7bd;
  --paper-ink: #382116;
  --walnut: #4c2819;
  --walnut-dark: #2b160f;
  --cocoa: #25150f;
  --brass: #d29a32;
  --brass-light: #ffd878;
  --amber: #efac45;
  --cyan: #7de7e4;
  --cyan-dark: #267e7b;
  --snow: #f5fbf6;
  --ink: #fff5da;
  --muted: #d4c6a6;
  --danger: #ff695b;
  --line: rgba(255, 210, 111, 0.55);
  --glass: rgba(7, 26, 25, 0.9);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.34);
  --cocoa-outline: 0 0 0 2px var(--cocoa);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 9px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Trebuchet MS", Verdana, Arial, sans-serif;
  --ease-spring: cubic-bezier(0.2, 0.9, 0.24, 1.15);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: min(320px, 100%);
  min-height: 100%;
  background: var(--midnight);
  scroll-behavior: smooth;
}

body {
  min-width: min(320px, 100%);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  background:
    radial-gradient(circle at 50% 84%, rgba(239, 172, 69, 0.17), transparent 30%),
    radial-gradient(circle at 12% 18%, rgba(59, 151, 127, 0.15), transparent 25%),
    linear-gradient(145deg, #061719 0%, #0c2b28 48%, #071819 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.42;
  background:
    repeating-linear-gradient(104deg, transparent 0 28px, rgba(255, 255, 255, 0.018) 29px 31px),
    repeating-linear-gradient(8deg, transparent 0 34px, rgba(11, 5, 3, 0.035) 35px 37px);
  mix-blend-mode: soft-light;
}

button,
input {
  font: inherit;
}

button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:not(:disabled) {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(0.55);
}

button,
.item-card,
.name-input {
  transition:
    transform 160ms var(--ease-spring),
    border-color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible,
.item-card:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(125, 231, 228, 0.22);
}

button:active:not(:disabled),
.item-card:active {
  transform: translateY(1px) scale(0.985);
}

[hidden] {
  display: none !important;
}

::selection {
  color: var(--cocoa);
  background: var(--brass-light);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(2, 15, 14, 0.5);
}

::-webkit-scrollbar-thumb {
  border: 2px solid rgba(2, 15, 14, 0.65);
  border-radius: 999px;
  background: linear-gradient(var(--brass), #8c5a1e);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#game-shell {
  position: relative;
  z-index: 1;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  overflow: clip;
}

#game-shell::before,
#game-shell::after {
  position: fixed;
  z-index: -1;
  width: 35vw;
  height: 35vw;
  min-width: 300px;
  min-height: 300px;
  pointer-events: none;
  content: "";
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.13;
}

#game-shell::before {
  top: -16vw;
  left: -10vw;
  background: var(--cyan);
}

#game-shell::after {
  right: -10vw;
  bottom: -18vw;
  background: var(--amber);
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 10px clamp(14px, 2.2vw, 34px);
  border-bottom: 2px solid rgba(255, 210, 111, 0.56);
  background:
    linear-gradient(90deg, rgba(23, 72, 54, 0.92), rgba(8, 31, 28, 0.98) 48%, rgba(38, 32, 20, 0.94)),
    repeating-linear-gradient(0deg, transparent 0 9px, rgba(255, 255, 255, 0.025) 10px 11px);
  box-shadow: 0 9px 28px rgba(0, 0, 0, 0.35), inset 0 -1px rgba(255, 240, 189, 0.13);
}

.topbar::after {
  position: absolute;
  right: 0;
  bottom: -5px;
  left: 0;
  height: 3px;
  content: "";
  opacity: 0.65;
  background: repeating-linear-gradient(90deg, var(--brass) 0 18px, transparent 18px 29px);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
}

.brand-ornament {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid var(--brass);
  border-radius: 50% 46% 52% 44%;
  color: var(--brass-light);
  font-size: 26px;
  background: radial-gradient(circle at 40% 34%, #b7482f, #661c1f 75%);
  box-shadow: var(--cocoa-outline), inset 0 0 0 3px rgba(255, 224, 139, 0.12), 0 5px 15px rgba(0, 0, 0, 0.35);
  transform: rotate(-3deg);
}

.brand-kicker,
.panel-eyebrow,
.certificate-kicker {
  margin-bottom: 2px;
  color: var(--brass-light);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 1.2;
  text-transform: uppercase;
}

.brand-title {
  max-width: 58vw;
  margin: 0;
  padding-block: 0.04em 0.13em;
  overflow: hidden;
  color: var(--cream);
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.14;
  letter-spacing: 0.025em;
  text-overflow: ellipsis;
  text-shadow: 0 2px 0 var(--cocoa), 0 0 15px rgba(255, 196, 78, 0.18);
  white-space: nowrap;
}

.utility-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.utility-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 6px 12px;
  gap: 7px;
  border: 1px solid rgba(242, 204, 114, 0.4);
  border-radius: 999px;
  color: var(--cream);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  background: linear-gradient(180deg, rgba(36, 81, 63, 0.9), rgba(11, 38, 33, 0.95));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 3px 0 rgba(25, 12, 8, 0.5);
}

.utility-btn:hover:not(:disabled),
.utility-btn[aria-pressed="true"] {
  border-color: var(--brass-light);
  color: #fff;
  background: linear-gradient(180deg, #34775a, #184938);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.15), 0 3px 0 rgba(25, 12, 8, 0.5), 0 0 16px rgba(125, 231, 228, 0.13);
  transform: translateY(-1px);
}

.utility-btn > span[aria-hidden="true"],
.utility-icon {
  color: var(--brass-light);
  font-size: 1.1rem;
  line-height: 1;
}

.workspace {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(132px, 164px) minmax(430px, 1fr) minmax(278px, 340px);
  width: min(1580px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: clamp(12px, 1.55vw, 24px);
  gap: clamp(11px, 1.35vw, 20px);
  align-items: stretch;
}

.panel {
  position: relative;
  border: 1px solid rgba(242, 196, 88, 0.57);
  border-radius: var(--radius-lg) var(--radius-xl) var(--radius-lg) var(--radius-xl);
  background:
    linear-gradient(150deg, rgba(18, 58, 47, 0.96), rgba(7, 29, 27, 0.97) 58%, rgba(36, 27, 18, 0.97)),
    repeating-linear-gradient(86deg, transparent 0 16px, rgba(255, 255, 255, 0.025) 17px 18px);
  box-shadow: var(--shadow-soft), inset 0 0 0 2px rgba(36, 18, 12, 0.78), inset 0 0 0 4px rgba(255, 214, 115, 0.08);
}

.panel::before {
  position: absolute;
  inset: 7px;
  z-index: 0;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 225, 145, 0.11);
  border-radius: calc(var(--radius-lg) - 4px) calc(var(--radius-xl) - 4px) calc(var(--radius-lg) - 4px) calc(var(--radius-xl) - 4px);
}

.panel > * {
  position: relative;
  z-index: 1;
}

.panel-title {
  margin: 0;
  color: var(--cream);
  font-family: var(--font-display);
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  line-height: 1.1;
  text-shadow: 0 2px 0 var(--cocoa);
}

.category-rail {
  position: relative;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.category-rail-scroll {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 11px 9px;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: var(--brass) rgba(2, 15, 14, 0.72);
  scroll-padding-block: 11px 62px;
}

.category-rail-scroll::-webkit-scrollbar {
  width: 11px;
  height: 10px;
}

.category-rail-scroll::-webkit-scrollbar-track {
  margin-block: 9px;
  border: 1px solid rgba(255, 216, 120, 0.12);
  border-radius: 999px;
  background: rgba(2, 15, 14, 0.72);
}

.category-rail-scroll::-webkit-scrollbar-thumb {
  min-height: 40px;
  border: 2px solid rgba(2, 15, 14, 0.78);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brass-light), var(--brass) 38%, #8c5a1e);
  background-clip: padding-box;
}

.category-rail-scroll::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #ffe7a1, var(--amber) 48%, #a76422);
  background-clip: padding-box;
}

.category-rail-scroll::-webkit-scrollbar-thumb:active {
  background: var(--amber);
  background-clip: padding-box;
}

.category-rail > .category-scroll-cue {
  position: absolute;
  right: 15px;
  bottom: 4px;
  left: 4px;
  z-index: 4;
  display: grid;
  height: 52px;
  padding-bottom: 8px;
  place-items: end center;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  border-radius: 0 0 12px 17px;
  background:
    radial-gradient(circle at 50% 88%, rgba(239, 172, 69, 0.22), transparent 36%),
    linear-gradient(180deg, transparent, rgba(7, 27, 26, 0.68) 48%, rgba(4, 17, 16, 0.98));
  transform: translateY(4px);
  transition: opacity 180ms ease, visibility 180ms ease, transform 180ms ease;
}

.category-rail > .category-scroll-cue::before {
  position: absolute;
  top: 13px;
  right: 20%;
  left: 20%;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(239, 172, 69, 0.34), transparent);
}

.category-rail > .category-scroll-cue .category-scroll-cue-btn {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  place-items: center;
  pointer-events: auto;
  appearance: none;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(239, 172, 69, 0.14), transparent 66%);
  opacity: 1;
  filter: none;
}

.category-rail > .category-scroll-cue .category-scroll-cue-btn:disabled {
  pointer-events: none;
  opacity: 1;
  filter: none;
}

.category-rail > .category-scroll-cue .category-scroll-cue-btn:hover,
.category-rail > .category-scroll-cue .category-scroll-cue-btn:focus-visible {
  background: radial-gradient(circle, rgba(255, 231, 161, 0.22), transparent 68%);
}

.category-rail > .category-scroll-cue .category-scroll-cue-btn::after {
  width: 13px;
  height: 13px;
  content: "";
  border-right: 3px solid var(--brass-light);
  border-bottom: 3px solid var(--brass-light);
  filter: drop-shadow(0 1px 0 var(--cocoa)) drop-shadow(0 0 5px rgba(239, 172, 69, 0.52));
  transform: translateY(-2px) rotate(45deg) scale(0.92);
  animation: category-scroll-invite 1.65s ease-in-out infinite;
}

.category-rail.can-scroll-down > .category-scroll-cue {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.category-rail > .category-scroll-cue .category-scroll-cue-btn:hover::after,
.category-rail > .category-scroll-cue .category-scroll-cue-btn:focus-visible::after {
  border-color: var(--cream);
}

@keyframes category-scroll-invite {
  0%, 100% {
    opacity: 0.5;
    transform: translateY(-3px) rotate(45deg) scale(0.9);
  }

  48% {
    opacity: 1;
    transform: translateY(4px) rotate(45deg) scale(1.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  .category-rail > .category-scroll-cue .category-scroll-cue-btn::after {
    opacity: 0.92;
    animation: none !important;
    transform: translateY(1px) rotate(45deg);
  }
}

html[data-background-motion="off"] .category-rail > .category-scroll-cue .category-scroll-cue-btn::after,
html[data-motion="gentle"] .category-rail > .category-scroll-cue .category-scroll-cue-btn::after {
  opacity: 0.92;
  animation: none !important;
  transform: translateY(1px) rotate(45deg);
}

@media (forced-colors: active) {
  .category-rail > .category-scroll-cue .category-scroll-cue-btn::after {
    border-color: ButtonText;
    filter: none;
  }
}

.category-btn {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 7px 8px;
  gap: 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 219, 133, 0.25);
  border-radius: 12px 15px 11px 15px;
  color: var(--muted);
  text-align: left;
  background: linear-gradient(140deg, rgba(12, 45, 38, 0.88), rgba(20, 30, 23, 0.92));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.055), 0 3px 0 rgba(27, 14, 8, 0.54);
}

.category-btn::after {
  position: absolute;
  top: 8px;
  right: -13px;
  width: 24px;
  height: calc(100% - 16px);
  content: "";
  border-radius: 50%;
  background: var(--brass);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 150ms ease, transform 150ms ease;
}

.category-btn:hover:not(:disabled):not([aria-pressed="true"]) {
  color: var(--cream);
  border-color: rgba(255, 215, 120, 0.57);
  background: linear-gradient(140deg, rgba(27, 84, 61, 0.94), rgba(19, 49, 39, 0.95));
  transform: translateX(2px);
}

.category-btn.is-active,
.category-btn.active,
.category-btn[aria-current="true"],
.category-btn[aria-pressed="true"] {
  color: #fff7dd;
  border-color: var(--brass-light);
  background: linear-gradient(135deg, #a52c2c 0%, #671d23 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.18), 0 3px 0 var(--cocoa), 0 0 16px rgba(230, 87, 54, 0.18);
}

.category-btn.is-active::after,
.category-btn.active::after,
.category-btn[aria-current="true"]::after,
.category-btn[aria-pressed="true"]::after {
  opacity: 1;
  transform: scale(1);
}

.category-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(255, 221, 139, 0.35);
  border-radius: 50% 46% 52% 44%;
  color: var(--brass-light);
  font-size: 1.12rem;
  line-height: 1;
  background: rgba(3, 24, 21, 0.65);
  box-shadow: inset 0 0 8px rgba(255, 210, 108, 0.08);
}

.category-label {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.025em;
  line-height: 1.1;
  text-overflow: clip;
  text-transform: uppercase;
  white-space: nowrap;
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  gap: 11px;
}

.stage-card {
  position: relative;
  isolation: isolate;
  flex: 1 1 auto;
  min-width: 0;
  min-height: clamp(410px, calc(100svh - 226px), 730px);
  overflow: hidden;
  border: 2px solid var(--brass);
  border-radius: 30px 22px 32px 20px;
  background:
    radial-gradient(ellipse at 50% 78%, rgba(235, 152, 51, 0.38), transparent 31%),
    radial-gradient(circle at 50% 25%, rgba(62, 165, 150, 0.16), transparent 40%),
    linear-gradient(180deg, #0c2c2b 0%, #113b32 48%, #331f15 100%);
  box-shadow: var(--shadow), inset 0 0 0 3px var(--cocoa), inset 0 0 0 5px rgba(255, 225, 140, 0.17);
}

.stage-card::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 18% 82%, rgba(0, 0, 0, 0.22)),
    repeating-linear-gradient(171deg, transparent 0 44px, rgba(255, 255, 255, 0.02) 45px 47px);
  mix-blend-mode: soft-light;
}

.stage-card::after {
  position: absolute;
  right: 8%;
  bottom: 2.5%;
  left: 8%;
  z-index: 1;
  height: 14%;
  pointer-events: none;
  content: "";
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 186, 73, 0.25), rgba(55, 27, 12, 0.24) 56%, transparent 70%);
  filter: blur(1px);
}

#scene-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.buddy-drag-handle {
  position: absolute;
  z-index: 6;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  touch-action: none;
  cursor: grab;
  border: 0;
  border-radius: 44%;
  background: transparent;
  outline: 2px dashed transparent;
  outline-offset: 2px;
  transform: translate(var(--buddy-drag-x, 0), var(--buddy-drag-y, 0));
}

.buddy-drag-handle[hidden] {
  display: none;
}

.buddy-drag-handle:hover {
  outline-color: rgba(255, 220, 132, 0.7);
  background: rgba(125, 231, 228, 0.07);
}

.stage-card.buddy-dragging .buddy-drag-handle {
  cursor: grabbing;
  outline-color: var(--cyan);
  background: rgba(125, 231, 228, 0.12);
}

.buddy-dismiss-hint {
  position: absolute;
  right: 50%;
  bottom: 16px;
  z-index: 12;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  pointer-events: none;
  border: 2px solid var(--cocoa);
  border-radius: 999px;
  color: var(--cocoa);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.055em;
  text-align: center;
  text-transform: uppercase;
  background: linear-gradient(145deg, #fff6d6, #e8c67b);
  box-shadow: 0 0 0 2px rgba(255, 218, 122, 0.55), 0 8px 18px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translate(50%, 10px);
  transition: opacity 140ms ease, transform 180ms var(--ease-spring), background 140ms ease;
}

.stage-card.buddy-dragging .buddy-dismiss-hint {
  opacity: 1;
  transform: translate(50%, 0);
}

.stage-card.buddy-remove-ready {
  border-color: var(--brass-light);
  box-shadow: var(--shadow), inset 0 0 0 3px var(--cocoa), inset 0 0 0 6px rgba(239, 172, 69, 0.3), 0 0 28px rgba(239, 172, 69, 0.34);
}

.stage-card.buddy-remove-ready .buddy-dismiss-hint {
  color: var(--cream);
  border-color: var(--brass-light);
  background: linear-gradient(145deg, #b93436, #741c25);
}

.stage-card.buddy-dragging .speech-bubble {
  opacity: 0;
}

.stage-hud {
  --stage-hud-control-height: 34px;
  position: absolute;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.stage-status-cluster {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  min-width: 0;
  max-width: 70%;
  gap: 6px;
}

.stage-status-cluster .status-pill {
  flex: 0 1 auto;
  min-width: var(--stage-hud-control-height);
  height: var(--stage-hud-control-height);
  min-height: var(--stage-hud-control-height);
  max-width: 100%;
}

#stage-status {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-undo-btn {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  height: var(--stage-hud-control-height);
  min-width: 68px;
  min-height: var(--stage-hud-control-height);
  padding: 4px 11px 4px 9px;
  gap: 6px;
  border: 1px solid rgba(255, 220, 137, 0.45);
  border-radius: 999px;
  color: var(--cream);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  line-height: 1;
  background: rgba(4, 24, 22, 0.94);
  box-shadow: 0 4px 13px rgba(0, 0, 0, 0.25), inset 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: auto;
}

.stage-undo-icon {
  color: var(--brass-light);
  font-size: 1rem;
  line-height: 1;
}

.stage-undo-btn:hover:not(:disabled) {
  border-color: rgba(125, 231, 228, 0.78);
  color: #fff;
  background: linear-gradient(180deg, rgba(34, 88, 70, 0.98), rgba(8, 42, 37, 0.98));
  box-shadow: 0 4px 13px rgba(0, 0, 0, 0.25), inset 0 1px rgba(255, 255, 255, 0.11), 0 0 14px rgba(125, 231, 228, 0.18);
  transform: translateY(-1px);
}

.stage-undo-btn:disabled {
  opacity: 0.42;
  filter: saturate(0.55);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), inset 0 1px rgba(255, 255, 255, 0.05);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 70%;
  padding: 6px 12px 6px 9px;
  gap: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 220, 137, 0.45);
  border-radius: 999px;
  color: var(--cream);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(4, 24, 22, 0.94);
  box-shadow: 0 4px 13px rgba(0, 0, 0, 0.25), inset 0 1px rgba(255, 255, 255, 0.08);
}

.status-pill.is-orb-only {
  max-width: none;
  padding-inline: 9px;
  gap: 0;
}

.status-pill.is-orb-only #stage-status {
  display: none;
}

.status-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 9px var(--cyan);
}


.speech-bubble {
  position: absolute;
  top: 17%;
  left: 7%;
  z-index: 9;
  width: min(220px, 42%);
  padding: 10px 13px;
  border: 2px solid var(--cocoa);
  border-radius: 16px 16px 16px 5px;
  color: var(--paper-ink);
  font-family: var(--font-display);
  font-size: clamp(0.82rem, 1.3vw, 1rem);
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  background: linear-gradient(145deg, #fff8df, #efd59d);
  box-shadow: 0 0 0 2px rgba(255, 227, 153, 0.75), 0 8px 18px rgba(0, 0, 0, 0.28);
  transform-origin: bottom left;
  animation: bubble-float 3.8s ease-in-out infinite;
}

.speech-bubble:empty {
  display: none;
}

.speech-bubble::after {
  position: absolute;
  bottom: -12px;
  left: 16px;
  width: 19px;
  height: 19px;
  content: "";
  border-right: 2px solid var(--cocoa);
  border-bottom: 2px solid var(--cocoa);
  background: #efd59d;
  transform: rotate(45deg) skew(8deg, 8deg);
}

@media (min-width: 721px) {
  .speech-bubble {
    top: clamp(116px, 22.5%, 197px);
    left: 14.5%;
    border-radius: 16px 16px 5px 16px;
    transform-origin: bottom right;
  }

  .speech-bubble::after {
    right: 14px;
    bottom: -11px;
    left: auto;
  }
}

.drop-hint {
  position: relative;
  z-index: 1;
  flex: 0 1 clamp(190px, 31%, 280px);
  max-width: min(50%, 280px);
  margin-right: 6px;
  padding: 7px 34px 7px 13px;
  overflow: visible;
  border: 2px solid var(--cocoa);
  border-radius: 14px 6px 14px 14px;
  color: #4a2418;
  font-size: clamp(0.61rem, 0.75vw, 0.72rem);
  font-weight: 900;
  letter-spacing: 0.045em;
  line-height: 1.2;
  text-align: left;
  text-overflow: clip;
  text-transform: uppercase;
  white-space: normal;
  background: linear-gradient(145deg, #fff7dc, #e9ca83);
  box-shadow: 0 0 0 2px rgba(255, 220, 133, 0.58), 0 7px 18px rgba(0, 0, 0, 0.3);
}

.drop-hint::before {
  position: absolute;
  top: 50%;
  right: 12px;
  content: "\2726";
  color: var(--red);
  font-size: 1rem;
  line-height: 1;
  transform: translateY(-50%);
}

.drop-hint::after {
  position: absolute;
  top: 50%;
  right: -19px;
  content: "\279C";
  color: var(--brass-light);
  font-family: system-ui, sans-serif;
  font-size: 2rem;
  line-height: 1;
  text-shadow: 0 2px 0 var(--cocoa), 0 0 8px rgba(255, 224, 145, 0.65);
  transform: translateY(-50%);
}

.stage-card.drag-over .drop-hint,
.stage-card.is-dragging .drop-hint {
  color: var(--cocoa);
  border-color: var(--cyan);
  background: var(--cyan);
  box-shadow: 0 0 26px rgba(125, 231, 228, 0.5);
}
.stage-card.drag-over .drop-hint::after,
.stage-card.drag-ready .drop-hint::after,
.stage-card.is-dragging .drop-hint::after {
  color: var(--cyan);
}

.stage-card.drag-over {
  border-color: var(--cyan);
  box-shadow: var(--shadow), inset 0 0 0 3px var(--cocoa), inset 0 0 0 6px rgba(125, 231, 228, 0.28), 0 0 28px rgba(125, 231, 228, 0.25);
}

.stage-sparkles {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  overflow: hidden;
}

.stage-sparkles > span {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brass-light);
  box-shadow: 0 0 12px var(--brass-light);
  animation: sparkle-pop 900ms var(--ease-spring) both;
}

.curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 14;
  width: 52%;
  pointer-events: none;
  border-inline: 2px solid var(--brass);
  background:
    repeating-linear-gradient(90deg, rgba(54, 4, 10, 0.12) 0 9%, rgba(255, 109, 78, 0.1) 10% 16%, rgba(49, 4, 10, 0.2) 17% 25%),
    linear-gradient(90deg, #6d1420, #b82d31 48%, #761621);
  box-shadow: inset 0 0 32px rgba(29, 4, 8, 0.7), 0 0 20px rgba(0, 0, 0, 0.4);
  transition: transform 600ms cubic-bezier(0.77, 0, 0.18, 1);
}

.curtain::after {
  position: absolute;
  top: 11%;
  width: 20px;
  height: 42px;
  content: "";
  border: 3px solid var(--cocoa);
  border-radius: 9px;
  background: linear-gradient(90deg, #8c5b1b, var(--brass-light), #8c5b1b);
}

.curtain-left {
  left: 0;
  border-radius: 26px 0 0 28px;
  transform: translateX(-104%);
}

.curtain-left::after {
  right: -8px;
}

.curtain-right {
  right: 0;
  border-radius: 0 20px 28px 0;
  transform: translateX(104%);
}

.curtain-right::after {
  left: -8px;
}

.stage-card.randomizing .curtain,
.randomizing .curtain {
  transform: translateX(0);
}

.stage-card.randomizing #scene-canvas,
.randomizing #scene-canvas {
  filter: saturate(1.25) drop-shadow(0 0 14px rgba(125, 231, 228, 0.33));
  animation: randomize-wobble 170ms ease-in-out infinite alternate;
}

.workbench-controls {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) repeat(3, minmax(0, 1fr));
  align-items: stretch;
  min-width: 0;
  min-height: 58px;
  padding: 8px;
  gap: 8px;
  border: 1px solid rgba(238, 190, 86, 0.58);
  border-radius: 16px 20px 14px 21px;
  background:
    linear-gradient(180deg, rgba(82, 43, 24, 0.98), rgba(43, 24, 16, 0.98)),
    repeating-linear-gradient(90deg, transparent 0 38px, rgba(255, 255, 255, 0.025) 39px 41px);
  box-shadow: inset 0 0 0 2px var(--cocoa), inset 0 1px rgba(255, 234, 174, 0.15), 0 7px 18px rgba(0, 0, 0, 0.3);
}

.workbench-controls::before {
  position: absolute;
  inset: 4px;
  pointer-events: none;
  content: "";
  border: 1px dashed rgba(255, 220, 140, 0.18);
  border-radius: 12px 16px 11px 17px;
}

.magic-btn,
.secondary-btn,
.lock-btn {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 14px;
  gap: 8px;
  overflow: hidden;
  border: 2px solid var(--cocoa);
  border-radius: 12px 14px 11px 15px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.035em;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
  box-shadow: 0 0 0 1px rgba(255, 215, 121, 0.4), inset 0 1px rgba(255, 255, 255, 0.15), 0 4px 0 rgba(24, 11, 7, 0.85);
}

.magic-btn {
  color: #fff8dd;
  border-color: #2b100c;
  background: linear-gradient(160deg, #d54a35 0%, #ad262d 52%, #741b24 100%);
}

.magic-btn::after {
  position: absolute;
  top: -80%;
  left: -45%;
  z-index: -1;
  width: 35%;
  height: 260%;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 239, 181, 0.46), transparent);
  transform: translate3d(0, 0, 0) rotate(18deg);
  animation: magic-shine 4.8s ease-in-out infinite;
}

.magic-btn:hover:not(:disabled) {
  filter: saturate(1.12) brightness(1.08);
  box-shadow: 0 0 0 1px var(--brass-light), inset 0 1px rgba(255, 255, 255, 0.18), 0 5px 0 rgba(24, 11, 7, 0.85), 0 0 20px rgba(255, 93, 65, 0.24);
  transform: translateY(-2px);
}

.secondary-btn,
.lock-btn {
  color: var(--cream);
  background: linear-gradient(160deg, #27654d, #123b31 58%, #0d2b27);
}

.secondary-btn:hover:not(:disabled),
.lock-btn:hover:not(:disabled) {
  border-color: var(--brass-light);
  background: linear-gradient(160deg, #348164, #194b3c 58%, #12352f);
  transform: translateY(-1px);
}

.lever {
  width: 100%;
  justify-content: flex-start;
  min-width: 0;
  padding-left: 56px;
}

.workbench-controls > #surprise-btn,
.workbench-controls > .coming-soon-action,
.workbench-controls > #reset-btn,
.workbench-controls > #finish-btn {
  width: 100%;
  min-width: 0;
  min-height: 48px;
}

.lever-knob {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 25px;
  height: 25px;
  border: 3px solid var(--cocoa);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8670 0 15%, #c92832 35%, #6c101c 78%);
  box-shadow: 0 0 0 2px var(--brass), 0 0 12px rgba(255, 77, 62, 0.4);
  transform: translateY(-50%);
}

.lever-knob::after {
  position: absolute;
  top: 19px;
  left: 8px;
  width: 5px;
  height: 25px;
  content: "";
  border: 1px solid var(--cocoa);
  border-radius: 3px;
  background: linear-gradient(90deg, #80501b, var(--brass-light), #80501b);
  transform: rotate(12deg);
  transform-origin: top;
}

.lever:active:not(:disabled) .lever-knob {
  transform: translate(5px, -44%) rotate(12deg);
}



.finish-btn {
  min-width: 112px;
  background: linear-gradient(160deg, #b47a1f, #88601b 48%, #594319);
}

.wardrobe {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  max-height: calc(100svh - 127px);
  padding: 15px 13px 13px;
  overflow: hidden;
}

.wardrobe-head,
.profile-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 45px;
  margin-bottom: 11px;
  gap: 10px;
}

.wardrobe-magic-sigil {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid #a9fff5;
  border-radius: 50% 44% 52% 46%;
  background:
    radial-gradient(circle at 34% 28%, #effffb 0 9%, #75eee1 10% 28%, #149da0 29% 60%, #07575e 61% 100%);
  box-shadow:
    0 0 0 2px var(--cocoa),
    0 0 0 3px rgba(238, 184, 63, 0.9),
    0 0 15px rgba(75, 226, 218, 0.58),
    inset -4px -5px 8px rgba(3, 48, 52, 0.44);
  transform: rotate(-7deg);
  animation: wardrobe-sigil-float 3.8s ease-in-out infinite;
}

.wardrobe-magic-sigil::before {
  content: "\2726";
  color: #fff4c6;
  font-size: 23px;
  line-height: 1;
  text-shadow: 0 1px 0 #704016, 0 0 8px rgba(255, 231, 139, 0.95);
  animation: wardrobe-sigil-pulse 2.4s ease-in-out infinite;
}

.wardrobe-magic-sigil::after {
  position: absolute;
  top: -3px;
  right: -4px;
  width: 7px;
  height: 7px;
  content: "";
  border-radius: 50%;
  background: var(--brass-light);
  box-shadow: -34px 24px 0 -1px #8ff8ee, -3px 34px 0 -2px #fff4c6;
  animation: wardrobe-sigil-spark 3.1s ease-in-out infinite;
}

@keyframes wardrobe-sigil-float {
  0%, 100% { transform: translateY(0) rotate(-7deg); }
  50% { transform: translateY(-3px) rotate(7deg); }
}

@keyframes wardrobe-sigil-pulse {
  0%, 100% { opacity: 0.82; transform: scale(0.9) rotate(-8deg); }
  50% { opacity: 1; transform: scale(1.12) rotate(8deg); }
}

@keyframes wardrobe-sigil-spark {
  0%, 100% { opacity: 0.35; transform: translate(0, 2px) scale(0.72); }
  48% { opacity: 1; transform: translate(2px, -2px) scale(1.15); }
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  min-height: 164px;
  padding: 4px 3px 12px;
  gap: 9px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.item-card {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  min-height: 122px;
  padding: 8px;
  overflow: hidden;
  border: 1px solid rgba(243, 207, 120, 0.38);
  border-radius: 13px 16px 12px 17px;
  color: var(--cream);
  text-align: left;
  background:
    radial-gradient(circle at 50% 26%, rgba(125, 231, 228, 0.09), transparent 43%),
    linear-gradient(150deg, rgba(27, 74, 57, 0.88), rgba(12, 37, 32, 0.94));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07), 0 4px 0 rgba(30, 15, 9, 0.68);
  user-select: none;
  -webkit-user-drag: element;
}

.item-card::after {
  position: absolute;
  inset: auto -15% -45% 30%;
  z-index: -1;
  height: 70%;
  content: "";
  border-radius: 50%;
  background: rgba(239, 172, 69, 0.11);
  filter: blur(13px);
}

.item-card:hover:not(:disabled) {
  z-index: 2;
  border-color: var(--brass-light);
  background:
    radial-gradient(circle at 50% 26%, rgba(125, 231, 228, 0.16), transparent 45%),
    linear-gradient(150deg, rgba(38, 99, 74, 0.94), rgba(16, 50, 42, 0.97));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 6px 0 rgba(30, 15, 9, 0.66), 0 10px 18px rgba(0, 0, 0, 0.22);
  transform: translateY(-3px) rotate(-0.3deg);
}

.item-card.is-selected,
.item-card.active,
.item-card[aria-pressed="true"],
.item-card[data-selected="true"] {
  color: #fff;
  border-color: var(--cyan);
  background:
    radial-gradient(circle at 50% 28%, rgba(125, 231, 228, 0.23), transparent 43%),
    linear-gradient(150deg, #326e57, #163f35);
  box-shadow: inset 0 0 0 2px rgba(125, 231, 228, 0.16), 0 0 0 2px var(--cocoa), 0 0 16px rgba(125, 231, 228, 0.23);
}

.item-card.is-selected::before,
.item-card[aria-pressed="true"]::before,
.item-card[data-selected="true"]::before {
  position: absolute;
  top: 7px;
  right: 7px;
  z-index: 3;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  content: "\2713";
  border: 2px solid var(--cocoa);
  border-radius: 50%;
  color: var(--cocoa);
  font-size: 0.76rem;
  font-weight: 1000;
  background: var(--cyan);
}
.item-grid[data-category="buddy"] .item-card.is-selected::before,
.item-grid[data-category="buddy"] .item-card[aria-pressed="true"]::before {
  content: "\2212";
  color: var(--cream);
  background: var(--red);
}

.item-card[aria-disabled="true"],
.item-card.is-locked {
  cursor: not-allowed;
  opacity: 0.62;
  filter: grayscale(0.35);
}

.item-icon {
  display: grid;
  width: 100%;
  min-height: 61px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 223, 145, 0.2);
  border-radius: 9px 12px 9px 13px;
  color: var(--brass-light);
  font-size: clamp(1.8rem, 3.5vw, 2.6rem);
  line-height: 1;
  background: radial-gradient(circle, rgba(255, 232, 172, 0.13), rgba(2, 20, 18, 0.4) 70%);
  text-shadow: 0 3px 0 var(--cocoa), 0 0 13px rgba(255, 211, 111, 0.2);
}

.item-icon img,
.item-icon svg,
.item-icon canvas {
  display: block;
  width: 100%;
  height: 61px;
  object-fit: contain;
}

.item-name {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 26px;
  min-height: 26px;
  max-height: 26px;
  margin-top: 6px;
  overflow: visible;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1;
  text-overflow: clip;
  text-wrap: balance;
  overflow-wrap: anywhere;
  white-space: normal;
}

.item-note {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-card {
  flex: 0 0 auto;
  margin-top: 2px;
  padding: 12px;
  border: 1px solid rgba(255, 215, 119, 0.42);
  border-radius: 15px 12px 18px 11px;
  background:
    linear-gradient(145deg, rgba(87, 47, 27, 0.93), rgba(42, 27, 19, 0.97)),
    repeating-linear-gradient(7deg, transparent 0 13px, rgba(255, 255, 255, 0.025) 14px 15px);
  box-shadow: inset 0 0 0 2px rgba(31, 15, 10, 0.65), 0 7px 17px rgba(0, 0, 0, 0.24);
}

.profile-heading {
  min-height: 34px;
  margin-bottom: 8px;
}

.wax-seal {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid #541117;
  border-radius: 48% 54% 45% 56%;
  color: #ffd599;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 900;
  background: radial-gradient(circle at 37% 30%, #df5544, #9d1c27 55%, #68141d 100%);
  box-shadow: inset 0 0 0 3px rgba(92, 13, 18, 0.32), 0 3px 7px rgba(0, 0, 0, 0.36);
  transform: rotate(-7deg);
}

.name-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.name-input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 2px solid var(--cocoa);
  border-radius: 10px 12px 9px 13px;
  color: var(--paper-ink);
  font-family: var(--font-display);
  font-size: 0.96rem;
  font-weight: 800;
  background: linear-gradient(145deg, #fff0c7, #e7c68b);
  box-shadow: 0 0 0 1px rgba(255, 221, 139, 0.5), inset 0 2px 5px rgba(94, 54, 27, 0.1);
}

.name-input::placeholder {
  color: #72553d;
  opacity: 0.72;
}

.name-input:read-only,
.name-input.is-locked {
  color: #4a3426;
  background: linear-gradient(145deg, #d9c196, #bda779);
}

.lock-btn {
  padding-inline: 12px;
  white-space: nowrap;
}

.personality-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 9px;
  gap: 7px;
}

.personality-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  min-height: 46px;
  padding: 7px 8px;
  gap: 7px;
  overflow: hidden;
  border: 1px solid rgba(255, 218, 133, 0.3);
  border-radius: 10px 12px 9px 13px;
  color: var(--cream-2);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.05;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: uppercase;
  background: rgba(7, 36, 31, 0.78);
  box-shadow: 0 3px 0 rgba(25, 12, 8, 0.56);
}

.personality-btn > span:first-child,
.personality-icon {
  flex: 0 0 auto;
  font-size: 1.15rem;
  line-height: 1;
}

.personality-btn:hover:not(:disabled) {
  color: #fff;
  border-color: var(--brass-light);
  background: rgba(31, 90, 68, 0.9);
  transform: translateY(-1px);
}

.personality-btn.is-active,
.personality-btn.active,
.personality-btn[aria-pressed="true"] {
  color: var(--cocoa);
  border-color: #fff3c6;
  background: linear-gradient(145deg, var(--brass-light), var(--brass));
  box-shadow: 0 0 0 2px var(--cocoa), 0 0 15px rgba(255, 205, 98, 0.2);
}

.brand-footer {
  flex-wrap: wrap;
  column-gap: 8px;
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 4px 18px;
  color: #b9aa8d;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

#secret-cookie {
  min-width: 44px;
  min-height: 44px;
  margin: -8px 0 -8px 7px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.1rem;
  background: transparent;
  filter: saturate(0.7);
  opacity: 0.42;
}

#secret-cookie:hover,
#secret-cookie:focus-visible {
  opacity: 1;
  filter: none;
  transform: rotate(10deg) scale(1.08);
}
.copyright-watermark {
  display: inline-flex;
  flex-direction: column;
  margin-left: 12px;
  gap: 0;
  align-items: center;
  color: rgba(255, 240, 204, 0.72);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: none;
  white-space: nowrap;
}

.privacy-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  color: #fff0cc;
  text-underline-offset: 3px;
}

.pfs-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pfs-r {
  font-size: .62em;
  vertical-align: .32em;
  line-height: 0;
  font-weight: 400;
}

.copyright-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.version-watermark {
  color: #fff0cc;
  font-size: 0.58rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  opacity: 0.3;
  text-transform: uppercase;
  white-space: nowrap;
}

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  padding:
    max(clamp(18px, 4vw, 60px), env(safe-area-inset-top))
    max(clamp(18px, 4vw, 60px), env(safe-area-inset-right))
    max(clamp(18px, 4vw, 60px), env(safe-area-inset-bottom))
    max(clamp(18px, 4vw, 60px), env(safe-area-inset-left));
  align-items: center;
  overflow: auto;
  background:
    radial-gradient(circle at 36% 56%, rgba(238, 167, 63, 0.2), transparent 25%),
    radial-gradient(circle at 78% 26%, rgba(45, 134, 102, 0.25), transparent 26%),
    linear-gradient(145deg, rgba(4, 19, 20, 0.98), rgba(8, 42, 38, 0.98) 58%, rgba(32, 21, 15, 0.98));
  transition: opacity 500ms ease, visibility 500ms ease;
}

.intro-overlay::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.35;
  background:
    radial-gradient(circle at 8% 12%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 82% 16%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 24% 70%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 91% 78%, #fff 0 1px, transparent 2px);
  background-size: 140px 160px, 180px 200px, 210px 190px, 260px 230px;
}

.intro-overlay.is-leaving,
.intro-overlay.is-open {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.door-scene {
  /* Auto margins center the card while keeping tall content scrollable. */
  flex-shrink: 0;
  margin-block: auto;
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 0.92fr) minmax(300px, 1.08fr);
  align-items: center;
  width: min(1000px, 100%);
  min-height: min(650px, calc(100svh - 48px));
  padding: clamp(20px, 4vw, 54px);
  gap: clamp(26px, 5vw, 76px);
  border: 1px solid rgba(255, 211, 111, 0.42);
  border-radius: 42px 28px 48px 31px;
  background:
    radial-gradient(circle at 29% 68%, rgba(255, 174, 66, 0.23), transparent 27%),
    linear-gradient(140deg, rgba(19, 68, 54, 0.74), rgba(6, 29, 27, 0.88) 48%, rgba(45, 28, 17, 0.8));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.54), inset 0 0 0 4px rgba(35, 17, 11, 0.7), inset 0 0 0 7px rgba(255, 218, 127, 0.07);
}

.door-scene::before,
.door-scene::after {
  position: absolute;
  width: 86px;
  height: 86px;
  pointer-events: none;
  content: "";
  border-color: var(--brass);
  opacity: 0.72;
}

.door-scene::before {
  top: 12px;
  left: 12px;
  border-top: 2px solid;
  border-left: 2px solid;
  border-radius: 22px 0 0;
}

.door-scene::after {
  right: 12px;
  bottom: 12px;
  border-right: 2px solid;
  border-bottom: 2px solid;
  border-radius: 0 0 26px;
}

.workshop-door {
  position: relative;
  justify-self: center;
  width: min(300px, 75vw);
  aspect-ratio: 0.62;
  border: 9px solid var(--walnut-dark);
  border-radius: 48% 48% 9px 9px / 16% 16% 9px 9px;
  background:
    linear-gradient(90deg, transparent 0 47%, rgba(48, 23, 12, 0.37) 48% 51%, transparent 52%),
    repeating-linear-gradient(90deg, #6d3d22 0 23%, #82502b 24% 47%, #5e331d 48% 70%);
  box-shadow: 0 0 0 3px var(--brass), 0 0 0 8px #2c1710, 0 25px 40px rgba(0, 0, 0, 0.48), inset 0 0 35px rgba(31, 11, 5, 0.7), 0 0 40px rgba(239, 172, 69, 0.11);
  transform-origin: left center;
  transform-style: preserve-3d;
  animation: door-breathe 4.4s ease-in-out infinite;
}

.workshop-door::before {
  position: absolute;
  inset: 28% 8% 9%;
  pointer-events: none;
  content: "";
  border: 3px solid rgba(47, 22, 11, 0.75);
  border-radius: 9px;
  box-shadow: inset 0 0 0 2px rgba(255, 209, 108, 0.17);
}

.workshop-door.is-opening,
.intro-overlay.is-leaving .workshop-door {
  animation: door-open 850ms cubic-bezier(0.5, 0, 0.18, 1) forwards;
}

.door-sign {
  position: absolute;
  top: 7%;
  left: 50%;
  display: grid;
  width: 82%;
  min-height: 84px;
  padding: 10px 12px;
  place-content: center;
  border: 3px solid var(--cocoa);
  border-radius: 10px 14px 9px 15px;
  color: var(--cream);
  text-align: center;
  text-shadow: 0 2px var(--cocoa);
  background: linear-gradient(150deg, #b4312c, #711b24);
  box-shadow: 0 0 0 2px var(--brass), 0 6px 10px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%) rotate(-1.5deg);
}

.door-sign span {
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.door-sign strong {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.5vw, 1.45rem);
  line-height: 1.08;
}

.door-window {
  position: absolute;
  top: 36%;
  left: 50%;
  display: grid;
  width: 42%;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 7px solid var(--cocoa);
  border-radius: 50% 48% 52% 47%;
  color: var(--brass-light);
  font-size: 2rem;
  background: radial-gradient(circle at 50% 70%, #eeb054, #27706c 38%, #092b2c 72%);
  box-shadow: 0 0 0 3px var(--brass), inset 0 0 22px rgba(3, 15, 17, 0.8), 0 0 20px rgba(255, 199, 91, 0.2);
  transform: translateX(-50%);
}

.door-window::before,
.door-window::after {
  position: absolute;
  content: "";
  background: var(--cocoa);
}

.door-window::before {
  width: 6px;
  height: 100%;
}

.door-window::after {
  width: 100%;
  height: 6px;
}

.door-knob {
  position: absolute;
  right: 10%;
  top: 62%;
  width: 27px;
  height: 27px;
  border: 3px solid var(--cocoa);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff0a8, var(--brass) 37%, #744412 75%);
  box-shadow: 0 0 0 2px rgba(255, 217, 118, 0.48), 0 0 14px rgba(255, 201, 87, 0.32);
}

.door-snow {
  position: absolute;
  bottom: clamp(25px, 7vw, 72px);
  left: clamp(25px, 5vw, 64px);
  z-index: 3;
  width: 40%;
  height: 42px;
  pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(245, 251, 246, 0.9), rgba(190, 229, 223, 0.45) 55%, transparent 72%);
  filter: blur(1px);
}

.door-copy {
  position: relative;
  z-index: 3;
  max-width: 470px;
}

.intro-brand {
  display: none;
}

.intro-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-bottom: 14px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 220, 135, 0.58);
  border-radius: 999px;
  color: var(--brass-light);
  font-size: 0.67rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: rgba(73, 37, 20, 0.65);
}

.door-copy h2 {
  margin: 0;
  color: var(--cream);
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.6vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.035em;
  text-wrap: balance;
  text-shadow: 0 4px 0 var(--cocoa), 0 0 28px rgba(255, 195, 82, 0.14);
}

.door-copy p {
  max-width: 42ch;
  margin: 19px 0 24px;
  color: #e7dac0;
  font-size: clamp(0.95rem, 1.5vw, 1.12rem);
  line-height: 1.6;
  text-wrap: pretty;
}

.intro-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.intro-actions .magic-btn {
  min-height: 52px;
  padding-inline: 23px;
  font-size: 0.86rem;
}

.text-btn {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: rgba(255, 215, 117, 0.45);
  text-underline-offset: 4px;
  background: transparent;
}

.text-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  padding: clamp(14px, 3vw, 34px);
  place-items: center;
  overflow: auto;
  background: rgba(1, 13, 14, 0.78);
  backdrop-filter: blur(12px) saturate(0.8);
  animation: modal-backdrop 220ms ease both;
}

.modal-card {
  position: relative;
  width: min(650px, 100%);
  max-height: calc(100svh - 36px);
  max-height: calc(100dvh - 36px);
  padding: clamp(23px, 4vw, 42px);
  overflow: auto;
  border: 2px solid var(--brass);
  border-radius: 27px 21px 31px 19px;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 8%, rgba(255, 204, 100, 0.12), transparent 24%),
    linear-gradient(145deg, #164b3a, #092d2b 50%, #302016 100%);
  box-shadow: var(--shadow), inset 0 0 0 3px var(--cocoa), inset 0 0 0 6px rgba(255, 221, 135, 0.08);
  animation: modal-card-in 300ms var(--ease-spring) both;
}

.modal-card::before {
  position: absolute;
  inset: 10px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 222, 143, 0.12);
  border-radius: 20px 15px 24px 14px;
}

.modal-card > * {
  position: relative;
  z-index: 1;
}

.modal-card h2 {
  margin: 4px 52px 21px 0;
  color: var(--cream);
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  line-height: 1;
  text-shadow: 0 3px var(--cocoa);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 10;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  border: 2px solid var(--brass-light);
  border-radius: 50%;
  color: var(--cream);
  font-size: 0;
  background:
    radial-gradient(circle at 32% 23%, rgba(255, 255, 255, 0.17), transparent 28%),
    linear-gradient(145deg, #ad3437, #7a1d25 56%, #57141b);
  background-clip: padding-box;
  box-shadow:
    0 0 0 2px var(--cocoa),
    inset 0 0 0 1px rgba(74, 18, 20, 0.82),
    inset 0 2px 0 rgba(255, 241, 203, 0.15),
    0 4px 0 rgba(23, 9, 6, 0.78),
    0 8px 16px rgba(0, 0, 0, 0.24);
}

.modal-close::before,
.modal-close::after {
  position: absolute;
  width: 18px;
  height: 3px;
  content: "";
  border-radius: 3px;
  background: currentColor;
  box-shadow: 0 1px 0 rgba(37, 21, 15, 0.55);
}

.modal-close::before {
  transform: rotate(45deg);
}

.modal-close::after {
  transform: rotate(-45deg);
}

.modal-close:hover {
  border-color: #ffe39a;
  filter: brightness(1.08) saturate(1.04);
  transform: none;
}

.modal-close:active:not(:disabled) {
  filter: brightness(0.97);
  transform: none;
  box-shadow:
    0 0 0 2px var(--cocoa),
    inset 0 0 0 1px rgba(74, 18, 20, 0.82),
    inset 0 2px 0 rgba(255, 241, 203, 0.12),
    0 2px 0 rgba(23, 9, 6, 0.78),
    0 4px 8px rgba(0, 0, 0, 0.2);
}

.modal-close:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 4px;
  box-shadow:
    0 0 0 2px var(--cocoa),
    inset 0 0 0 1px rgba(74, 18, 20, 0.82),
    inset 0 2px 0 rgba(255, 241, 203, 0.15),
    0 4px 0 rgba(23, 9, 6, 0.78),
    0 8px 16px rgba(0, 0, 0, 0.24);
}

.help-card {
  width: min(760px, 100%);
}

.help-card h2 {
  margin-right: 52px;
  font-size: clamp(2rem, 3.4vw, 2.55rem);
  letter-spacing: -0.025em;
  white-space: nowrap;
}

.help-steps {
  display: grid;
  gap: 10px;
}

.help-step {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  padding: 11px 12px;
  gap: 13px;
  border: 1px solid rgba(255, 217, 128, 0.22);
  border-radius: 13px;
  background: rgba(5, 30, 27, 0.58);
}

.help-number {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 2px solid var(--brass);
  border-radius: 50%;
  color: #fff4d2;
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(145deg, #ad3438, #6f1c28 72%);
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 210, 0.32),
    0 3px 0 rgba(34, 10, 12, 0.72),
    0 0 0 1px rgba(255, 222, 143, 0.22);
  text-shadow: 0 2px 0 rgba(49, 15, 17, 0.9);
}

@media (max-width: 600px) {
  .help-card h2 {
    max-width: calc(100% - 46px);
    margin-right: 46px;
    font-size: clamp(1.65rem, 8vw, 2.15rem);
    line-height: 1.02;
    white-space: normal;
    text-wrap: balance;
  }

  .help-step {
    grid-template-columns: 42px minmax(0, 1fr);
    padding: 9px 10px;
    gap: 10px;
  }

  .help-number {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
}

.shortcut-note {
  margin-top: 15px;
  padding: 10px 12px;
  border-left: 3px solid var(--cyan);
  border-radius: 0 9px 9px 0;
  color: #d7e8df;
  font-size: 0.78rem;
  background: rgba(34, 101, 82, 0.25);
}

.reveal-card {
  width: min(1040px, 100%);
  text-align: center;
}

.reveal-card h2 {
  margin-right: 0;
}

.reveal-stars {
  margin-bottom: 4px;
  color: var(--brass-light);
  font-size: 1.2rem;
  letter-spacing: 0.42em;
  text-shadow: 0 0 14px rgba(255, 212, 108, 0.46);
}

.reveal-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(330px, 1.28fr);
  align-items: stretch;
  gap: clamp(14px, 2.5vw, 25px);
  text-align: left;
}

.portrait-frame {
  position: relative;
  min-height: 340px;
  padding: 9px;
  border: 3px solid var(--cocoa);
  border-radius: 18px 14px 20px 13px;
  background: linear-gradient(145deg, var(--brass-light), #87581d);
  box-shadow: 0 0 0 2px rgba(255, 222, 132, 0.44), 0 9px 22px rgba(0, 0, 0, 0.3);
}

.portrait-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 320px;
  border: 2px solid var(--cocoa);
  border-radius: 11px;
  background: linear-gradient(180deg, #154d45, #0e2928 62%, #49301c);
  object-fit: contain;
}

.certificate {
  position: relative;
  min-width: 0;
  padding: clamp(22px, 3.4vw, 42px);
  overflow: hidden;
  border: 3px double #8e5c1f;
  border-radius: 10px 15px 9px 16px;
  color: var(--paper-ink);
  background:
    radial-gradient(circle at 12% 15%, rgba(121, 69, 28, 0.08), transparent 24%),
    radial-gradient(circle at 82% 80%, rgba(121, 69, 28, 0.08), transparent 25%),
    linear-gradient(145deg, #fff2c9, #ead09b);
  box-shadow: inset 0 0 0 7px rgba(255, 246, 213, 0.45), 0 10px 24px rgba(0, 0, 0, 0.32);
}

.certificate::before,
.certificate::after {
  position: absolute;
  width: 72px;
  height: 72px;
  content: "";
  border-color: #9d6928;
  opacity: 0.5;
}

.certificate::before {
  top: 12px;
  left: 12px;
  border-top: 2px solid;
  border-left: 2px solid;
  border-radius: 12px 0;
}

.certificate::after {
  right: 12px;
  bottom: 12px;
  border-right: 2px solid;
  border-bottom: 2px solid;
  border-radius: 0 12px;
}

.certificate-brand {
  color: #7e1c23;
  font-size: 0.68rem;
  font-weight: 1000;
  letter-spacing: 0.17em;
  text-align: center;
  text-transform: uppercase;
}

.certificate .certificate-kicker {
  margin-top: 16px;
  color: #7b5a2c;
  text-align: center;
}

.certificate h3 {
  margin: 7px 0 2px;
  color: #4c201b;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 0.95;
  text-align: center;
  text-wrap: balance;
}

.certificate-role {
  margin-bottom: 18px;
  color: #8e2426;
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-style: italic;
  font-weight: 700;
  text-align: center;
}

.certificate dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  margin: 0;
  padding: 12px 0;
  gap: 5px 12px;
  border-top: 1px solid rgba(102, 59, 27, 0.25);
  border-bottom: 1px solid rgba(102, 59, 27, 0.25);
}

.certificate dt {
  color: #7c2724;
  font-weight: 900;
}

.certificate dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.certificate p {
  margin: 15px 0;
  font-family: var(--font-display);
  font-size: 0.93rem;
  line-height: 1.55;
}

.certificate-signature {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 50px;
  gap: 16px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-style: italic;
}

.keepsake-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 20px;
  gap: 8px;
}

.keepsake-actions button {
  min-height: 50px;
}


.magic-card {
  width: min(600px, 100%);
  text-align: center;
}

.magic-card h2 {
  margin-right: 0;
}

.magic-machine {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  margin-bottom: 10px;
  gap: 17px;
  color: var(--brass-light);
  font-size: 2.4rem;
  text-shadow: 0 0 18px rgba(255, 211, 104, 0.38);
}

.magic-machine span:first-child {
  animation: gear-spin 3s linear infinite;
}

.magic-machine span:nth-child(2) {
  color: var(--cyan);
  animation: sparkle-pulse 850ms ease-in-out infinite alternate;
}

.magic-machine span:last-child {
  animation: gear-spin-reverse 2.5s linear infinite;
}

.magic-progress {
  width: 100%;
  height: 16px;
  margin-top: 20px;
  overflow: hidden;
  border: 2px solid var(--cocoa);
  border-radius: 999px;
  background: rgba(0, 15, 15, 0.65);
  box-shadow: 0 0 0 1px rgba(255, 213, 115, 0.43);
}

.magic-progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: repeating-linear-gradient(120deg, var(--cyan-dark) 0 16px, var(--cyan) 16px 31px, var(--brass-light) 31px 45px);
  box-shadow: 0 0 15px rgba(125, 231, 228, 0.43);
  transition: width 400ms ease;
}

.elf-film {
  margin-top: 20px;
  padding: 9px;
  border: 3px solid var(--cocoa);
  border-radius: 15px;
  background: #1d120d;
  box-shadow: 0 0 0 2px var(--brass), 0 8px 20px rgba(0, 0, 0, 0.35);
}

.elf-film canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  background: var(--midnight);
}

.toast {
  position: fixed;
  right: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 2000;
  width: max-content;
  max-width: min(430px, calc(100vw - 30px));
  min-height: 48px;
  padding: 12px 17px;
  border: 1px solid var(--brass-light);
  border-radius: 13px 16px 12px 17px;
  color: var(--cream);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
  background: linear-gradient(145deg, rgba(29, 90, 69, 0.98), rgba(8, 38, 34, 0.98));
  box-shadow: var(--shadow), inset 0 0 0 2px var(--cocoa);
  transform: translateX(50%);
  animation: toast-in 350ms var(--ease-spring) both;
}

.snow-layer {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -24px;
  width: var(--snow-size, 7px);
  height: var(--snow-size, 7px);
  border-radius: 50%;
  background: rgba(242, 255, 251, var(--snow-opacity, 0.72));
  box-shadow: 0 0 7px rgba(219, 255, 249, 0.6);
  animation: snow-fall var(--snow-duration, 9s) linear var(--snow-delay, 0s) infinite;
}

.confetti {
  position: fixed;
  top: -18px;
  left: var(--confetti-left, 50%);
  z-index: 1900;
  width: var(--confetti-width, 9px);
  height: var(--confetti-height, 15px);
  pointer-events: none;
  border: 2px solid rgba(38, 18, 10, 0.38);
  border-radius: 2px 5px 2px 5px;
  background: var(--confetti-color, var(--brass-light));
  box-shadow: 0 0 8px color-mix(in srgb, var(--confetti-color, var(--brass-light)) 55%, transparent);
  animation: confetti-fall var(--confetti-duration, 2.8s) cubic-bezier(0.2, 0.65, 0.4, 1) var(--confetti-delay, 0s) forwards;
}

#dev {
  position: fixed;
  bottom: 8px;
  left: 8px;
  z-index: 3000;
  max-width: min(420px, calc(100vw - 16px));
  padding: 6px 8px;
  border: 1px solid rgba(125, 231, 228, 0.35);
  border-radius: 7px;
  color: #b7f7ed;
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  line-height: 1.35;
  white-space: pre-wrap;
  background: rgba(0, 15, 15, 0.84);
  pointer-events: none;
}

#dev:empty {
  display: none;
}

@keyframes bubble-float {
  0%, 100% { transform: translateY(0) rotate(-0.5deg); }
  50% { transform: translateY(-5px) rotate(0.5deg); }
}

@keyframes sparkle-pop {
  0% { opacity: 0; transform: scale(0) rotate(0deg); }
  45% { opacity: 1; transform: scale(1.4) rotate(90deg); }
  100% { opacity: 0; transform: scale(0.3) rotate(180deg); }
}

@keyframes randomize-wobble {
  from { transform: translateX(-1px) rotate(-0.15deg); }
  to { transform: translateX(1px) rotate(0.15deg); }
}

@keyframes magic-shine {
  0%, 68% { opacity: 0; transform: translate3d(0, 0, 0) rotate(18deg); }
  74% { opacity: 1; }
  88%, 100% { opacity: 0; transform: translate3d(515%, 0, 0) rotate(18deg); }
}

@keyframes door-breathe {
  0%, 100% { box-shadow: 0 0 0 3px var(--brass), 0 0 0 8px #2c1710, 0 25px 40px rgba(0, 0, 0, 0.48), inset 0 0 35px rgba(31, 11, 5, 0.7), 0 0 35px rgba(239, 172, 69, 0.08); }
  50% { box-shadow: 0 0 0 3px var(--brass-light), 0 0 0 8px #2c1710, 0 25px 40px rgba(0, 0, 0, 0.48), inset 0 0 35px rgba(31, 11, 5, 0.7), 0 0 52px rgba(239, 172, 69, 0.19); }
}

@keyframes door-open {
  0% { transform: perspective(900px) rotateY(0deg); filter: brightness(1); }
  55% { filter: brightness(1.3); }
  100% { transform: perspective(900px) rotateY(-82deg); filter: brightness(1.15); }
}

@keyframes modal-backdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96) rotate(-0.4deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0deg); }
}

@keyframes gear-spin {
  to { transform: rotate(360deg); }
}

@keyframes gear-spin-reverse {
  to { transform: rotate(-360deg); }
}

@keyframes sparkle-pulse {
  from { opacity: 0.45; transform: scale(0.72) rotate(-12deg); }
  to { opacity: 1; transform: scale(1.18) rotate(12deg); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(50%, 18px) scale(0.94); }
  to { opacity: 1; transform: translate(50%, 0) scale(1); }
}

@keyframes snow-fall {
  0% { transform: translate3d(0, -20px, 0) rotate(0deg); }
  42% { transform: translate3d(var(--snow-drift, 20px), 43vh, 0) rotate(160deg); }
  100% { transform: translate3d(calc(var(--snow-drift, 20px) * -0.45), 105vh, 0) rotate(360deg); }
}

@keyframes confetti-fall {
  0% { opacity: 0; transform: translate3d(0, -16px, 0) rotate(0deg); }
  8% { opacity: 1; }
  100% { opacity: 0.88; transform: translate3d(var(--confetti-drift, 70px), 108vh, 0) rotate(var(--confetti-spin, 680deg)); }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 124px minmax(400px, 1fr) minmax(250px, 294px);
    gap: 11px;
    padding-inline: 12px;
  }

  .category-rail-scroll {
    padding-inline: 7px;
  }

  .category-btn {
    grid-template-columns: 31px minmax(0, 1fr);
    padding-inline: 6px;
  }

  .category-icon {
    width: 31px;
    height: 31px;
  }

  .category-label {
    font-size: 0.64rem;
  }

  .utility-label {
    display: none;
  }

  .utility-btn {
    width: 44px;
    padding-inline: 0;
  }

  .item-card {
    min-height: 112px;
  }

  .item-icon,
  .item-icon img,
  .item-icon svg,
  .item-icon canvas {
    min-height: 54px;
    height: 54px;
  }

  .personality-grid {
    grid-template-columns: 1fr;
  }

  .personality-btn {
    min-height: 44px;
  }


}

@media (min-width: 961px) and (max-width: 1350px) {
  .drop-hint {
    flex-basis: 148px;
    max-width: 148px;
    margin-right: 16px;
    padding: 7px 27px 7px 9px;
    font-size: 0.56rem;
  }

  .drop-hint::before {
    right: 8px;
  }

  .drop-hint::after {
    right: -24px;
    font-size: 1.75rem;
  }
}

@media (max-width: 960px) {
  body {
    overflow-y: auto;
  }

  #game-shell {
    overflow: visible;
  }

  .workbench-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workbench-controls > #surprise-btn {
    grid-column: auto;
  }

  .workspace {
    grid-template-columns: 122px minmax(0, 1fr);
    align-items: start;
  }

  .category-rail {
    min-height: 560px;
    max-height: calc(100svh - 130px);
  }

  .stage-card {
    min-height: clamp(440px, calc(100svh - 224px), 700px);
  }

  .drop-hint {
    max-width: min(49%, 230px);
    margin-right: 0;
    margin-bottom: 20px;
    padding: 8px 12px;
    text-align: center;
  }

  .drop-hint::before {
    display: none;
  }

  .drop-hint::after {
    top: auto;
    right: 15px;
    bottom: -28px;
    transform: rotate(90deg);
  }

  .wardrobe {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(270px, 0.8fr);
    max-height: none;
    gap: 12px;
  }

  .wardrobe-head {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .item-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 145px;
    max-height: 340px;
  }

  .profile-card {
    align-self: start;
    margin-top: 3px;
  }

  .profile-heading {
    margin-bottom: 8px;
  }

  .reveal-layout {
    grid-template-columns: minmax(190px, 0.65fr) minmax(300px, 1.35fr);
  }
}

@media (max-width: 720px) {
  body {
    font-size: 14px;
  }

  .topbar {
    position: sticky;
    top: 0;
    min-height: 64px;
    padding:
      max(8px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      8px
      max(10px, env(safe-area-inset-left));
  }

  .brand {
    gap: 8px;
  }

  .brand-ornament {
    flex-basis: 42px;
    width: 42px;
    height: 42px;
    font-size: 21px;
  }

  .brand-kicker {
    font-size: 0.56rem;
  }

  .brand-title {
    max-width: calc(100vw - 242px);
    font-size: clamp(1rem, 4.5vw, 1.35rem);
  }

  .utility-actions {
    gap: 4px;
  }

  .utility-btn {
    border-color: rgba(242, 204, 114, 0.26);
    background: rgba(14, 55, 45, 0.85);
  }

  .workspace {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 9px max(9px, env(safe-area-inset-right)) 9px max(9px, env(safe-area-inset-left));
    gap: 9px;
  }

  .category-rail {
    order: 1;
    min-height: 60px;
    max-height: none;
  }

  .category-rail-scroll {
    flex-direction: row;
    height: auto;
    padding: 7px;
    gap: 7px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-padding-block: 0;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }

  .category-rail > .category-scroll-cue {
    display: none;
  }

  .category-btn {
    flex: 0 0 auto;
    grid-template-columns: 31px auto;
    width: auto;
    min-width: 104px;
    min-height: 46px;
    padding: 6px 10px 6px 7px;
    scroll-snap-align: start;
  }

  .category-btn:hover:not(:disabled):not([aria-pressed="true"]) {
    transform: translateY(-1px);
  }

  .category-btn::after {
    top: auto;
    right: 8px;
    bottom: -8px;
    width: calc(100% - 16px);
    height: 12px;
  }

  .category-label {
    max-width: 86px;
    font-size: 0.63rem;
  }

  .stage-wrap {
    order: 2;
    scroll-margin-top: calc(72px + env(safe-area-inset-top));
  }

  .stage-card {
    flex: none;
    min-height: clamp(380px, 57svh, 520px);
    border-radius: 20px 16px 22px 15px;
  }

  .stage-hud {
    align-items: flex-start;
    gap: 6px;
  }

  .stage-status-cluster {
    max-width: 48%;
    gap: 5px;
  }

  .stage-status-cluster .status-pill {
    max-width: 100%;
  }

  .stage-undo-btn {
    width: 44px;
    min-width: 44px;
    padding: 0;
  }

  .stage-undo-btn::after {
    position: absolute;
    inset-block: -5px;
    inset-inline: 0;
    content: "";
  }

  .stage-undo-label {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .status-pill {
    max-width: 45%;
  }

  .drop-hint {
    flex: 0 1 50%;
    max-width: 50%;
    margin-bottom: 16px;
    padding: 6px 9px;
    font-size: 0.61rem;
  }

  .workbench-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 0;
    padding: 7px;
  }

  .lever {
    min-width: 0;
  }

  .workbench-controls > #surprise-btn,
  .workbench-controls > .coming-soon-action,
  .workbench-controls > #reset-btn,
  .workbench-controls > #finish-btn {
    width: 100%;
    min-height: 48px;
  }

  .finish-btn {
    grid-column: auto;
  }

  .wardrobe {
    order: 3;
    display: flex;
    max-height: none;
    padding: 13px 10px 11px;
    scroll-margin-top: calc(72px + env(safe-area-inset-top));
  }

  .wardrobe-head {
    margin-bottom: 7px;
  }

  .item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
  }

  .item-card {
    min-height: 124px;
  }

  .profile-card {
    width: 100%;
  }

  .personality-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand-footer {
    min-height: 52px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .copyright-watermark {
    flex-basis: 100%;
    margin-left: 0;
    font-size: 0.61rem;
  }

  .version-watermark {
    font-size: 0.52rem;
  }

  .door-scene {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 26px 20px;
    gap: 28px;
  }

  .workshop-door {
    width: min(166px, 42vw);
  }

  /* Keep the miniature door decorative; the readable brand lives beside it. */
  .door-sign {
    top: 8%;
    width: 30%;
    min-height: 0;
    aspect-ratio: 1;
    padding: 0;
    border-width: 2px;
    border-radius: 50%;
    transform: translateX(-50%);
  }

  .door-sign span,
  .door-sign strong {
    display: none;
  }

  .door-sign::after {
    content: "✦";
    color: var(--brass-light);
    font-size: clamp(1rem, 5vw, 1.75rem);
    line-height: 1;
  }

  .door-window {
    top: 40%;
    width: 42%;
    border-width: 4px;
    font-size: 1.2rem;
  }

  .door-window::before {
    width: 3px;
  }

  .door-window::after {
    height: 3px;
  }

  .door-knob {
    top: 71%;
    width: 18px;
    height: 18px;
    border-width: 2px;
  }

  .door-snow {
    /* The stacked welcome has no separate floor for this decorative glow. */
    display: none;
  }

  .door-copy {
    justify-self: center;
    text-align: center;
  }

  .door-copy p {
    margin-inline: auto;
  }

  .intro-brand {
    display: block;
    margin-bottom: 12px;
    color: var(--brass-light);
    font-family: var(--font-display);
    font-size: clamp(1.02rem, 3.8vw, 1.3rem);
    font-weight: 800;
    line-height: 1.2;
    text-wrap: balance;
  }

  .intro-badge {
    display: none;
  }

  .intro-actions {
    justify-content: center;
  }

  .reveal-layout {
    grid-template-columns: 1fr;
  }

  .portrait-frame {
    min-height: 300px;
  }

  .portrait-frame canvas {
    min-height: 280px;
    max-height: 55svh;
  }

  .keepsake-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 430px) {
  .topbar {
    gap: 6px;
  }

  .brand-ornament {
    display: none;
  }

  .brand-title {
    max-width: calc(100vw - 202px);
    font-size: 1rem;
  }

  .brand-kicker {
    max-width: calc(100vw - 202px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .utility-actions {
    flex: 0 0 188px;
    justify-content: flex-end;
  }

  .utility-btn {
    width: 44px;
    min-width: 44px;
  }

  .workspace {
    padding-right: max(7px, env(safe-area-inset-right));
    padding-left: max(7px, env(safe-area-inset-left));
  }

  .stage-wrap,
  .wardrobe {
    scroll-margin-top: calc(110px + env(safe-area-inset-top));
  }

  .stage-card {
    min-height: clamp(350px, 52svh, 430px);
  }

  .stage-hud {
    top: 8px;
    right: 10px;
    left: 10px;
  }

  .stage-status-cluster {
    max-width: 46%;
  }

  .status-pill {
    max-width: 44%;
    padding-inline: 8px 10px;
    font-size: 0.66rem;
  }

  .speech-bubble {
    top: 15%;
    left: 4%;
    width: 43%;
    padding: 8px 9px;
    font-size: 0.75rem;
  }

  .drop-hint {
    flex-basis: 52%;
    max-width: 52%;
    padding: 6px 8px;
    font-size: 0.56rem;
  }

  .workbench-controls {
    gap: 7px;
  }

  .workbench-controls button {
    padding-inline: 8px;
    font-size: 0.69rem;
  }

  .lever {
    padding-left: 48px !important;
  }


  .wardrobe {
    border-radius: 15px 19px 15px 20px;
  }

  .item-grid {
    gap: 8px;
  }

  .item-card {
    padding: 7px;
  }

  .item-name {
    font-size: 0.75rem;
  }

  .profile-card {
    padding: 10px;
  }

  .personality-grid {
    gap: 6px;
  }

  .personality-btn {
    font-size: 0.59rem;
  }

  .intro-overlay {
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .door-scene {
    padding: 22px 14px 25px;
    border-radius: 25px 18px 28px 19px;
  }

  .workshop-door {
    width: min(158px, 42vw);
    border-width: 7px;
  }

  .door-sign {
    min-height: 0;
    padding: 0;
  }

  .door-copy h2 {
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .door-copy p {
    margin-block: 14px 17px;
    font-size: 0.86rem;
    line-height: 1.5;
  }

  .modal {
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .modal-card {
    max-height: calc(100svh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 24px 17px;
    border-radius: 19px 15px 21px 14px;
  }

  .modal-close {
    top: 11px;
    right: 11px;
  }

  .modal-card h2 {
    margin-right: 48px;
    font-size: 1.7rem;
  }

  .reveal-card h2,
  .magic-card h2 {
    margin-right: 48px;
  }

  .certificate {
    padding: 24px 17px;
  }

  .certificate h3 {
    font-size: 2rem;
  }

  .certificate dl {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .certificate dd {
    margin-bottom: 5px;
  }

  .keepsake-actions {
    grid-template-columns: 1fr;
  }

  .toast {
    bottom: max(14px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) and (max-height: 700px) and (orientation: portrait) {
  .door-scene {
    padding: 14px 12px 16px;
    gap: 12px;
  }

  .workshop-door {
    width: min(90px, 29vw);
    border-width: 5px;
  }

  .door-sign {
    min-height: 0;
    padding: 0;
  }

  .door-knob {
    width: 14px;
    height: 14px;
  }

  .intro-brand {
    margin-bottom: 10px;
  }

  .intro-badge {
    padding: 7px 12px;
    font-size: 0.58rem;
  }

  .door-copy h2 {
    font-size: clamp(1.65rem, 9vw, 2.15rem);
    line-height: 0.98;
  }

  .door-copy p {
    margin-block: 8px 10px;
    font-size: 0.74rem;
    line-height: 1.35;
  }

  .intro-actions {
    gap: 6px;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .topbar {
    position: relative;
  }

  .stage-card {
    min-height: 360px;
  }

  .door-scene {
    grid-template-columns: 220px 1fr;
    min-height: 480px;
  }

  .workshop-door {
    width: 190px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .snowflake,
  .confetti {
    display: none !important;
  }
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after,
body.motion-reduced *,
body.motion-reduced *::before,
body.motion-reduced *::after,
body[data-motion="reduced"] *,
body[data-motion="reduced"] *::before,
body[data-motion="reduced"] *::after,
html[data-motion="gentle"] *,
html[data-motion="gentle"] *::before,
html[data-motion="gentle"] *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

body.reduce-motion .snowflake,
body.reduce-motion .confetti,
body.motion-reduced .snowflake,
body.motion-reduced .confetti,
body[data-motion="reduced"] .snowflake,
body[data-motion="reduced"] .confetti,
html[data-motion="gentle"] .snowflake,
html[data-motion="gentle"] .confetti {
  display: none !important;
}

@media (forced-colors: active) {
  .modal-close {
    forced-color-adjust: none;
    color: ButtonText;
    border-color: ButtonText;
    background: ButtonFace;
    box-shadow: none;
  }

  .modal-close::before,
  .modal-close::after {
    background: ButtonText;
    box-shadow: none;
  }

  .modal-close:focus-visible {
    outline-color: Highlight;
    box-shadow: none;
  }
}

@media print {
  @page {
    size: portrait;
    margin: 0.45in;
  }

  html,
  body {
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: visible !important;
    color: #26160e;
    background: #fff !important;
  }

  body * {
    visibility: hidden !important;
  }

  .modal:has(.certificate),
  .modal-card:has(.certificate),
  .reveal-layout:has(.certificate) {
    position: static !important;
    display: block !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
  }

  .certificate,
  .certificate * {
    visibility: visible !important;
  }

  .certificate {
    position: fixed !important;
    inset: 0 !important;
    display: block !important;
    width: 100% !important;
    min-height: calc(100vh - 0.9in) !important;
    margin: 0 !important;
    padding: 0.55in !important;
    border: 4px double #7d4f18 !important;
    border-radius: 0 !important;
    color: #2f1a11 !important;
    background: #f8e6b9 !important;
    box-shadow: inset 0 0 0 8px #fff4d3 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .certificate h3 {
    font-size: 38pt;
  }

  .certificate-brand,
  .certificate-role,
  .certificate-kicker,
  .wax-seal {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}
