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

:root {
  --bg-dark: #1a1a2e;
  --bg-card: #16213e;
  --bg-panel: #0f3460;
  --accent: #e94560;
  --accent2: #533483;
  --text: #eee;
  --text-dim: #999;
  --feu: #ff6b35;
  --eau: #4ecdc4;
  --plante: #45b649;
  --foudre: #ffd93d;
  --ombre: #8b5cf6;
  --lumiere: #fbbf24;
  --hp-high: #4ade80;
  --hp-mid: #fbbf24;
  --hp-low: #ef4444;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.screen { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.screen.active { display: flex; }

/* MENU */
.menu-container {
  text-align: center;
  max-width: 500px;
  width: 100%;
}

.game-title {
  font-size: 4rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2), var(--foudre));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
  text-shadow: none;
  letter-spacing: 4px;
}

.subtitle { color: var(--text-dim); margin-bottom: 40px; font-size: 1.1rem; }

.btn {
  padding: 14px 36px;
  border: none;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
  margin: 6px;
}

.btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary { background: linear-gradient(135deg, var(--accent), #c0392b); color: #fff; }
.btn-secondary { background: var(--bg-panel); color: var(--text); border: 2px solid #334; }
.btn-action { background: var(--bg-panel); color: var(--text); border: 2px solid #445; flex: 1; }
.btn-action:hover { border-color: var(--accent); }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.menu-buttons .btn { width: 260px; }

.status-text { margin-top: 20px; color: var(--text-dim); font-size: 0.9rem; }

/* LOADER */
.loader {
  width: 50px; height: 50px; margin: 30px auto;
  border: 4px solid #333; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* BESTIARY */
.bestiary-container { max-width: 900px; width: 100%; padding: 20px; }
.bestiary-container h2 { text-align: center; margin-bottom: 20px; font-size: 2rem; }
.bestiary-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 20px; max-height: 70vh; overflow-y: auto; padding: 4px;
}

.bestiary-card {
  background: var(--bg-card); border-radius: 12px; padding: 16px;
  border: 2px solid transparent; transition: border-color 0.2s;
}
.bestiary-card:hover { border-color: #445; }
.bestiary-card .emoji { font-size: 2.5rem; display: block; text-align: center; margin-bottom: 8px; }
.bestiary-card .name { font-weight: 700; font-size: 1.1rem; text-align: center; display: block; }
.bestiary-card .stats { font-size: 0.8rem; color: var(--text-dim); margin-top: 8px; }
.bestiary-card .stats div { display: flex; justify-content: space-between; margin: 2px 0; }

/* TEAM SELECT */
.select-container { max-width: 1000px; width: 100%; padding: 20px; text-align: center; }
.select-container h2 { margin-bottom: 8px; }
#select-count { color: var(--text-dim); margin-bottom: 20px; }

.creature-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 20px; max-height: 60vh; overflow-y: auto; padding: 4px;
}

.creature-card {
  background: var(--bg-card); border-radius: 12px; padding: 14px;
  cursor: pointer; border: 3px solid transparent;
  transition: all 0.2s; text-align: center;
}
.creature-card:hover { border-color: #556; transform: translateY(-2px); }
.creature-card.selected { border-color: var(--accent); background: rgba(233,69,96,0.15); }
.creature-card .emoji { font-size: 2.2rem; display: block; }
.creature-card .name { font-weight: 700; display: block; margin-top: 4px; }
.creature-card .type-badge { display: inline-block; margin-top: 4px; }
.creature-card .mini-stats { font-size: 0.75rem; color: var(--text-dim); margin-top: 6px; }

/* TYPE BADGES */
.type-badge {
  padding: 2px 10px; border-radius: 20px; font-size: 0.75rem;
  font-weight: 700; text-transform: uppercase;
}
.type-feu { background: var(--feu); color: #fff; }
.type-eau { background: var(--eau); color: #111; }
.type-plante { background: var(--plante); color: #fff; }
.type-foudre { background: var(--foudre); color: #111; }
.type-ombre { background: var(--ombre); color: #fff; }
.type-lumiere { background: var(--lumiere); color: #111; }

/* BATTLE */
.battle-container { max-width: 800px; width: 100%; }

.battle-field {
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px; min-height: 320px;
  background: linear-gradient(180deg, #1a1a3e 0%, #0d2137 50%, #1a3a2e 100%);
  border-radius: 16px; position: relative;
}

.battle-side { display: flex; flex-direction: column; gap: 6px; }

.opponent-side { align-items: flex-end; }
.player-side { align-items: flex-start; }

.creature-sprite {
  font-size: 4rem; line-height: 1;
  transition: all 0.3s;
}

.creature-sprite.attack-anim { animation: attackShake 0.4s ease-in-out; }
.creature-sprite.hit-anim { animation: hitFlash 0.5s ease-in-out; }
.creature-sprite.faint-anim { animation: faint 0.8s ease-in forwards; }
.creature-sprite.enter-anim { animation: enterBattle 0.5s ease-out; }

@keyframes attackShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(20px); }
  75% { transform: translateX(-10px); }
}
@keyframes hitFlash {
  0%, 100% { opacity: 1; filter: none; }
  25% { opacity: 0.3; filter: brightness(3); }
  50% { opacity: 1; filter: brightness(2); }
  75% { opacity: 0.5; }
}
@keyframes faint {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(30px) scale(0.5); }
}
@keyframes enterBattle {
  0% { opacity: 0; transform: scale(0.3); }
  100% { opacity: 1; transform: scale(1); }
}

.opponent-sprite { transform: scaleX(-1); }
.opponent-sprite.attack-anim { animation: attackShakeOpp 0.4s ease-in-out; }
@keyframes attackShakeOpp {
  0%, 100% { transform: scaleX(-1) translateX(0); }
  25% { transform: scaleX(-1) translateX(20px); }
  75% { transform: scaleX(-1) translateX(-10px); }
}

.creature-info { display: flex; align-items: center; gap: 8px; }
.creature-name { font-weight: 700; font-size: 1.2rem; }

.hp-bar-container {
  width: 220px; height: 18px; background: #222; border-radius: 10px;
  position: relative; overflow: hidden; border: 2px solid #333;
}
.hp-bar {
  height: 100%; border-radius: 8px; transition: width 0.6s ease, background 0.3s;
  background: var(--hp-high);
}
.hp-bar.mid { background: var(--hp-mid); }
.hp-bar.low { background: var(--hp-low); }
.hp-text {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-size: 0.7rem; font-weight: 700; text-shadow: 1px 1px 2px #000;
}

.status-badge {
  font-size: 0.7rem; padding: 1px 8px; border-radius: 10px; font-weight: 700;
}
.status-poison { background: #a855f7; color: #fff; }
.status-burn { background: #ef4444; color: #fff; }
.status-paralysis { background: #eab308; color: #111; }

/* BATTLE LOG */
.battle-log {
  background: var(--bg-card); border-radius: 12px; padding: 12px;
  margin: 12px 0; max-height: 120px; overflow-y: auto;
  font-size: 0.9rem; line-height: 1.6;
}
.battle-log p { margin: 2px 0; }
.log-super { color: #4ade80; font-weight: 700; }
.log-not-effective { color: #f87171; }
.log-ko { color: var(--accent); font-weight: 700; }

/* ACTION PANEL */
.action-panel {
  background: var(--bg-card); border-radius: 12px; padding: 16px;
}

.action-buttons { display: flex; gap: 12px; }

.action-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;
}
.action-list.hidden { display: none; }

.attack-btn {
  background: var(--bg-panel); border: 2px solid #445; border-radius: 10px;
  padding: 10px; cursor: pointer; color: var(--text); text-align: left;
  transition: all 0.2s;
}
.attack-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.attack-btn .atk-name { font-weight: 700; display: block; }
.attack-btn .atk-info { font-size: 0.75rem; color: var(--text-dim); }

.switch-btn {
  background: var(--bg-panel); border: 2px solid #445; border-radius: 10px;
  padding: 10px; cursor: pointer; color: var(--text); text-align: left;
  display: flex; align-items: center; gap: 10px; transition: all 0.2s;
}
.switch-btn:hover { border-color: var(--accent); }
.switch-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.switch-btn .sw-emoji { font-size: 1.5rem; }
.switch-btn .sw-info { flex: 1; }
.switch-btn .sw-name { font-weight: 700; display: block; }
.switch-btn .sw-hp { font-size: 0.8rem; color: var(--text-dim); }

.team-indicators {
  display: flex; justify-content: space-between; padding: 8px 0;
}
.team-balls { display: flex; gap: 6px; }
.team-ball {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #555; background: #333;
}
.team-ball.alive { background: var(--hp-high); border-color: #4ade80; }
.team-ball.fainted { background: var(--hp-low); border-color: #ef4444; }
.team-ball.active { box-shadow: 0 0 6px #fff; }

#waiting-action p { text-align: center; color: var(--text-dim); padding: 10px; }
.hidden { display: none !important; }

/* RESULT */
#screen-result .menu-container h2 { font-size: 2.5rem; margin-bottom: 16px; }
.result-win { color: #4ade80; }
.result-lose { color: var(--accent); }

/* Responsive */
@media (max-width: 600px) {
  .game-title { font-size: 2.5rem; }
  .creature-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .bestiary-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .action-list { grid-template-columns: 1fr; }
  .hp-bar-container { width: 160px; }
  .creature-sprite { font-size: 3rem; }
}
