:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --bg3: #1a1a28;
  --accent: #00ff88;
  --accent2: #0088ff;
  --warning: #ff8800;
  --danger: #ff3355;
  --text: #e8e8f0;
  --text-dim: #8888aa;
  --border: #2a2a3a;
  --radius: 12px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', monospace;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

/* ── LOADING ── */
.loading-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 40px;
}

.logo-text {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 8px;
  text-align: center;
  line-height: 1.1;
  color: var(--text);
}
.logo-text span { color: var(--accent); }

.loading-bar {
  width: 200px;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  overflow: hidden;
}
.loading-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  animation: loadfill 2s ease-in-out forwards;
}
@keyframes loadfill { to { width: 100%; } }

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

/* ── ONBOARDING ── */
.onboarding-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px 24px;
}

.axis-face {
  font-size: 64px;
  color: var(--accent);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.6; } }

/* ── AXIS MESSAGE ── */
.axis-message {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  width: 100%;
  max-width: 480px;
}

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

.agent-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}
.agent-rank {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 3px;
  margin-top: 4px;
}

.credits-display {
  text-align: right;
}
.credits-amount {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 1px;
}
.credits-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 3px;
}

.streak-bar {
  background: var(--bg3);
  padding: 8px 20px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
}

.home-message {
  margin: 16px 20px;
  font-size: 14px;
}

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

.mission-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}
.mission-card:active { transform: scale(0.97); }
.mission-card.completed {
  border-color: var(--accent);
  opacity: 0.6;
}
.mission-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.mission-card[data-type="spelling"]::before { background: var(--accent); }
.mission-card[data-type="reading"]::before { background: var(--accent2); }
.mission-card[data-type="writing"]::before { background: #aa44ff; }
.mission-card[data-type="numbers"]::before { background: var(--warning); }
.mission-card[data-type="social"]::before { background: #ff44aa; }
.mission-card[data-type="coding"]::before { background: #44ffff; }

.mission-icon { font-size: 24px; }
.mission-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.mission-credits {
  font-size: 13px;
  color: var(--accent);
  font-weight: 700;
}

/* ── HARD MOMENT BUTTON ── */
.hard-moment-btn {
  margin: 0 20px 16px;
  width: calc(100% - 40px);
  padding: 16px;
  background: transparent;
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.15s;
}
.hard-moment-btn:active {
  background: var(--danger);
  color: white;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  padding: 14px;
  background: none;
  border: none;
  font-size: 20px;
  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: 52px 20px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: 'Courier New', monospace;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}
.module-title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
}
.module-character { font-size: 20px; }

.module-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  overflow-y: auto;
}

/* ── INPUT FIELDS ── */
.mission-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--text);
  font-family: 'Courier New', monospace;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
  -webkit-user-select: text;
  user-select: text;
}
.mission-input:focus { border-color: var(--accent); }
.mission-input::placeholder { color: var(--text-dim); }

textarea.mission-input {
  min-height: 120px;
  resize: none;
}

/* ── BUTTONS ── */
.btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius);
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:active { opacity: 0.85; }
.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}

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

/* ── HINT BUTTON ── */
.hint-btn {
  background: none;
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  color: var(--warning);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 8px 16px;
  cursor: pointer;
  letter-spacing: 1px;
}
.hint-cost { font-size: 10px; color: var(--text-dim); margin-top: 4px; text-align: center; }

/* ── FEEDBACK ── */
.feedback-area {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
}
.feedback-area.correct { border-color: var(--accent); }
.feedback-area.incorrect { border-color: var(--warning); }

.credits-burst {
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 2px;
  animation: burst 0.5s ease-out;
}
@keyframes burst {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

/* ── HARD MOMENT SCREEN ── */
.hard-moment-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 40px 24px;
}

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

.hm-message {
  text-align: center;
  border-left-color: var(--danger);
}

.hm-timer {
  text-align: center;
}
.hm-timer-count {
  font-size: 64px;
  font-weight: 900;
  color: var(--danger);
  letter-spacing: 4px;
}
.hm-timer-label {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 4px;
  margin-top: 8px;
}

#hm-action-area { width: 100%; max-width: 400px; }

/* ── DEBRIEF ── */
.debrief-content { padding: 52px 20px 20px; flex: 1; overflow-y: auto; }
.debrief-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.debrief-title { font-size: 14px; font-weight: 700; letter-spacing: 3px; color: var(--accent); }

.debrief-question {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.debrief-q-text {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* ── REWARDS ── */
.rewards-content { padding: 52px 20px 20px; flex: 1; overflow-y: auto; }
.rewards-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.rewards-title { font-size: 14px; font-weight: 700; letter-spacing: 3px; color: var(--accent); }

.reward-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.reward-name { font-size: 14px; font-weight: 700; }
.reward-cost { font-size: 13px; color: var(--accent); }
.reward-progress {
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.reward-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.reward-claimed {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 2px;
}

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

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  z-index: 9999;
  transition: opacity 0.3s;
}
.toast.hidden { display: none; }

/* ── MULTI-CHOICE ONBOARDING ── */
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}
.choice-pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px 8px;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
}
.choice-pill.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0,255,136,0.1);
}

.hidden { display: none !important; }
