/* ============================================================
   THAUMAZEIN — Mobile-first CSS
   ============================================================ */

:root {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card-hover: #242442;
  --text: #e8e8f0;
  --text-muted: #9090a8;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --danger: #e74c3c;
  --success: #2ecc71;
  --gold: #f39c12;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT ===== */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 100px;
}

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  padding: 16px 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.app-header h1 {
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}

.app-header .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.btn-back {
  background: none;
  border: none;
  color: var(--accent-light);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
}

/* ===== NAV BOTTOM ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 10px;
  cursor: pointer;
  padding: 4px 16px;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--accent-light);
}

.nav-item .nav-icon {
  font-size: 22px;
}

/* ===== VIEWS ===== */
.view {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view.active { display: block; }

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

/* ===== HOME ===== */
.home-hero {
  text-align: center;
  padding: 40px 0 24px;
}

.home-hero .logo {
  font-size: 64px;
  margin-bottom: 8px;
}

.home-hero h2 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-hero p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 8px;
  line-height: 1.6;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

.mode-card {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-card:active {
  transform: scale(0.97);
  background: var(--bg-card-hover);
}

.mode-card .emoji {
  font-size: 36px;
  margin-bottom: 8px;
}

.mode-card h3 {
  font-size: 14px;
  font-weight: 600;
}

.mode-card p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stats-bar {
  display: flex;
  justify-content: space-around;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 20px;
}

.stat-item {
  text-align: center;
}

.stat-item .num {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-item .label {
  font-size: 10px;
  color: var(--text-muted);
}

/* ===== CARD LIBRARY ===== */
.category-section {
  margin-bottom: 24px;
}

.category-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-item {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-item:active {
  transform: scale(0.98);
  background: var(--bg-card-hover);
}

.card-item .card-num {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 28px;
}

.card-item .card-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.card-item .card-tags {
  display: flex;
  gap: 4px;
}

.card-item .tag {
  font-size: 9px;
  background: rgba(108,92,231,0.2);
  color: var(--accent-light);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.card-item .card-check {
  font-size: 16px;
  margin-left: 8px;
}

/* ===== DILEMMA VIEW ===== */
.dilemma-header {
  margin-bottom: 16px;
}

.dilemma-header .meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}

.dilemma-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.dilemma-situation {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  line-height: 1.7;
  font-size: 15px;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.option-btn {
  background: var(--bg-card);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  color: var(--text);
}

.option-btn:active { transform: scale(0.98); }

.option-btn.selected-a {
  border-color: var(--danger);
  background: rgba(231,76,60,0.1);
}

.option-btn.selected-b {
  border-color: var(--success);
  background: rgba(46,204,113,0.1);
}

.option-btn .option-label {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 4px;
}

.option-btn .option-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== ANALYSIS (VERSO) ===== */
.analysis-section {
  margin-top: 16px;
}

.analysis-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.analysis-card h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.lunette-item {
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 8px;
}

.lunette-item .lunette-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
}

.lunette-item .lunette-philo {
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 4px;
}

.lunette-item .lunette-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.curseur-item {
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-muted);
}

.curseur-item:last-child { border-bottom: none; }

/* ===== INTERACTIVE CURSEURS ===== */
.curseur-interactif {
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  transition: all 0.3s;
  border: 1px solid rgba(255,255,255,0.06);
}

.curseur-interactif.answered {
  opacity: 0.7;
  border-color: rgba(108,92,231,0.3);
}

.curseur-question {
  line-height: 1.5;
  margin-bottom: 10px;
}

.curseur-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-hold {
  background: rgba(255,255,255,0.08) !important;
  color: var(--text) !important;
  border: 1px solid rgba(255,255,255,0.15) !important;
  flex: 1;
  min-width: 120px;
}

.btn-switch {
  background: rgba(108,92,231,0.2) !important;
  color: var(--accent-light) !important;
  border: 1px solid var(--accent) !important;
  flex: 1;
  min-width: 120px;
}

.btn-hold:active, .btn-switch:active {
  transform: scale(0.96);
}

.vertige-text {
  font-style: italic;
  font-size: 14px;
  line-height: 1.6;
  color: var(--accent-light);
  padding: 12px;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ===== CONTEXT STORY CARD ===== */
.context-card {
  background: var(--bg-card);
  border-left: 3px solid rgba(108,92,231,0.3);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}

.context-card h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.context-text {
  font-style: italic;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

/* ===== PROFILE VIEW ===== */
.profile-header {
  text-align: center;
  padding: 24px 0;
}

.profile-header .primary-arch {
  font-size: 56px;
  margin-bottom: 8px;
}

.profile-header h2 {
  font-size: 24px;
  font-weight: 700;
}

.profile-header .sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.radar-container {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
}

.radar-container canvas {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1/1;
}

.archetype-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.archetype-row {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.archetype-row .arch-color {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}

.archetype-row .arch-info {
  flex: 1;
}

.archetype-row .arch-name {
  font-size: 14px;
  font-weight: 600;
}

.archetype-row .arch-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.archetype-row .arch-score {
  font-weight: 700;
  font-size: 16px;
  min-width: 36px;
  text-align: right;
}

/* ===== GROUP ===== */
.group-players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.player-chip {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-chip .remove {
  font-size: 14px;
  cursor: pointer;
  opacity: 0.5;
}

.add-player-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.add-player-form input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.add-player-form input:focus {
  border-color: var(--accent);
}

.btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:active { transform: scale(0.96); }
.btn-outline {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent-light);
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-success { background: var(--success); }
.btn-block { width: 100%; }

/* ===== GROUP COMPARISON ===== */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.compare-player {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.compare-player .cp-name {
  font-size: 13px;
  font-weight: 600;
}

.compare-player .cp-arch {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.link-map {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  min-height: 200px;
}

.link-map canvas {
  width: 100%;
  height: auto;
}

.link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 13px;
}

.link-item .link-value {
  font-weight: 700;
}

/* ===== UTILITIES ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state .emoji {
  font-size: 48px;
  margin-bottom: 12px;
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tag-filter .filter-btn {
  font-size: 11px;
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 4px 12px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.tag-filter .filter-btn.active {
  background: var(--accent) !important;
  color: white !important;
  border-color: var(--accent) !important;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* ===== ARCHETYPE DETAIL MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 100%;
}

.modal-content h3 {
  font-size: 20px;
  margin-bottom: 8px;
}

.modal-content p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}