/* ── Reset & Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #111827;
  --card:      #1f2937;
  --border:    #374151;
  --text:      #f3f4f6;
  --muted:     #9ca3af;
  --accent:    #60a5fa;
  --danger:    #f87171;
  --success:   #34d399;
  --pump-bg:   #7f1d1d;
  --pump-fg:   #fca5a5;
  --stop-bg:   #064e3b;
  --stop-fg:   #6ee7b7;
  --advice-pump-border: #ef4444;
  --advice-stop-border: #10b981;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

/* ── Pages ──────────────────────────────────────────────────────────────── */
.page {
  display: none;
  width: 100%;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.page.active { display: flex; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 44px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  text-align: center;
}
.card-wide { max-width: 700px; }

.card h1 { font-size: 1.75rem; margin-bottom: 20px; }
.card h2 { font-size: 1.4rem;  margin-bottom: 18px; }

.prose p  { margin-bottom: 10px; }
.prose ul, .prose ol { text-align: left; margin: 14px 0 14px 20px; }
.prose li { margin-bottom: 7px; }

/* ── Utility classes ────────────────────────────────────────────────────── */
.muted   { color: var(--muted); font-size: .9em; }
.hint    { color: var(--muted); font-size: .85em; margin-top: 8px; }
.accent  { color: var(--accent); }
.danger  { color: var(--danger); }
.tag     { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: .85em; font-weight: 600; }
.tag-pump { background: rgba(239,68,68,.15); color: var(--danger); }
.tag-stop { background: rgba(16,185,129,.15); color: var(--success); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 11px 26px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #111;
  margin-top: 22px;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn-large { font-size: 1.05rem; padding: 13px 32px; }

.btn-pump {
  background: var(--pump-bg);
  color: var(--pump-fg);
  border: 1px solid var(--advice-pump-border);
  font-size: 1.05rem;
  padding: 14px 36px;
}
.btn-pump:hover:not(:disabled) { filter: brightness(1.2); }

.btn-stop {
  background: var(--stop-bg);
  color: var(--stop-fg);
  border: 1px solid var(--advice-stop-border);
  font-size: 1.05rem;
  padding: 14px 36px;
}
.btn-stop:hover:not(:disabled) { filter: brightness(1.2); }

/* ── Camera ──────────────────────────────────────────────────────────────── */
.camera-feed {
  border-radius: 8px;
  background: #000;
  transform: scaleX(-1);   /* mirror for natural selfie view */
  display: block;
}
.cam-large  { width: 320px; height: 240px; }
.cam-small  { width: 130px; height: 98px;  border: 2px solid var(--border); }

.preview-wrap { margin: 18px 0 4px; display: flex; justify-content: center; }

/* ── Baseline ─────────────────────────────────────────────────────────────── */
.countdown-wrap { margin: 28px 0; }
.big-number { font-size: 5rem; font-weight: 700; color: var(--accent); line-height: 1; }

/* ── Trial page layout ──────────────────────────────────────────────────── */
#page-trial {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 20px 20px;
  gap: 0;
}

#trial-topbar {
  width: 100%;
  max-width: 780px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: .88rem;
  color: var(--muted);
  margin-bottom: 16px;
  flex-shrink: 0;
}

#camera-corner {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 200;
  text-align: center;
}
.cam-hint { font-size: .68rem; color: var(--muted); margin-top: 3px; }

#trial-content {
  width: 100%;
  max-width: 680px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 520px;
}

/* ── Trial Steps ─────────────────────────────────────────────────────────── */
.trial-step {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  animation: fadeUp .28s ease;
}
.trial-step.active { display: flex; }

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

#step-announce h2 { font-size: 1.9rem; margin-bottom: 10px; }

/* ── Balloon ─────────────────────────────────────────────────────────────── */
.balloon-area {
  height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 8px 0 16px;
}

.balloon {
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  transition: width .2s, height .2s;
}
.balloon::after {
  content: '';
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 22px;
  background: var(--muted);
}

.balloon-low {
  background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b);
  box-shadow: 0 6px 24px rgba(245,158,11,.35);
}
.balloon-medium {
  background: radial-gradient(circle at 35% 30%, #fca5a5, #ef4444);
  box-shadow: 0 6px 24px rgba(239,68,68,.35);
}
.balloon-high {
  background: radial-gradient(circle at 35% 30%, #c084fc, #7c3aed);
  box-shadow: 0 6px 24px rgba(124,58,237,.35);
}

/* ── Step 2: State ───────────────────────────────────────────────────────── */
.state-info { max-width: 480px; margin-top: 6px; }
.state-info p { margin-bottom: 7px; }

/* ── Step 3+4: Advice + Decision ─────────────────────────────────────────── */
.reward-line { font-size: 1.15rem; margin-bottom: 14px; }

.state-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .95rem;
  color: var(--muted);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 18px;
  margin-bottom: 14px;
}
.bar-sep { color: var(--border); }

.advice-box {
  font-size: 1.2rem;
  font-weight: 700;
  padding: 14px 30px;
  border-radius: 10px;
  border: 2px solid transparent;
  margin: 4px 0 8px;
}
.advice-pump {
  background: rgba(239,68,68,.1);
  border-color: var(--advice-pump-border);
  color: #fca5a5;
}
.advice-stop {
  background: rgba(16,185,129,.1);
  border-color: var(--advice-stop-border);
  color: #6ee7b7;
}

.urgent-msg {
  height: 22px;
  font-size: .9rem;
  font-weight: 600;
  color: #fbbf24;
  margin-bottom: 6px;
}

.decision-area { margin-top: 8px; }
.decision-area > p { margin-bottom: 14px; }
.decision-row { display: flex; gap: 18px; justify-content: center; }

/* ── Step 5: Outcome ─────────────────────────────────────────────────────── */
.outcome-text {
  font-size: 1.25rem;
  font-weight: 700;
  padding: 14px 24px;
  border-radius: 8px;
  margin: 4px 0 14px;
}
.outcome-stop    { background: rgba(16,185,129,.12);  color: #6ee7b7; }
.outcome-exploded{ background: rgba(239,68,68,.12);   color: #fca5a5; }
.outcome-success { background: rgba(96,165,250,.12);  color: #93c5fd; }

.score-block { margin-top: 6px; font-size: 1rem; }
.score-big   { font-size: 1.5rem; }

/* ── Step 6: Trust Rating ────────────────────────────────────────────────── */
#step-trust h2  { margin-bottom: 16px; }

.trust-prompt   { max-width: 500px; margin-bottom: 20px; }
.trust-prompt p { margin-bottom: 8px; }

.scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  color: var(--muted);
  margin: 6px 0 10px;
}

.say-hint {
  background: rgba(255,255,255,.05);
  border-radius: 6px;
  padding: 9px 14px;
  font-size: .95rem;
}

#trust-pre-rec { margin: 8px 0 4px; }

#trust-rec-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(233,69,96,.1);
  border: 1px solid #e94560;
  padding: 14px 22px;
  border-radius: 8px;
  font-size: 1rem;
}
.mic-icon { font-size: 1.4rem; }

#trust-buttons { margin-top: 20px; }
#trust-buttons p { margin-bottom: 14px; font-size: .95rem; color: var(--muted); }

.rating-row { display: flex; gap: 10px; justify-content: center; }

.rating-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.rating-btn:hover   { border-color: var(--accent); color: var(--accent); }
.rating-btn.selected{ background: var(--accent); border-color: var(--accent); color: #111; }

/* ── Step 7: ITI ─────────────────────────────────────────────────────────── */
.iti-text { font-size: 1.3rem; color: var(--muted); }

/* ── Completion ──────────────────────────────────────────────────────────── */
.final-score-wrap { margin: 22px 0; }

.code-wrap {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  margin-top: 20px;
}
.comp-code {
  font-family: 'Courier New', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 4px;
  margin: 10px 0;
}
