    :root {
      --bg-base: #06070a;
      --surface-1: #0e1015;
      --surface-2: #161820;
      --surface-3: #1f232d;
      --border-subtle: #232733;
      --border-focus: #3b4255;
      --text-primary: #f3f5f8;
      --text-secondary: #8c93a4;
      --text-muted: #525868;
      --accent-blue: #3b82f6;
      --accent-gold: #f59e0b;
      --accent-crimson: #e11d48;
      --accent-soft: rgba(59, 130, 246, 0.15);
      --indicator-live: #10b981;
      --indicator-standby: #eab308;
      --font-mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
      --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    }

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

    html, body {
      width: 100%;
      height: 100%;
      overflow: hidden;
      background: var(--bg-base);
      color: var(--text-primary);
      font-family: var(--font-sans);
      touch-action: manipulation;
    }

    #stage-container {
      touch-action: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      width: 100%;
      height: 100%;
      height: 100dvh;
      display: flex;
      align-items: center;
      justify-content: center;
      background: radial-gradient(circle at 50% 50%, #11141c 0%, #06070a 85%);
      overflow: hidden;
    }

    /* Calibrated Camera Display Frame (Lustra 100% Zero-Crop Preservation) */
    #viewport-frame {
      touch-action: none;
      position: relative;
      width: 100%;
      height: 100%;
      display: block;
      overflow: hidden;
    }

    #render-surface {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: block;
      z-index: 1;
    }

    #vector-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      display: block;
      pointer-events: none;
      z-index: 2;
    }

    /* HUD Chrome */
    .hud-layer {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      pointer-events: none;
      z-index: 10;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      box-sizing: border-box;
      padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    }

    .interactive {
      pointer-events: auto;
    }

    /* Top Navigation Bar */
    .top-bar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 100%;
    }

    .brand-block {
      display: flex;
      flex-direction: column;
      gap: 2px;
      cursor: pointer;
    }

    .brand-title {
      font-family: var(--font-mono);
      font-size: 14px;
      font-weight: 700;
      letter-spacing: 0.18em;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .status-dot {
      width: 7px;
      height: 7px;
      border-radius: 50%;
      background: var(--indicator-live);
      transition: background 0.2s ease;
    }

    .status-dot.standby {
      background: var(--indicator-standby);
    }

    .brand-tag {
      font-family: var(--font-mono);
      font-size: 9px;
      letter-spacing: 0.1em;
      color: var(--text-muted);
      text-transform: uppercase;
    }

    .top-actions {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .btn-icon {
      width: 40px;
      height: 40px;
      border-radius: 7px;
      background: rgba(14, 16, 21, 0.90);
      border: 1px solid var(--border-subtle);
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      backdrop-filter: blur(14px);
      -webkit-backdrop-filter: blur(14px);
      transition: all 0.15s ease;
    }

    .btn-icon:hover {
      background: var(--surface-2);
      color: var(--text-primary);
      border-color: var(--border-focus);
    }

    .btn-icon.active {
      color: #93c5fd;
      border-color: var(--accent-blue);
      background: var(--accent-soft);
    }

    .btn-icon svg {
      width: 18px;
      height: 18px;
      fill: none;
      stroke: currentColor;
      stroke-width: 1.8;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

    /* Scene Category Tabs */
    .scene-selector {
      display: flex;
      justify-content: center;
      width: 100%;
      margin-bottom: 2px;
      flex-shrink: 0;
    }

    .scene-pill {
      touch-action: pan-x;
      -webkit-overflow-scrolling: touch;
      flex-shrink: 0;
      background: rgba(14, 16, 21, 0.92);
      border: 1px solid var(--border-subtle);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border-radius: 24px;
      padding: 3px;
      display: flex;
      gap: 3px;
      max-width: 100%;
      overflow-x: auto;
      scrollbar-width: none;
    }

    .scene-pill::-webkit-scrollbar {
      display: none;
    }

    .scene-btn {
      background: transparent;
      border: 1px solid transparent;
      color: var(--text-secondary);
      padding: 7px 13px;
      font-family: var(--font-mono);
      font-size: 10px;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      border-radius: 20px;
      cursor: pointer;
      white-space: nowrap;
      transition: all 0.15s ease;
    }

    .scene-btn.active {
      background: var(--surface-3);
      color: var(--text-primary);
      border-color: var(--border-focus);
    }

    /* Bottom Control Bar */
    .bottom-bar {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 5px;
      width: 100%;
      max-width: 100%;
      box-sizing: border-box;
      padding-bottom: max(6px, env(safe-area-inset-bottom));
      flex-shrink: 0;
      z-index: 20;
    }

    .dock-container {
      background: rgba(14, 16, 21, 0.94);
      border: 1px solid var(--border-subtle);
      backdrop-filter: blur(18px);
      -webkit-backdrop-filter: blur(18px);
      border-radius: 10px;
      padding: 4px;
      display: flex;
      gap: 4px;
      max-width: 100%;
      overflow-x: auto;
      overflow-y: hidden;
      scrollbar-width: none;
      -webkit-overflow-scrolling: touch;
      touch-action: pan-x;
      align-items: center;
      flex-shrink: 0;
    }

    .dock-container::-webkit-scrollbar {
      display: none;
    }

    .filter-tab {
      background: transparent;
      border: 1px solid transparent;
      color: var(--text-secondary);
      padding: 8px 12px;
      font-family: var(--font-mono);
      font-size: 10px;
      font-weight: 600;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      cursor: pointer;
      border-radius: 6px;
      white-space: nowrap;
      transition: all 0.15s ease;
    }

    .filter-tab:hover {
      color: var(--text-primary);
      background: rgba(255, 255, 255, 0.04);
    }

    .filter-tab.active {
      background: var(--surface-2);
      border-color: var(--border-focus);
      color: #93c5fd;
    }

    /* Color Swatches (Hair & Lipstick) */
    .swatch-group {
      display: flex;
      gap: 8px;
      align-items: center;
      padding: 4px 8px;
    }

    .swatch-label {
      font-family: var(--font-mono);
      font-size: 9px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--text-muted);
      margin-right: 4px;
    }

    .swatch {
      width: 26px;
      height: 26px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 0.2);
      cursor: pointer;
      position: relative;
      flex-shrink: 0;
      transition: transform 0.15s ease, border-color 0.15s;
    }

    .swatch:hover, .swatch.active {
      transform: scale(1.18);
      border-color: #ffffff;
    }

    .swatch.none::after {
      content: "";
      position: absolute;
      top: 50%;
      left: 10%;
      right: 10%;
      height: 2px;
      background: #ef4444;
      transform: rotate(45deg);
    }

    /* Game and Spell Badges */
    .status-badge {
      position: absolute;
      top: 70px;
      left: 50%;
      transform: translateX(-50%);
      background: rgba(14, 16, 21, 0.90);
      border: 1px solid var(--border-subtle);
      backdrop-filter: blur(14px);
      padding: 6px 18px;
      border-radius: 20px;
      font-family: var(--font-mono);
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.1em;
      color: #93c5fd;
      text-transform: uppercase;
      pointer-events: none;
      z-index: 10;
      display: none;
    }

    /* Slide-out Settings Drawer */
    .settings-drawer {
      position: absolute;
      top: 0;
      right: -360px;
      width: 340px;
      height: 100%;
      background: rgba(14, 16, 21, 0.97);
      border-left: 1px solid var(--border-subtle);
      backdrop-filter: blur(24px);
      -webkit-backdrop-filter: blur(24px);
      z-index: 50;
      display: flex;
      flex-direction: column;
      padding: 22px;
      gap: 18px;
      overflow-y: auto;
      transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .settings-drawer.open {
      right: 0;
    }

    .drawer-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-bottom: 12px;
      border-bottom: 1px solid var(--border-subtle);
    }

    .drawer-title {
      font-family: var(--font-mono);
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--text-primary);
    }

    .section-label {
      font-family: var(--font-mono);
      font-size: 9.5px;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--text-muted);
      margin-bottom: 6px;
    }

    .settings-group {
      display: flex;
      flex-direction: column;
      gap: 12px;
    }

    .slider-row {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .slider-info {
      display: flex;
      justify-content: space-between;
      font-family: var(--font-mono);
      font-size: 10px;
      color: var(--text-secondary);
    }

    input[type="range"] {
      -webkit-appearance: none;
      width: 100%;
      height: 6px;
      border-radius: 3px;
      background: #232733;
      outline: none;
      cursor: pointer;
    }

    input[type="range"]::-webkit-slider-runnable-track {
      height: 6px;
      border-radius: 3px;
      background: transparent !important;
      border: none;
    }

    input[type="range"]::-moz-range-track {
      height: 6px;
      border-radius: 3px;
      background: transparent !important;
      border: none;
    }

    input[type="range"]::-moz-range-thumb {
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: #f1f3f8;
      border: 2px solid var(--accent-blue);
      cursor: pointer;
    }

    input[type="range"]::-webkit-slider-thumb {
      -webkit-appearance: none;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      background: #f1f3f8;
      border: 2px solid var(--accent-blue);
      cursor: pointer;
      margin-top: -4px;
    }

    .toggle-row {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 5px 0;
      font-family: var(--font-mono);
      font-size: 10.5px;
      color: var(--text-secondary);
    }

    .switch-btn {
      background: var(--surface-2);
      border: 1px solid var(--border-subtle);
      color: var(--text-primary);
      padding: 5px 12px;
      border-radius: 4px;
      font-family: var(--font-mono);
      font-size: 9.5px;
      font-weight: 600;
      cursor: pointer;
      text-transform: uppercase;
      transition: all 0.15s ease;
    }

    .switch-btn.active {
      border-color: var(--accent-blue);
      color: #93c5fd;
      background: var(--accent-soft);
    }

    /* Onboarding Modal */
    .onboard-modal {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(6, 7, 10, 0.88);
      backdrop-filter: blur(22px);
      -webkit-backdrop-filter: blur(22px);
      z-index: 100;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    .modal-card {
      background: var(--surface-1);
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      width: 100%;
      max-width: 480px;
      padding: 24px 26px;
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .modal-head {
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .modal-title {
      font-family: var(--font-mono);
      font-size: 14px;
      font-weight: 700;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      color: var(--text-primary);
    }

    .modal-tag {
      font-family: var(--font-mono);
      font-size: 9.5px;
      letter-spacing: 0.08em;
      color: var(--text-muted);
      text-transform: uppercase;
    }

    .instruction-steps {
      display: flex;
      flex-direction: column;
      gap: 10px;
      font-size: 12px;
      line-height: 1.5;
      color: var(--text-secondary);
    }

    .step-item {
      display: flex;
      gap: 10px;
      align-items: flex-start;
    }

    .step-num {
      font-family: var(--font-mono);
      font-size: 9.5px;
      font-weight: 700;
      color: #93c5fd;
      background: var(--accent-soft);
      border: 1px solid rgba(59, 130, 246, 0.3);
      padding: 2px 6px;
      border-radius: 4px;
      flex-shrink: 0;
    }

    .modal-actions {
      display: flex;
      gap: 10px;
      margin-top: 6px;
    }

    .btn-primary {
      flex: 1;
      background: #f1f3f8;
      color: #06070a;
      border: none;
      padding: 11px 16px;
      font-family: var(--font-mono);
      font-size: 11px;
      font-weight: 700;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      border-radius: 5px;
      cursor: pointer;
      transition: background 0.15s ease;
    }

    .btn-primary:hover {
      background: #ffffff;
    }

    .btn-ghost {
      background: var(--surface-2);
      border: 1px solid var(--border-subtle);
      color: var(--text-secondary);
      padding: 11px 16px;
      font-family: var(--font-mono);
      font-size: 11px;
      font-weight: 600;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      border-radius: 5px;
      cursor: pointer;
    }

    @media (max-width: 768px) {
      .hud-layer {
        padding: max(6px, env(safe-area-inset-top)) 6px max(6px, env(safe-area-inset-bottom)) 6px;
      }
      .status-badge {
        top: 60px;
        padding: 4px 12px;
        font-size: 10px;
      }
      .settings-drawer { width: 100%; right: -100%; }
      .dock-container { width: 100%; justify-content: flex-start; padding: 3px; }
      .filter-tab { padding: 6px 10px; font-size: 9.5px; }
      .scene-btn { padding: 5px 9px; font-size: 10px; }
      .modal-card { padding: 18px; }
      .bottom-bar {
        gap: 4px;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
      }
      .scene-selector {
        margin-bottom: 1px;
      }
    }
#avatar-canvas{position:absolute;top:0;left:0;width:100%;height:100%;display:none;z-index:1;background:radial-gradient(ellipse at 50% 35%,#1b2340 0%,#06070a 75%)}

/* Floating PWA Install Banner */
.pwa-banner {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 480px);
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 100;
  animation: pwaBannerSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pwaBannerSlideDown {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.pwa-banner-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.pwa-banner-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}
.pwa-banner-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.pwa-banner-title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: #f8fafc;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pwa-banner-desc {
  font-family: var(--font-mono);
  font-size: 10px;
  color: #94a3b8;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pwa-btn-install {
  background: #2563eb;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
.pwa-btn-install:hover {
  background: #1d4ed8;
}
.pwa-btn-dismiss {
  background: transparent;
  color: #94a3b8;
  border: 1px solid transparent;
  font-size: 14px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.pwa-btn-dismiss:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
}
.btn-pack-select {
  font-size: 10px;
  padding: 6px 8px;
  border-radius: 4px;
}


/* Interactive Spotlight Tour */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: auto;
}
.tour-highlight {
  position: absolute;
  border-radius: 8px;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 0 9999px rgba(3, 4, 7, 0.72), 0 0 24px rgba(56, 189, 248, 0.55);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.tour-card {
  position: absolute;
  width: min(340px, 92vw);
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  padding: 16px;
  color: var(--text-primary);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1001;
  box-sizing: border-box;
}
.tour-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.tour-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.tour-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s ease;
}
.tour-close-btn:hover {
  color: #f1f5f9;
}
.tour-title {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.tour-desc {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}
.tour-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  padding-top: 10px;
}
.tour-dots {
  display: flex;
  gap: 5px;
}
.tour-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.3);
  transition: all 0.2s ease;
}
.tour-dot.active {
  background: #38bdf8;
  width: 14px;
  border-radius: 3px;
}
.tour-buttons {
  display: flex;
  gap: 6px;
}

    .color-picker-input {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      border: 1px solid rgba(255, 255, 255, 0.35);
      padding: 0;
      cursor: pointer;
      background: transparent;
      outline: none;
      vertical-align: middle;
      transition: transform 0.15s ease, border-color 0.15s ease;
    }
    .color-picker-input:hover {
      transform: scale(1.15);
      border-color: #38bdf8;
    }
    .color-picker-input::-webkit-color-swatch-wrapper {
      padding: 0;
    }
    .color-picker-input::-webkit-color-swatch {
      border: none;
      border-radius: 50%;
    }
    .custom-color-label {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      margin-left: 3px;
    }

    .dock-controls-group {
      display: flex;
      gap: 4px;
      padding-right: 6px;
      border-right: 1px solid rgba(255, 255, 255, 0.12);
      margin-right: 2px;
      flex-shrink: 0;
    }
    .dock-controls-group .action-btn {
      border-color: rgba(56, 189, 248, 0.4);
      color: #38bdf8;
    }
    .dock-controls-group .action-btn.active {
      background: rgba(56, 189, 248, 0.25);
      border-color: #38bdf8;
      color: #ffffff;
    }
