:root {
  color-scheme: dark;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --glass: rgba(11, 22, 30, 0.46);
  --glass-strong: rgba(8, 17, 24, 0.68);
  --line: rgba(232, 248, 255, 0.2);
  --light: rgba(245, 252, 255, 0.94);
  --gold: #ffc247;
  --cyan: #61dbff;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #78bfd9;
  touch-action: none;
}

body {
  position: fixed;
  inset: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
canvas,
.control-zone {
  touch-action: none;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: 0;
  padding: 0;
  color: inherit;
  background: transparent;
}

#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 255, 255, 0.28), transparent 35%),
    linear-gradient(#70bee0, #437f9e);
}

#game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  outline: none;
}

#game-canvas:active {
  cursor: grabbing;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.icon-button,
.action-button,
.control-zone {
  pointer-events: auto;
}

.icon-button {
  position: absolute;
  z-index: 12;
  top: calc(var(--safe-top) + 14px);
  left: calc(var(--safe-left) + 14px);
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 28%, rgba(255, 255, 255, 0.2), transparent 42%),
    var(--glass);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.22),
    inset 0 1px rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px) saturate(1.25);
  -webkit-backdrop-filter: blur(12px) saturate(1.25);
  transition: transform 120ms ease, background 120ms ease;
}

#back-button {
  z-index: 12;
  color: inherit;
  text-decoration: none;
}

#reset-button {
  left: calc(var(--safe-left) + 76px);
}

.icon-button:active {
  transform: scale(0.9) rotate(-8deg);
  background-color: rgba(255, 194, 71, 0.24);
}

.icon-button svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: var(--light);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#progress-orbs {
  position: absolute;
  z-index: 12;
  top: calc(var(--safe-top) + 15px);
  left: 50%;
  display: flex;
  gap: 9px;
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: var(--glass);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.16),
    inset 0 1px rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateX(-50%);
}

.progress-crystal {
  width: 17px;
  height: 23px;
  opacity: 0.34;
  filter: grayscale(1) brightness(1.2);
  transform: translateY(0) scale(0.92);
  transition:
    opacity 280ms ease,
    filter 280ms ease,
    transform 420ms cubic-bezier(.2, 1.8, .35, 1);
}

.progress-crystal svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.progress-crystal path:first-child {
  fill: rgba(174, 213, 228, 0.56);
  stroke: rgba(255, 255, 255, 0.46);
  stroke-width: 2;
}

.progress-crystal path:last-child {
  fill: rgba(255, 255, 255, 0.12);
}

.progress-crystal.is-lit {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(97, 219, 255, 0.95));
  transform: translateY(-2px) scale(1.07);
}

.progress-crystal.is-lit path:first-child {
  fill: #57d6ff;
  stroke: #dff9ff;
}

.progress-crystal.is-lit path:last-child {
  fill: rgba(255, 255, 255, 0.52);
}

.progress-crystal.is-popping {
  animation: crystal-pop 580ms cubic-bezier(.16, 1.7, .35, 1);
}

@keyframes crystal-pop {
  0% { transform: translateY(0) scale(0.5) rotate(-12deg); }
  42% { transform: translateY(-8px) scale(1.38) rotate(7deg); }
  100% { transform: translateY(-2px) scale(1.07) rotate(0); }
}

#camera-hint {
  position: absolute;
  right: calc(var(--safe-right) + 86px);
  bottom: calc(var(--safe-bottom) + 126px);
  width: 106px;
  height: 58px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 500ms ease, transform 500ms ease;
}

#camera-hint.is-visible {
  opacity: 0.6;
  transform: translateY(0);
  animation: camera-sway 2.2s ease-in-out infinite;
}

#camera-hint svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: rgba(255, 255, 255, 0.86);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

@keyframes camera-sway {
  0%, 100% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
}

#touch-controls {
  position: absolute;
  z-index: 12;
  inset: 0;
}

#joystick {
  position: absolute;
  left: calc(var(--safe-left) + clamp(18px, 4.2vw, 54px));
  bottom: calc(var(--safe-bottom) + clamp(18px, 4.2vw, 48px));
  width: clamp(112px, 17vw, 148px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  opacity: 0.94;
}

.joystick-ring {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, transparent 0 34%, rgba(255, 255, 255, 0.045) 35% 36%, transparent 37%),
    radial-gradient(circle at 38% 28%, rgba(255, 255, 255, 0.18), transparent 36%),
    var(--glass-strong);
  box-shadow:
    0 16px 42px rgba(0, 0, 0, 0.28),
    inset 0 1px rgba(255, 255, 255, 0.12),
    inset 0 -12px 28px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(13px) saturate(1.25);
  -webkit-backdrop-filter: blur(13px) saturate(1.25);
}

#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48%;
  height: 48%;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #ffd675 0, #ffc247 34%, #d88a17 78%, #9a5710 100%);
  box-shadow:
    0 10px 18px rgba(0, 0, 0, 0.32),
    inset 0 2px rgba(255, 255, 255, 0.42),
    inset 0 -7px rgba(112, 56, 6, 0.22),
    0 0 0 7px rgba(255, 194, 71, 0.06);
  transform: translate(-50%, -50%);
  will-change: transform;
}

#joystick.is-active #joystick-knob {
  box-shadow:
    0 12px 22px rgba(0, 0, 0, 0.36),
    inset 0 2px rgba(255, 255, 255, 0.52),
    inset 0 -7px rgba(112, 56, 6, 0.2),
    0 0 0 10px rgba(255, 194, 71, 0.09),
    0 0 28px rgba(255, 194, 71, 0.2);
}

.tick {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0.7;
  border-style: solid;
}

.tick-up {
  left: 50%;
  top: 8px;
  border-width: 0 6px 8px;
  border-color: transparent transparent rgba(255,255,255,.72);
  transform: translateX(-50%);
}

.tick-right {
  right: 8px;
  top: 50%;
  border-width: 6px 0 6px 8px;
  border-color: transparent transparent transparent rgba(255,255,255,.72);
  transform: translateY(-50%);
}

.tick-down {
  left: 50%;
  bottom: 8px;
  border-width: 8px 6px 0;
  border-color: rgba(255,255,255,.72) transparent transparent;
  transform: translateX(-50%);
}

.tick-left {
  left: 8px;
  top: 50%;
  border-width: 6px 8px 6px 0;
  border-color: transparent rgba(255,255,255,.72) transparent transparent;
  transform: translateY(-50%);
}

.action-button {
  position: absolute;
  right: calc(var(--safe-right) + clamp(20px, 5vw, 62px));
  bottom: calc(var(--safe-bottom) + clamp(24px, 5vw, 56px));
  width: clamp(92px, 13.5vw, 122px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: visible;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 27%, rgba(255, 255, 255, 0.52), transparent 25%),
    radial-gradient(circle, #ffca55 0 36%, #e8941d 68%, #a9540c 100%);
  box-shadow:
    0 17px 42px rgba(0, 0, 0, 0.3),
    inset 0 3px rgba(255, 255, 255, 0.36),
    inset 0 -11px rgba(105, 42, 5, 0.25),
    0 0 0 10px rgba(8, 17, 24, 0.3),
    0 0 0 11px rgba(255, 255, 255, 0.13);
  transition: transform 90ms ease, filter 90ms ease;
}

.action-button::after {
  content: "";
  position: absolute;
  inset: -17px;
  border: 2px solid rgba(255, 206, 98, 0.22);
  border-radius: inherit;
  animation: action-pulse 1.8s ease-out infinite;
}

.action-button:active,
.action-button.is-active {
  transform: scale(0.89) translateY(2px);
  filter: saturate(1.25) brightness(1.08);
}

.action-button.is-active::after {
  animation-duration: 0.65s;
  border-color: rgba(255, 236, 180, 0.55);
}

.action-button svg {
  width: 68%;
  height: 68%;
  overflow: visible;
  fill: #fff7df;
  stroke: #fff7df;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 4px rgba(111, 53, 0, 0.35));
}

.action-button svg circle {
  stroke: none;
}

.action-button .jump-arc,
.action-button .jump-tip {
  fill: none;
  stroke-width: 5;
  opacity: 0.82;
}

@keyframes action-pulse {
  0% { transform: scale(0.9); opacity: 0.75; }
  90%, 100% { transform: scale(1.13); opacity: 0; }
}

#respawn-wash,
#white-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

#respawn-wash {
  background: radial-gradient(circle at center, rgba(149, 229, 255, 0.2), rgba(4, 18, 30, 0.9));
  transition: opacity 180ms ease;
}

#respawn-wash.is-visible {
  opacity: 1;
}

#white-flash {
  background: white;
  mix-blend-mode: screen;
}

#white-flash.is-visible {
  animation: white-flash 420ms ease-out;
}

@keyframes white-flash {
  0% { opacity: 0.72; }
  100% { opacity: 0; }
}

@media (hover: hover) and (pointer: fine) {
  #joystick {
    width: 104px;
    left: 22px;
    bottom: 22px;
    opacity: 0.46;
    transition: opacity 180ms ease, transform 180ms ease;
  }

  #joystick:hover,
  #joystick.is-active {
    opacity: 0.92;
    transform: scale(1.03);
  }

  .action-button {
    width: 82px;
    right: 28px;
    bottom: 27px;
    opacity: 0.62;
    transition: opacity 160ms ease, transform 90ms ease, filter 90ms ease;
  }

  .action-button:hover,
  .action-button.is-active {
    opacity: 1;
  }

  #camera-hint {
    right: 68px;
    bottom: 104px;
  }
}

@media (max-width: 680px) {
  .icon-button {
    width: 45px;
    height: 45px;
  }

  #progress-orbs {
    top: calc(var(--safe-top) + 12px);
  }

  #camera-hint {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 820px) {
  #joystick {
    width: min(30vw, 132px);
  }

  .action-button {
    width: min(24vw, 108px);
  }
}

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

/* --------------------------------------------------------------------------
   JELLY CINEMATIC / liquid control language
   -------------------------------------------------------------------------- */
#joystick {
  --joy-angle: 0deg;
  --joy-stretch-x: 1;
  --joy-stretch-y: 1;
  --joy-core-x: 1;
  --joy-core-y: 1;
  --joy-opacity: 0;
  --knob-scale-x: 1;
  --knob-scale-y: 1;
}

.joystick-ring {
  overflow: visible;
  transform-origin: center;
  transition: transform 180ms cubic-bezier(.2,.9,.25,1.2);
}

.joystick-flow,
.joystick-liquid-core {
  position: absolute;
  left: 50%;
  top: 50%;
  pointer-events: none;
  border-radius: 999px;
  transform-origin: center;
  will-change: transform, opacity;
}

.joystick-flow {
  width: 78%;
  height: 35%;
  border: 1px solid rgba(255, 218, 123, 0.55);
  background:
    linear-gradient(90deg, rgba(255, 194, 71, 0), rgba(255, 212, 111, 0.2) 55%, rgba(255, 244, 205, 0.72));
  box-shadow:
    inset -12px 0 20px rgba(255, 197, 76, 0.18),
    14px 0 25px rgba(255, 188, 52, 0.2);
  opacity: var(--joy-opacity);
  transform:
    translate(-50%, -50%)
    rotate(var(--joy-angle))
    scaleX(var(--joy-stretch-x))
    scaleY(var(--joy-stretch-y));
  transition: opacity 130ms ease;
}

.joystick-liquid-core {
  width: 46%;
  height: 46%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: radial-gradient(circle at 37% 28%, rgba(255,255,255,.22), rgba(255,194,71,.06) 55%, transparent 72%);
  opacity: calc(0.18 + var(--joy-opacity));
  transform:
    translate(-50%, -50%)
    rotate(var(--joy-angle))
    scaleX(var(--joy-core-x))
    scaleY(var(--joy-core-y));
}

#joystick-knob {
  transform: translate(-50%, -50%) scaleX(var(--knob-scale-x)) scaleY(var(--knob-scale-y));
  transition: box-shadow 120ms ease, filter 120ms ease;
}

#joystick.is-active .joystick-ring {
  filter: saturate(1.12) brightness(1.04);
}

.action-button {
  --charge-angle: 0deg;
  --liquid-x: 1;
  --liquid-y: 1;
  --action-glow: 0.16;
  isolation: isolate;
}

.action-charge {
  position: absolute;
  inset: -16px;
  z-index: -1;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    rgba(255, 241, 192, 0.85) 0deg,
    rgba(255, 189, 49, 0.72) var(--charge-angle),
    rgba(255, 255, 255, 0.04) var(--charge-angle),
    rgba(255, 255, 255, 0.04) 360deg
  );
  -webkit-mask: radial-gradient(circle, transparent 0 69%, #000 71% 78%, transparent 80%);
  mask: radial-gradient(circle, transparent 0 69%, #000 71% 78%, transparent 80%);
  filter: drop-shadow(0 0 12px rgba(255, 189, 49, var(--action-glow)));
  opacity: 0.78;
  transform: rotate(0.001deg);
}

.action-liquid {
  position: absolute;
  inset: 13%;
  z-index: 0;
  border-radius: 48% 52% 55% 45% / 44% 48% 52% 56%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,.3), transparent 24%),
    linear-gradient(145deg, rgba(255,224,144,.22), rgba(152,70,0,.08));
  box-shadow:
    inset 7px 8px 13px rgba(255,255,255,.09),
    inset -9px -11px 17px rgba(90,34,0,.14);
  transform: scaleX(var(--liquid-x)) scaleY(var(--liquid-y)) rotate(-4deg);
  transition: transform 120ms cubic-bezier(.2,1.25,.3,1), border-radius 180ms ease;
  animation: action-liquid-idle 4.2s ease-in-out infinite;
}

.action-button svg {
  position: relative;
  z-index: 2;
  transition: transform 130ms cubic-bezier(.2,1.3,.3,1), opacity 130ms ease;
}

.action-button.is-active .action-liquid {
  border-radius: 58% 42% 47% 53% / 55% 59% 41% 45%;
}

.action-button[data-mode="climb"] svg,
.action-button[data-mode="hang"] svg {
  transform: translateY(-2px) scaleX(1.08) scaleY(1.16);
}

.action-button[data-mode="mantle"] svg {
  transform: translateY(-4px) rotate(-8deg) scale(1.05);
}

.action-button[data-mode="air"] svg {
  transform: translateY(-3px) scaleY(1.08);
}

.action-button[data-mode="win"] {
  animation: action-win 1.15s ease-in-out infinite;
}

@keyframes action-liquid-idle {
  0%, 100% { border-radius: 48% 52% 55% 45% / 44% 48% 52% 56%; }
  50% { border-radius: 54% 46% 43% 57% / 53% 44% 56% 47%; }
}

@keyframes action-win {
  0%, 100% { filter: hue-rotate(0deg) brightness(1); }
  50% { filter: hue-rotate(18deg) brightness(1.17); }
}

#signal-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.38;
  background:
    linear-gradient(90deg, rgba(89,224,255,.08), transparent 4%, transparent 96%, rgba(255,190,70,.08)),
    linear-gradient(rgba(255,255,255,.045), transparent 5%, transparent 95%, rgba(14,45,58,.08));
  mix-blend-mode: screen;
}

@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .icon-button,
  #progress-orbs,
  .joystick-ring {
    background-color: rgba(8, 17, 24, 0.82);
  }
}

@media (prefers-reduced-motion: reduce) {
  .joystick-flow,
  .joystick-liquid-core,
  .action-liquid {
    transition-duration: 1ms !important;
    animation: none !important;
  }
}

/* Adaptive quality is presented as an intentional visual state, not a failure. */
html[data-art-mode="crystal"] #signal-frame {
  opacity: 0.30;
}

html[data-art-mode="flow"] #signal-frame {
  opacity: 0.46;
  background-size: 100% 100%, 100% 100%, 7px 7px;
  background-image:
    linear-gradient(90deg, rgba(89,224,255,.11), transparent 5%, transparent 95%, rgba(255,190,70,.11)),
    linear-gradient(rgba(255,255,255,.055), transparent 6%, transparent 94%, rgba(14,45,58,.1)),
    radial-gradient(circle at center, rgba(255,255,255,.025) 0 1px, transparent 1.2px);
}

html[data-art-mode="fracture"] #signal-frame {
  opacity: 0.58;
  background-size: 100% 100%, 100% 100%, 5px 5px;
  background-image:
    linear-gradient(90deg, rgba(89,224,255,.15), transparent 6%, transparent 94%, rgba(255,190,70,.15)),
    linear-gradient(rgba(255,255,255,.07), transparent 7%, transparent 93%, rgba(14,45,58,.13)),
    linear-gradient(135deg, rgba(255,255,255,.026) 25%, transparent 25% 75%, rgba(255,255,255,.026) 75%);
  animation: fracture-frame 1.1s steps(2, end) infinite;
}

@keyframes fracture-frame {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(.5px); }
}

@media (prefers-reduced-motion: reduce) {
  html[data-art-mode="fracture"] #signal-frame { animation: none; }
}

/* --------------------------------------------------------------------------
   JELLY CINEMATIC AAA / icon-only character atelier and letterbox director
   -------------------------------------------------------------------------- */
#customize-button {
  left: auto;
  right: calc(var(--safe-right) + 14px);
}

#customize-button svg {
  width: 29px;
  height: 29px;
  stroke-width: 4.2;
}

#customize-button.is-active {
  transform: scale(0.94) rotate(7deg);
  border-color: rgba(133, 235, 255, 0.58);
  background:
    radial-gradient(circle at 36% 28%, rgba(255, 255, 255, 0.31), transparent 42%),
    rgba(23, 105, 126, 0.66);
  box-shadow:
    0 0 0 6px rgba(89, 225, 255, 0.09),
    0 12px 34px rgba(0, 0, 0, 0.28),
    inset 0 1px rgba(255, 255, 255, 0.2);
}

#cinematic-bars {
  --cinematic-bars: 0;
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  overflow: hidden;
}

#cinematic-bars i,
#cinematic-bars b {
  position: absolute;
  left: 0;
  width: 100%;
  height: calc(11.5vh * var(--cinematic-bars));
  min-height: 0;
  display: block;
  background:
    linear-gradient(180deg, rgba(2, 7, 12, 0.99), rgba(3, 9, 14, 0.97));
  box-shadow: 0 0 40px rgba(0, 0, 0, calc(var(--cinematic-bars) * .45));
  will-change: height, transform;
}

#cinematic-bars i {
  top: 0;
  transform: translateY(calc((1 - var(--cinematic-bars)) * -18px));
}

#cinematic-bars b {
  bottom: 0;
  transform: translateY(calc((1 - var(--cinematic-bars)) * 18px));
}

#customizer {
  position: absolute;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 260ms ease, visibility 0s linear 280ms;
}

#customizer::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 36% 44%, rgba(168, 239, 255, 0.12), transparent 34%),
    linear-gradient(90deg, rgba(5, 14, 22, 0.08), rgba(5, 14, 22, 0.14) 50%, rgba(5, 12, 20, 0.64));
  /* Keep the live character razor sharp. A full-screen backdrop blur also
     blurs the character because world and hero share one WebGL canvas. */
  opacity: 0.82;
  transition: opacity 300ms ease;
}

#customizer.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

#customizer.is-open::before {
  opacity: 1;
}

#customizer-stage {
  position: absolute;
  inset: 0 clamp(342px, 31vw, 440px) 0 0;
  z-index: 1;
  pointer-events: auto;
  cursor: ew-resize;
}

#customizer-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  width: 72px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-top-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  opacity: 0.42;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(112, 230, 255, 0.19), transparent);
  filter: drop-shadow(0 0 12px rgba(102, 226, 255, 0.28));
  animation: customizer-orbit-hint 2.8s ease-in-out infinite;
}

#customizer-stage.is-dragging::after {
  opacity: 0.8;
  animation: none;
}

@keyframes customizer-orbit-hint {
  0%, 100% { transform: translateX(-50%) scaleX(.82); opacity: .28; }
  50% { transform: translateX(-50%) scaleX(1.12); opacity: .58; }
}

.customizer-shell {
  position: absolute;
  z-index: 2;
  top: calc(var(--safe-top) + 78px);
  right: calc(var(--safe-right) + 18px);
  bottom: calc(var(--safe-bottom) + 18px);
  width: clamp(318px, 29vw, 416px);
  display: grid;
  grid-template-rows: auto auto minmax(104px, 1fr) auto auto;
  align-content: center;
  gap: clamp(10px, 1.35vh, 16px);
  padding: clamp(15px, 2vw, 22px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(218, 246, 255, 0.24);
  border-radius: 30px;
  background:
    radial-gradient(circle at 17% 4%, rgba(255, 255, 255, 0.15), transparent 28%),
    linear-gradient(155deg, rgba(17, 35, 46, 0.8), rgba(5, 14, 22, 0.88));
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.42),
    inset 0 1px rgba(255, 255, 255, 0.16),
    inset 0 -1px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(22px) saturate(1.28);
  -webkit-backdrop-filter: blur(22px) saturate(1.28);
  transform: translateX(calc(100% + 30px)) scale(.97);
  opacity: 0;
  transition:
    transform 480ms cubic-bezier(.16, 1, .3, 1),
    opacity 260ms ease;
}

#customizer.is-open .customizer-shell {
  transform: translateX(0) scale(1);
  opacity: 1;
}

.customizer-body-row,
.customizer-zone-row,
.customizer-swatch-row,
.customizer-pattern-row,
.customizer-action-row {
  display: grid;
  gap: 9px;
}

.customizer-body-row {
  grid-template-columns: repeat(3, 1fr);
}

.body-choice,
.zone-choice,
.pattern-choice,
.customizer-action,
.customizer-swatch-row button {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(224, 247, 255, 0.14);
  background:
    radial-gradient(circle at 35% 24%, rgba(255, 255, 255, 0.12), transparent 45%),
    rgba(255, 255, 255, 0.045);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.08),
    0 7px 16px rgba(0, 0, 0, 0.12);
  transition:
    transform 150ms cubic-bezier(.2, 1.5, .3, 1),
    border-color 150ms ease,
    background 150ms ease,
    box-shadow 150ms ease;
}

.body-choice:active,
.zone-choice:active,
.pattern-choice:active,
.customizer-action:active,
.customizer-swatch-row button:active {
  transform: scale(.9);
}

.body-choice.is-selected,
.zone-choice.is-selected,
.pattern-choice.is-selected,
.customizer-swatch-row button.is-selected {
  border-color: rgba(148, 237, 255, 0.78);
  background:
    radial-gradient(circle at 42% 30%, rgba(202, 250, 255, 0.22), transparent 46%),
    rgba(74, 204, 230, 0.14);
  box-shadow:
    0 0 0 3px rgba(98, 227, 255, 0.09),
    0 8px 22px rgba(0, 0, 0, 0.2),
    inset 0 1px rgba(255, 255, 255, 0.17);
}

.body-choice {
  height: 78px;
  border-radius: 20px;
}

.body-choice span {
  position: relative;
  width: 31px;
  height: 38px;
  border-radius: 48% 52% 45% 55% / 45% 44% 56% 55%;
  background: linear-gradient(145deg, #fff9ed, #c6e6e9 68%, #84b9c5);
  box-shadow:
    inset 6px 5px 10px rgba(255, 255, 255, 0.52),
    inset -7px -8px 10px rgba(24, 88, 105, 0.16),
    0 8px 15px rgba(0, 0, 0, 0.28);
}

.body-choice span::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -23px;
  width: 36px;
  height: 34px;
  border-radius: 50%;
  background: inherit;
  box-shadow: inherit;
  transform: translateX(-50%);
}

.body-choice span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 50px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.35), transparent 68%);
  transform: translateX(-50%);
  z-index: -1;
}

.body-slim span { transform: scaleX(.72) scaleY(1.08); }
.body-standard span { transform: scale(1); }
.body-chubby span { transform: scaleX(1.28) scaleY(.91); }

.customizer-zone-row {
  grid-template-columns: repeat(4, 1fr);
}

.zone-choice {
  height: 52px;
  border-radius: 16px;
  --zone-color: #f6eee2;
}

.zone-figure {
  position: relative;
  width: 18px;
  height: 25px;
  border-radius: 45% 45% 38% 38%;
  border: 2px solid rgba(225, 247, 255, 0.52);
  background: rgba(176, 211, 219, 0.15);
}

.zone-figure::before,
.zone-figure::after {
  content: "";
  position: absolute;
  display: block;
}

.zone-figure::before {
  left: 50%;
  top: -11px;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(225, 247, 255, 0.52);
  border-radius: 50%;
  background: rgba(176, 211, 219, 0.15);
  transform: translateX(-50%);
}

.zone-figure::after {
  left: -8px;
  top: 4px;
  width: 30px;
  height: 20px;
  border-left: 4px solid rgba(225, 247, 255, 0.52);
  border-right: 4px solid rgba(225, 247, 255, 0.52);
  border-radius: 8px;
}

.zone-head::before,
.zone-body,
.zone-arms::after,
.zone-hands::after,
.zone-legs,
.zone-feet,
.zone-scarf,
.zone-emblem {
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--zone-color), transparent 45%));
}

.zone-head::before { background: var(--zone-color); }
.zone-body { background: var(--zone-color); }
.zone-arms::after { border-color: var(--zone-color); }
.zone-hands::after { border-color: var(--zone-color); border-width: 0 5px; }
.zone-legs { border-bottom: 8px double var(--zone-color); }
.zone-feet { box-shadow: inset 0 -7px var(--zone-color); }
.zone-scarf { box-shadow: inset 0 5px var(--zone-color); }
.zone-emblem::after {
  left: 5px;
  top: 7px;
  width: 6px;
  height: 6px;
  border: 0;
  border-radius: 1px;
  background: var(--zone-color);
  transform: rotate(45deg);
}

.customizer-swatch-row {
  grid-template-columns: repeat(8, 1fr);
  align-content: center;
}

.customizer-swatch-row button {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 27%, rgba(255, 255, 255, .68), transparent 24%),
    var(--swatch, #fff);
  box-shadow:
    inset 0 1px 3px rgba(255, 255, 255, 0.55),
    inset 0 -5px 8px rgba(0, 0, 0, 0.18),
    0 5px 12px rgba(0, 0, 0, 0.24);
}

.customizer-swatch-row button.is-selected::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid rgba(222, 250, 255, 0.92);
  border-radius: inherit;
  box-shadow: 0 0 13px rgba(112, 230, 255, 0.5);
}

.customizer-pattern-row {
  grid-template-columns: repeat(4, 1fr);
}

.pattern-choice {
  height: 48px;
  border-radius: 15px;
  --pattern-color: #f6eee2;
}

.pattern-choice span {
  width: 38px;
  height: 25px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 48% 52% 43% 57% / 52% 43% 57% 48%;
  background-color: var(--pattern-color);
  box-shadow:
    inset 5px 5px 9px rgba(255,255,255,.32),
    inset -6px -6px 10px rgba(0,0,0,.13);
}

.pattern-bands span {
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,.48) 0 4px, transparent 4px 9px);
}

.pattern-bubbles span {
  background-image:
    radial-gradient(circle at 25% 30%, rgba(255,255,255,.68) 0 3px, transparent 3.5px),
    radial-gradient(circle at 67% 58%, rgba(12,40,55,.22) 0 4px, transparent 4.5px),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.42) 0 2px, transparent 2.5px);
}

.pattern-split span {
  background-image: linear-gradient(90deg, transparent 0 48%, rgba(19, 46, 63, 0.32) 50% 100%);
}

.customizer-action-row {
  grid-template-columns: 1fr 1fr 1.28fr;
}

.customizer-action {
  height: 52px;
  border-radius: 17px;
}

.customizer-action svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: rgba(240, 251, 255, 0.9);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.customizer-done {
  border-color: rgba(255, 210, 101, 0.42);
  background:
    radial-gradient(circle at 35% 24%, rgba(255,255,255,.3), transparent 44%),
    linear-gradient(145deg, rgba(255, 202, 83, 0.84), rgba(196, 112, 19, 0.9));
  box-shadow:
    0 10px 24px rgba(0,0,0,.24),
    inset 0 1px rgba(255,255,255,.34),
    inset 0 -6px rgba(89,39,2,.17);
}

.customizer-done svg {
  stroke: #fff8de;
  stroke-width: 7;
  filter: drop-shadow(0 3px 3px rgba(86, 39, 0, .25));
}

html.is-customizing #touch-controls,
html.is-customizing #progress-orbs,
html.is-customizing #reset-button,
html.is-customizing #camera-hint {
  opacity: 0;
  transform: translateY(12px) scale(.96);
  pointer-events: none;
  transition: opacity 180ms ease, transform 240ms ease;
}

html:not(.is-customizing) #touch-controls,
html:not(.is-customizing) #progress-orbs,
html:not(.is-customizing) #reset-button,
html:not(.is-customizing) #camera-hint {
  transition: opacity 220ms ease, transform 300ms cubic-bezier(.2, 1, .3, 1);
}

@media (max-width: 820px), (pointer: coarse) and (orientation: portrait) {
  #customizer-stage {
    inset: 0 0 min(48vh, 430px) 0;
  }

  .customizer-shell {
    top: auto;
    left: calc(var(--safe-left) + 10px);
    right: calc(var(--safe-right) + 10px);
    bottom: calc(var(--safe-bottom) + 9px);
    width: auto;
    max-height: min(48vh, 430px);
    grid-template-columns: .9fr 1.3fr;
    grid-template-rows: auto auto auto;
    gap: 9px 12px;
    padding: 13px;
    border-radius: 25px;
    transform: translateY(calc(100% + 30px)) scale(.98);
  }

  #customizer.is-open .customizer-shell {
    transform: translateY(0) scale(1);
  }

  .customizer-body-row { grid-column: 1; grid-row: 1; }
  .customizer-zone-row { grid-column: 2; grid-row: 1 / span 2; }
  .customizer-swatch-row { grid-column: 1 / -1; grid-row: 3; grid-template-columns: repeat(8, 1fr); }
  .customizer-pattern-row { grid-column: 1; grid-row: 2; }
  .customizer-action-row { grid-column: 2; grid-row: 2; align-self: end; }

  .body-choice { height: 54px; border-radius: 15px; }
  .body-choice span { width: 23px; height: 27px; }
  .body-choice span::before { top: -16px; width: 27px; height: 25px; }
  .zone-choice { height: 43px; border-radius: 13px; }
  .zone-figure { transform: scale(.8); }
  .pattern-choice { height: 42px; border-radius: 13px; }
  .pattern-choice span { width: 31px; height: 20px; }
  .customizer-action { height: 44px; border-radius: 13px; }
  .customizer-action svg { width: 22px; height: 22px; }
}


@media (pointer: coarse) and (orientation: landscape) and (min-width: 821px) {
  #customizer-stage {
    inset: 0 clamp(350px, 37vw, 410px) 0 0;
  }

  .customizer-shell {
    top: calc(var(--safe-top) + 58px);
    right: calc(var(--safe-right) + 12px);
    bottom: calc(var(--safe-bottom) + 12px);
    width: clamp(330px, 35vw, 390px);
    padding: 16px;
    gap: 10px;
    border-radius: 26px;
  }

  .body-choice { height: 70px; }
  .zone-choice { min-height: 50px; }
  .pattern-choice { min-height: 48px; }
  .customizer-action { min-height: 52px; }
}

@media (orientation: portrait) and (max-width: 680px) {
  #customizer-stage {
    inset: 0 0 min(53vh, 440px) 0;
  }

  .customizer-shell {
    max-height: min(53vh, 440px);
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, auto);
    overflow-y: auto;
  }

  .customizer-body-row,
  .customizer-zone-row,
  .customizer-swatch-row,
  .customizer-pattern-row,
  .customizer-action-row {
    grid-column: 1;
    grid-row: auto;
  }

  .customizer-zone-row { grid-template-columns: repeat(8, 1fr); }
  .customizer-swatch-row { grid-template-columns: repeat(8, 1fr); }
  .zone-choice { height: 39px; }
  .zone-figure { transform: scale(.68); }
}

@media (prefers-reduced-motion: reduce) {
  #cinematic-bars i,
  #cinematic-bars b,
  .customizer-shell,
  #customizer,
  #customizer-stage::after {
    transition-duration: 1ms !important;
    animation: none !important;
  }
}

/* --------------------------------------------------------------------------
   BUILDER WORLD AAA — icon-only architecture atelier
   -------------------------------------------------------------------------- */
#builder-button {
  left: auto;
  right: calc(var(--safe-right) + 76px);
}

#builder-button svg {
  width: 28px;
  height: 28px;
  stroke-width: 4.7;
}

#builder-button.is-active {
  transform: scale(.94) rotate(-5deg);
  border-color: color-mix(in srgb, var(--builder-theme, #63ebd4), white 32%);
  background:
    radial-gradient(circle at 34% 27%, rgba(255,255,255,.32), transparent 39%),
    color-mix(in srgb, var(--builder-theme, #63ebd4), rgba(6,23,31,.78) 72%);
  box-shadow:
    0 0 0 6px color-mix(in srgb, var(--builder-theme, #63ebd4), transparent 87%),
    0 14px 34px rgba(0,0,0,.3),
    inset 0 1px rgba(255,255,255,.25);
}

#builder-hud {
  --builder-theme: #63ebd4;
  position: absolute;
  inset: 0;
  z-index: 48;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 0s linear 220ms;
}

#builder-hud.is-open {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.builder-shell {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 17px);
  width: min(900px, calc(100vw - 390px));
  min-width: 560px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  padding: 11px;
  pointer-events: auto;
  border: 1px solid rgba(226,249,255,.22);
  border-radius: 27px;
  background:
    radial-gradient(circle at 13% 0%, color-mix(in srgb, var(--builder-theme), transparent 82%), transparent 34%),
    linear-gradient(150deg, rgba(15,33,43,.76), rgba(5,14,21,.89));
  box-shadow:
    0 24px 70px rgba(0,0,0,.38),
    inset 0 1px rgba(255,255,255,.16),
    inset 0 -1px rgba(0,0,0,.34),
    0 0 38px color-mix(in srgb, var(--builder-theme), transparent 92%);
  backdrop-filter: blur(20px) saturate(1.25);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
  transform: translate(-50%, calc(100% + 34px)) scale(.96);
  opacity: 0;
  transition:
    transform 460ms cubic-bezier(.16,1,.3,1),
    opacity 220ms ease,
    border-color 260ms ease;
}

#builder-hud.is-open .builder-shell {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
}

.builder-palette {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 7px;
}

.builder-piece,
.builder-action,
.builder-theme-row button {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(225,247,255,.14);
  background:
    radial-gradient(circle at 34% 22%, rgba(255,255,255,.14), transparent 43%),
    rgba(255,255,255,.045);
  box-shadow:
    inset 0 1px rgba(255,255,255,.1),
    0 7px 16px rgba(0,0,0,.13);
  transition:
    transform 125ms cubic-bezier(.2,1.55,.3,1),
    background 140ms ease,
    border-color 140ms ease,
    filter 140ms ease,
    opacity 140ms ease;
}

.builder-piece {
  height: clamp(52px, 6.8vw, 68px);
  border-radius: 18px;
}

.builder-piece::after,
.builder-action::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  background: radial-gradient(circle at center, color-mix(in srgb, var(--builder-theme), transparent 70%), transparent 67%);
  transition: opacity 140ms ease;
}

.builder-piece svg,
.builder-action svg,
#builder-progress svg {
  width: 58%;
  height: 58%;
  overflow: visible;
  fill: none;
  stroke: rgba(239,251,255,.9);
  stroke-width: 4.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.3));
  transition: transform 180ms cubic-bezier(.2,1.5,.3,1), stroke 150ms ease;
}

.builder-piece:active,
.builder-action:active,
.builder-theme-row button:active {
  transform: scale(.88);
}

.builder-piece.is-selected,
.builder-theme-row button.is-selected {
  border-color: color-mix(in srgb, var(--builder-theme), white 35%);
  background:
    radial-gradient(circle at 38% 24%, rgba(255,255,255,.24), transparent 45%),
    color-mix(in srgb, var(--builder-theme), rgba(5,19,27,.92) 79%);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--builder-theme), transparent 88%),
    0 8px 22px rgba(0,0,0,.22),
    inset 0 1px rgba(255,255,255,.19);
}

.builder-piece.is-selected::after,
.builder-action:hover::after {
  opacity: .58;
}

.builder-piece.is-selected svg {
  stroke: #efffff;
  transform: translateY(-2px) scale(1.08);
  filter:
    drop-shadow(0 0 7px color-mix(in srgb, var(--builder-theme), transparent 28%))
    drop-shadow(0 4px 7px rgba(0,0,0,.28));
}

.builder-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.builder-theme-row {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  gap: 6px;
}

.builder-theme-row button {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.builder-theme-row button i {
  width: 15px;
  height: 22px;
  clip-path: polygon(50% 0, 100% 34%, 72% 100%, 28% 100%, 0 34%);
  background:
    linear-gradient(90deg, rgba(255,255,255,.15), rgba(255,255,255,.65) 34%, transparent 36%),
    #63ebd4;
  box-shadow: 0 0 11px currentColor;
  filter: drop-shadow(0 0 6px currentColor);
}

.builder-theme-row button[data-build-theme="meadow"] { color: #63ebd4; }
.builder-theme-row button[data-build-theme="meadow"] i { background-color: #63ebd4; }
.builder-theme-row button[data-build-theme="sunstone"] { color: #ffc45f; }
.builder-theme-row button[data-build-theme="sunstone"] i { background-color: #ffc45f; }
.builder-theme-row button[data-build-theme="moonstone"] { color: #73d9ff; }
.builder-theme-row button[data-build-theme="moonstone"] i { background-color: #73d9ff; }

.builder-transform-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(40px, 1fr)) minmax(54px, 1.22fr);
  gap: 6px;
}

.builder-action {
  height: 42px;
  border-radius: 14px;
}

.builder-action svg {
  width: 24px;
  height: 24px;
  stroke-width: 4.5;
}

.builder-action.is-disabled {
  opacity: .28;
  filter: grayscale(1);
}

.builder-remove {
  border-color: rgba(255,173,99,.2);
}

.builder-reset {
  opacity: .72;
}

.builder-place {
  border-color: color-mix(in srgb, var(--builder-theme), white 32%);
  background:
    radial-gradient(circle at 35% 22%, rgba(255,255,255,.32), transparent 42%),
    linear-gradient(145deg,
      color-mix(in srgb, var(--builder-theme), white 8%),
      color-mix(in srgb, var(--builder-theme), #113a36 58%));
  box-shadow:
    0 9px 22px color-mix(in srgb, var(--builder-theme), transparent 80%),
    inset 0 1px rgba(255,255,255,.32),
    inset 0 -5px rgba(0,0,0,.13);
}

.builder-place svg {
  width: 30px;
  height: 30px;
  stroke: white;
}

.builder-place.is-invalid {
  border-color: rgba(255,170,77,.55);
  background:
    radial-gradient(circle at 35% 22%, rgba(255,255,255,.22), transparent 42%),
    linear-gradient(145deg, rgba(228,130,41,.76), rgba(113,51,18,.9));
  filter: saturate(.82);
}

#builder-progress {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 146px);
  display: grid;
  grid-template-columns: repeat(3, 38px);
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(225,248,255,.17);
  border-radius: 17px;
  background: rgba(7,18,25,.58);
  box-shadow: 0 12px 28px rgba(0,0,0,.25), inset 0 1px rgba(255,255,255,.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translate(-50%, 18px) scale(.94);
  opacity: 0;
  transition: transform 400ms cubic-bezier(.16,1,.3,1), opacity 180ms ease;
}

#builder-hud.is-open #builder-progress {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
}

#builder-progress span {
  width: 38px;
  height: 32px;
  display: grid;
  place-items: center;
  opacity: .28;
  filter: grayscale(1);
  transition: opacity 220ms ease, filter 260ms ease, transform 420ms cubic-bezier(.2,1.8,.35,1);
}

#builder-progress span.is-lit {
  opacity: 1;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--builder-theme), transparent 18%));
  transform: translateY(-2px) scale(1.08);
}

#builder-progress span.is-lit svg {
  stroke: color-mix(in srgb, var(--builder-theme), white 35%);
}

#builder-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.72) rotate(45deg);
  transition: opacity 160ms ease, transform 380ms cubic-bezier(.2,1.55,.3,1), filter 160ms ease;
}

#builder-reticle.is-visible {
  opacity: .75;
  transform: translate(-50%, -50%) scale(1) rotate(45deg);
}

#builder-reticle i {
  position: absolute;
  width: 13px;
  height: 13px;
  border-style: solid;
  border-color: color-mix(in srgb, var(--builder-theme), white 35%);
  filter: drop-shadow(0 0 6px var(--builder-theme));
}

#builder-reticle i:nth-child(1) { left: 0; top: 0; border-width: 2px 0 0 2px; }
#builder-reticle i:nth-child(2) { right: 0; top: 0; border-width: 2px 2px 0 0; }
#builder-reticle i:nth-child(3) { right: 0; bottom: 0; border-width: 0 2px 2px 0; }
#builder-reticle i:nth-child(4) { left: 0; bottom: 0; border-width: 0 0 2px 2px; }
#builder-reticle b {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--builder-theme), white 25%);
  box-shadow: 0 0 10px var(--builder-theme);
  transform: translate(-50%, -50%);
}

#builder-reticle.is-invalid {
  filter: hue-rotate(128deg) saturate(1.8);
}

html.builder-active #camera-hint {
  opacity: 0 !important;
}

html.builder-active #progress-orbs {
  opacity: .58;
  transform: translateX(-50%) scale(.92);
}

html.builder-active #jump-button {
  opacity: .74;
}

@media (hover: hover) and (pointer: fine) {
  .builder-piece:hover,
  .builder-action:hover,
  .builder-theme-row button:hover {
    border-color: rgba(225,249,255,.34);
    filter: brightness(1.1);
  }
}

@media (pointer: coarse) and (orientation: landscape) {
  .builder-shell {
    width: calc(100vw - 370px);
    min-width: 570px;
    bottom: calc(var(--safe-bottom) + 10px);
    padding: 9px;
    gap: 7px;
    border-radius: 23px;
  }

  .builder-piece {
    height: 54px;
    border-radius: 15px;
  }

  .builder-controls { gap: 7px; }
  .builder-theme-row { grid-template-columns: repeat(3, 44px); gap: 5px; }
  .builder-theme-row button { width: 44px; height: 44px; border-radius: 12px; }
  .builder-action { min-width: 44px; height: 44px; border-radius: 12px; }
  .builder-transform-row { gap: 5px; grid-template-columns: repeat(7, minmax(44px, 1fr)) minmax(54px, 1.2fr); }
  #builder-progress { bottom: calc(var(--safe-bottom) + 126px); }
}

@media (orientation: portrait), (max-width: 760px) {
  #builder-button { right: calc(var(--safe-right) + 68px); }

  .builder-shell {
    width: calc(100vw - var(--safe-left) - var(--safe-right) - 18px);
    min-width: 0;
    bottom: calc(var(--safe-bottom) + 132px);
    padding: 9px;
    gap: 7px;
    border-radius: 23px;
  }

  .builder-palette { gap: 5px; }
  .builder-piece { height: clamp(42px, 11vw, 55px); border-radius: 14px; }
  .builder-piece svg { width: 62%; height: 62%; stroke-width: 4.6; }
  .builder-controls { grid-template-columns: 1fr; gap: 6px; }
  .builder-theme-row { position: absolute; right: 10px; top: -48px; grid-template-columns: repeat(3, 36px); }
  .builder-theme-row button { width: 36px; height: 36px; border-radius: 12px; }
  .builder-transform-row { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
  .builder-action { height: 38px; border-radius: 11px; }
  .builder-action svg { width: 21px; height: 21px; }
  #builder-progress { bottom: calc(var(--safe-bottom) + 280px); }
  #builder-reticle { top: 40%; }
}

@media (orientation: portrait) and (max-height: 700px) {
  .builder-shell { bottom: calc(var(--safe-bottom) + 102px); }
  #builder-progress { bottom: calc(var(--safe-bottom) + 244px); }
  .builder-piece { height: 42px; }
  .builder-action { height: 34px; }
}

@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .builder-shell,
  #builder-progress {
    background-color: rgba(7,18,25,.94);
  }
}

@media (prefers-reduced-motion: reduce) {
  .builder-shell,
  #builder-progress,
  #builder-reticle,
  .builder-piece,
  .builder-action {
    transition-duration: 1ms !important;
  }
}

/* --------------------------------------------------------------------------
   MOUNTAIN CLIFF ROUTE — icon-only chapter rhythm
   -------------------------------------------------------------------------- */
#course-ribbon {
  --course-progress: 0%;
  --course-color: #ffc55a;
  position: absolute;
  z-index: 12;
  top: calc(var(--safe-top) + 61px);
  left: 50%;
  width: min(286px, 58vw);
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
  transform: translateX(-50%);
  opacity: .88;
  filter: drop-shadow(0 7px 16px rgba(0,0,0,.28));
  transition: opacity 220ms ease, transform 320ms cubic-bezier(.2,1.2,.3,1);
}

#course-ribbon .course-line {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 50%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(232,248,255,.16);
  box-shadow: inset 0 1px rgba(255,255,255,.1);
  transform: translateY(-50%);
}

#course-ribbon .course-line i {
  display: block;
  width: var(--course-progress);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffc45a, #8de9ff 72%, #f8fdff);
  box-shadow: 0 0 12px color-mix(in srgb, var(--course-color), transparent 15%);
  transition: width 260ms cubic-bezier(.22,.82,.22,1);
}

#course-ribbon b {
  position: relative;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(235,249,255,.2);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255,255,255,.23), transparent 35%),
    rgba(8,20,28,.66);
  box-shadow: 0 6px 15px rgba(0,0,0,.2), inset 0 1px rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform: scale(.76);
  opacity: .46;
  transition: transform 360ms cubic-bezier(.2,1.45,.28,1), opacity 220ms ease, border-color 220ms ease, background 220ms ease;
}

#course-ribbon b svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: rgba(233,248,255,.8);
  stroke-width: 4.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#course-ribbon b.is-complete {
  opacity: .9;
  transform: scale(.88);
  border-color: rgba(255,207,104,.54);
  background: rgba(91,55,11,.54);
}

#course-ribbon b.is-active {
  opacity: 1;
  transform: scale(1.08) translateY(-1px);
  border-color: rgba(228,250,255,.8);
  background:
    radial-gradient(circle at 34% 28%, rgba(255,255,255,.42), transparent 32%),
    color-mix(in srgb, var(--course-color), rgba(6,20,30,.78) 72%);
  box-shadow:
    0 0 0 5px color-mix(in srgb, var(--course-color), transparent 84%),
    0 0 18px color-mix(in srgb, var(--course-color), transparent 30%),
    inset 0 1px rgba(255,255,255,.26);
}

html[data-course-stage="base"] #course-ribbon { --course-color: #ffc45a; }
html[data-course-stage="climb"] #course-ribbon { --course-color: #ffb83e; }
html[data-course-stage="sprint"] #course-ribbon { --course-color: #ffce62; }
html[data-course-stage="summit"] #course-ribbon { --course-color: #fff1a3; }
html[data-course-stage="snowboard"] #course-ribbon { --course-color: #68e5ff; }

.action-button[data-mode="sprint"] {
  background:
    radial-gradient(circle at 34% 27%, rgba(255,255,255,.58), transparent 25%),
    radial-gradient(circle, #ffd46c 0 34%, #ed9e22 67%, #9f4f0b 100%);
}

.action-button[data-mode="sprint"] svg {
  transform: rotate(-9deg) scaleX(1.08);
}

.action-button[data-mode="snowboard"] {
  background:
    radial-gradient(circle at 34% 27%, rgba(255,255,255,.68), transparent 25%),
    radial-gradient(circle, #a7f2ff 0 34%, #39b8e4 66%, #17608f 100%);
  box-shadow:
    0 17px 42px rgba(0,0,0,.3),
    inset 0 3px rgba(255,255,255,.42),
    inset 0 -11px rgba(6,49,78,.26),
    0 0 0 10px rgba(8,17,24,.3),
    0 0 0 11px rgba(255,255,255,.13),
    0 0 22px rgba(70,217,255,.3);
}

.action-button[data-mode="snowboard"] svg {
  transform: rotate(-15deg) translateY(-2px) scale(1.04);
}

#builder-button.is-unavailable {
  opacity: .34;
  filter: grayscale(.55) saturate(.55);
}

#builder-button.is-denied {
  animation: builder-denied 480ms cubic-bezier(.2,1.25,.3,1);
}

@keyframes builder-denied {
  0%, 100% { transform: translateX(0) scale(1); }
  20% { transform: translateX(-6px) scale(.9) rotate(-8deg); }
  45% { transform: translateX(5px) scale(.93) rotate(7deg); }
  70% { transform: translateX(-3px) scale(.96) rotate(-3deg); }
}

html[data-course-stage="sprint"] #customize-button,
html[data-course-stage="summit"] #customize-button,
html[data-course-stage="snowboard"] #customize-button {
  opacity: .28;
  pointer-events: none;
}

html[data-course-stage="sprint"] #builder-button,
html[data-course-stage="summit"] #builder-button,
html[data-course-stage="snowboard"] #builder-button {
  opacity: .22;
  pointer-events: none;
  cursor: default;
}

@media (pointer: coarse), (max-width: 760px) {
  #course-ribbon {
    top: calc(var(--safe-top) + 58px);
    width: min(250px, 61vw);
    height: 36px;
  }
  #course-ribbon b { width: 28px; height: 28px; }
  #course-ribbon b svg { width: 18px; height: 18px; stroke-width: 4.5; }
  #progress-orbs { gap: 6px; padding: 7px 11px; }
  .progress-crystal { width: 14px; height: 20px; }
}

html.builder-active #course-ribbon,
html.customizer-active #course-ribbon {
  opacity: .34;
  transform: translateX(-50%) scale(.94);
}

/* First-run guide: one tiny task at a time, without stopping play. */
#tutorial-help-button {
  left: auto;
  right: calc(var(--safe-right) + 138px);
  z-index: 13;
  color: #f7fdff;
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
}

#balance-tutorial {
  position: absolute;
  z-index: 14;
  top: calc(var(--safe-top) + 112px);
  left: 50%;
  width: min(350px, calc(100vw - var(--safe-left) - var(--safe-right) - 28px));
  padding: 13px 14px 14px;
  pointer-events: auto;
  border: 1px solid rgba(239, 251, 255, .34);
  border-radius: 22px;
  color: #f8fdff;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 203, 90, .18), transparent 42%),
    linear-gradient(150deg, rgba(10, 30, 40, .92), rgba(4, 14, 22, .94));
  box-shadow: 0 18px 48px rgba(0, 0, 0, .34), inset 0 1px rgba(255, 255, 255, .14);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  transform: translateX(-50%);
}

#balance-tutorial[hidden] { display: none !important; }

.balance-tutorial-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#balance-tutorial-step {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: #ffe49b;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
}

#balance-tutorial-skip {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 14px;
  color: rgba(241, 250, 255, .8);
  font-size: 12px;
  font-weight: 800;
}

#balance-tutorial-skip:active { background: rgba(255, 255, 255, .1); }

#balance-tutorial-title {
  margin: 2px 0 5px;
  font-size: clamp(21px, 4.2vw, 27px);
  line-height: 1.05;
}

#balance-tutorial-copy {
  margin: 0;
  color: rgba(239, 249, 255, .83);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.35;
}

#balance-tutorial-action {
  width: max-content;
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  color: #17212a;
  background: #ffd365;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: .08em;
}

.tutorial-focus {
  z-index: 13 !important;
  outline: 4px solid rgba(255, 221, 125, .9);
  outline-offset: 7px;
  animation: tutorial-focus-pulse 1.25s ease-in-out infinite;
}

/* Keep each first-run beat legible: only the control needed now stays live. */
html[data-balance-tutorial-step] #reset-button,
html[data-balance-tutorial-step] #customize-button,
html[data-balance-tutorial-step] #builder-button,
html[data-balance-tutorial-step] #joystick,
html[data-balance-tutorial-step] #jump-button,
html[data-balance-tutorial-step] #course-ribbon,
html[data-balance-tutorial-step] #progress-orbs {
  opacity: .2 !important;
  filter: saturate(.25) brightness(.76);
  pointer-events: none !important;
  transition: opacity 180ms ease, filter 180ms ease, transform 180ms ease;
}

html[data-balance-tutorial-step="0"] #joystick,
html[data-balance-tutorial-step="1"] #jump-button,
html[data-balance-tutorial-step="2"] #builder-button,
html[data-balance-tutorial-step="2"] #course-ribbon {
  opacity: 1 !important;
  filter: none;
  pointer-events: auto !important;
}

@keyframes tutorial-focus-pulse {
  0%, 100% { outline-color: rgba(255, 221, 125, .58); }
  50% { outline-color: rgba(255, 245, 205, 1); }
}

@media (orientation: portrait), (max-width: 760px) {
  #tutorial-help-button { right: calc(var(--safe-right) + 126px); }
  #balance-tutorial { top: calc(var(--safe-top) + 106px); }
}

@media (orientation: landscape) and (max-height: 700px) {
  #balance-tutorial {
    top: calc(var(--safe-top) + 103px);
    width: min(330px, 38vw);
    padding: 10px 12px 11px;
  }
  #balance-tutorial-title { font-size: 20px; }
  #balance-tutorial-copy { font-size: 13px; }
  #balance-tutorial-action { margin-top: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  .tutorial-focus { animation: none; }
}
