:root {
  --wizard-bg: #071019;
  --wizard-panel: #0d1b29;
  --wizard-line: #24425a;
  --wizard-text: #e9f7ff;
  --wizard-muted: #8ba6b7;
  --wizard-cyan: #66e3ff;
  --wizard-amber: #ffc857;
  --wizard-violet: #b79cff;
  --wizard-red: #ff6b7a;
  --wizard-green: #70efad;
  --wizard-gold: #ffd700;
  --scene-width: 100%;
  --scene-height: 100%;
}

.wizard-body {
  margin: 0;
  background: var(--wizard-bg);
  color: var(--wizard-text);
  font: 15px/1.5 Inter, system-ui, sans-serif;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

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

.skip {
  position: absolute;
  left: -999px;
  z-index: 1000;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
}

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #17324a 0%, #071019 70%);
  transition: opacity 0.8s ease, visibility 0.8s ease;
}
.intro-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.intro-content {
  text-align: center;
  animation: introFadeIn 1.5s ease;
}
.intro-aurora-glow {
  width: 200px;
  height: 200px;
  margin: 0 auto 2rem;
  border-radius: 50%;
  background: radial-gradient(circle, var(--wizard-cyan) 0%, transparent 70%);
  animation: pulseGlow 2s ease-in-out infinite;
}
.intro-title {
  font-size: clamp(2.5rem, 8vw, 5rem);
  margin: 0;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--wizard-cyan), var(--wizard-violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.intro-subtitle {
  font-size: 1.2rem;
  color: var(--wizard-muted);
  margin: 0.5rem 0 2rem;
}
.intro-skip {
  background: transparent;
  border: 1px solid var(--wizard-line);
  color: var(--wizard-text);
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.2s, background 0.2s;
}
.intro-skip:hover,
.intro-skip:focus {
  border-color: var(--wizard-cyan);
  background: rgba(102, 227, 255, 0.1);
}

.wizard-main {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 420px);
  height: 100%;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

.scene-container {
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 30% 20%, #17324a 0%, #071019 60%);
}

.scene-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Intent HUD must receive clicks despite .scene-layer pointer-events: none (inherited). */
.bridge-intent-panel {
  position: absolute;
  left: 50%;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  width: min(420px, calc(100% - 1.5rem));
  pointer-events: auto;
  z-index: 20;
}
.bridge-intent-panel input,
.bridge-intent-panel button {
  pointer-events: auto;
}
.bridge-intent-panel input[type="text"] {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  background: rgba(13, 27, 41, 0.92);
  border: 1px solid var(--wizard-line);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  color: var(--wizard-text);
  font-size: 16px; /* avoid iOS zoom */
  backdrop-filter: blur(8px);
}
.bridge-intent-panel input[type="text"]::placeholder {
  color: var(--wizard-muted);
}
.bridge-intent-panel button {
  flex: 0 0 auto;
  min-height: 44px;
  min-width: 72px;
  background: var(--wizard-cyan);
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  color: #071019;
  font-weight: 600;
  cursor: pointer;
}

.scene-bg {
  background:
    radial-gradient(circle at 20% 80%, rgba(183, 156, 255, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(102, 227, 255, 0.1) 0%, transparent 40%);
}

.scene-particles {
  z-index: 1;
}

.scene-neural {
  z-index: 2;
  opacity: 0.6;
}

.scene-aurora-waves {
  z-index: 3;
}
.wave {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30%;
  opacity: 0.15;
  background: linear-gradient(to top, var(--wizard-cyan), transparent);
}
.wave-1 { animation: waveMove 8s ease-in-out infinite; }
.wave-2 { animation: waveMove 10s ease-in-out infinite reverse; opacity: 0.1; }
.wave-3 { animation: waveMove 12s ease-in-out infinite; opacity: 0.05; }

.scene-portal {
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.scene-portal.active {
  opacity: 1;
}
.portal-svg {
  width: 280px;
  height: 280px;
}
.portal-ring {
  transform-origin: 150px 150px;
}
.ring-1 { animation: portalSpin 20s linear infinite; }
.ring-2 { animation: portalSpin 15s linear infinite reverse; }
.ring-3 { animation: portalSpin 25s linear infinite; }
.portal-core {
  animation: portalPulse 3s ease-in-out infinite;
}

.scene-characters {
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sprite-container {
  position: absolute;
  transition: transform 0.6s ease, opacity 0.6s ease;
}

.supasoloc-container {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  width: 200px;
  height: 300px;
}
.supasoloc-container.visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}
.supasoloc-container.breathing {
  animation: spriteBreath 4s ease-in-out infinite;
}

.raster-sprite {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: saturate(0.9);
  transition: opacity 0.4s ease, filter 0.4s ease;
}
.raster-sprite.loading {
  opacity: 0.3;
  filter: blur(4px);
}
.raster-sprite.loaded {
  opacity: 1;
  filter: saturate(0.9);
}

.sprite-outline-svg {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  pointer-events: none;
}
.sprite-outline-path {
  stroke-dasharray: 800;
  stroke-dashoffset: 800;
  animation: drawOutline 2s ease forwards;
}

.wand-trail-layer {
  position: absolute;
  top: -20px;
  right: -30px;
  width: 100px;
  height: 100px;
}
.wand-trail-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.wand-trail-path {
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: drawWandTrail 1.5s ease forwards 0.5s;
}
.wand-sparkle {
  animation: sparklePulse 1s ease-in-out infinite;
}

.seeker-container {
  left: 20%;
  top: 60%;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  width: 120px;
  height: 180px;
}
.seeker-container.visible {
  opacity: 0.8;
  transform: translate(-50%, -50%) scale(1);
}

.book-container {
  right: 15%;
  top: 55%;
  transform: translate(50%, -50%) scale(0.6);
  opacity: 0;
  width: 100px;
  height: 100px;
}
.book-container.visible {
  opacity: 0.9;
  transform: translate(50%, -50%) scale(1);
}
.book-container.opening {
  animation: bookOpen 1s ease forwards;
}

.scene-agent-cores {
  z-index: 6;
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.scene-agent-cores.active {
  opacity: 1;
}

.agent-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.core-orb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent, var(--wizard-cyan));
  box-shadow: 0 0 12px var(--accent, var(--wizard-cyan));
  animation: coreOrbit 3s ease-in-out infinite;
}
.core-label {
  font-size: 10px;
  color: var(--wizard-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wizard-panel {
  background: linear-gradient(145deg, rgba(13, 27, 41, 0.98), rgba(7, 16, 25, 0.98));
  border-left: 1px solid var(--wizard-line);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.wizard-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--wizard-line);
}

.wizard-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.step-counter {
  font-size: 0.85rem;
  color: var(--wizard-muted);
  font-weight: 600;
}

.xp-display {
  font-size: 0.85rem;
  color: var(--wizard-amber);
  font-weight: 700;
}

.progress-bar {
  height: 6px;
  background: var(--wizard-line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--wizard-cyan), var(--wizard-violet));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.wizard-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.step-title {
  font-size: 1.6rem;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.speaker-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(102, 227, 255, 0.1);
  border: 1px solid var(--wizard-cyan);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--wizard-cyan);
  margin-bottom: 16px;
}

.speaker-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--wizard-cyan);
  animation: pulseGlow 2s ease-in-out infinite;
}

.step-dialogue {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--wizard-text);
  margin: 0 0 20px;
}

.step-inputs {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.85rem;
  color: var(--wizard-muted);
  font-weight: 600;
}

.input-group input[type="text"],
.input-group select {
  background: #071521;
  border: 1px solid var(--wizard-line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--wizard-text);
  font-size: 0.95rem;
}

.input-group input[type="text"]:focus,
.input-group select:focus {
  outline: 2px solid var(--wizard-cyan);
  outline-offset: -1px;
}

.checkbox-group,
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.checkbox-label,
.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}

.checkbox-label:hover,
.radio-label:hover {
  border-color: var(--wizard-line);
  background: rgba(102, 227, 255, 0.05);
}

.checkbox-label input,
.radio-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--wizard-cyan);
}

.review-summary {
  background: rgba(102, 227, 255, 0.05);
  border: 1px solid var(--wizard-line);
  border-radius: 12px;
  padding: 16px;
}

.review-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--wizard-line);
  font-size: 0.9rem;
}
.review-item:last-child {
  border-bottom: none;
}
.review-label {
  color: var(--wizard-muted);
}
.review-value {
  color: var(--wizard-text);
  font-weight: 600;
}

.wizard-controls {
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--wizard-line);
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  min-height: 44px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
  border: 1px solid transparent;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.btn-prev {
  background: transparent;
  border-color: var(--wizard-line);
  color: var(--wizard-text);
}
.btn-prev:not(:disabled):hover {
  border-color: var(--wizard-cyan);
}

.btn-next {
  background: var(--wizard-cyan);
  color: #041018;
}
.btn-next:not(:disabled):hover {
  background: #7de8ff;
}

.btn-next.complete {
  background: var(--wizard-green);
}

@keyframes introFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes waveMove {
  0%, 100% { transform: translateY(0) scaleY(1); }
  50% { transform: translateY(-10px) scaleY(1.1); }
}

@keyframes portalSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes portalPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes spriteBreath {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -52%) scale(1.02); }
}

@keyframes drawOutline {
  to { stroke-dashoffset: 0; }
}

@keyframes drawWandTrail {
  to { stroke-dashoffset: 0; }
}

@keyframes sparklePulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.8); }
}

@keyframes bookOpen {
  0% { transform: translate(50%, -50%) scale(1) rotateY(0deg); }
  100% { transform: translate(50%, -50%) scale(1.1) rotateY(-20deg); }
}

@keyframes coreOrbit {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .intro-overlay {
    transition: none;
  }
}

@media (max-width: 900px) {
  .wizard-main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(32vh, 42vh) minmax(0, 1fr);
  }
  .scene-container {
    height: auto;
    min-height: 32vh;
  }
  .wizard-panel {
    border-left: none;
    border-top: 1px solid var(--wizard-line);
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .wizard-content {
    overflow: auto;
  }
  .supasoloc-container {
    width: 120px;
    height: 180px;
  }
  .seeker-container {
    width: 72px;
    height: 108px;
  }
  .book-container {
    width: 64px;
    height: 64px;
  }
  .portal-svg {
    width: 160px;
    height: 160px;
  }
  .bridge-intent-panel {
    bottom: max(0.5rem, env(safe-area-inset-bottom));
    width: calc(100% - 1rem);
  }
  .scene-agent-cores {
    bottom: 3.6rem;
    left: 8px;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 55%;
  }
  .agent-dialogue-panel {
    bottom: 4.6rem !important;
    max-width: calc(100% - 1rem) !important;
    font-size: 0.85rem !important;
  }
}

@media (max-width: 480px) {
  .wizard-main {
    grid-template-rows: minmax(30vh, 38vh) minmax(0, 1fr);
  }
  .wizard-header {
    padding: 12px 14px 10px;
  }
  .wizard-content {
    padding: 14px;
  }
  .step-title {
    font-size: 1.25rem;
  }
  .step-dialogue {
    font-size: 0.95rem;
  }
  .wizard-controls {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    gap: 8px;
  }
  .btn {
    min-height: 44px;
    padding: 12px 14px;
    font-size: 0.9rem;
  }
  .bridge-intent-panel {
    gap: 0.4rem;
  }
  .bridge-intent-panel input[type="text"],
  .bridge-intent-panel button {
    min-height: 44px;
  }
  .scene-agent-cores {
    bottom: 3.4rem;
    left: 6px;
    gap: 6px;
  }
  .core-orb {
    width: 20px;
    height: 20px;
  }
  .core-label {
    font-size: 8px;
  }
  .input-group input[type="text"],
  .input-group select {
    min-height: 44px;
    font-size: 16px;
  }
  .checkbox-label,
  .radio-label {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
}

.scene-sprite-garden {
  z-index: 4;
  pointer-events: none;
}

/* Phase 2: Activation Sequence */
.activation-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(125,232,255,0.15) 0%, #071019 70%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 1s ease, visibility 1s ease;
}
.activation-overlay[hidden] {
  display: flex;
}
.activation-overlay:not([hidden]) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.activation-content {
  text-align: center;
  max-width: 560px;
  padding: 2rem;
}
.activation-glow {
  width: 180px;
  height: 180px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  background: radial-gradient(circle, var(--wizard-cyan) 0%, transparent 70%);
  animation: pulseGlow 2s ease-in-out infinite;
}
.activation-title {
  font-size: clamp(2rem, 6vw, 3.5rem);
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--wizard-cyan), var(--wizard-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.activation-message {
  color: var(--wizard-muted);
  margin: 0 0 2rem;
  line-height: 1.6;
}
.activation-close {
  background: linear-gradient(135deg, var(--wizard-cyan), var(--wizard-violet));
  border: none;
  color: #071019;
  padding: 0.8rem 2rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}
.activation-close:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(125,232,255,0.5);
}
