/* =========================================================================
   style.css — MISE EN PAGE + EFFETS
   ========================================================================= */

:root {
  --green: #1D9E75;
  --green-dark: #0F6E56;
  --orange: #D85A30;
  --amber: #BA7517;
  --ink: #2C2C2A;
  --paper: #FAF6EE;
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #2a2622;
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#game {
  width: 100%;
  max-width: 960px;
}

/* ---- ÉCRANS ---- */
.screen { display: none; }
.screen.is-active { display: block; }

/* ---- ÉCRAN TITRE (splash versus) ---- */
#screen-title { text-align: center; }
.title-stage {
  position: relative; width: 100%; aspect-ratio: 16/9;
  border-radius: 14px; overflow: hidden; border: 3px solid var(--amber);
}
.title-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.title-overlay {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 58%, rgba(0,0,0,.12), rgba(0,0,0,.74));
}
.title-fighter {
  position: absolute; bottom: 0; height: 78%; width: auto;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,.5));
}
/* les deux dessins regardent vers l'extérieur -> on les retourne pour le face-à-face */
.title-fighter-left  { left: 1%;  transform: scaleX(-1); }
.title-fighter-right { right: 1%; transform: scaleX(-1); }

.title-center {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.title-kicker {
  margin: 0; color: #FAC775; font-size: 15px; font-weight: 700; letter-spacing: 4px;
  text-shadow: 0 2px 4px rgba(0,0,0,.6);
}
.title-logo {
  margin: 0; color: #fff; font-weight: 900; line-height: .95; letter-spacing: 2px;
  font-size: clamp(40px, 8vw, 84px);
  text-shadow: 0 3px 0 var(--orange), 0 6px 0 rgba(0,0,0,.35), 0 0 28px rgba(0,0,0,.55);
}
.title-sub {
  margin: 2px 0 18px; color: #fff; font-weight: 600; letter-spacing: 2px;
  font-size: clamp(13px, 2.2vw, 20px); text-shadow: 0 2px 4px rgba(0,0,0,.7);
}
.btn-start {
  font: inherit; font-size: 22px; font-weight: 800; letter-spacing: 1px; cursor: pointer;
  padding: 14px 44px; border-radius: 999px; border: 3px solid #fff;
  background: var(--orange); color: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,.3); transition: transform .08s, box-shadow .08s, background .15s;
}
.btn-start:hover { background: #c04e26; }
.btn-start:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.3); }
.vs-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 1;
  font-size: clamp(60px, 14vw, 140px); font-weight: 900; letter-spacing: 4px;
  color: rgba(255,255,255,.08); pointer-events: none;
}
.hint {
  margin: 16px auto 0; max-width: 480px; font-size: 14px; color: #cfc8bb;
}

/* ---- BOUTONS ---- */
.btn {
  font: inherit; font-size: 18px; font-weight: 600;
  padding: 12px 32px; border-radius: 999px; border: none;
  cursor: pointer; transition: transform .08s, background .15s;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(.96); }
.btn:disabled { background: #b8b3a8; cursor: not-allowed; }

/* ---- ÉCRAN SÉLECTION (rebrandé DA) ---- */
#screen-select { text-align: center; }
.select-stage {
  position: relative; border-radius: 14px; overflow: hidden; border: 3px solid var(--amber);
}
.select-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.select-overlay { position: absolute; inset: 0; background: linear-gradient(rgba(0,0,0,.5), rgba(0,0,0,.78)); }
.select-content {
  position: relative; z-index: 1; padding: 34px 20px 38px;
  display: flex; flex-direction: column; align-items: center; gap: 26px;
}
.select-title {
  margin: 0; color: #fff; font-weight: 900; letter-spacing: 2px;
  font-size: clamp(22px, 4vw, 40px);
  text-shadow: 0 3px 0 var(--orange), 0 0 20px rgba(0,0,0,.6);
}

/* sélecteur de mode 1J / 2J */
.mode-toggle { display: flex; gap: 0; border-radius: 999px; overflow: hidden; border: 2px solid var(--amber); }
.mode-btn {
  font: inherit; font-weight: 800; letter-spacing: 1px; cursor: pointer;
  padding: 8px 20px; border: none; background: rgba(26,22,18,.7); color: #cfc8bb;
  transition: background .15s, color .15s;
}
.mode-btn.is-on { background: var(--amber); color: #1a1612; }
.mode-hint { margin: -8px 0 0; color: #FAC775; font-size: 13px; }

.character-list { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; }
.char-card {
  font: inherit; cursor: pointer; color: #fff; width: 210px;
  background: rgba(26,22,18,.82); border: 3px solid rgba(255,255,255,.16);
  border-radius: 14px; padding: 12px;
  transition: transform .1s, border-color .15s, box-shadow .15s;
}
.char-card:hover { transform: translateY(-6px); border-color: rgba(250,199,117,.6); }
.char-card.is-selected {
  border-color: var(--amber); transform: translateY(-6px);
  box-shadow: 0 0 0 3px rgba(186,117,23,.45), 0 12px 26px rgba(0,0,0,.5);
}
.char-portrait {
  height: 200px; border-radius: 10px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--c) 30%, #1a1612);
  display: flex; align-items: flex-end; justify-content: center; overflow: hidden;
}
.char-name { font-size: 21px; font-weight: 800; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,.5); }
.char-stats { font-size: 13px; color: #FAC775; margin-top: 4px; }

.btn-start:disabled {
  background: #6b665e; border-color: rgba(255,255,255,.3); color: #cfc8bb;
  cursor: not-allowed; box-shadow: none; transform: none;
}

/* ---- SCÈNE DE COMBAT ---- */
#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  border: 3px solid var(--amber);
  user-select: none;
}
/* tremblement d'écran (game-feel) */
#stage.shake { animation: screenshake .22s ease; }
#stage.shake.shake-big { animation: screenshake-big .42s ease; }
@keyframes screenshake { 0%,100%{transform:translate(0,0)} 25%{transform:translate(-5px,3px)} 50%{transform:translate(4px,-3px)} 75%{transform:translate(-3px,-2px)} }
@keyframes screenshake-big { 0%,100%{transform:translate(0,0)} 20%{transform:translate(-10px,6px)} 40%{transform:translate(9px,-6px)} 60%{transform:translate(-7px,5px)} 80%{transform:translate(6px,-4px)} }
.stage-bg {
  position: absolute; inset: 0;
  background: var(--bg, #E1F5EE);
  display: flex; align-items: center; justify-content: center;
}
.bg-img { width: 100%; height: 100%; object-fit: cover; display: none; }
.bg-img.ok { display: block; }
.bg-emoji { font-size: 140px; opacity: .25; }
.bg-img.ok + .bg-emoji { display: none; }
/* sol */
.stage-bg::after {
  content: ""; position: absolute; bottom: 0; left: 0; right: 0;
  height: 14%; background: rgba(15,110,86,.25);
}

/* ---- HUD (vie / jauge / manches) ---- */
.hud {
  position: absolute; top: 14px; width: 44%; z-index: 3;
  font-size: 13px; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
  display: flex; gap: 8px; align-items: flex-start;
}
.hud-left { left: 14px; }
.hud-right { right: 14px; flex-direction: row-reverse; }
.hud-info { flex: 1; min-width: 0; }

/* portraits façon "versus" */
.portrait {
  width: 46px; height: 46px; flex: 0 0 46px;
  border: 2px solid #fff; border-radius: 8px; overflow: hidden;
  background: color-mix(in srgb, var(--c) 30%, #000);
}
.portrait-img { width: 100%; height: 140%; object-fit: cover; object-position: top center; display: none; }
.portrait-img.ok { display: block; }
.portrait-emoji { font-size: 30px; display: flex; align-items: center; justify-content: center; height: 100%; }
.portrait-img.ok ~ .portrait-emoji { display: none; }
.portrait-img.flipped { transform: scaleX(-1); }
.hud-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.hud-right .hud-top { flex-direction: row-reverse; }
.hud-name { font-weight: 700; }
.rounds { display: flex; gap: 4px; }
.pip {
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid #fff; box-sizing: border-box;
}
.pip.is-won { background: #FAC775; border-color: #FAC775; }

.hp-bar {
  height: 16px; background: rgba(0,0,0,.35);
  border: 2px solid #fff; border-radius: 8px; overflow: hidden;
}
.hp-fill {
  height: 100%; width: 100%; background: var(--green);
  transition: width .2s ease;
}
.hud-right .hp-fill { margin-left: auto; }
.hud-right .hp-bar { display: flex; justify-content: flex-end; }

.gauge-bar {
  height: 7px; margin-top: 4px; width: 70%;
  background: rgba(0,0,0,.3); border-radius: 4px; overflow: hidden;
}
.hud-right .gauge-bar { margin-left: auto; }
.gauge-fill { height: 100%; width: 0; background: var(--amber); transition: width .2s; }
.gauge-fill.is-full { background: #FAC775; animation: pulse .6s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---- COMBATTANTS ---- */
.fighter {
  position: absolute; bottom: 10%; z-index: 2;
  width: 26%; height: 64%;
  display: flex; align-items: flex-end; justify-content: center;
  transition: transform .12s ease;
}
.fighter-left  { left: 8%;  }
.fighter-right { right: 8%; }

.sprite {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: flex-end; justify-content: center;
}
/* le flip (orientation face à l'adversaire) vit sur le sprite,
   indépendamment des animations d'état portées par .fighter */
.sprite.flipped { transform: scaleX(-1); }
.sprite-img { max-width: 100%; max-height: 100%; object-fit: contain; display: none; }
.sprite-img.ok { display: block; }
.sprite-emoji {
  font-size: 110px; line-height: 1;
  filter: drop-shadow(0 6px 6px rgba(0,0,0,.3));
}
.sprite-img.ok + .sprite-emoji { display: none; }

/* éclair de télégraphe au-dessus de l'attaquant */
.telegraph {
  position: absolute; top: -6%; left: 50%;
  transform: translateX(-50%);
  font-size: 40px; opacity: 0; transition: opacity .1s;
}
.telegraph.is-on { opacity: 1; animation: blink .4s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---- ÉTATS VISUELS ----
   Le flip est sur .sprite ; ici on n'anime que la position du conteneur.
   Seule la direction du fendre (lunge) dépend du côté gauche/droite. */
.st-windup  { transform: translateY(-2px) scale(1.02); }

.fighter-left.st-attack  { animation: lunge-l .25s ease; }
.fighter-right.st-attack { animation: lunge-r .25s ease; }
@keyframes lunge-l { 50% { transform: translateX(28%); } }
@keyframes lunge-r { 50% { transform: translateX(-28%); } }

.st-dodge   { opacity: .9; }
.st-dodge.kind-duck { transform: translateY(20%) scale(.9); }   /* baisser : vers le bas */
.st-dodge.kind-jump { animation: hop .45s ease; }               /* saut : bond vers le haut */
@keyframes hop { 0% { transform: translateY(0); } 45% { transform: translateY(-55%); } 100% { transform: translateY(0); } }

.st-parry   { filter: brightness(1.4); }
.st-parry::after {
  content: "💳"; position: absolute; bottom: 40%; font-size: 34px;
}

.st-hit     { animation: shake .25s; filter: brightness(1.6) sepia(1) hue-rotate(-30deg); }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-10px)} 75%{transform:translateX(10px)} }

.st-stunned { animation: wobble 1s infinite; opacity: .8; }
@keyframes wobble { 50% { transform: rotate(4deg); } }

.st-ko      { transform: translateY(30%) rotate(-12deg); opacity: .6; filter: grayscale(.6); }

/* ---- BANNIÈRE (Manche 1, K.O. !) ---- */
.banner {
  position: absolute; top: 42%; left: 0; right: 0; z-index: 5;
  text-align: center; font-size: 44px; font-weight: 800; color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.banner.is-on { opacity: 1; }

/* ---- EFFETS FLOTTANTS (Touché !, Parade !) ---- */
.fx-layer {
  position: absolute; top: 26%; left: 0; right: 0; z-index: 4;
  text-align: center; pointer-events: none;
}
.fx {
  display: inline-block; font-weight: 800; font-size: 26px;
  animation: floatUp .7s ease forwards;
  text-shadow: 0 2px 0 rgba(0,0,0,.4);
}
.fx-good    { color: #FAC775; }
.fx-special { color: #fff; background: var(--orange); padding: 2px 14px; border-radius: 999px; }
.fx-miss    { color: #d7d2c8; font-size: 20px; }
.fx-combo   { color: #fff; background: #A32D2D; padding: 2px 14px; border-radius: 999px; font-size: 30px; }
@keyframes floatUp { from{transform:translateY(10px);opacity:0} 30%{opacity:1} to{transform:translateY(-24px);opacity:0} }

/* ---- PROJECTILES (mascottes lancées) ---- */
.proj-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.projectile {
  position: absolute; top: 42%;
  height: 22%; width: auto;
  transform: translate(-50%, -50%);
  animation: projspin .5s linear;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.35));
}
.projectile.flip { transform: translate(-50%, -50%) scaleX(-1); }
@keyframes projspin { from { rotate: -12deg; } to { rotate: 12deg; } }

/* ---- LÉGENDE DES TOUCHES ---- */
.controls-legend {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-top: 14px;
}
.key {
  background: var(--paper); color: var(--ink);
  font-size: 12px; padding: 5px 12px; border-radius: 8px;
}
.key b { color: var(--green-dark); }

/* ---- OVERLAY RÉSULTAT (DA) ---- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(0,0,0,.72);
  display: none; align-items: center; justify-content: center;
}
.overlay.is-on { display: flex; }
.result-card {
  position: relative; color: #fff; text-align: center; min-width: 320px;
  background: rgba(26,22,18,.94); border: 3px solid var(--amber); border-radius: 18px;
  padding: 24px 48px 32px; box-shadow: 0 16px 44px rgba(0,0,0,.55);
}
.result-fighter { height: 200px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 6px; }
.result-fighter img { max-height: 100%; max-width: 220px; filter: drop-shadow(0 8px 10px rgba(0,0,0,.5)); }
#result-title { margin: 4px 0; font-size: 48px; font-weight: 900; letter-spacing: 2px; }
.result-card.win  #result-title { color: #FAC775; text-shadow: 0 3px 0 var(--orange); }
.result-card.lose #result-title { color: #e08a78; }
.result-card.lose .result-fighter img { filter: grayscale(.5) drop-shadow(0 8px 10px rgba(0,0,0,.5)); }
.result-score { margin: 0 0 22px; color: #cfc8bb; font-size: 16px; letter-spacing: 1px; }
