* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0e1a;
  --bg-2: #131826;
  --bg-3: #1a2034;
  --fg: #e8edf7;
  --muted: #8a93a8;
  --accent: #4ec9ff;
  --accent-dim: #2c4258;
  --line: #2a3147;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 1100px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── Header ─────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.85rem 1.1rem 0.55rem;
  flex-shrink: 0;
}
h1 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.progress {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.progress .sep { opacity: 0.4; padding: 0 2px; }
#step-num { color: var(--fg); }

/* ─── Stage (SVG container) ─────────────────────────── */
.stage {
  flex: 1;
  min-height: 0;
  background:
    radial-gradient(ellipse at center, #141b2e 0%, var(--bg-2) 65%, var(--bg) 100%);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
}

/* On portrait mobile, cap the stage so the wide top-down view doesn't
   drown the panel in empty space. Panel grows to fill the remainder. */
@media (orientation: portrait) {
  .stage {
    flex: 0 0 auto;
    height: min(58vh, 520px);
  }
  .panel {
    flex: 1 1 auto;
    overflow-y: auto;
  }
}
#scene {
  width: 100%;
  height: 100%;
  display: block;
}

/* SVG layer fade */
#scene .layer {
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
}
#scene .layer.on {
  opacity: 1;
}
#scene .layer.dim {
  opacity: 0.35;
}
/* The shell outline stays as a faint context once on */
#scene .layer.context {
  opacity: 0.55;
}

/* highlight pulse on newly added layer */
@keyframes pulse-in {
  0%   { opacity: 0; filter: drop-shadow(0 0 0 transparent); }
  50%  { opacity: 1; filter: drop-shadow(0 0 8px rgba(78, 201, 255, 0.7)); }
  100% { opacity: 1; filter: drop-shadow(0 0 0 transparent); }
}
#scene .layer.flash {
  animation: pulse-in 1.1s ease-out;
}

/* ─── Panel ──────────────────────────────────────────── */
.panel {
  padding: 1rem 1.25rem 1.25rem;
  flex-shrink: 0;
  background: var(--bg);
}
.step-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 0.4rem;
  font-weight: 500;
}
h2 {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}
#step-body {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  min-height: 5.2em;
}
#step-body strong { color: var(--fg); font-weight: 500; }

.dots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 1rem 0 0.8rem;
}
.dot {
  flex: 1 1 12px;
  min-width: 12px;
  max-width: 28px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  transition: background 0.2s;
  cursor: pointer;
  border: none;
  padding: 0;
}
.dot.active { background: var(--accent); }
.dot.done { background: var(--accent-dim); }

.nav {
  display: flex;
  gap: 0.5rem;
}
button {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font: 500 0.95rem inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  min-height: 48px;
  flex: 1;
}
button:hover { background: var(--bg-3); }
button:active { transform: scale(0.985); }
button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}
button.primary {
  background: var(--accent);
  color: #001824;
  border-color: var(--accent);
  flex: 1.8;
  font-weight: 600;
}
button.primary:hover { background: #71d4ff; }

/* ─── Desktop side-by-side layout ─────────────────── */
@media (min-width: 820px) and (orientation: landscape) {
  main {
    flex-direction: row;
    align-items: stretch;
    padding: 0;
  }
  header {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 2;
    background: linear-gradient(to bottom, rgba(10,14,26,0.95), transparent);
    padding: 1rem 1.25rem 1.5rem;
  }
  .stage {
    flex: 1.4;
    border-top: none;
    border-bottom: none;
    border-right: 1px solid var(--line);
  }
  .panel {
    flex: 1;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem 2rem 2.5rem;
  }
  h2 { font-size: 1.7rem; }
  #step-body { font-size: 1rem; min-height: 7em; }
}
