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

:root {
  --bg: #0f0f13;
  --bg2: #16161d;
  --bg3: #1e1e28;
  --border: #2a2a38;
  --text: #e8e6e0;
  --text2: #9a9890;
  --text3: #5a5856;
  --gold: #c9a84c;
  --gold2: #f0cc6e;
  --loyal: #4a8fd4;
  --chaos: #d45a4a;
  --bon: #4ad47a;
  --mauvais: #9a4ad4;
  --common: #9a9890;
  --rare: #c9a84c;
  --hp: #e05050;
  --xp: #5090d0;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* Layout */
#app { min-height: 100vh; }
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* Header */
.header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.header-title { font-size: 18px; font-weight: 600; color: var(--gold); letter-spacing: 0.05em; }
.header-player { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text2); }
.header-player img { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); }

/* Buttons */
.btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn-primary { background: var(--gold); color: #0f0f13; border-color: var(--gold); font-weight: 600; }
.btn-primary:hover { background: var(--gold2); border-color: var(--gold2); color: #0f0f13; }
.btn-danger { border-color: var(--chaos); color: var(--chaos); }
.btn-danger:hover { background: rgba(212,90,74,0.1); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }

/* Login Screen */
#screen-login {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a24 0%, #0f0f13 70%);
}
.login-box { text-align: center; max-width: 400px; padding: 40px; }
.login-title { font-size: 36px; font-weight: 700; color: var(--gold); margin-bottom: 8px; letter-spacing: 0.1em; }
.login-sub { color: var(--text2); font-size: 15px; margin-bottom: 40px; }
.login-divider { color: var(--text3); margin: 20px 0; font-size: 12px; }

/* Google button */
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #333; border: none;
  padding: 10px 24px; border-radius: var(--radius);
  cursor: pointer; font-size: 14px; font-weight: 500; width: 100%;
  transition: background 0.15s;
}
.btn-google:hover { background: #f0f0f0; }
.btn-google svg { width: 18px; height: 18px; }

/* Menu Screen */
#screen-menu { padding: 0; }
.menu-content { flex: 1; padding: 24px; max-width: 900px; margin: 0 auto; width: 100%; }
.menu-section { margin-bottom: 24px; }
.menu-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 24px; }
.stat-box { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-align: center; }
.stat-val { font-size: 22px; font-weight: 700; color: var(--gold); }
.stat-label { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* Hero Selection */
.hero-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.hero-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; cursor: pointer; transition: all 0.15s;
}
.hero-card:hover { border-color: var(--gold); }
.hero-card.selected { border-color: var(--gold); background: rgba(201,168,76,0.08); }
.hero-name { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.hero-desc { font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.hero-stats { display: flex; gap: 12px; }
.hero-stat { font-size: 11px; color: var(--text3); }
.hero-stat span { color: var(--text); font-weight: 500; }
.hero-passive { margin-top: 10px; padding: 8px 10px; background: var(--bg3); border-radius: var(--radius); border-left: 2px solid var(--gold); }
.hero-passive-name { font-size: 11px; font-weight: 600; color: var(--gold); }
.hero-passive-desc { font-size: 11px; color: var(--text2); margin-top: 2px; }
.hero-bias { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.bias-tag { font-size: 10px; padding: 1px 7px; border-radius: 20px; }

/* Game Screen */
#screen-game { flex-direction: row; }
.game-sidebar {
  width: 260px; background: var(--bg2); border-right: 1px solid var(--border);
  padding: 16px; display: flex; flex-direction: column; gap: 14px; flex-shrink: 0;
  overflow-y: auto;
}
.game-main { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }

/* HUD */
.hud-hero-name { font-size: 16px; font-weight: 600; color: var(--text); }
.hud-identity { font-size: 11px; color: var(--gold); font-style: italic; margin-top: 2px; }
.hud-bar { margin-top: 8px; }
.hud-bar-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--text3); margin-bottom: 3px; }
.bar-track { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
.bar-hp { background: var(--hp); }
.bar-xp { background: var(--xp); }

/* Alignment */
.align-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.align-item { padding: 6px 8px; background: var(--bg3); border-radius: var(--radius); }
.align-name { font-size: 10px; color: var(--text3); margin-bottom: 3px; }
.align-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.align-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }
.fill-loyal { background: var(--loyal); }
.fill-chaos { background: var(--chaos); }
.fill-bon { background: var(--bon); }
.fill-mauvais { background: var(--mauvais); }

/* Gold & XP HUD */
.hud-resources { display: flex; gap: 8px; }
.resource-box { flex: 1; background: var(--bg3); border-radius: var(--radius); padding: 6px 8px; text-align: center; }
.resource-val { font-size: 16px; font-weight: 700; }
.resource-label { font-size: 10px; color: var(--text3); }
.resource-gold .resource-val { color: var(--gold); }
.resource-level .resource-val { color: var(--xp); }

/* Slots */
.slots-row { display: flex; gap: 6px; flex-wrap: wrap; }
.slot {
  width: 44px; height: 44px; background: var(--bg3); border: 1px dashed var(--border);
  border-radius: var(--radius); display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text3); cursor: default; position: relative;
}
.slot.filled { border-style: solid; border-color: var(--border); cursor: pointer; }
.slot.filled:hover { border-color: var(--gold); }
.slot-icon { font-size: 18px; }
.slot-rarity-dot {
  position: absolute; bottom: 2px; right: 2px;
  width: 6px; height: 6px; border-radius: 50%;
}
.dot-common { background: var(--common); }
.dot-rare { background: var(--gold); }

/* Chapter phases */
.phase-indicator { display: flex; gap: 6px; align-items: center; }
.phase-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.phase-dot.active { background: var(--gold); }
.phase-dot.done { background: var(--text3); }
.chapter-title { font-size: 18px; font-weight: 600; color: var(--gold); margin-bottom: 4px; }
.chapter-phase { font-size: 12px; color: var(--text3); }

/* Scene */
.scene-text { font-size: 15px; color: var(--text); line-height: 1.7; margin-bottom: 20px; font-style: italic; background: var(--bg3); padding: 16px; border-radius: var(--radius-lg); border-left: 3px solid var(--gold); }
.scene-choices { display: flex; flex-direction: column; gap: 10px; }
.choice-btn {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text);
  padding: 12px 16px; border-radius: var(--radius); cursor: pointer; text-align: left;
  font-size: 13px; font-family: inherit; transition: all 0.15s; line-height: 1.5;
}
.choice-btn:hover { border-color: var(--gold); background: rgba(201,168,76,0.06); }
.choice-effects { display: flex; gap: 6px; margin-top: 6px; }
.effect-tag { font-size: 10px; padding: 1px 7px; border-radius: 20px; }

/* Shop */
.shop-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.shop-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px; display: flex; flex-direction: column; gap: 8px;
  transition: border-color 0.15s;
}
.shop-item.affinity-high { border-color: rgba(201,168,76,0.5); }
.shop-item.affinity-med { border-color: rgba(201,168,76,0.25); }
.item-header { display: flex; justify-content: space-between; align-items: flex-start; }
.item-name { font-size: 14px; font-weight: 600; }
.item-rarity { font-size: 10px; padding: 1px 7px; border-radius: 20px; }
.rarity-common { background: rgba(154,152,144,0.2); color: var(--common); }
.rarity-rare { background: rgba(201,168,76,0.2); color: var(--gold); }
.item-type { font-size: 10px; color: var(--text3); }
.item-cooldown { font-size: 10px; color: var(--text3); }
.item-effect { font-size: 12px; color: var(--text2); background: var(--bg3); padding: 8px 10px; border-radius: var(--radius); }
.item-cost { font-size: 16px; font-weight: 700; color: var(--gold); }
.item-cost-label { font-size: 10px; color: var(--text3); }
.btn-buy { width: 100%; }

/* Combat */
.combat-arena {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; text-align: center;
}
.combatants { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.combatant { flex: 1; }
.combatant-name { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.combatant-hp { font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.combatant-stats { display: flex; gap: 12px; justify-content: center; font-size: 12px; color: var(--text3); }
.combatant-stat span { color: var(--text); }
.vs-divider { font-size: 24px; font-weight: 700; color: var(--text3); flex-shrink: 0; }
.combat-log {
  background: var(--bg3); border-radius: var(--radius); padding: 12px;
  max-height: 180px; overflow-y: auto; text-align: left; margin-bottom: 16px;
  font-size: 12px; color: var(--text2); line-height: 1.8;
}
.log-win { color: var(--bon); }
.log-loss { color: var(--chaos); }
.log-neutral { color: var(--text3); }

/* Result */
.result-banner {
  padding: 20px; border-radius: var(--radius-lg); text-align: center; margin-bottom: 16px;
}
.result-win { background: rgba(74,212,122,0.1); border: 1px solid rgba(74,212,122,0.3); }
.result-loss { background: rgba(212,90,74,0.1); border: 1px solid rgba(212,90,74,0.3); }
.result-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.result-win .result-title { color: var(--bon); }
.result-loss .result-title { color: var(--chaos); }
.result-rewards { display: flex; gap: 16px; justify-content: center; margin-top: 12px; }
.reward { font-size: 13px; color: var(--text2); }
.reward span { color: var(--text); font-weight: 600; }

/* Identity reveal */
.identity-reveal {
  background: rgba(201,168,76,0.08); border: 1px solid rgba(201,168,76,0.3);
  border-radius: var(--radius-lg); padding: 16px; text-align: center; margin-bottom: 16px;
}
.identity-reveal-title { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.identity-reveal-name { font-size: 20px; font-weight: 700; color: var(--gold); }
.identity-reveal-desc { font-size: 13px; color: var(--text2); margin-top: 4px; }

/* Level up */
.levelup-banner {
  background: rgba(80,144,208,0.1); border: 1px solid rgba(80,144,208,0.3);
  border-radius: var(--radius); padding: 10px 16px; text-align: center; margin-bottom: 10px;
  font-size: 13px; color: var(--xp);
}

/* Run end */
.run-end { text-align: center; padding: 40px 20px; }
.run-end-title { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.run-summary { max-width: 400px; margin: 20px auto; }

/* Leaderboard */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.lb-rank { width: 24px; font-size: 13px; color: var(--text3); text-align: center; }
.lb-avatar { width: 32px; height: 32px; border-radius: 50%; }
.lb-name { flex: 1; font-size: 13px; }
.lb-wins { font-size: 13px; color: var(--gold); font-weight: 600; }

/* Responsive */
@media (max-width: 700px) {
  #screen-game { flex-direction: column; }
  .game-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .shop-items { grid-template-columns: 1fr; }
  .hero-grid { grid-template-columns: 1fr; }
  .menu-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.25s ease; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
.pulse { animation: pulse 1.5s infinite; }

/* Auth forms */
.auth-tabs { display: flex; gap: 0; margin-bottom: 20px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.auth-tab { flex: 1; padding: 8px; background: transparent; border: none; color: var(--text2); cursor: pointer; font-size: 13px; font-family: inherit; transition: all 0.15s; }
.auth-tab.active { background: var(--bg3); color: var(--text); }
.auth-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.auth-form input { background: var(--bg3); border: 1px solid var(--border); color: var(--text); padding: 10px 14px; border-radius: var(--radius); font-size: 14px; font-family: inherit; outline: none; transition: border-color 0.15s; }
.auth-form input:focus { border-color: var(--gold); }
.auth-form input::placeholder { color: var(--text3); }
.auth-error { font-size: 12px; color: var(--chaos); min-height: 16px; }

/* Landing page */
#screen-landing { justify-content: center; align-items: center; }
.landing-hero { width: 100%; max-width: 640px; padding: 40px 24px; margin: 0 auto; }
.landing-content { display: flex; flex-direction: column; gap: 0; }
.landing-title { font-size: 48px; font-weight: 700; color: var(--gold); letter-spacing: 0.12em; text-align: center; margin-bottom: 8px; }
.landing-tagline { font-size: 15px; color: var(--text2); text-align: center; margin-bottom: 32px; }
.landing-features { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 32px; }
.landing-feature { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 14px; display: flex; gap: 12px; align-items: flex-start; }
.lf-icon { font-size: 20px; flex-shrink: 0; width: 24px; text-align: center; margin-top: 1px; }
.lf-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.lf-sub { font-size: 11px; color: var(--text3); line-height: 1.45; }
.landing-actions { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.btn-lg { padding: 10px 28px; font-size: 14px; }
.landing-divider { text-align: center; font-size: 11px; color: var(--text3); }

/* Login back */
.login-back { font-size: 12px; color: var(--text3); cursor: pointer; margin-bottom: 16px; display: inline-block; }
.login-back:hover { color: var(--text2); }

/* Fix bouton inscription — remplace display:none par visibility */
.auth-form { display: none; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.auth-form.active-form { display: flex; }

/* Game layout fix */
.game-main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.game-chapter-header { padding: 16px 20px 0; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; border-bottom: 0.5px solid var(--border); padding-bottom: 12px; margin-bottom: 0; }
.game-main { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
