/* ============================================================
   AI Fight — Arcade Retro CSS
   Police: Press Start 2P (Google Fonts)
   Palette: fond noir, néon bleu (#00f0ff) / rouge (#ff003c)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

:root {
  --neon-blue:  #00f0ff;
  --neon-red:   #ff003c;
  --neon-gold:  #ffd700;
  --bg:         #0a0a0a;
  --bg2:        #111;
  --text:       #eee;
}

html { font-size: 16px; background: var(--bg); }

body {
  font-family: 'Press Start 2P', monospace;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
  overflow-x: hidden;
}

/* ── TITRE ─────────────────────────────────────────────── */
.site-title {
  font-size: clamp(1rem, 4vw, 2rem);
  color: var(--neon-gold);
  text-shadow: 0 0 12px var(--neon-gold), 0 0 32px #ff8c00;
  letter-spacing: 4px;
  margin-bottom: 8px;
  text-align: center;
}
.site-sub {
  font-size: .7rem;
  color: var(--neon-gold);
  opacity: .7;
  letter-spacing: 4px;
  margin-bottom: 40px;
  text-align: center;
  text-shadow: 0 0 8px var(--neon-gold);
}

/* ── ARÈNE ─────────────────────────────────────────────── */
.arena {
  width: 100%;
  max-width: 860px;
  background: var(--bg2);
  border: 2px solid #333;
  border-radius: 4px;
  padding: 24px 16px 32px;
  position: relative;
}

/* Barres de vie */
.health-bars {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}
.health-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.health-bar-wrap.right { align-items: flex-end; }
.fighter-name {
  font-size: .5rem;
  color: #aaa;
  letter-spacing: 1px;
  min-height: 1.2em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 100%;
}
.health-bar-outer {
  width: 100%;
  height: 14px;
  background: #222;
  border: 1px solid #444;
}
.health-bar-inner {
  height: 100%;
  width: 100%;
  transition: width 1.2s ease-out;
}
.health-bar-wrap:first-child .health-bar-inner { background: var(--neon-blue); }
.health-bar-wrap.right       .health-bar-inner { background: var(--neon-red); float: right; }

.vs-badge {
  font-size: .7rem;
  color: var(--neon-gold);
  text-shadow: 0 0 8px var(--neon-gold);
  flex-shrink: 0;
  padding: 0 8px;
}

/* ── COMBATTANTS ───────────────────────────────────────── */
.fighters-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 16px;
  min-height: 200px;
  margin-bottom: 32px;
}

.fighter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.fighter-container.right .fighter-sprite { transform: scaleX(-1); }

/* ── NINJA (P1) — animated GIF via <img> ─────────────────── */
.ninja-sprite {
  height: 200px;
  width: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── BOXEUR (P2) — animated GIF, swap src via JS ──────── */
.boxer-sprite {
  height: 200px;
  width: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Flash victoire — commun aux deux */
.sprite-winner {
  filter: drop-shadow(0 0 12px var(--neon-gold));
  animation: winner-glow 1s ease-in-out infinite alternate;
}
@keyframes winner-glow {
  from { filter: drop-shadow(0 0 8px var(--neon-gold)); }
  to   { filter: drop-shadow(0 0 24px var(--neon-gold)) brightness(1.3); }
}

/* ── FORMULAIRE ────────────────────────────────────────── */
.fight-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.word-input {
  flex: 1;
  min-width: 120px;
  max-width: 280px;
  font-family: 'Press Start 2P', monospace;
  font-size: .65rem;
  padding: 12px 14px;
  background: #0d0d0d;
  border: 2px solid #444;
  color: var(--text);
  outline: none;
  letter-spacing: 1px;
  transition: border-color .2s;
}
.word-input:focus { border-color: var(--neon-gold); }
.word-input.input-left  { border-color: var(--neon-blue); }
.word-input.input-right { border-color: var(--neon-red); text-align: right; }

.fight-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: .75rem;
  padding: 14px 24px;
  background: var(--neon-gold);
  color: #000;
  border: none;
  cursor: pointer;
  letter-spacing: 2px;
  text-transform: uppercase;
  transition: transform .1s, box-shadow .1s;
  flex-shrink: 0;
}
.fight-btn:hover  { transform: scale(1.05); box-shadow: 0 0 16px var(--neon-gold); }
.fight-btn:active { transform: scale(.97); }
.fight-btn:disabled { background: #555; color: #888; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── RÉSULTATS ─────────────────────────────────────────── */
#results { margin-top: 40px; display: none; }

.result-headline {
  text-align: center;
  font-size: clamp(.7rem, 3vw, 1.2rem);
  margin-bottom: 24px;
}
.result-headline .winner-name {
  color: var(--neon-gold);
  text-shadow: 0 0 12px var(--neon-gold);
  display: block;
  margin-top: 8px;
}

.scores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.score-card {
  background: #0d0d0d;
  border: 1px solid #333;
  padding: 16px;
}
.score-card h3 {
  font-size: .55rem;
  margin-bottom: 12px;
  color: #aaa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.score-card.is-winner h3 { color: var(--neon-gold); }
.score-card.is-loser  h3 { color: #666; }

.score-final {
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 16px;
}
.score-card.is-winner .score-final { color: var(--neon-gold); text-shadow: 0 0 12px var(--neon-gold); }
.score-card.is-loser  .score-final { color: #555; }

.score-detail { font-size: .4rem; color: #777; }
.score-detail {
  font-size: .4rem;
  color: #777;
  width: 100%;
}
.score-detail-grid {
  display: grid;
  grid-template-columns: auto 32px 32px;
  gap: 3px 8px;
  align-items: center;
}
.score-detail-grid .sdg-header {
  color: #555;
  text-align: center;
  font-size: .35rem;
  padding-bottom: 4px;
  border-bottom: 1px solid #222;
}
.score-detail-grid .sdg-label { color: #888; }
.score-detail-grid .sdg-val   { color: var(--text); text-align: center; }

/* Tableau comparatif juge */
.judges-table {
  font-size: .4rem;
  width: 100%;
  border-collapse: collapse;
  color: #888;
  margin-top: 16px;
}
.judges-table th, .judges-table td {
  padding: 6px 8px;
  text-align: center;
  border: 1px solid #222;
}
.judges-table th     { color: #555; background: #0d0d0d; }
.judges-table td:first-child { text-align: left; color: #aaa; }
.judges-table .winner-cell { color: var(--neon-gold); }
.judges-table .final-row td {
  color: var(--neon-gold);
  font-size: .45rem;
  border-bottom: 2px solid #333;
  background: #111;
}

/* ── TITRE DE SECTION ───────────────────────────────────── */
.section-title {
  font-size: .6rem;
  color: #555;
  letter-spacing: 3px;
  margin-bottom: 20px;
  text-align: left;
}

/* ── FIGHTS VEDETTES ────────────────────────────────────── */
.featured-section {
  margin-top: 48px;
  width: 100%;
  max-width: 860px;
}
.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.featured-card {
  background: #0d0d0d;
  border: 1px solid #2a2a2a;
  padding: 16px;
}
.fc-label {
  font-size: .38rem;
  color: var(--neon-gold);
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.fc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.fc-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fc-name {
  font-size: .4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fc-winner .fc-name { color: var(--neon-gold); }
.fc-loser  .fc-name { color: #555; }
.fc-bar-wrap {
  width: 100%;
  height: 6px;
  background: #1a1a1a;
}
.fc-bar       { height: 100%; background: var(--neon-blue); transition: width .8s ease; }
.fc-bar-red   { background: var(--neon-red); }
.fc-score {
  font-size: .5rem;
  color: #888;
}
.fc-winner .fc-score { color: var(--neon-gold); }
.fc-vs {
  font-size: .4rem;
  color: #333;
  flex-shrink: 0;
}
.fc-winner-line {
  font-size: .4rem;
  color: var(--neon-gold);
  text-align: center;
  border-top: 1px solid #1a1a1a;
  padding-top: 8px;
}

/* ── HISTORIQUE ────────────────────────────────────────── */
.recent-fights {
  margin-top: 40px;
  width: 100%;
  max-width: 860px;
}
.fight-list { list-style: none; }
.fight-item {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #111;
  font-size: .38rem;
}
.fight-item .fw { color: var(--neon-gold); }
.fight-item .fl { color: #444; }
.fight-item .fs { color: #555; }
.fight-item .fd { color: #222; }

/* ── LOADING ────────────────────────────────────────────── */
#loading {
  display: none;
  text-align: center;
  font-size: .5rem;
  color: var(--neon-gold);
  letter-spacing: 3px;
  margin-top: 24px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── ERREUR ─────────────────────────────────────────────── */
#error-msg {
  display: none;
  text-align: center;
  font-size: .45rem;
  color: var(--neon-red);
  margin-top: 16px;
}

/* ── FLASH ──────────────────────────────────────────────── */
.flash-overlay {
  position: fixed; inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  transition: opacity .05s;
}
.flash-overlay.flash { opacity: .4; }

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 600px) {
  :root { --scale: 2.5; }
  .fighters-row { padding: 0 4px; }
  .fight-form { flex-direction: column; align-items: stretch; }
  .word-input { max-width: 100%; text-align: left !important; }
  .scores-grid { grid-template-columns: 1fr; }
}
