/* ===================================================
   KURO ARCANA — Kuro Brawl (brawl.js, brawl-jeu.js) : classes .kb-*
   Écran de sélection dans la zone de l'Arcade (étapes sur mobile, un écran sur ordinateur), commandes
   (.kb-reglages), combat en plein écran (Canvas + bandeau + commandes tactiles), écran de fin (.kb-fin).
   =================================================== */

/* ---------- Écran de choix ---------- */
.kb-choix { gap: 14px; }
.kb-sous-titre {
  margin: 8px 0 0;
  font-family: 'Cinzel', serif;
  font-size: 1.1rem;
  color: var(--or-dore);
  letter-spacing: 0.06em;
}
.kb-note, .kb-gain, .kb-commandes-aide {
  margin: 0;
  max-width: 60ch;
  font-family: 'Raleway', sans-serif;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.78);
  text-align: center;
}
.kb-gain { color: var(--or-dore); font-weight: 700; }
.kb-options { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.kb-option {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 999px;
  background: rgba(20, 10, 35, 0.7);
  color: #fff;
  font-family: 'Raleway', sans-serif;
  font-size: 1rem;
  cursor: pointer;
}
.kb-option.kb-actif { border-color: var(--or-dore); background: linear-gradient(135deg, rgba(139, 0, 0, 0.75), rgba(107, 0, 128, 0.75)); color: var(--or-dore); }
.kb-persos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  width: min(100%, 760px);
}
.kb-perso {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 10px 8px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--kb-teinte) 35%, transparent), rgba(10, 6, 20, 0.85) 70%);
  color: #fff;
  cursor: pointer;
}
.kb-perso.kb-actif { border-color: var(--kb-teinte); box-shadow: 0 0 16px color-mix(in srgb, var(--kb-teinte) 60%, transparent); }
.kb-perso.kb-verrou { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.7); }
.kb-perso-image {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 2px solid var(--kb-teinte);
  border-radius: 50%;
  background: #1a1028 center 12% / cover no-repeat;
  font-size: 2rem;
}
.kb-perso-nom { font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 700; }
.kb-perso-univers { font-family: 'Raleway', sans-serif; font-size: 1rem; color: rgba(255, 255, 255, 0.7); text-align: center; }

/* ---------- Combat ---------- */
body.kb-en-combat { overflow: hidden; }
.kb-combat {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: #07050d;
  color: #fff;
  font-family: 'Raleway', sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.kb-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.2));
}
.kb-joueur { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.kb-j2 { flex-direction: row-reverse; text-align: right; }
.kb-portrait {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid #ffd700;
  border-radius: 50%;
  background: #1a1028 center 12% / cover no-repeat;
  font-size: 1.1rem;
  font-weight: 700;
}
.kb-j2 .kb-portrait { border-color: #ff5470; }
.kb-joueur-infos { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; }
.kb-nom { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kb-pourcent {
  --kb-chaleur: 0;
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 900;
  color: color-mix(in srgb, #ff2a2a calc(var(--kb-chaleur) * 100%), #ffffff);
  text-shadow: 0 2px 4px #000;
}
.kb-vies { font-size: 1rem; color: #ffd700; letter-spacing: 2px; }
.kb-j2 .kb-vies { color: #ff5470; }
.kb-jauge { position: absolute; left: 52px; right: 0; bottom: -4px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.kb-j2 .kb-jauge { left: 0; right: 52px; }
.kb-jauge span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd700, #ff8a1f); }
.kb-centre { display: flex; align-items: center; gap: 6px; }
.kb-chrono { font-family: 'Cinzel', serif; font-size: 1rem; color: var(--or-dore); white-space: nowrap; }
.kb-pause {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.kb-scene { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.kb-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.kb-annonce {
  position: absolute;
  inset: 40% 0 auto;
  margin: 0;
  font-family: 'Cinzel', serif;
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--or-dore);
  text-align: center;
  text-shadow: 0 0 18px rgba(255, 84, 112, 0.8), 0 3px 0 #000;
  pointer-events: none;
  animation: kb-annonce 0.9s ease-out;
}
.kb-annonce[hidden] { display: none; }
@keyframes kb-annonce { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Ultime : bande au portrait de la carte, le temps du gel du moteur */
.kb-ultime {
  --kb-teinte: #ffd700;
  position: absolute;
  inset: 25% 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 6%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--kb-teinte) 55%, #000) 20%, color-mix(in srgb, var(--kb-teinte) 55%, #000) 80%, transparent);
  pointer-events: none;
  animation: kb-ultime 0.8s ease-out;
}
.kb-ultime[hidden] { display: none; }
.kb-ultime-joueur2 { flex-direction: row-reverse; }
.kb-ultime-image { width: min(30vw, 180px); height: 100%; background: center 15% / cover no-repeat; border-radius: 12px; box-shadow: 0 0 30px var(--kb-teinte); }
.kb-ultime-nom { font-family: 'Cinzel', serif; font-size: clamp(1.2rem, 4vw, 2.4rem); font-weight: 900; color: #fff; text-shadow: 0 3px 0 #000, 0 0 20px var(--kb-teinte); }
@keyframes kb-ultime { from { transform: translateX(-30%) skewX(-12deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* Commandes tactiles : sous la scène en portrait, par-dessus en paysage */
.kb-commandes { display: none; }
.kb-tactile .kb-commandes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 14px;
  background: rgba(0, 0, 0, 0.55);
}
.kb-joystick {
  position: relative;
  flex: none;
  width: 140px;
  height: 140px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
  touch-action: none;
}
.kb-joystick-bouton {
  position: absolute;
  left: calc(50% - 30px);
  top: calc(50% - 30px);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #b9a6ff);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}
.kb-boutons {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(2, 60px);
  gap: 10px;
}
.kb-btn {
  width: 60px;
  height: 60px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(30, 20, 50, 0.85);
  color: #fff;
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  font-weight: 900;
  touch-action: none;
}
.kb-btn.kb-appuye { transform: scale(0.92); filter: brightness(1.4); }
/* Réglages du joueur : position (glissée) et taille des commandes tactiles */
.kb-joystick, .kb-btn { translate: var(--kb-dx, 0) var(--kb-dy, 0); scale: var(--kb-taille, 1); }
.kb-btn-attaque { grid-column: 3; grid-row: 2; background: #8b0000; border-color: #ffd700; }
.kb-btn-special { grid-column: 2; grid-row: 2; background: #4b2a8a; }
.kb-btn-saut { grid-column: 3; grid-row: 1; background: #1f6f5c; }
.kb-btn-garde { grid-column: 2; grid-row: 1; background: #1f3a8a; }
.kb-btn-ultime { grid-column: 1; grid-row: 1 / span 2; align-self: center; opacity: 0.45; }
.kb-ultime-pret .kb-btn-ultime { opacity: 1; background: radial-gradient(circle, #ffd700, #ff8a1f); color: #2a1200; animation: kb-pret 1s ease-in-out infinite alternate; }
@keyframes kb-pret { to { box-shadow: 0 0 20px #ffd700; } }
.kb-aide-clavier { margin: 0; padding: 6px 12px; font-size: 1rem; color: rgba(255, 255, 255, 0.6); text-align: center; }
.kb-tactile .kb-aide-clavier { display: none; }

@media (orientation: landscape) and (max-height: 560px) {
  .kb-tactile .kb-commandes {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0 max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: none;
    pointer-events: none;
  }
  .kb-tactile .kb-joystick, .kb-tactile .kb-btn { pointer-events: auto; opacity: 0.8; }
  .kb-tactile .kb-btn-ultime { opacity: 0.4; }
  .kb-tactile.kb-ultime-pret .kb-btn-ultime { opacity: 1; }
  .kb-hud { padding: 4px 12px; }
}

/* Pause */
.kb-pause-calque { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, 0.7); }
.kb-pause-calque[hidden] { display: none; }
.kb-pause-boite { display: flex; flex-direction: column; gap: 12px; padding: 24px; border: 1px solid var(--or-dore); border-radius: 16px; background: #140a22; }
.kb-pause-titre { margin: 0; font-family: 'Cinzel', serif; font-size: 1.6rem; color: var(--or-dore); text-align: center; }

@media (max-width: 768px) {
  .kb-persos { grid-template-columns: repeat(3, 1fr); }
  .kb-perso-image { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .kb-annonce, .kb-ultime, .kb-ultime-pret .kb-btn-ultime { animation: none; }
}

/* ---------- Sélection façon jeu de combat ---------- */
.kb-etapes { display: none; }
.kb-nav { display: none; }
.kb-section { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.kb-selection { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; width: min(100%, 980px); }
.kb-selection .kb-persos { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); width: 100%; }
.kb-perso { position: relative; }
.kb-perso.kb-verrou { cursor: pointer; }
.kb-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--or-dore);
  color: #2a1200;
  font-family: 'Raleway', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}
.kb-badge-sprite { background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 400; }
.kb-cadenas { position: absolute; top: 6px; right: 8px; font-size: 1.1rem; }
.kb-apercu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--kb-teinte);
  border-radius: 16px;
  background: radial-gradient(circle at 50% 25%, color-mix(in srgb, var(--kb-teinte) 30%, transparent), rgba(10, 6, 20, 0.92) 70%);
}
.kb-apercu-canvas { width: 160px; height: 170px; image-rendering: pixelated; }
.kb-apercu-infos { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.kb-apercu-nom { margin: 0; font-family: 'Cinzel', serif; font-size: 1.4rem; font-weight: 900; color: #fff; }
.kb-apercu-univers { margin: 0; font-family: 'Raleway', sans-serif; font-size: 1rem; color: rgba(255, 255, 255, 0.7); }
.kb-condition.kb-verrouille { color: #ffb4b4; }
.kb-coups { display: flex; flex-direction: column; gap: 4px; width: 100%; margin: 4px 0 0; padding: 0; list-style: none; }
.kb-coups li { display: flex; align-items: center; gap: 8px; font-family: 'Raleway', sans-serif; font-size: 1rem; color: #fff; }
.kb-coup-touche { flex: none; min-width: 44px; padding: 2px 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.12); color: var(--or-dore); font-weight: 700; text-align: center; }
.kb-arenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; width: min(100%, 820px); }
.kb-arene {
  display: flex;
  align-items: flex-end;
  min-height: 84px;
  padding: 10px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--kb-ciel1), var(--kb-ciel2));
  box-shadow: inset 0 -14px 0 color-mix(in srgb, var(--kb-teinte) 45%, transparent);
  color: #fff;
  cursor: pointer;
}
.kb-arene.kb-actif { border-color: var(--or-dore); box-shadow: inset 0 -14px 0 color-mix(in srgb, var(--kb-teinte) 45%, transparent), 0 0 14px rgba(255, 215, 0, 0.5); }
.kb-arene-nom { font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 700; text-shadow: 0 2px 4px #000; }
.kb-option:disabled { opacity: 0.5; cursor: not-allowed; }
.kb-bas { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

@media (max-width: 768px) {
  .kb-etapes { display: flex; justify-content: center; gap: 8px; margin: 0; padding: 0; list-style: none; font-family: 'Raleway', sans-serif; font-size: 1rem; color: rgba(255, 255, 255, 0.55); }
  .kb-etapes .kb-actif { color: var(--or-dore); font-weight: 700; }
  .kb-nav { display: flex; justify-content: center; gap: 10px; }
  .kb-choix[data-kb-etape-active="1"] .kb-section:not([data-kb-section="1"]),
  .kb-choix[data-kb-etape-active="2"] .kb-section:not([data-kb-section="2"]),
  .kb-choix[data-kb-etape-active="3"] .kb-section:not([data-kb-section="3"]) { display: none; }
  .kb-selection { grid-template-columns: 1fr; }
  .kb-selection .kb-persos { grid-template-columns: repeat(3, 1fr); }
  .kb-apercu { order: -1; flex-direction: row; }
  .kb-apercu-canvas { width: 110px; height: 130px; flex: none; }
  .kb-apercu-infos { align-items: flex-start; }
  .kb-arenes { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Commandes ---------- */
.kb-reglages { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, 0.78); overflow-y: auto; }
.kb-reglages-boite { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(100%, 560px); padding: 20px 16px; border: 1px solid var(--or-dore); border-radius: 16px; background: #140a22; }
.kb-reglages-titre { margin: 0; font-family: 'Cinzel', serif; font-size: 1.5rem; color: var(--or-dore); }
.kb-reglages-liste { display: flex; flex-direction: column; gap: 6px; width: 100%; margin: 0; padding: 0; list-style: none; }
.kb-reglage { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kb-reglage-action { font-family: 'Raleway', sans-serif; font-size: 1rem; color: #fff; }
.kb-reglage-touche { min-width: 150px; min-height: 44px; }
.kb-reglage-touche.kb-attente { border-color: var(--or-dore); color: var(--or-dore); }
.kb-reglages-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.kb-apercu-zone { position: relative; width: 100%; padding: 30px 0; border: 1px dashed rgba(255, 255, 255, 0.3); border-radius: 12px; }
.kb-apercu-tactile { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.kb-apercu-tactile [data-kb-deplacer] { cursor: grab; touch-action: none; }
.kb-taille { display: flex; align-items: center; gap: 10px; font-family: 'Raleway', sans-serif; font-size: 1rem; color: #fff; }
.kb-taille input { width: 160px; min-height: 44px; accent-color: var(--or-dore); }

/* ---------- Fin de partie ---------- */
.kb-fin { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(100%, 640px); margin: 0 auto; padding: 16px; border: 1px solid rgba(255, 215, 0, 0.4); border-radius: 18px; background: rgba(20, 10, 35, 0.92); }
.kb-fin-scene { display: flex; align-items: flex-end; justify-content: center; gap: 16px; width: 100%; }
.kb-fin-scene figure { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0; font-family: 'Cinzel', serif; font-size: 1rem; color: #fff; }
.kb-fin-gagnant canvas { width: 200px; height: 220px; filter: drop-shadow(0 0 18px var(--kb-teinte)); image-rendering: pixelated; }
.kb-fin-perdant canvas { width: 110px; height: 120px; opacity: 0.85; image-rendering: pixelated; }
.kb-fin-egalite .kb-fin-gagnant canvas { width: 150px; height: 165px; }
.kb-stats { width: 100%; border-collapse: collapse; font-family: 'Raleway', sans-serif; font-size: 1rem; color: #fff; }
.kb-stats th, .kb-stats td { padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); text-align: center; }
.kb-stats tbody th { text-align: left; font-weight: 400; color: rgba(255, 255, 255, 0.75); }
.kb-stats thead th { color: var(--or-dore); }
.kb-canvas { image-rendering: pixelated; }
@media (max-width: 768px) {
  .kb-fin-gagnant canvas { width: 150px; height: 165px; }
  .kb-fin-perdant canvas { width: 90px; height: 100px; }
  .kb-reglage-touche { min-width: 120px; }
}
