/* ═══════════════════════════════════════════════════════════
   CIPHER COURIER — Cyberpunk Encryption Learning App
   ═══════════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── THEME VARIABLES ──────────────────────────────────── */
:root {
  --bg: #0a0e17;
  --bg2: #0f1520;
  --panel: #111827;
  --panel2: #161e2f;
  --border: #1e293b;
  --border-bright: #334155;
  --text: #e2e8f0;
  --text-dim: #64748b;
  --text-muted: #475569;
  --accent: #00f0ff;
  --accent-dim: #00a0aa;
  --success: #00ff88;
  --error: #ff4466;
  --warning: #ffaa00;
  --node-color: var(--accent);
  --glow: 0 0 12px rgba(0, 240, 255, 0.15);
  --glow-strong: 0 0 24px rgba(0, 240, 255, 0.25);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f1f5f9;
    --bg2: #e2e8f0;
    --panel: #ffffff;
    --panel2: #f8fafc;
    --border: #cbd5e1;
    --border-bright: #94a3b8;
    --text: #1e293b;
    --text-dim: #64748b;
    --text-muted: #94a3b8;
    --accent: #0891b2;
    --accent-dim: #0e7490;
    --success: #059669;
    --error: #dc2626;
    --warning: #d97706;
    --glow: 0 0 12px rgba(8, 145, 178, 0.1);
    --glow-strong: 0 0 24px rgba(8, 145, 178, 0.15);
  }
}

html[data-theme="dark"] {
  --bg: #0a0e17;
  --bg2: #0f1520;
  --panel: #111827;
  --panel2: #161e2f;
  --border: #1e293b;
  --border-bright: #334155;
  --text: #e2e8f0;
  --text-dim: #64748b;
  --text-muted: #475569;
  --accent: #00f0ff;
  --accent-dim: #00a0aa;
  --success: #00ff88;
  --error: #ff4466;
  --warning: #ffaa00;
  --glow: 0 0 12px rgba(0, 240, 255, 0.15);
  --glow-strong: 0 0 24px rgba(0, 240, 255, 0.25);
}

html[data-theme="light"] {
  --bg: #f1f5f9;
  --bg2: #e2e8f0;
  --panel: #ffffff;
  --panel2: #f8fafc;
  --border: #cbd5e1;
  --border-bright: #94a3b8;
  --text: #1e293b;
  --text-dim: #64748b;
  --text-muted: #94a3b8;
  --accent: #0891b2;
  --accent-dim: #0e7490;
  --success: #059669;
  --error: #dc2626;
  --warning: #d97706;
  --glow: 0 0 12px rgba(8, 145, 178, 0.1);
  --glow-strong: 0 0 24px rgba(8, 145, 178, 0.15);
}

html { color-scheme: dark; }
@media (prefers-color-scheme: light) { html { color-scheme: light; } }
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

/* ── BOOT OVERLAY ─────────────────────────────────────── */
.boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}
.boot-text {
  font-size: 13px;
  color: var(--accent);
  text-align: left;
  line-height: 2;
  letter-spacing: 0.05em;
}
.boot-text div { opacity: 0; animation: bootFade 0.4s ease forwards; }
.boot-text div:nth-child(1) { animation-delay: 0.2s; }
.boot-text div:nth-child(2) { animation-delay: 0.6s; }
.boot-text div:nth-child(3) { animation-delay: 1.0s; }
.boot-ready { color: var(--success) !important; animation-delay: 1.4s !important; }
@keyframes bootFade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── APP LAYOUT ───────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0;
}

/* ── HUD ──────────────────────────────────────────────── */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.hud-left { display: flex; flex-direction: column; }
.hud-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: var(--glow);
  text-transform: uppercase;
}
.hud-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.hud-right { display: flex; align-items: center; gap: 12px; }
.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.stat-label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.stat-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.sound-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  color: var(--text-dim);
  cursor: pointer;
  transition: var(--transition);
}
.sound-toggle:hover { color: var(--accent); border-color: var(--accent); }
.sound-toggle.muted { opacity: 0.4; }

/* ── NAV BAR ──────────────────────────────────────────── */
.nav-bar {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
}
.nav-btn:hover { color: var(--text); background: var(--panel); }
.nav-btn.active {
  color: var(--accent);
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: var(--glow);
}
.nav-icon { font-size: 14px; }

/* ── MAIN CONTENT ─────────────────────────────────────── */
#main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ── SCREEN TITLES ────────────────────────────────────── */
.screen-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  margin-bottom: 4px;
}
.screen-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ── MISSION BRIEFING ─────────────────────────────────── */
.mission-briefing {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
}
.briefing-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
}
.briefing-icon { font-size: 16px; }
.briefing-stamp {
  margin-left: auto;
  font-size: 9px;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.15em;
}
.briefing-body { padding: 14px; }
.briefing-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 8px;
}
.briefing-text:last-child { margin-bottom: 0; }
.briefing-text strong { color: var(--text); }
.briefing-cta {
  color: var(--accent) !important;
  font-weight: 600;
}

/* ── PROGRESS BAR ─────────────────────────────────────── */
.progress-section { margin-bottom: 16px; }
.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 3px;
  transition: width 0.5s ease;
}
.progress-text {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
}

/* ── NODE GRID ────────────────────────────────────────── */
.node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.node-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.node-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--node-color);
  opacity: 0.6;
}
.node-card:not(.locked):hover {
  border-color: var(--node-color);
  box-shadow: var(--glow);
  transform: translateY(-2px);
}
.node-card.locked {
  opacity: 0.4;
  cursor: default;
}
.node-card.completed::before {
  background: var(--success);
  opacity: 1;
}
.node-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--node-color);
}
.node-icon.locked-icon { color: var(--text-muted); }
.node-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  text-transform: uppercase;
}
.node-tag {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.node-status {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}
.done-status { color: var(--success); }
.next-status { color: var(--accent); background: rgba(0,240,255,0.1); }
.unlocked-status { color: var(--text-dim); }
.locked-status { color: var(--text-muted); }
.node-hint {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
}
.node-enter {
  font-size: 9px;
  color: var(--accent);
  margin-top: 4px;
  opacity: 0;
  transition: var(--transition);
}
.node-card:not(.locked):hover .node-enter { opacity: 1; }

/* ── BADGES PANEL ─────────────────────────────────────── */
.badges-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 16px;
}
.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
}
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.badge-item {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  transition: var(--transition);
}
.badge-item.earned {
  border-color: var(--badge-color);
  box-shadow: 0 0 8px rgba(0,0,0,0.2);
}
.badge-item.locked { opacity: 0.35; }
.badge-icon {
  width: 24px;
  height: 24px;
  color: var(--badge-color);
}
.badge-name {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  text-transform: uppercase;
}
.badge-desc {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ── NODE DETAIL ──────────────────────────────────────── */
.node-detail {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: var(--transition);
  margin: 14px 14px 0;
}
.back-btn:hover { color: var(--accent); border-color: var(--accent); }

.node-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.node-header-icon {
  width: 48px;
  height: 48px;
  color: var(--node-color);
  flex-shrink: 0;
}
.node-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  text-transform: uppercase;
}
.node-tag {
  font-size: 10px;
  color: var(--node-color);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.node-era {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── TAB BAR ──────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab-btn {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--text); background: var(--panel2); }
.tab-btn.active {
  color: var(--node-color);
  border-bottom-color: var(--node-color);
}

/* ── NODE DETAIL WRAP ─────────────────────────────────── */
.node-detail-wrap {
  display: flex;
  flex-direction: column;
}
@media (min-width: 640px) {
  .node-detail-wrap {
    flex-direction: row;
  }
  .node-detail-main { flex: 1; min-width: 0; }
  .alphabet-sidebar { width: 200px; flex-shrink: 0; }
}

/* ── LEARN SECTION ────────────────────────────────────── */
.learn-section { padding: 16px; }
.learn-intro {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.section-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 10px;
  text-transform: uppercase;
}
.how-list {
  list-style: none;
  margin-bottom: 16px;
}
.how-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.how-num {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.how-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  padding-top: 2px;
}
.why-matters {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
}
.why-matters-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--warning);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.why-matters-text {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}
.learn-summary {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  padding: 10px;
  background: var(--panel2);
  border-left: 3px solid var(--node-color);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 16px;
}
.summary-label {
  font-weight: 700;
  color: var(--node-color);
  margin-right: 4px;
}

/* ── INTERACTIVE WHEEL ────────────────────────────────── */
.interactive-wheel-section {
  margin-bottom: 16px;
}
.wheel-instruction {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-align: center;
}
.caesar-wheel-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}
.caesar-wheel {
  width: 300px;
  height: 300px;
  max-width: 100%;
}
.wheel-letter {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  fill: var(--text-dim);
  transition: var(--transition);
}
.wheel-letter.active {
  fill: var(--accent);
  font-weight: 700;
}
.wheel-hub {
  fill: var(--panel2);
  stroke: var(--border);
  stroke-width: 1;
}
.wheel-center-text {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 14px;
  font-weight: 700;
  fill: var(--accent);
  text-anchor: middle;
  dominant-baseline: central;
}
.wheel-marker {
  fill: var(--accent);
}
.wheel-ray {
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0.5;
}
.wheel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}
.wheel-ctrl-btn {
  padding: 6px 14px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.wheel-ctrl-btn:hover { color: var(--accent); border-color: var(--accent); }
.wheel-shift-display {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.wheel-mapping {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  overflow-x: auto;
}
.wheel-mapping-row {
  display: flex;
  gap: 2px;
  margin-bottom: 4px;
}
.wheel-mapping-row:last-child { margin-bottom: 0; }
.wm-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 40px;
  display: flex;
  align-items: center;
  letter-spacing: 0.05em;
}
.wm-cell {
  font-size: 9px;
  font-family: 'SF Mono', monospace;
  color: var(--text-dim);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}
.wm-cell.cipher { color: var(--accent); font-weight: 600; }

/* ── CAESAR WHEEL (static example) ────────────────────── */
.caesar-wheel-section {
  margin-bottom: 16px;
}
.wheel-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 8px;
}

/* ── ALPHABET SIDEBAR ─────────────────────────────────── */
.alphabet-sidebar {
  background: var(--panel2);
  border-top: 1px solid var(--border);
  padding: 12px;
}
@media (min-width: 640px) {
  .alphabet-sidebar {
    border-top: none;
    border-left: 1px solid var(--border);
  }
}
.alpha-ref-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.alpha-ref-sub {
  font-size: 9px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.alpha-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-bottom: 8px;
}
.alpha-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.alpha-cell:hover { border-color: var(--accent); }
.alpha-cell.alpha-hl {
  background: rgba(0, 240, 255, 0.1);
  border-color: var(--accent);
}
.alpha-letter {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.alpha-num {
  font-size: 8px;
  color: var(--text-muted);
  line-height: 1;
}
.alpha-ref-instruction {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
}
.alpha-ref-tip {
  font-size: 10px;
  color: var(--accent);
  margin-top: 8px;
  padding: 6px 8px;
  background: var(--panel);
  border-radius: 4px;
  text-align: center;
  line-height: 1.4;
}

/* ── EXAMPLE SECTION ──────────────────────────────────── */
.example-section { padding: 16px; }
.ex-prompt {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  padding: 8px 12px;
  background: rgba(0, 240, 255, 0.05);
  border: 1px solid rgba(0, 240, 255, 0.15);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

/* ── CIPHER GRID ──────────────────────────────────────── */
.cipher-grid {
  margin-bottom: 14px;
}
.cipher-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}
.cipher-row-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  min-width: 44px;
}
.cipher-cell {
  width: 28px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  transition: var(--transition);
}
.cipher-cell.current-plain {
  border-color: var(--node-color);
  box-shadow: var(--glow);
}
.cipher-cell.key-cell {
  font-size: 9px;
  color: var(--accent);
  background: rgba(0, 240, 255, 0.05);
}
.cipher-cell-result {
  color: var(--accent);
}
.cipher-cell-result.revealed {
  background: rgba(0, 255, 136, 0.08);
  border-color: var(--success);
  color: var(--success);
}
.cipher-cell-result.active {
  border-color: var(--node-color);
  box-shadow: var(--glow);
  animation: cipherPulse 1s ease infinite;
}
@keyframes cipherPulse {
  0%, 100% { box-shadow: var(--glow); }
  50% { box-shadow: var(--glow-strong); }
}

/* ── WALKTHROUGH ──────────────────────────────────────── */
.walkthrough {
  margin-bottom: 14px;
}
.wt-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.wt-journey {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 10px;
}
.wt-big-letter-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.wt-big-letter {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', monospace;
  font-size: 20px;
  font-weight: 700;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.wt-big-letter.result {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--glow);
}
.wt-letter-info {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: center;
  max-width: 80px;
}
.wt-arrow-big {
  font-size: 18px;
  color: var(--text-muted);
}
.wt-math-box {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.wt-math-line {
  font-size: 11px;
  font-family: 'SF Mono', monospace;
  color: var(--text-dim);
}
.wt-math-wrap {
  color: var(--accent);
  font-weight: 600;
}
.wt-xor-math {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.wt-bin-row {
  font-size: 11px;
  font-family: 'SF Mono', monospace;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}
.wt-bin-label { min-width: 60px; }
.wt-bin-val {
  color: var(--accent);
  font-weight: 600;
}
.wt-bin-divider {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.1em;
}
.wt-bin-row.result .wt-bin-val { color: var(--success); }
.wt-counting {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}
.wt-counting-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.wt-count-steps {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.wt-count-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: wtCountIn 0.3s ease both;
}
@keyframes wtCountIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}
.wt-count-letter {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  font-family: 'SF Mono', monospace;
}
.wt-count-num {
  font-size: 8px;
  color: var(--text-muted);
}
.wt-simple {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  padding: 8px 12px;
  background: var(--panel2);
  border-left: 3px solid var(--node-color);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ── STEP DOTS & CONTROLS ─────────────────────────────── */
.ex-step-label {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 12px;
  padding: 10px;
  background: var(--panel2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.step-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}
.step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: var(--transition);
}
.step-dot.on {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.4);
}
.ex-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── CHALLENGE SECTION ────────────────────────────────── */
.challenge-section { padding: 16px; }
.challenge-prompt {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  padding: 12px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  line-height: 1.6;
  white-space: pre-line;
}
.result-box {
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  text-align: center;
}
.result-box.success {
  background: rgba(0, 255, 136, 0.08);
  border: 1px solid rgba(0, 255, 136, 0.2);
}
.result-box.error {
  background: rgba(255, 68, 102, 0.08);
  border: 1px solid rgba(255, 68, 102, 0.2);
}
.result-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.result-box.success .result-title { color: var(--success); }
.result-box.error .result-title { color: var(--error); }
.result-msg {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.result-sub {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.result-badge {
  font-size: 11px;
  color: var(--warning);
  font-weight: 700;
  margin-top: 4px;
}
.result-unlock {
  font-size: 11px;
  color: var(--success);
  margin-top: 4px;
}
.challenge-hint {
  font-size: 11px;
  color: var(--warning);
  padding: 8px 12px;
  background: rgba(255, 170, 0, 0.05);
  border: 1px solid rgba(255, 170, 0, 0.15);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.challenge-hint-small {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.challenge-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.challenge-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── OPTION BUTTONS ───────────────────────────────────── */
.option-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(0, 240, 255, 0.05);
}
.option-btn:disabled { cursor: default; }
.option-btn.correct-flash {
  border-color: var(--success) !important;
  background: rgba(0, 255, 136, 0.1) !important;
}
.option-btn.wrong-flash {
  border-color: var(--error) !important;
  background: rgba(255, 68, 102, 0.1) !important;
}
.option-btn.dimmed { opacity: 0.4; }
.option-letter {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.option-text { flex: 1; }

/* ── CYBER BUTTONS ────────────────────────────────────── */
.cyber-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.cyber-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--glow);
}
.cyber-btn.secondary:hover {
  border-color: var(--text-dim);
  color: var(--text-dim);
  box-shadow: none;
}
.cyber-btn.large {
  padding: 12px 24px;
  font-size: 13px;
  width: 100%;
}
.cyber-btn.small {
  padding: 6px 12px;
  font-size: 10px;
}

/* ── ARCHIVE ──────────────────────────────────────────── */
.archive { padding: 0; }
.archive-list { display: flex; flex-direction: column; gap: 8px; }
.archive-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  transition: var(--transition);
}
.archive-card.locked { opacity: 0.4; }
.archive-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.archive-icon {
  width: 32px;
  height: 32px;
  color: var(--node-color);
  flex-shrink: 0;
}
.archive-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  text-transform: uppercase;
}
.archive-tag {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.archive-check {
  margin-left: auto;
  color: var(--success);
}
.archive-summary {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 8px;
}
.archive-example {
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 8px;
  line-height: 1.5;
}
.archive-ex-label {
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
}
.archive-locked-msg {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

/* ── TRIAL GRID ───────────────────────────────────────── */
.trial { padding: 0; }
.trial-info {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.trial-stat {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.trial-stat-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.trial-stat-label {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}
.trial-locked {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.trial-rules {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 16px;
}
.trial-rule {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 0;
  line-height: 1.5;
}
.trial-result {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}
.trial-result.pass { border-color: var(--success); }
.trial-result.fail { border-color: var(--error); }
.result-big {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.trial-result.pass .result-big { color: var(--success); }
.trial-result.fail .result-big { color: var(--error); }
.result-score {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 4px;
}
.result-pct {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}
.result-badge-earned {
  font-size: 12px;
  color: var(--warning);
  font-weight: 700;
  margin-bottom: 4px;
}
.result-score-add {
  font-size: 12px;
  color: var(--success);
  margin-bottom: 12px;
}
.result-encourage {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.answer-review {
  text-align: left;
  margin-bottom: 16px;
}
.review-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}
.review-icon {
  font-weight: 700;
  min-width: 16px;
}
.review-item.right .review-icon { color: var(--success); }
.review-item.wrong .review-icon { color: var(--error); }
.review-q { color: var(--text-dim); }
.trial-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── QUIZ ─────────────────────────────────────────────── */
.quiz-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.quiz-progress {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.quiz-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.quiz-score {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.quiz-question-type {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.quiz-question {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.6;
  white-space: pre-line;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── SYMMETRIC VISUAL ─────────────────────────────────── */
.sym-visual {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.sym-box {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  text-align: center;
  min-width: 60px;
  transition: var(--transition);
}
.sym-box.faded { opacity: 0.3; }
.sym-box.active {
  border-color: var(--accent);
  box-shadow: var(--glow);
}
.sym-box.restored {
  border-color: var(--success);
  box-shadow: 0 0 12px rgba(0, 255, 136, 0.2);
}
.sym-label {
  font-size: 8px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 2px;
}
.sym-content {
  font-family: 'SF Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.sym-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0.3;
  transition: var(--transition);
}
.sym-arrow.active { opacity: 1; }
.sym-arrow-text {
  font-size: 8px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sym-arrow-line {
  font-size: 12px;
  color: var(--accent);
}
.sym-key-tag {
  font-size: 7px;
  color: var(--text-muted);
  background: var(--panel);
  padding: 2px 4px;
  border-radius: 2px;
}

/* ── RAIL FENCE VISUAL ────────────────────────────────── */
.railfence-visual {
  margin-bottom: 14px;
}
.rf-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
  text-align: center;
}
.rf-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.rf-rail {
  display: flex;
  gap: 3px;
}
.rf-cell {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SF Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  transition: var(--transition);
}
.rf-cell.on-rail {
  color: var(--text);
  border-color: var(--border-bright);
}
.rf-cell.revealed {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 240, 255, 0.08);
}
.rf-readout {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.rf-readout-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.rf-readout-rail {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.rf-rail-num {
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
}
.rf-readout-cell {
  font-family: 'SF Mono', monospace;
  font-weight: 700;
  color: var(--text);
}
.rf-readout-cell.revealed {
  color: var(--accent);
}

/* ── ERROR SCREEN ─────────────────────────────────────── */
.error-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--error);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

/* ── SCROLLBAR ────────────────────────────────────────── */
#main::-webkit-scrollbar { width: 6px; }
#main::-webkit-scrollbar-track { background: transparent; }
#main::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
#main::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 480px) {
  .hud { padding: 8px 12px; }
  .hud-title { font-size: 14px; }
  .nav-btn { padding: 6px 8px; font-size: 10px; }
  #main { padding: 12px; }
  .node-grid { grid-template-columns: repeat(2, 1fr); }
  .badges-grid { grid-template-columns: repeat(2, 1fr); }
  .cipher-cell { width: 24px; height: 28px; font-size: 12px; }
  .sym-visual { gap: 4px; }
  .sym-box { padding: 6px 8px; min-width: 48px; }
  .sym-content { font-size: 11px; }
}

@media (max-width: 360px) {
  .hud-title { font-size: 12px; }
  .hud-sub { font-size: 9px; }
  .stat-val { font-size: 14px; }
  .node-grid { grid-template-columns: 1fr; }
  .badges-grid { grid-template-columns: 1fr; }
}
