/* ─── Mission Protocol — Deep Space Learning UI ─────────────────────────────────
   Mobile-first (ages 2–5). Serene, not gamified. No timer anxiety.             */

/* ─── Variables ─── */
:root {
  --bg-void: #040810;
  --bg-panel: #070d18;
  --bg-card: #0b1220;
  --bg-card-hover: #111828;
  --fg: #dce8f0;
  --fg-muted: #6a8090;
  --accent-dust: #c8a84b;
  --accent-dust-glow: rgba(200,168,75,0.25);
  --accent-teal: #3d8f82;
  --accent-cyan: #4ab5c8;
  --accent-violet: #8a6bbf;
  --border-subtle: rgba(220,232,240,0.07);
  --border-dust: rgba(200,168,75,0.15);
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg-void);
  color: var(--fg);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
}

/* ─── Starfield ─── */
.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.star-dot {
  position: absolute;
  border-radius: 50%;
  background: #fff;
}
.star-dot.twinkle {
  animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle {
  0%   { opacity: 0.2; }
  100% { opacity: 0.8; }
}

/* ─── App Shell ─── */
.mission-app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Screen containers ─── */
.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 100vh;
}
.screen.active { display: flex; }

/* ─── Launch Screen ─── */
.launch-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px 24px 24px;
  gap: 0;
}

.launch-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(200,168,75,0.08);
  border: 1px solid var(--border-dust);
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-dust);
  margin-bottom: 24px;
}

.launch-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  font-weight: 700;
  color: var(--fg);
  text-align: center;
  margin-bottom: 12px;
  line-height: 1.2;
}

.launch-sub {
  font-size: 0.95rem;
  color: var(--fg-muted);
  text-align: center;
  max-width: 340px;
  margin-bottom: 40px;
  line-height: 1.6;
}

/* ─── Pillar selector ─── */
.pillar-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 32px;
}

.pillar-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 16px;
  cursor: pointer;
  transition: border-color 0.25s, transform 0.15s, box-shadow 0.25s;
}
.pillar-card:hover {
  border-color: rgba(74,180,200,0.3);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.pillar-card:active { transform: scale(0.97); }
.pillar-card.selected {
  border-color: var(--accent-cyan);
  background: rgba(74,180,200,0.06);
  box-shadow: 0 0 16px rgba(74,180,200,0.15);
}

.pillar-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}
.pillar-card[data-pillar="LITERACY"] .pillar-icon {
  background: linear-gradient(135deg, rgba(58,140,200,0.2), rgba(58,140,200,0.05));
  border: 1px solid rgba(58,140,200,0.3);
}
.pillar-card[data-pillar="MATHEMATICS"] .pillar-icon {
  background: linear-gradient(135deg, rgba(200,168,75,0.2), rgba(200,168,75,0.05));
  border: 1px solid rgba(200,168,75,0.3);
}
.pillar-card[data-pillar="COGNITIVE_SPATIAL"] .pillar-icon {
  background: linear-gradient(135deg, rgba(138,107,191,0.2), rgba(138,107,191,0.05));
  border: 1px solid rgba(138,107,191,0.3);
}

.pillar-info { flex: 1; min-width: 0; }
.pillar-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 2px;
}
.pillar-desc {
  font-size: 0.75rem;
  color: var(--fg-muted);
  line-height: 1.4;
}
.pillar-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--fg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: transparent;
  transition: all 0.2s;
  flex-shrink: 0;
}
.pillar-card.selected .pillar-check {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  color: #040810;
}

/* Auto-select hint */
.auto-hint {
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: 0.04em;
}

/* ─── Launch button ─── */
.btn-launch {
  width: 100%;
  max-width: 360px;
  padding: 18px 32px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-teal));
  color: #040810;
  border: none;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(74,180,200,0.25);
}
.btn-launch:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(74,180,200,0.35); }
.btn-launch:active { transform: scale(0.97); }
.btn-launch:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ─── Active Learning Screen ─── */

/* Progress dots */
.mission-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 20px 8px;
}
.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-muted);
  opacity: 0.3;
  transition: all 0.4s ease;
}
.progress-dot.done { background: var(--accent-teal); opacity: 1; }
.progress-dot.current { background: var(--accent-cyan); opacity: 1; box-shadow: 0 0 8px rgba(74,180,200,0.4); transform: scale(1.3); }

.mission-counter {
  text-align: center;
  font-size: 0.72rem;
  color: var(--fg-muted);
  letter-spacing: 0.08em;
  padding: 4px 0 12px;
}

/* Item card */
.item-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  gap: 0;
}

/* Adaptive visual cues */
.item-area.cue-highlight {
  box-shadow: 0 0 0 3px rgba(74, 181, 200, 0.4);
  border-radius: 16px;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(200, 168, 75, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(200, 168, 75, 0.15); }
}
.item-area.cue-pulse {
  animation: pulse-glow 1.8s ease-in-out infinite;
}

.prompt-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 24px 20px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  margin-bottom: 28px;
}

.prompt-pillar-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 16px;
}
.prompt-pillar-tag.literacy {
  background: rgba(58,140,200,0.12);
  color: rgba(74,180,220,0.9);
  border: 1px solid rgba(58,140,200,0.2);
}
.prompt-pillar-tag.math {
  background: rgba(200,168,75,0.1);
  color: var(--accent-dust);
  border: 1px solid var(--border-dust);
}
.prompt-pillar-tag.cognitive {
  background: rgba(138,107,191,0.12);
  color: var(--accent-violet);
  border: 1px solid rgba(138,107,191,0.2);
}

.prompt-text {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 4.5vw, 1.5rem);
  font-weight: 600;
  color: var(--fg);
  line-height: 1.4;
  margin-bottom: 14px;
}

.space-fact-card {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(74,180,200,0.05);
  border: 1px solid rgba(74,180,200,0.1);
  border-radius: 10px;
  text-align: left;
}
.space-fact-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.space-fact-text { font-size: 0.75rem; color: var(--fg-muted); line-height: 1.4; }

/* Answer options */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.option-btn {
  aspect-ratio: 1;
  min-height: 88px;
  background: var(--bg-card);
  border: 2px solid var(--border-subtle);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  padding: 12px;
  position: relative;
  overflow: hidden;
}
.option-btn:active { transform: scale(0.95); }
.option-btn.selected {
  border-color: var(--accent-cyan);
  background: rgba(74,180,200,0.08);
  box-shadow: 0 0 14px rgba(74,180,200,0.2);
}
.option-btn.disabled { pointer-events: none; opacity: 0.5; }

.option-icon {
  font-size: clamp(2rem, 10vw, 3rem);
  line-height: 1;
  display: block;
  text-align: center;
}

/* ─── Feedback Overlay ─── */
.feedback-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.feedback-overlay.visible { opacity: 1; pointer-events: all; }

.feedback-bubble {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 40px;
  background: var(--bg-card);
  border-radius: 20px;
  border: 1px solid var(--border-subtle);
  text-align: center;
  animation: feedback-pop 0.4s cubic-bezier(0.23,1,0.32,1);
}
.feedback-bubble.correct {
  border-color: rgba(61,143,130,0.4);
  box-shadow: 0 0 30px rgba(61,143,130,0.15);
}
.feedback-bubble.incorrect {
  border-color: rgba(138,107,191,0.3);
  box-shadow: 0 0 30px rgba(138,107,191,0.1);
}

@keyframes feedback-pop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.feedback-icon { font-size: 3rem; }
.feedback-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
}
.feedback-sub {
  font-size: 0.8rem;
  color: var(--fg-muted);
  margin-top: -4px;
}

/* ─── Circuit Breaker — Mission Pause ─── */
.cb-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(4,8,16,0.92);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.cb-overlay.visible { opacity: 1; pointer-events: all; }

.cb-stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.cb-star {
  position: absolute;
  border-radius: 50%;
  background: rgba(74,180,200,0.3);
  animation: cb-pulse 3s ease-in-out infinite;
}
@keyframes cb-pulse {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.cb-icon { font-size: 3.5rem; animation: cb-breathe 3s ease-in-out infinite; }
@keyframes cb-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.cb-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--fg);
  text-align: center;
}
.cb-sub {
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-align: center;
  max-width: 280px;
  line-height: 1.5;
}

.cb-progress {
  width: 200px;
  height: 4px;
  background: var(--bg-card);
  border-radius: 999px;
  overflow: hidden;
}
.cb-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-teal));
  border-radius: 999px;
  transition: width 5s linear;
  width: 0%;
}
.cb-overlay.visible .cb-progress-fill { width: 100%; }

/* ─── Session Timer ─── */
.mission-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px 4px;
  font-size: 0.72rem;
  color: var(--fg-muted);
  letter-spacing: 0.06em;
}
.timer-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  opacity: 0.5;
}
.timer-dot.live { opacity: 1; animation: timer-pulse 2s ease-in-out infinite; }
@keyframes timer-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ─── Exit Button ─── */
.exit-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--fg-muted);
  transition: all 0.2s;
  z-index: 10;
}
.exit-btn:hover { background: rgba(255,255,255,0.1); color: var(--fg); }

/* ─── Complete Screen ─── */
.complete-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  gap: 0;
}

.complete-icon-wrap {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: complete-spin 0.8s cubic-bezier(0.23,1,0.32,1);
}
@keyframes complete-spin {
  0% { transform: rotate(-20deg) scale(0.5); opacity: 0; }
  60% { transform: rotate(5deg) scale(1.1); }
  100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

.complete-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 8px;
  text-align: center;
}

.complete-sub {
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-align: center;
  margin-bottom: 36px;
}

/* Stats */
.stats-row {
  display: flex;
  gap: 16px;
  margin-bottom: 40px;
  width: 100%;
  max-width: 360px;
}
.stat-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 18px 12px;
  text-align: center;
}
.stat-val {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-dust);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label { font-size: 0.7rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.08em; }

/* Star Dust award */
.dust-award {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 28px;
  background: rgba(200,168,75,0.08);
  border: 1px solid var(--border-dust);
  border-radius: 999px;
  margin-bottom: 32px;
}
.dust-award-icon { font-size: 1.5rem; }
.dust-award-text { font-size: 1rem; color: var(--accent-dust); font-weight: 500; }

/* Complete actions */
.complete-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; }

.btn-secondary {
  padding: 16px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-secondary:active { transform: scale(0.97); }
.btn-secondary:hover { border-color: var(--accent-cyan); color: var(--fg); }

/* ─── Loading spinner ─── */
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Confirm exit dialog ─── */
.exit-confirm {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(4,8,16,0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 40px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.exit-confirm.visible { opacity: 1; pointer-events: all; }
.exit-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px 20px 0 0;
  padding: 28px 24px 40px;
  width: 100%;
  max-width: 480px;
  text-align: center;
  animation: slide-up 0.3s cubic-bezier(0.23,1,0.32,1);
}
.exit-sheet h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--fg);
  margin-bottom: 8px;
}
.exit-sheet p { font-size: 0.85rem; color: var(--fg-muted); margin-bottom: 24px; }
.exit-actions { display: flex; gap: 12px; }
.exit-actions .btn { flex: 1; padding: 14px; }

/* ─── ZenMode — LayoutController ─── */
body.zen-mode #nav,
body.zen-mode header:not(.mission-header),
body.zen-mode footer,
body.zen-mode .sidebar,
body.zen-mode [role="navigation"],
body.zen-mode .header,
body.zen-mode .footer,
body.zen-mode .top-bar,
body.zen-mode .site-nav {
  display: none !important;
}
body.zen-mode .item-area { padding-top: 20px; }

/* ─── MicroStepProgress ─── */
.step-progress {
  text-align: center;
  margin-bottom: 12px;
  font-family: var(--font-body);
}
.step-label {
  font-size: 14px;
  color: var(--accent-cyan);
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0.85;
}
.step-track {
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.step-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-violet), var(--accent-cyan));
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ─── Celebration Badge — GamificationService ─── */
.celebration-badge {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: rgba(20,10,40,0.92);
  border: 2px solid var(--accent-cyan);
  border-radius: 50px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  z-index: 9999;
  box-shadow: 0 0 20px rgba(160,196,255,0.4);
  pointer-events: none;
}
.celebration-badge.badge-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.celebration-badge span {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--accent-cyan);
}

/* ─── Credits-depleted modal ─── */
#credits-modal {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 8, 16, 0.85);
  backdrop-filter: blur(8px);
}
#credits-modal.visible { display: flex; }

.credits-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 36px 28px;
  max-width: 340px;
  width: calc(100% - 48px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.credits-modal-icon {
  font-size: 2.5rem;
  line-height: 1;
}
.credits-modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.35;
}
.credits-modal-body {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--fg-muted);
  line-height: 1.6;
  max-width: 280px;
}
.credits-modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.credits-modal-dismiss {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 10px 20px;
  cursor: pointer;
}
.credits-modal-cta {
  background: var(--accent-cyan);
  border: none;
  border-radius: 999px;
  color: #040810;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 24px;
  text-decoration: none;
  cursor: pointer;
}

/* ─── Responsive ─── */
@media (min-width: 480px) {
  .options-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .options-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
}