/* =========================================================================
   style.css — mise en page & effets visuels
   ========================================================================= */

:root {
  --bg: #0b0d12;
  --panel: rgba(10, 12, 18, 0.72);
  --audi: #e23b3b;
  --bmw: #3b7be2;
  --gold: #ffcc44;
  --text: #f3f5fa;
}

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

html, body {
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  overflow: hidden;
}

/* Cadre du jeu : ratio 3:2, centré, s'adapte à la fenêtre. */
#game {
  position: relative;
  width: min(100vw, 177.78vh);     /* 16:9 max basé sur la hauteur… */
  max-width: 1100px;
  aspect-ratio: 3 / 2;
  margin: auto;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
  user-select: none;
}

/* --- gestion des écrans --- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.screen.is-active { display: flex; }

.screen-heading {
  font-size: clamp(20px, 4vw, 40px);
  letter-spacing: 4px;
  margin-bottom: 4%;
  text-shadow: 0 2px 10px #000;
}

.hint {
  margin-top: 18px;
  font-size: 13px;
  opacity: 0.65;
  letter-spacing: 1px;
}

.btn {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 14px 38px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  transition: transform 0.08s, box-shadow 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--audi), var(--bmw));
  color: #fff;
  box-shadow: 0 6px 24px rgba(59, 123, 226, 0.4);
}
.btn-primary:hover { box-shadow: 0 8px 32px rgba(226, 59, 59, 0.55); }

/* ================= ÉCRAN TITRE ================= */
#screen-title {
  background: url("../assets/ui/title.png") center/cover no-repeat, #000;
}
.title-content {
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.6), transparent 70%);
  padding: 60px;
}
.logo {
  font-size: clamp(40px, 9vw, 92px);
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(90deg, var(--audi), #fff 50%, var(--bmw));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 4px 30px rgba(0,0,0,0.8);
}
.logo span { -webkit-text-fill-color: var(--text); font-size: 0.4em; opacity: 0.8; }
.subtitle {
  letter-spacing: 12px;
  font-size: clamp(12px, 2.4vw, 22px);
  opacity: 0.8;
  margin: 6px 0 34px;
}

/* ================= ÉCRAN SÉLECTION ================= */
.select-grid { display: flex; gap: 5%; }
.char-card {
  cursor: pointer;
  width: clamp(150px, 26vw, 280px);
  background: var(--panel);
  border: 3px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 18px;
  text-align: center;
  transition: transform 0.12s, border-color 0.2s, box-shadow 0.2s;
}
.char-card:hover { transform: translateY(-8px); }
.char-card.selected { transform: translateY(-8px) scale(1.03); }
.char-card img {
  width: 100%;
  height: clamp(140px, 24vh, 240px);
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.6));
}
.char-card h3 { margin-top: 10px; font-size: 26px; letter-spacing: 3px; }

/* ================= ÉCRAN COMBAT ================= */
#screen-fight { justify-content: flex-start; }

/* --- HUD --- */
.hud {
  position: relative;
  z-index: 5;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px 0;
}
.hud-side { flex: 1; display: flex; flex-direction: column; }
.hud-right { align-items: flex-end; }
.hud-center { padding-top: 4px; }

.bar {
  height: 16px;
  width: 100%;
  background: rgba(0,0,0,0.6);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 4px;
  overflow: hidden;
}
.healthbar { transform: skewX(-18deg); }
.hud-right .healthbar { transform: skewX(18deg); }
.bar-fill { height: 100%; transition: width 0.18s ease-out; }
.bar-fill.hp { width: 100%; background: linear-gradient(90deg, #ffd24a, #ff5a3c); }
.hud-right .bar-fill.hp { float: right; }

.meterbar { height: 8px; margin-top: 5px; border-color: rgba(255,255,255,0.2); }
.bar-fill.meter { width: 0%; background: linear-gradient(90deg, #36d1ff, #4a8bff); }
.hud-right .bar-fill.meter { float: right; }
.meter.full { background: linear-gradient(90deg, var(--gold), #fff); box-shadow: 0 0 10px var(--gold); }

.nameplate { height: 26px; object-fit: contain; margin: 5px 0; }
.hud-right .nameplate { align-self: flex-end; }

.rounds { display: flex; gap: 6px; margin-bottom: 4px; height: 12px; }
.hud-right .rounds { justify-content: flex-end; }
.round-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--gold); }
.round-dot.won { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

.timer {
  font-size: 34px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 8px #000;
  min-width: 70px;
  text-align: center;
}

/* --- Arène --- */
.arena {
  position: absolute;
  inset: 0;
  background: url("../assets/backgrounds/arena.png") center/cover no-repeat, var(--bg);
  z-index: 1;
}
.arena::after { /* léger assombrissement pour lisibilité du HUD */
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.45), transparent 22%);
  pointer-events: none;
}

/* --- Combattants --- */
.fighter {
  position: absolute;
  bottom: 12%;
  width: 30%;
  height: 62%;
  transform: translateX(-50%);
  /* déplacement mis à jour chaque frame : pas de transition (sinon ça "flotte") */
}
.fighter .sprite,
.fighter .emoji-fallback {
  position: absolute;
  inset: 0;
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: contain;
}
.emoji-fallback {
  display: none;
  font-size: clamp(60px, 18vh, 150px);
  align-items: flex-end;
  justify-content: center;
  text-align: center;
  line-height: 1;
}
.fighter.use-fallback .sprite { display: none; }
.fighter.use-fallback .emoji-fallback { display: flex; }

/* L'orientation de chaque sprite est gérée par ui.js (transform en ligne),
   pose par pose, pour que chaque mech regarde toujours l'adversaire. */

/* effets transitoires */
.fighter.flash-hit   .sprite { animation: hitFlash 0.18s steps(2); }
.fighter.flash-hit            { animation: shake 0.18s; }
.fighter.flash-block .sprite  { filter: drop-shadow(0 0 12px #6cf) brightness(1.3); }
.fighter.flash-dodge          { opacity: 0.55; }
.fighter.ko .sprite           { filter: grayscale(0.7) brightness(0.7); transform: rotate(-8deg); }

@keyframes hitFlash { 0%,100% { filter: none; } 50% { filter: brightness(3) saturate(2) sepia(1) hue-rotate(-30deg); } }
@keyframes shake {
  0%,100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 8px)); }
  75% { transform: translateX(calc(-50% + 8px)); }
}

/* --- Projectiles --- */
.projectiles { position: absolute; inset: 0; pointer-events: none; }
.projectile {
  position: absolute;
  bottom: 42%;
  width: 11%;
  height: 20%;
  transform: translate(-50%, 0);
  background: url("../assets/fx/projectile.png") center/contain no-repeat;
  animation: spin 0.4s linear infinite;
  filter: drop-shadow(0 0 14px var(--gold)) drop-shadow(0 0 6px #fff);
}
@keyframes spin { to { transform: translate(-50%, 0) rotate(360deg); } }

/* --- Annonces (ROUND 1, K.O., victoire) --- */
.announce {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6;
  font-size: clamp(30px, 8vw, 80px);
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 4px 24px #000;
  pointer-events: none;
  opacity: 0;
}
.announce.show { animation: pop 0.5s ease-out forwards; }
.announce.win  { color: var(--gold); }
@keyframes pop {
  0% { opacity: 0; transform: scale(1.6); }
  20% { opacity: 1; transform: scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0.9; transform: scale(1); }
}

/* --- Aide touches --- */
.controls-help {
  position: absolute;
  bottom: 8px;
  width: 100%;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 12px;
  opacity: 0.8;
}
.controls-help kbd {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  padding: 1px 7px;
  font-family: inherit;
}

/* écrans mis en avant via la classe is-active déjà gérée plus haut */
.btn-primary { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 8px 36px rgba(255,204,68,0.5); } }

/* ================= ÉCRAN DE SCORE / FIN ================= */
#screen-end {
  background: radial-gradient(ellipse at center, rgba(30,30,40,0.9), rgba(0,0,0,0.96)),
              url("../assets/backgrounds/arena.png") center/cover no-repeat;
}
.end-card { text-align: center; animation: pop 0.5s ease-out; }
.end-kicker {
  letter-spacing: 10px;
  font-size: clamp(14px, 2.4vw, 22px);
  color: var(--gold);
  margin-bottom: 6px;
}
.end-winner { display: flex; flex-direction: column; align-items: center; }
.end-sprite {
  width: clamp(140px, 22vw, 240px);
  height: clamp(150px, 26vh, 260px);
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 0 30px rgba(255,204,68,0.5));
  font-size: clamp(80px, 16vh, 150px);
  display: flex; align-items: flex-end; justify-content: center;
}
.end-name {
  font-size: clamp(34px, 7vw, 70px);
  font-weight: 900;
  letter-spacing: 5px;
  margin-top: 4px;
}
.end-score {
  font-size: clamp(26px, 5vw, 48px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 6px;
  margin: 10px 0 26px;
  opacity: 0.92;
}
.end-buttons { display: flex; gap: 16px; justify-content: center; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 2px solid rgba(255,255,255,0.4);
}
.btn-ghost:hover { border-color: #fff; background: rgba(255,255,255,0.08); }
