/* ── RESET & BASE ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg:        #0d0f14;
  --bg2:       #13161e;
  --bg3:       #1c2030;
  --accent:    #00e5a0;
  --accent2:   #ff6b35;
  --accent3:   #7c6fff;
  --warning:   #ffa502;
  --danger:    #ff4757;
  --text:      #e8eaf0;
  --text-dim:  #e2e8f0;
  --border:    rgba(255,255,255,0.08);
  --radius:    12px;
  --font:      -apple-system, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  --mono:      'SF Mono', 'Courier New', monospace;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── SCREENS ───────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.screen.active { display: block; }

/* ── LOADING ───────────────────────────────────────────────────────────────── */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px;
  text-align: center;
}

.logo-text {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 40px;
  color: var(--text);
}

.logo-text span { color: var(--accent); }

.loading-bar {
  width: 200px;
  height: 3px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 16px;
}

.loading-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  animation: loadfill 2s ease-in-out forwards;
}

@keyframes loadfill {
  from { width: 0; }
  to   { width: 100%; }
}

.loading-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}

/* ── ONBOARDING ────────────────────────────────────────────────────────────── */
.onboarding-content {
  min-height: 100vh;
  padding: 60px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.axis-face {
  font-size: 60px;
  margin-bottom: 24px;
  color: var(--accent);
}

/* ── HOME HEADER ───────────────────────────────────────────────────────────── */
.home-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 16px 8px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.agent-name {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.1em;
}

.agent-rank {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  margin-top: 2px;
}

/* ── DUAL CURRENCY ─────────────────────────────────────────────────────────── */
.currency-display {
  display: flex;
  align-items: center;
  gap: 12px;
}

.currency-item { text-align: right; }

.credits-amount {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.token-amount { color: var(--accent3); }

.credits-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: #ffffff;
  margin-top: 2px;
}

.credits-aud {
  font-family: var(--mono);
  color: #ffffff;
  margin-top: 1px;
}

.currency-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

/* ── WEEKLY BAR ────────────────────────────────────────────────────────────── */
.weekly-bar {
  height: 4px;
  background: var(--bg3);
  margin: 0;
}

.weekly-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent3));
  transition: width 0.5s ease;
  width: 0%;
}

.weekly-bar-label {
  font-family: var(--mono);
  font-size: 10px;
  color: #ffffff;
  letter-spacing: 0.08em;
  text-align: center;
  padding: 4px 16px;
  background: var(--bg2);
}

/* ── STREAK ────────────────────────────────────────────────────────────────── */
.streak-bar {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--warning);
  text-align: center;
  padding: 6px 16px;
  background: var(--bg2);
}

/* ── AXIS MESSAGE ──────────────────────────────────────────────────────────── */
.axis-message {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
}

.home-message {
  padding: 14px 16px;
  background: var(--bg2);
  border-left: 3px solid var(--accent);
  margin: 0;
  font-size: 14px;
}

/* ── WEEKLY MISSIONS STRIP ─────────────────────────────────────────────────── */
.weekly-missions-strip {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
}

.wm-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--accent3);
  margin-bottom: 10px;
}

.wm-item { margin-bottom: 8px; }

.wm-name {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}

.wm-bar-wrap {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 3px;
}

.wm-bar-fill {
  height: 100%;
  background: var(--accent3);
  border-radius: 2px;
  transition: width 0.4s;
}

.wm-progress {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* ── MISSION GRID ──────────────────────────────────────────────────────────── */
.mission-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.mission-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  user-select: none;
}

.mission-card:active:not(.completed) {
  transform: scale(0.97);
  border-color: var(--accent);
}

.mission-card.completed {
  opacity: 0.55;
  cursor: default;
  border-color: var(--accent);
  border-style: solid;
}

.mission-lock-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 14px;
}

.mission-icon {
  font-size: 28px;
  margin-bottom: 6px;
}

.mission-name {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  margin-bottom: 3px;
}

.mission-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.mission-credits {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.mission-card.completed .mission-credits { color: var(--text-dim); }

/* ── EXTRA CLASS BUTTON ────────────────────────────────────────────────────── */
.extra-class-btn {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent3), var(--accent2));
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124,111,255,0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(124,111,255,0); }
}

/* ── HARD MOMENT BUTTON ────────────────────────────────────────────────────── */
.hard-moment-btn {
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  padding: 16px;
  background: var(--bg3);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.15s;
}

.hard-moment-btn:active {
  background: var(--danger);
  color: #fff;
}

/* ── BOTTOM NAV ────────────────────────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  background: var(--bg2);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
}

.nav-btn {
  background: none;
  border: none;
  font-size: 22px;
  padding: 8px 16px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.nav-btn.active { opacity: 1; }

/* ── MODULE SCREEN ─────────────────────────────────────────────────────────── */
.module-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.back-btn {
  background: none;
  border: 1px solid var(--border);
  color: #ffffff;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.module-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  flex: 1;
}

.module-character { font-size: 24px; }

.module-content {
  padding: 20px 16px;
}

/* ── INPUTS ────────────────────────────────────────────────────────────────── */
.mission-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  outline: none;
  margin-top: 8px;
  -webkit-appearance: none;
  transition: border-color 0.2s;
}

.mission-input:focus { border-color: var(--accent); }

textarea.mission-input {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.writing-input { min-height: 150px; }

.char-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  text-align: right;
}

/* ── BUTTONS ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 13px 24px;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-align: center;
  width: 100%;
}

.btn:active { transform: scale(0.97); }
.btn-primary  { background: var(--accent);  color: #000; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-ghost    { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.btn-row .btn { flex: 1; }

/* ── CHOICE PILLS ──────────────────────────────────────────────────────────── */
.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.choice-pill {
  padding: 10px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  line-height: 1.4;
}

.choice-pill.selected {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

/* ── CHOICE BUTTONS (social module) ───────────────────────────────────────── */
.choice-btn {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  margin-bottom: 10px;
  transition: all 0.15s;
}

.choice-btn:active {
  border-color: var(--accent);
  background: var(--bg2);
}

/* ── NUMBERS PROBLEM ───────────────────────────────────────────────────────── */
.numbers-problem {
  font-size: 20px;
  text-align: center;
  padding: 24px 16px;
  background: var(--bg3);
  border-radius: var(--radius);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ── SPELLING ──────────────────────────────────────────────────────────────── */
.play-btn {
  font-size: 16px;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.phonics-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 8px;
  font-family: var(--mono);
  letter-spacing: 0.05em;
}

.hint-btn {
  padding: 10px 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.hint-cost {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 6px;
  letter-spacing: 0.05em;
}

/* ── FEEDBACK ──────────────────────────────────────────────────────────────── */
.feedback-area {
  margin-top: 20px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--bg2);
  border: 1px solid var(--border);
}

.feedback-area.hidden { display: none; }
.feedback-area.correct   { border-color: var(--accent); }
.feedback-area.incorrect { border-color: var(--accent2); }

.feedback-text {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.credits-burst {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin: 12px 0;
}

.tokens-burst {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent3);
  text-align: center;
  margin: 8px 0;
}

.bd-bonus {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--warning);
  text-align: center;
  margin: 6px 0;
}

.session-bonus {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--accent);
  text-align: center;
  margin: 10px 0;
  padding: 10px;
  background: rgba(0,229,160,0.1);
  border-radius: 8px;
}

.level-up {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--warning);
  text-align: center;
  margin: 8px 0;
}

.reward-alert {
  font-size: 13px;
  color: var(--warning);
  text-align: center;
  margin: 8px 0;
  padding: 10px;
  background: rgba(255,165,2,0.1);
  border-radius: 8px;
}

.formula-box {
  font-family: var(--mono);
  font-size: 18px;
  text-align: center;
  padding: 12px;
  background: var(--bg3);
  border-radius: 8px;
  color: var(--accent);
  margin: 10px 0;
  letter-spacing: 0.05em;
}

/* ── VIDEO RECOMMENDATION ──────────────────────────────────────────────────── */
.video-rec {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg3);
  border-radius: 8px;
  border-left: 3px solid var(--accent2);
}

.video-rec-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--accent2);
  margin-bottom: 4px;
}

.video-rec-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.video-rec-search {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── BAD DAY ───────────────────────────────────────────────────────────────── */
.bad-day-screen {
  padding: 16px;
  grid-column: span 2;
}

.bad-day-msg {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 14px;
  background: var(--bg3);
  border-radius: var(--radius);
  border-left: 3px solid var(--warning);
}

/* ── HARD MOMENT SCREEN ────────────────────────────────────────────────────── */
.hard-moment-content {
  min-height: 100vh;
  padding: 60px 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.hm-character { font-size: 64px; margin-bottom: 24px; }

.hm-message {
  font-size: 18px;
  line-height: 1.6;
  margin-bottom: 32px;
  max-width: 320px;
}

.hm-timer { text-align: center; margin-bottom: 32px; }
.hm-timer.hidden { display: none; }

#hm-timer-count {
  font-family: var(--mono);
  font-size: 64px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.hm-timer-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ── DEBRIEF ───────────────────────────────────────────────────────────────── */
.debrief-content { padding: 0; }

.debrief-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.debrief-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}

#debrief-area { padding: 20px 16px; }

.debrief-question { margin-bottom: 20px; }

.debrief-q-text {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

/* ── REWARDS SCREEN ────────────────────────────────────────────────────────── */
.rewards-content { padding: 0; }

.rewards-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.rewards-title {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.rewards-balance {
  display: flex;
  justify-content: center;
  gap: 32px;
  padding: 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.rewards-balance-item { text-align: center; }
.rb-value { font-family: var(--mono); font-size: 24px; font-weight: 700; color: var(--accent); }
.rb-label { font-family: var(--mono); font-size: 10px; color: var(--text-dim); letter-spacing: 0.1em; margin-top: 2px; }

#rewards-list { padding: 12px 16px; }

.reward-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.reward-tier-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.reward-name {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.reward-cost {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 10px;
}

.reward-progress {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.reward-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s;
}

.reward-progress-fill.token { background: var(--accent3); }

.reward-pct {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.reward-claim-btn {
  padding: 12px;
  font-size: 12px;
}

/* ── VIDEO VAULT ───────────────────────────────────────────────────────────── */
.video-vault-sub {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-align: center;
  padding: 8px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

#video-list { padding: 12px 16px; }

.video-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}

.video-icon { font-size: 28px; flex-shrink: 0; }

.video-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
}

.video-channel {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.video-search {
  font-size: 12px;
  color: var(--accent);
  font-family: var(--mono);
}

/* ── TRANSMITTING ──────────────────────────────────────────────────────────── */
.transmitting {
  text-align: center;
  padding: 40px 20px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.loading-msg {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* ── TOAST ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast.hidden { display: none; }

/* ── SCROLLBAR ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 2px; }
