/* ============================================================
   ÉQUILIBRE ÉLÉMENTAIRE — feuille de style mobile-first
   ============================================================ */

:root {
  --bg: #0b0a1a;
  --panel: #16142e;
  --panel2: #1e1b3f;
  --text: #e8e6f5;
  --muted: #8f8ab0;
  --gold: #ffd54f;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  border: none;
  border-radius: 12px;
  background: var(--panel2);
  color: var(--text);
  padding: 12px 18px;
  font-size: 15px;
  cursor: pointer;
}
button:active { transform: scale(0.96); }
button.danger { background: #3a1a2a; color: #ff8080; }
button.ghost { background: transparent; color: var(--muted); }
button:disabled { opacity: 0.4; transform: none; }

/* ---------- en-tête ---------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: rgba(11, 10, 26, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #2a2750;
}

#mana-display { flex: 1; line-height: 1.1; }
#mana-count {
  font-size: 26px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
#mana-sub { font-size: 11px; color: var(--muted); }
#mana-rate {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}
#btn-menu {
  font-size: 20px;
  padding: 6px 12px;
  border-radius: 10px;
}

/* ---------- zone de canalisation ---------- */

#channel-zone {
  padding: 16px 14px 10px;
  text-align: center;
}

#orb-wrap { position: relative; display: inline-block; }

#orb {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4d4390, #1c1740 70%);
  border: 2px solid #4a4390;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  box-shadow: 0 0 30px rgba(120, 100, 255, 0.25);
  transition: transform 0.08s;
}
#orb.pressed { transform: scale(0.92); }
#orb-core { font-size: 44px; pointer-events: none; }

.float-num {
  position: absolute;
  pointer-events: none;
  font-weight: 700;
  color: var(--gold);
  font-size: 16px;
  animation: floatUp 0.9s ease-out forwards;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

@keyframes floatUp {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-46px); }
}

#tap-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- barre d'équilibre ---------- */

#balance-strip {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  margin-top: 14px;
  background: #221f45;
  border: 1px solid #2a2750;
}
#balance-strip .seg { transition: flex-grow 0.3s; }
#balance-strip .seg.ok { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35); }

/* ---------- générateurs ---------- */

#generators { padding: 0 14px; }

#buy-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}
.buy-label { font-size: 13px; color: var(--muted); }
.buy-btn {
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid #2a2750;
}
.buy-btn.active {
  background: #3d3680;
  border-color: #6c63c4;
  color: #fff;
}

#gen-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gen-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border-radius: 14px;
  padding: 10px 12px;
  border: 1px solid #24204a;
  width: 100%;
  text-align: left;
  color: var(--text);
}
.gen-card:disabled { opacity: 0.55; }
.gen-card:active:not(:disabled) { transform: scale(0.98); }

.gen-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.gen-info { flex: 1; min-width: 0; }
.gen-name { font-size: 15px; font-weight: 600; }
.gen-name .lvl { color: var(--muted); font-weight: 400; font-size: 13px; }
.gen-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.gen-cost {
  font-size: 13px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-align: right;
  flex-shrink: 0;
}
.gen-cost .per { display: block; font-size: 10px; color: var(--muted); }

/* ---------- rituels ---------- */

#rituals { padding: 16px 14px 40px; }
#rituals h2 { font-size: 16px; margin-bottom: 8px; }

#ritual-list { display: flex; flex-direction: column; gap: 8px; }

.ritual-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid #2a2750;
  border-radius: 14px;
  padding: 12px;
  width: 100%;
  text-align: left;
  color: var(--text);
}
.ritual-card.ready {
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 213, 79, 0.25);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255,213,79,0.15); }
  50% { box-shadow: 0 0 26px rgba(255,213,79,0.4); }
}
.ritual-card:disabled { opacity: 0.5; }

.ritual-icon { font-size: 26px; flex-shrink: 0; }
.ritual-info { flex: 1; min-width: 0; }
.ritual-name { font-size: 15px; font-weight: 600; }
.ritual-req { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ritual-req .done { color: #7ddc8a; }
.ritual-req .todo { color: #ff9070; }

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 4, 15, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.overlay.hidden { display: none; }

.ending-card, .menu-card {
  background: var(--panel);
  border: 1px solid #3a3560;
  border-radius: 18px;
  padding: 26px 22px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}

#ending-icon { font-size: 54px; }
#ending-title { font-size: 22px; margin: 10px 0 12px; color: var(--gold); }
#ending-text { font-size: 14px; line-height: 1.6; color: #cfcbe8; }
#ending-progress { margin-top: 16px; font-size: 12px; color: var(--muted); }
#btn-reincarnate {
  margin-top: 18px;
  width: 100%;
  background: linear-gradient(135deg, #5b4fd6, #7a5cd6);
  font-size: 16px;
  font-weight: 600;
}
#btn-continue { margin-top: 10px; width: 100%; }

.menu-card h2 { font-size: 18px; margin-bottom: 6px; }
.menu-card h3 { font-size: 13px; color: var(--muted); margin: 16px 0 8px; text-align: left; }
#menu-incarnations { font-size: 12px; color: var(--muted); }

#menu-endings { display: flex; gap: 8px; flex-wrap: wrap; }
.ending-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--panel2);
  border: 1px solid #2a2750;
  color: var(--muted);
}
.ending-chip.done { color: var(--gold); border-color: var(--gold); }

.menu-row { display: flex; gap: 8px; margin-top: 18px; }
.menu-row button { flex: 1; }
#btn-menu-close { margin-top: 10px; width: 100%; }

#btn-reload {
  margin-top: 18px;
  width: 100%;
  background: linear-gradient(135deg, #5b4fd6, #7a5cd6);
  font-size: 16px;
  font-weight: 600;
}
