/* ---------- Base ---------- */
:root {
  --bg: #10141c;
  --panel: #1b2230;
  --ink: #f2f5fa;
  --muted: #a9b4c6;
  --accent: #ffcc4d;
  --accent-ink: #1a1206;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 800px;               /* largeur minimale raisonnable */
  overflow-x: hidden;             /* jamais de débordement horizontal */
  font: 16px/1.4 system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

/* Focus clavier toujours visible */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: .15em .45em;
  border: 1px solid #4a566b;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #2a3242;
  font: 600 .95em/1 ui-monospace, monospace;
  text-align: center;
}

/* ---------- Scène ---------- */
#scene {
  position: relative;
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 30%, #2c3549 0%, #151b26 60%, #0c1017 100%);
}

/* Secousse de la scène lors d'un impact */
#scene.shake { animation: shake 180ms ease-out; }
@keyframes shake {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-6px, 3px); }
  50%  { transform: translate(5px, -4px); }
  75%  { transform: translate(-3px, -2px); }
  100% { transform: translate(0, 0); }
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(10, 14, 20, .72);
  z-index: 5;
}

.hud-box {
  min-width: 92px;
  padding: 6px 12px;
  border: 1px solid #3a465c;
  border-radius: 8px;
  background: #141a25;
  text-align: center;
}
.hud-label { display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hud-box strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }

#keyHints {
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
#keyHints li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #3a465c;
  border-radius: 8px;
  font-size: .8rem;
  color: var(--muted);
  transition: background 120ms, color 120ms, transform 120ms;
}
/* Indication visuelle quand la touche est pressée */
#keyHints li.active {
  background: var(--accent);
  color: var(--accent-ink);
  transform: translateY(2px);
}
#keyHints li.active kbd { background: #fff; color: var(--accent-ink); border-color: #b98f1c; }

#toggles { display: flex; gap: 8px; margin-left: auto; }
.toggle {
  padding: 8px 12px;
  border: 1px solid #4a566b;
  border-radius: 8px;
  background: #202939;
  color: var(--ink);
  font-size: .8rem;
  cursor: pointer;
}
.toggle[aria-pressed="false"] { background: #12161f; color: var(--muted); }

/* ---------- Cible ---------- */
#targetZone {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

#face {
  position: relative;
  width: 320px;
  height: 380px;
  border-radius: 50%;               /* zone ovale */
  overflow: hidden;                 /* recadrage de l'image */
  background: #0c1017;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 6px rgba(255, 255, 255, .06);
}

#face svg, #face img, #face canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#face img { object-fit: cover; }    /* image centrée et recadrée */
#marks, #blood { pointer-events: none; }

/* Les hématomes se fondent dans la peau (ou dans la photo chargée). */
#marks { mix-blend-mode: multiply; }
/* Le sang, lui, se pose par-dessus. */
#blood { mix-blend-mode: normal; }
#face.no-gore #blood, #face.no-gore #marks { display: none; }

/* Marques : révélées par paliers selon le nombre de coups */
.mark { opacity: 0; transition: opacity 600ms; }
#face[data-injury="1"] .lvl1,
#face[data-injury="2"] :is(.lvl1, .lvl2),
#face[data-injury="3"] :is(.lvl1, .lvl2, .lvl3),
#face[data-injury="4"] .mark { opacity: 1; }
/* Teint qui vire à mesure que les coups s'accumulent */
#face[data-injury="3"] { filter: saturate(1.1) contrast(1.05); }
#face[data-injury="4"] { filter: saturate(1.15) contrast(1.08) brightness(.95); }

/* Flash d'impact */
#flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
#flash.on { animation: flash 140ms ease-out; }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }

/* Réactions de la cible — une animation par type de coup */
#face.jabL  { animation: jabL  220ms ease-out; }
#face.hookL { animation: hookL 240ms ease-out; }
#face.jabR  { animation: jabR  220ms ease-out; }
#face.hookR { animation: hookR 240ms ease-out; }

/* Coup gauche : la cible part vers la droite. Direct : recul (scale). */
@keyframes jabL {
  30%  { transform: translate(26px, 4px) scale(.94) rotate(3deg); }
  100% { transform: none; }
}
/* Crochet : rotation latérale plus marquée */
@keyframes hookL {
  30%  { transform: translate(34px, -6px) scale(.97) rotate(11deg); }
  100% { transform: none; }
}
@keyframes jabR {
  30%  { transform: translate(-26px, 4px) scale(.94) rotate(-3deg); }
  100% { transform: none; }
}
@keyframes hookR {
  30%  { transform: translate(-34px, -6px) scale(.97) rotate(-11deg); }
  100% { transform: none; }
}

#comboMsg {
  height: 2rem;
  margin: 14px 0 0;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}
#comboMsg.show { animation: comboPop 700ms ease-out; }
@keyframes comboPop {
  0%   { opacity: 0; transform: scale(.7); }
  20%  { opacity: 1; transform: scale(1.1); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

/* ---------- Particules ---------- */
#particles { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
/* Gouttes projetées : forme étirée, orientée dans le sens de la vitesse. */
.particle {
  position: absolute;
  border-radius: 52% 52% 58% 58% / 62% 62% 38% 38%;
  background: #8e0f14;
  box-shadow: inset -1px -2px 3px rgba(0, 0, 0, .45);
}

/* ---------- Mains ---------- */
#hands {
  position: absolute;
  inset: auto 0 0 0;
  height: 340px;
  pointer-events: none;
  z-index: 3;
}

.hand {
  position: absolute;
  bottom: -24px;
  width: 240px;
  height: 320px;
}
#handLeft  { left: 6%;  transform: rotate(-12deg); }
#handRight { right: 6%; transform: rotate(12deg); }

/* Poing cartoon en SVG (voir <symbol id="fistShape"> dans index.html) */
.fist {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .45));
}
/* Les deux mains partagent le même dessin ; la gauche est miroitée pour que
   les pouces se fassent face. Le miroir est porté par .fist et non par .hand,
   afin de ne pas perturber les keyframes de frappe. */
#handLeft .fist { transform: scaleX(-1); }

/* Quatre animations de frappe distinctes (150–250 ms) */
#handLeft.jab   { animation: handJabL  190ms ease-out; }
#handLeft.hook  { animation: handHookL 240ms ease-out; }
#handRight.jab  { animation: handJabR  190ms ease-out; }
#handRight.hook { animation: handHookR 240ms ease-out; }

/* Départ garde → cible → impact → retour */
@keyframes handJabL {
  0%   { transform: rotate(-12deg) translate(0, 0) scale(1); }
  45%  { transform: rotate(-4deg) translate(150px, -230px) scale(.62); }
  60%  { transform: rotate(-4deg) translate(140px, -218px) scale(.68); }
  100% { transform: rotate(-12deg) translate(0, 0) scale(1); }
}
@keyframes handHookL {
  0%   { transform: rotate(-12deg) translate(0, 0) scale(1); }
  50%  { transform: rotate(46deg) translate(210px, -180px) scale(.68); }
  65%  { transform: rotate(40deg) translate(196px, -172px) scale(.74); }
  100% { transform: rotate(-12deg) translate(0, 0) scale(1); }
}
@keyframes handJabR {
  0%   { transform: rotate(12deg) translate(0, 0) scale(1); }
  45%  { transform: rotate(4deg) translate(-150px, -230px) scale(.62); }
  60%  { transform: rotate(4deg) translate(-140px, -218px) scale(.68); }
  100% { transform: rotate(12deg) translate(0, 0) scale(1); }
}
@keyframes handHookR {
  0%   { transform: rotate(12deg) translate(0, 0) scale(1); }
  50%  { transform: rotate(-46deg) translate(-210px, -180px) scale(.68); }
  65%  { transform: rotate(-40deg) translate(-196px, -172px) scale(.74); }
  100% { transform: rotate(12deg) translate(0, 0) scale(1); }
}

/* ---------- Écrans ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 9, 14, .82);
  z-index: 10;
}
.overlay.hidden { display: none; }

.panel {
  width: min(560px, 92vw);
  padding: 28px 32px;
  border: 1px solid #39445a;
  border-radius: 14px;
  background: var(--panel);
  text-align: center;
}
.panel h1 { margin: 0 0 6px; font-size: 2.2rem; }
.tagline { margin: 0 0 20px; color: var(--muted); }

.controls { width: 100%; margin: 0 0 20px; border-collapse: collapse; }
.controls caption { padding-bottom: 8px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }
.controls th, .controls td { padding: 6px 8px; border-bottom: 1px solid #2c3547; text-align: left; }
.controls th { width: 60px; }
.controls td { border-bottom: 1px solid #2c3547; }

.face-picker {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px dashed #4a566b;
  border-radius: 10px;
  text-align: left;
}
.face-picker label { font-size: .9rem; color: var(--muted); }
#btnDefaultFace {
  justify-self: start;
  padding: 8px 12px;
  border: 1px solid #4a566b;
  border-radius: 8px;
  background: #202939;
  color: var(--ink);
  cursor: pointer;
}

.primary {
  padding: 14px 28px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.08); }

.final { margin: 6px 0; font-size: 1.2rem; }
.final strong { color: var(--accent); }

/* ---------- Petits écrans ---------- */
@media (max-width: 1000px) {
  #face { width: 230px; height: 275px; }
  .hand { width: 150px; height: 190px; }
  #handLeft { left: 2%; }
  #handRight { right: 2%; }
  #keyHints li span { display: none; }   /* on garde les touches, on gagne de la place */
}

/* ---------- Mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  #scene.shake { animation: none; }
  #face.jabL, #face.hookL, #face.jabR, #face.hookR { animation-duration: 1ms; }
}
