:root {
  --bg-top: #071224;
  --bg-mid: #040a16;
  --bg-deep: #02040a;
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.22);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.22);
  --amber: #fbbf24;
  --amber-bright: #fef08a;
  --coral: #fb7185;
  --text-main: #f1f5f9;
  --text-muted: rgba(148, 163, 184, 0.84);
  --hud-bg: rgba(7, 13, 27, 0.78);
  --hud-border: rgba(148, 163, 184, 0.18);
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #0a1930 0%, #040914 58%, #02040a 100%);
  color: var(--text-main);
  font-family: var(--font-sans);
  user-select: none;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
}

/* Stage Canvas */
.stage-wrap {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#neuralCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  outline: none;
}

#neuralCanvas.is-dragging {
  cursor: grabbing;
}

#neuralCanvas.is-hovering-node {
  cursor: pointer;
}

/* Top Observatory HUD */
.story-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  contain: layout style;
  background: linear-gradient(180deg, rgba(2, 4, 10, 0.88) 0%, rgba(2, 4, 10, 0.45) 75%, rgba(2, 4, 10, 0) 100%);
}

.top-utility-row {
  width: 100%;
  max-width: 1080px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: auto;
  flex-wrap: wrap;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title-group {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-kicker {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: rgba(34, 211, 238, 0.82);
}

.brand-name {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-main);
}

.utility-right-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-pill-btn {
  min-width: 48px;
  height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.2s ease, background 0.2s ease;
}

.icon-pill-btn:hover {
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(15, 29, 52, 0.88);
}

.icon-pill-btn:active {
  transform: scale(0.94);
}

.icon-pill-btn.is-active {
  border-color: rgba(251, 191, 36, 0.65);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.22);
}

/* Segmented View Switch (Micro vs Panorama) */
.view-switch {
  display: inline-flex;
  padding: 2px;
  border-radius: 10px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: rgba(6, 14, 28, 0.88);
  backdrop-filter: blur(12px);
}

.view-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  height: 28px;
  padding: 0 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.view-btn:hover {
  color: var(--text-main);
}

.view-btn.is-active {
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.26), rgba(56, 189, 248, 0.18));
  color: #e0f7ff;
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.5);
}

.text-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  color: rgba(226, 232, 240, 0.88);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.text-pill-btn:hover {
  border-color: rgba(34, 211, 238, 0.45);
}

.text-pill-btn .dot-ind {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.55);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.text-pill-btn.is-active {
  border-color: rgba(34, 211, 238, 0.62);
  background: rgba(12, 34, 58, 0.86);
  color: #e0f7ff;
}

.text-pill-btn.is-active .dot-ind {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.inspire-pill-btn.is-active {
  border-color: rgba(251, 191, 36, 0.65);
  background: rgba(69, 39, 8, 0.68);
  color: var(--amber-bright);
}

.inspire-pill-btn.is-active .dot-ind {
  background: var(--amber);
  box-shadow: 0 0 8px var(--amber);
}

.mood-pill-btn.is-active {
  border-color: rgba(251, 113, 133, 0.72);
  background: rgba(136, 19, 55, 0.72);
  color: #ffe4e6;
}

.mood-pill-btn.is-active .dot-ind {
  background: var(--coral);
  box-shadow: 0 0 8px var(--coral);
}

/* Optional Inspirational Banner (Hidden by default) */
.inspire-banner {
  max-width: 720px;
  padding: 10px 18px;
  border-radius: 14px;
  border: 1px solid rgba(251, 191, 36, 0.32);
  background: rgba(12, 18, 34, 0.84);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 24px rgba(251, 191, 36, 0.08);
  text-align: center;
  animation: fadeSlideDown 0.28s ease;
}

.inspire-banner[hidden] {
  display: none;
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.inspire-headline {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.35;
}

.inspire-headline .hl-gold {
  color: var(--amber-bright);
  font-size: clamp(16px, 3.2vw, 22px);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.inspire-headline .hl-light {
  color: #e2e8f0;
  font-size: clamp(13px, 2.5vw, 15.5px);
  font-weight: 500;
}

.inspire-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: rgba(34, 211, 238, 0.88);
  font-weight: 500;
}

/* Telemetry Row */
.telemetry-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stage-subtitle {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(6, 12, 24, 0.72);
  font-size: clamp(12.5px, 2.6vw, 14.5px);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #e2e8f0;
}

.sub-micro {
  color: rgba(203, 213, 225, 0.85);
}

.sub-count {
  color: var(--cyan);
  font-family: var(--font-mono);
  margin: 0 2px;
}

.sub-gold {
  color: var(--amber);
}

.network-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.25);
  background: rgba(6, 16, 32, 0.76);
  font-size: 12px;
}

.stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.stat-label {
  color: var(--text-muted);
  font-weight: 500;
}

.stat-val {
  font-family: var(--font-mono);
  color: var(--text-main);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Breakthrough Background Watermark */
.breakthrough-mark {
  position: absolute;
  left: 50%;
  bottom: 24%;
  transform: translate(-50%, 0) scale(0.88);
  font-size: clamp(58px, 15vw, 124px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: rgba(251, 191, 36, 0.14);
  text-shadow: 0 0 42px rgba(251, 191, 36, 0.12);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease, transform 1s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 2;
  white-space: nowrap;
}

.breakthrough-mark.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* Floating Progress Pill (near growth cone) */
.progress-pill {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 6;
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.42);
  background: rgba(6, 13, 26, 0.88);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 16px rgba(34, 211, 238, 0.12);
  pointer-events: none;
  contain: layout style;
  white-space: nowrap;
  transition: opacity 0.35s ease, border-color 0.3s ease, box-shadow 0.3s ease;
  will-change: transform, opacity;
}

.progress-pill.is-near-target {
  border-color: rgba(251, 146, 60, 0.72);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55), 0 0 20px rgba(251, 146, 60, 0.22);
}

.progress-pill.is-hidden {
  opacity: 0;
}

.pill-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.pill-pct {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #f8fafc;
}

/* Interactive Panorama Hint */
.panorama-hint {
  position: absolute;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid rgba(167, 139, 250, 0.38);
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(10px);
  font-size: 12px;
  color: #ddd6fe;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 28px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.panorama-hint[hidden] {
  display: none;
}

/* Optional Scientific Anatomy Overlay */
.anatomy-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.anatomy-callout {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -100%);
  min-height: 36px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: rgba(5, 12, 24, 0.92);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  cursor: pointer;
  font-family: var(--font-sans);
  text-align: left;
  transition: opacity 0.25s ease, border-color 0.2s ease, transform 0.14s ease;
}

.anatomy-callout:hover,
.anatomy-callout.is-selected {
  border-color: var(--amber);
  background: rgba(14, 30, 54, 0.96);
}

.anatomy-callout strong {
  font-size: 11.5px;
  font-weight: 700;
  color: #e0f7ff;
}

.anatomy-callout span {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: rgba(148, 163, 184, 0.88);
}

/* Interactive Knowledge Card */
.knowledge-card {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 28px));
  max-height: 44dvh;
  overflow-y: auto;
  touch-action: pan-y;
  z-index: 30;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  background: rgba(6, 13, 26, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.78);
  contain: layout style;
}

.kc-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.kc-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #e0f7ff;
}

.kc-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
}

.kc-close-btn {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--hud-border);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-main);
  font-size: 14px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.kc-body {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.92);
}

/* Minimal Presenter Floating Bar */
.presenter-bar {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--hud-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.presenter-bar[hidden],
.knowledge-card[hidden],
.decay-action-btn[hidden],
.sleep-action-btn[hidden] {
  display: none;
}

.pres-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.45);
  background: rgba(14, 116, 144, 0.45);
  color: #f8fafc;
  font-size: 13px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.pres-step-label {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  padding: 0 4px;
}

.pres-exit-btn {
  height: 34px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--hud-border);
  background: rgba(15, 23, 42, 0.85);
  color: #cbd5e1;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.app-shell.is-presenting .top-utility-row,
.app-shell.is-presenting .control-dock {
  display: none;
}

.app-shell.is-presenting .bottom-caption {
  font-size: clamp(16px, 3.6vw, 22px);
  margin-bottom: 12px;
}

.decay-action-btn {
  border: 1px solid rgba(251, 113, 133, 0.55);
  background: rgba(136, 19, 55, 0.55);
  color: #ffe4e6;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, filter 0.18s ease;
}

.sleep-action-btn {
  border: 1px solid rgba(167, 139, 250, 0.55);
  background: rgba(49, 46, 129, 0.65);
  color: #e0e7ff;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.14s ease, filter 0.18s ease;
}

.decay-action-btn:hover,
.sleep-action-btn:hover {
  filter: brightness(1.15);
}

.decay-action-btn:active,
.sleep-action-btn:active {
  transform: scale(0.95);
}

/* Bottom Footer & Compact Control Dock */
.story-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 16px max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  contain: layout style;
  background: linear-gradient(0deg, rgba(2, 4, 10, 0.92) 0%, rgba(2, 4, 10, 0.6) 68%, rgba(2, 4, 10, 0) 100%);
  pointer-events: none;
}

.bottom-caption {
  margin: 0;
  text-align: center;
  font-size: clamp(14px, 3vw, 17.5px);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.45;
  color: #e2e8f0;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
  max-width: 720px;
}

.hl-cyan {
  color: var(--cyan);
  font-weight: 700;
}

.hl-coral {
  color: #fb923c;
  font-weight: 700;
}

.hl-gold {
  color: var(--amber);
  font-weight: 700;
}

.control-dock {
  width: 100%;
  max-width: 600px;
  padding: 9px 12px;
  border-radius: 16px;
  background: var(--hud-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--hud-border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.48);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.dock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  flex-shrink: 0;
  padding: 3px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.14);
}

.mode-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 7px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.mode-btn.is-active {
  background: rgba(34, 211, 238, 0.18);
  color: #e0f7ff;
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.4);
}

.action-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.primary-action-btn {
  border: 1px solid rgba(34, 211, 238, 0.55);
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.85), rgba(8, 145, 178, 0.72));
  color: #f8fafc;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.2);
  transition: transform 0.14s ease, filter 0.18s ease, box-shadow 0.2s ease;
}

.primary-action-btn:hover {
  filter: brightness(1.12);
}

.primary-action-btn:active {
  transform: scale(0.95);
}

.primary-action-btn.is-pulse {
  border-color: rgba(251, 191, 36, 0.85);
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.88), rgba(245, 158, 11, 0.75));
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.35);
}

.primary-action-btn.is-complete {
  border-color: rgba(251, 191, 36, 0.7);
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.78), rgba(217, 119, 6, 0.7));
}

.icon-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--hud-border);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text-main);
  font-size: 15px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.14s ease;
}

.icon-action-btn:hover {
  border-color: rgba(34, 211, 238, 0.55);
}

.icon-action-btn:active {
  transform: scale(0.93);
}

.dock-row-meter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 2px;
}

.meter-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.meter-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.28s ease;
}

.meter-cyan {
  background: linear-gradient(90deg, #06b6d4, #22d3ee);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.5);
}

.meter-gold {
  background: linear-gradient(90deg, #d97706, #fbbf24);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

.meter-val {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .brand-title-group {
    display: none;
  }

  .story-header {
    padding: max(10px, env(safe-area-inset-top)) 10px 8px;
  }

  .story-footer {
    padding: 12px 10px max(10px, env(safe-area-inset-bottom));
    gap: 8px;
  }

  .control-dock {
    padding: 8px 10px;
  }

  .dock-row-meter {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
