/* ====== Reset basique ====== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: #0c1c3c;
  color: #fff;
  display: grid;
  place-items: center;
}

/* ====== Shell + carte ====== */
.stats-shell {
  width: min(1020px, 96vw);
  padding: 18px;
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: #1d2d50;
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0,0,0,.3);
  position: sticky;
  top: 10px;
  z-index: 10;
}

.side .player-name {
  font-size: clamp(18px, 2.4vw, 26px);
  font-weight: 800;
  letter-spacing: .3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-a .player-name { text-align: left; }
.side-b .player-name { text-align: right; }

.center { text-align: center; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .8px;
  background: #2b5236;
  border: 1px solid rgba(255,255,255,.1);
  opacity: .95;
}
.badge.pulse { animation: pulse 1.4s infinite; }
.badge.ended { background: #404a63; opacity: .85; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(43,82,54,.8); }
  70% { box-shadow: 0 0 0 12px rgba(43,82,54,0); }
  100% { box-shadow: 0 0 0 0 rgba(43,82,54,0); }
}

.vs {
  margin-top: 6px;
  font-weight: 900;
  font-size: clamp(18px, 2.3vw, 22px);
  letter-spacing: 1.2px;
  color: #ffcc00;
  text-shadow: 0 1px 0 rgba(0,0,0,.5);
}

.set-summary {
  margin-top: 6px;
  font-size: 14px;
  color: #dcdcdc;
}

/* ====== Boutons de sets ====== */
.set-buttons {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
}
.set-buttons button {
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  background: #2b5236;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, background .2s;
}
.set-buttons button:hover { transform: translateY(-1px); background: #22412b; }
.set-buttons button:active { transform: translateY(0); }
.set-buttons button.active { background: #fff; color: #2b5236; }

/* ====== Carte de stats ====== */
.stats-card {
  background: #131e3a;
  border: 1px solid rgba(255,255,255,.06);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  padding: 10px;
  overflow: hidden;
}

/* ====== Ligne stat ====== */
.stat-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #1b2a4a;
  border-radius: 12px;
  margin: 10px;
  position: relative;
}
.stat-row + .stat-row { margin-top: 10px; }

.stat-row .label {
  font-weight: 800;
  color: #eaeaea;
  text-align: center;
  font-size: clamp(14px, 2vw, 16px);
  white-space: nowrap;
}
.stat-row .value {
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 900;
}
.stat-row .value.left { text-align: left; }
.stat-row .value.right { text-align: right; }

/* Barres de progression bi-latérales */
.stat-row.has-bar { padding-bottom: 28px; }
.bar-wrap {
  position: absolute;
  left: 12px; right: 12px; bottom: 10px;
  height: 8px;
  background: #0f1730;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.06);
}

/* Deux voies qui ne se chevauchent pas */
.lane {
  position: absolute;
  top: 0; bottom: 0;
  width: 50%;
}
.lane-left  { left: 0;  border-right: 1px solid rgba(255,255,255,.04); }
.lane-right { right: 0; border-left:  1px solid rgba(0,0,0,.08); }

/* ⬇️ Barres: départ du centre vers l’extérieur */
.bar {
  position: absolute;
  top: 0; bottom: 0;
  width: 100%;
  transform: scaleX(0);
  transition: transform .35s ease;
  will-change: transform;
}
.bar-left  { left: 0;  transform-origin: right center; background: linear-gradient(270deg, #2b5236, #3b7a4c); }
.bar-right { right: 0; transform-origin: left  center; background: linear-gradient(90deg,  #2b5236, #3b7a4c); }

/* ====== Chips (pills) ====== */
.chips { background: #152443; }

/* Valeurs extrêmes collées aux bords pour Aces / DF / Total points */
.stat-row.chips {
  display: flex;                 /* override du grid pour cette rangée */
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f1a34;
  border: 1px solid rgba(255,255,255,.06);
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 800;
  justify-content: space-between;
}
.chip-strong { background: #0f2338; }
.chip-danger { background: #2c1a1f; border-color: rgba(255,0,0,.15); }
.chip .chip-label { opacity: .8; font-size: 12px; letter-spacing: .5px; }
.chip .chip-value { font-size: 16px; }

/* Coller les chips aux bords */
.stat-row.chips .chip.left  { margin-right: auto; justify-content: flex-start; }
.stat-row.chips .chip.right { margin-left:  auto; justify-content: flex-end; }

/* Label centré et stable */
.stat-row.chips .label {
  flex-shrink: 0;
  text-align: center;
  font-weight: 800;
  font-size: clamp(14px, 2vw, 16px);
}

/* ====== Responsive ====== */
@media (max-width: 840px) {
  /* Garde une grille lisible en petit écran */
  .stat-row {
    grid-template-columns: auto 1fr auto; /* gauche | centre | droite */
    gap: 8px;
    text-align: center;
  }

  .stat-row .label {
    order: 0;             /* centre */
    font-size: 13px;
  }

  .stat-row .value.left {
    text-align: left;     /* aligné à gauche */
    font-size: 14px;
  }

  .stat-row .value.right {
    text-align: right;    /* aligné à droite */
    font-size: 14px;
  }

  /* Chips en responsive : bord à bord + espace réduit */
  .stat-row.chips {
    justify-content: space-between;
    gap: 6px;
  }
  .stat-row.chips .chip.left  { margin-right: auto; }
  .stat-row.chips .chip.right { margin-left:  auto; }
}

@media (max-width: 520px) {
  .stats-shell { padding: 12px; }
  .stat-row { margin: 8px 6px; padding: 12px; }
  .bar-wrap { left: 10px; right: 10px; }
}
