/* =====================================================================
   PAIRING MATRIX — CSS
   Refonte visuelle v2 — 2026
   Système : CSS custom properties, dark/light via classe html.dark
   ===================================================================== */

/* -----------------------------------------------------------------------
   1. VARIABLES SPÉCIFIQUES AUX PAGES PAIRING
   Override les variables globales de base.css pour les pages pairing
   ----------------------------------------------------------------------- */

/* Dark mode (défaut — html.dark) */
.pairing-page {
  --bg:      #120808;
  --panel:   #1c0f0f;
  --panel2:  #160a0a;
  --text:    #f1f1f1;
  --muted:   #9ca3af;
  --muted2:  #6b7280;
  --line:    #3d1c1c;
  --accent:  #bd0f0f;
  --accent2: #8B0000;
  --gold:    #C5A059;
  --shadow:  0 10px 30px rgba(0, 0, 0, 0.6);
}

/* Light mode — html:not(.dark) */
html:not(.dark) .pairing-page {
  --bg:      #f8f6f6;
  --panel:   #ffffff;
  --panel2:  #f0ecec;
  --text:    #0F0F0F;
  --muted:   #6b7280;
  --muted2:  #9ca3af;
  --line:    #e5dede;
  --accent:  #bd0f0f;
  --accent2: #8B0000;
  --shadow:  0 4px 20px rgba(0, 0, 0, 0.1);
}


/* -----------------------------------------------------------------------
   2. HEADER — personnalisation pour pages pairing
   ----------------------------------------------------------------------- */

.pairing-page .shared-header {
  background: linear-gradient(135deg, rgba(189, 15, 15, 0.18), rgba(18, 8, 8, 0.97));
  border-bottom: 1px solid var(--line);
}

html:not(.dark) .pairing-page .shared-header {
  background: linear-gradient(135deg, rgba(189, 15, 15, 0.08), rgba(248, 246, 246, 0.99));
  border-bottom: 1px solid var(--line);
}

.pairing-page .shared-header__title {
  color: var(--accent);
}


/* -----------------------------------------------------------------------
   3. SCROLLBAR
   ----------------------------------------------------------------------- */

.pairing-page ::-webkit-scrollbar       { width: 8px; height: 8px; }
.pairing-page ::-webkit-scrollbar-track { background: var(--bg); }
.pairing-page ::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.pairing-page ::-webkit-scrollbar-thumb:hover { background: var(--accent2); }


/* -----------------------------------------------------------------------
   4. LAYOUT DE BASE
   ----------------------------------------------------------------------- */

.pairing-matrix {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pairing-matrix--mode .panel-bd {
  display: flex;
  justify-content: center;
}

.pairing-matrix__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 18px;
}


/* -----------------------------------------------------------------------
   5. PANNEAU GÉNÉRIQUE
   ----------------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

.panel-hd h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Icône inline dans les titres de sections */
.panel-hd h2 .material-symbols-outlined,
.panel-hd__icon {
  font-size: 20px;
  color: var(--accent);
  flex-shrink: 0;
}

.panel-title--highlight {
  font-weight: 700;
  color: var(--accent);
}

.panel-bd {
  display: flex;
  flex-direction: column;
  gap: 12px;
}


/* -----------------------------------------------------------------------
   6. GRILLES & FORMULAIRES
   ----------------------------------------------------------------------- */

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.grid-2 .full { grid-column: 1 / -1; }

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.grid-3 .full { grid-column: 1 / -1; }

.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.config-grid .form-group { min-width: 0; }

.config-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.config-actions input[type="file"] { display: none; }
.config-actions .form-group { min-width: 220px; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.form-group--inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}
.form-group--inline label {
  min-width: 90px;
  margin: 0;
  font-size: 13px;
}
.form-group--inline select,
.form-group--inline input { flex: 1; }

.form-group--stacked {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.form-group--stacked label {
  min-width: 0;
  margin: 0;
}
.form-group--stacked select,
.form-group--stacked input { width: 100%; }

.form-group input,
.form-group select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
  outline: none;
}

.pairing-matrix select,
.pairing-matrix option {
  color: var(--text);
  background: var(--panel);
}


/* -----------------------------------------------------------------------
   7. BOUTONS
   ----------------------------------------------------------------------- */

.btn {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.btn:hover { background: var(--accent2); }
.btn:active { transform: scale(0.97); }

.btn.btn-secondary {
  background: var(--panel2);
  border-color: var(--line);
  color: var(--text);
}
.btn.btn-secondary:hover { border-color: var(--accent); background: var(--panel); }

.btn.btn-tertiary {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.btn.btn-tertiary:hover { border-color: var(--accent); color: var(--text); }

.btn-small { padding: 6px 12px; font-size: 12px; }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


/* -----------------------------------------------------------------------
   8. TEXTES UTILITAIRES
   ----------------------------------------------------------------------- */

.muted {
  color: var(--muted);
  font-size: 13px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.hidden { display: none; }

.modal.hidden { display: none; }


/* -----------------------------------------------------------------------
   9. MODE SELECTION — grille des 4 cartes
   ----------------------------------------------------------------------- */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  width: 100%;
}

.mode-card {
  position: relative;
  background: var(--panel);
  border-radius: 14px;
  padding: 28px 24px;
  text-decoration: none;
  color: inherit;
  transition: all 0.25s ease;
  border: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: visible;
}

.mode-card:hover {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(189, 15, 15, 0.2);
}

/* Icône de la carte */
.mode-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(189, 15, 15, 0.15);
  color: var(--accent);
  margin-bottom: 18px;
  flex-shrink: 0;
}

.mode-card__icon .material-symbols-outlined {
  font-size: 28px;
}

/* Variante live — icône et hover verts */
.mode-card--live {
  border-color: rgba(34, 197, 94, 0.3);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.08);
}
.mode-card--live .mode-card__icon {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}
.mode-card--live:hover {
  border-color: #22c55e;
  box-shadow: 0 12px 32px rgba(34, 197, 94, 0.2);
}
.mode-card--live h3,
.mode-card--live:hover h3 { color: #22c55e; }

/* Variante gaming — icône et hover violets */
.mode-card--gaming {
  border-color: rgba(168, 85, 247, 0.3);
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.08);
}
.mode-card--gaming .mode-card__icon {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
}
.mode-card--gaming:hover {
  border-color: #a855f7;
  box-shadow: 0 12px 32px rgba(168, 85, 247, 0.2);
}
.mode-card--gaming h3,
.mode-card--gaming:hover h3 { color: #a855f7; }

/* Titre et description dans les cartes */
.mode-card h3 {
  color: var(--gold);
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: 0.01em;
  transition: color 0.2s;
}
.mode-card:hover h3 { color: var(--accent); }

.mode-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  flex: 1;
  margin: 0 0 16px;
}

/* Pied de carte — accès & flèche */
.mode-card__footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mode-card__access {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted2);
}

.mode-card__arrow .material-symbols-outlined {
  font-size: 18px;
  color: var(--muted2);
  transition: transform 0.2s, color 0.2s;
}
.mode-card:hover .mode-card__arrow .material-symbols-outlined {
  transform: translateX(4px);
  color: var(--accent);
}
.mode-card--live:hover .mode-card__arrow .material-symbols-outlined { color: #22c55e; }
.mode-card--gaming:hover .mode-card__arrow .material-symbols-outlined { color: #a855f7; }

/* Badge "Actif" positionné en haut de carte */
.mode-card__badge {
  position: absolute;
  top: -11px;
  right: 16px;
  padding: 3px 10px;
  background: #22c55e;
  color: #051a09;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 999px;
}

/* Label de restriction en dessous de l'accès */
.mode-card__lock {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #22c55e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.mode-card--gaming .mode-card__lock { color: #a855f7; }
.mode-card__lock .material-symbols-outlined { font-size: 13px; }


/* -----------------------------------------------------------------------
   10. SECTION AIDE — bas de la page sélection
   ----------------------------------------------------------------------- */

.pm-help-section {
  margin-top: 48px;
  padding: 32px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

.pm-help-section h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.pm-help-section p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

.pm-help-section__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}


/* -----------------------------------------------------------------------
   11. ROSTER
   ----------------------------------------------------------------------- */

.roster {
  display: grid;
  gap: 8px;
}

.roster-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 8px;
  align-items: center;
}


/* -----------------------------------------------------------------------
   12. SÉLECTION FACTION
   ----------------------------------------------------------------------- */

.faction-count {
  font-size: 13px;
  color: var(--muted);
}

.faction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.faction-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  font-size: 13px;
  transition: border-color 0.2s;
  cursor: pointer;
}

.faction-item:hover {
  border-color: rgba(189, 15, 15, 0.4);
}

.faction-item input[type="checkbox"] {
  accent-color: var(--accent);
}


/* -----------------------------------------------------------------------
   13. MATRICE D'ESTIMATION
   ----------------------------------------------------------------------- */

.matrix-wrap {
  overflow-x: auto;
}

.matrix {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.matrix th,
.matrix td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: center;
  font-size: 13px;
}

.matrix th {
  background: var(--panel2);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
}

.matrix .row-label {
  text-align: left;
  font-weight: 600;
  background: var(--panel2);
  white-space: nowrap;
  padding-left: 12px;
}

.matrix input {
  width: 60px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-align: center;
  font-weight: 600;
  transition: border-color 0.15s;
}

.matrix input:focus {
  border-color: var(--accent);
  outline: none;
}


/* -----------------------------------------------------------------------
   14. COULEURS DE SCORE
   ----------------------------------------------------------------------- */

.score-low   { background: rgba(232, 65,  24, 0.20); }
.score-mid   { background: rgba(245, 159,  0, 0.20); }
.score-even  { background: rgba(251, 197, 49, 0.20); }
.score-good  { background: rgba( 46, 204,113, 0.20); }
.score-max   { background: rgba( 39, 174, 96, 0.35); }

.total-value {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  display: inline-block;
  min-width: 52px;
  text-align: center;
  font-weight: 700;
}

.total-low  { background: rgba(232,  65,  24, 0.25); color: #e84118; }
.total-mid  { background: rgba(251, 197,  49, 0.25); color: #f5c518; }
.total-high { background: rgba( 46, 204, 113, 0.25); color: #2ecc71; }


/* -----------------------------------------------------------------------
   15. MATCH-UPS
   ----------------------------------------------------------------------- */

.matchups {
  display: grid;
  gap: 10px;
}

.matchup-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.matchup-lock {
  cursor: pointer;
  color: var(--muted);
  font-size: 18px;
  user-select: none;
  transition: color 0.2s;
  line-height: 1;
}

.matchup-lock:hover { color: var(--text); }

.matchup-lock--locked { color: var(--accent); }
.matchup-lock--locked:hover { color: var(--accent); }

.matchup-row--locked {
  background: rgba(189, 15, 15, 0.05);
  border-radius: 8px;
  padding: 2px 6px;
}

.matchup-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted2);
  min-width: 48px;
  text-align: center;
  white-space: nowrap;
}

.matchup-label--def { color: #3b82f6; }
.matchup-label--att { color: #f59e0b; }
.matchup-label--refuse { color: #ef4444; }
.matchup-label--oublie { color: var(--muted); }

.matchup-row select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}

.score-pill {
  min-width: 44px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-weight: 700;
  font-size: 13px;
}

.total {
  font-size: 16px;
  font-weight: 700;
  text-align: right;
  color: var(--text);
  margin-top: 4px;
}

/* Designation controls */
.pm-designation-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.def-select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 12px;
  max-width: 180px;
}

/* Bloc total avec seuil de victoire */
.pm-total-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--panel2);
  border: 1px solid var(--line);
  margin-top: 8px;
}

.pm-total-block .total { margin-top: 0; }

.pm-victory-threshold {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.pm-victory-threshold .material-symbols-outlined {
  font-size: 16px;
}

.pm-victory-threshold.threshold-ok {
  color: #22c55e;
}

.pm-victory-threshold.threshold-ko {
  color: var(--accent);
}


/* -----------------------------------------------------------------------
   16. SÉLECTION D'ÉQUIPE & MATRICE
   ----------------------------------------------------------------------- */

.team-select-list,
.matrix-select-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.team-select-card,
.matrix-select-card {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.team-select-card:hover,
.matrix-select-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(189, 15, 15, 0.15);
}

.team-select-card__title,
.matrix-select-card__title {
  font-weight: 700;
  font-size: 14px;
}

.team-select-card__meta,
.matrix-select-card__meta {
  font-size: 11px;
  color: var(--muted);
}

/* Matrix grid layout */
.matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

/* Matrix card header (title + badge) */
.matrix-select-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

/* Matrix dates */
.matrix-select-card__dates {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: var(--muted);
}

/* Matrix actions (Ouvrir + Stats) */
.matrix-select-card__actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
  flex-wrap: wrap;
}

/* Badge Clôturée */
.matrix-select-card__badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.matrix-select-card__badge--closed {
  background: rgba(100, 116, 139, 0.2);
  color: var(--muted);
  border: 1px solid rgba(100, 116, 139, 0.35);
}

/* Closed card subtle style */
.matrix-select-card--closed {
  opacity: 0.85;
}

/* Bouton Stats */
.btn-stats-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.5);
  color: #22c55e;
  border-radius: 6px;
  font-size: 12px;
  padding: 4px 10px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-stats-link:hover {
  background: rgba(34, 197, 94, 0.18);
  border-color: #22c55e;
}

/* Matrix tabs */
.matrix-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.matrix-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.matrix-tab-btn:hover {
  color: var(--text);
}
.matrix-tab-btn--active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.matrix-tab-count {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  color: var(--muted);
}
.matrix-tab-btn--active .matrix-tab-count {
  background: rgba(189, 15, 15, 0.12);
  border-color: rgba(189, 15, 15, 0.3);
  color: var(--accent);
}


/* -----------------------------------------------------------------------
   17. BANNIÈRE LECTURE SEULE / ACCÈS REFUSÉ
   ----------------------------------------------------------------------- */

.readonly-banner {
  background: rgba(212, 160, 23, 0.12);
  border: 1px solid rgba(212, 160, 23, 0.45);
  border-radius: 10px;
  padding: 12px 18px;
  color: #f5d488;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}


/* -----------------------------------------------------------------------
   18. LISTE D'IMPORT
   ----------------------------------------------------------------------- */

.import-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.import-item {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 220px);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
}

.import-item small {
  color: var(--muted2);
}


/* -----------------------------------------------------------------------
   19. ZONE DE DÉPÔT (DROPZONE)
   ----------------------------------------------------------------------- */

.dropzone {
  border: 2px dashed var(--line);
  background: var(--panel2);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone p {
  margin: 0;
  color: var(--muted);
}

.dropzone input[type="file"] { display: none; }

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(189, 15, 15, 0.06);
}


/* -----------------------------------------------------------------------
   20. MODAL
   ----------------------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.modal-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line);
  width: min(720px, 92vw);
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-card--list-preview {
  width: 80vw;
  height: 80vh;
  max-width: 95vw;
  max-height: 95vh;
  min-width: 480px;
  min-height: 360px;
  resize: both;
  overflow: hidden;
}

.modal-card--list-preview .modal-bd {
  flex: 1;
  min-height: 0;
}

.modal-card h2 { margin: 0; }

.modal-hd,
.modal-ft {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-ft {
  border-bottom: none;
  border-top: 1px solid var(--line);
  gap: 12px;
}

.modal-bd {
  padding: 20px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}


/* -----------------------------------------------------------------------
   21. LISTE PRÉVISUALISATION (Army List)
   ----------------------------------------------------------------------- */

.list-emoji-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  user-select: none;
}

.list-emoji-action:hover,
.list-emoji-action:focus-visible {
  transform: scale(1.1);
}

.list-preview-meta {
  color: var(--muted);
  font-size: 13px;
}

.list-preview-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
}

.list-preview-markdown {
  width: 100%;
  height: 100%;
  min-height: 320px;
  overflow-y: auto;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel2);
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  box-sizing: border-box;
}

.list-preview-markdown h1,
.list-preview-markdown h2,
.list-preview-markdown h3 {
  color: var(--accent);
  margin-top: 1.2em;
  margin-bottom: 0.4em;
}

.list-preview-markdown strong { color: var(--gold, var(--accent)); }

.list-preview-markdown table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}

.list-preview-markdown th,
.list-preview-markdown td {
  border: 1px solid var(--line);
  padding: 6px 10px;
  text-align: left;
}

.list-preview-markdown th { background: var(--panel); }

.list-preview-markdown ul,
.list-preview-markdown ol {
  padding-left: 20px;
  margin: 8px 0;
}

.list-preview-markdown pre,
.list-preview-markdown code {
  background: var(--panel);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 12px;
}

/* Association modal — grande modale saisie manuelle */
.modal-card--list-assoc {
  width: 75vw;
  max-width: 880px;
  height: 82vh;
  display: flex;
  flex-direction: column;
}

.modal-card--list-assoc .modal-bd {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.list-assoc-manual-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 12px;
}

/* Association modal — onglets de type */
.list-assoc-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}

.list-assoc-tab {
  flex: 1;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: var(--muted);
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.list-assoc-tab + .list-assoc-tab {
  border-left: 1px solid var(--line);
}

.list-assoc-tab--active {
  background: var(--accent);
  color: #fff;
}

.list-assoc-tab:not(.list-assoc-tab--active):hover {
  background: var(--panel2);
  color: var(--text);
}


/* -----------------------------------------------------------------------
   22. MATRICES JOUEUR (mode joueur — rondes)
   ----------------------------------------------------------------------- */

.player-matrices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.round-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}

.round-card:hover {
  border-color: rgba(189, 15, 15, 0.4);
}

.round-card h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.player-matrix-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 10px;
  overflow: hidden;
}

.player-matrix-table th,
.player-matrix-table td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
}

.player-matrix-table th {
  background: var(--panel2);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.player-matrix-table input {
  width: 60px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-align: center;
  font-weight: 600;
}

.player-matrix-table td:first-child {
  text-align: left;
  font-weight: 600;
  background: var(--panel2);
}


/* -----------------------------------------------------------------------
   23. MODE LIVE — SPLIT ZONE
   ----------------------------------------------------------------------- */

.live-split-zone {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.live-split-zone__left,
.live-split-zone__right {
  min-width: 0;
}

.live-split-zone__right .panel {
  border-color: rgba(46, 204, 113, 0.2);
}

.matrix-cell--dimmed {
  opacity: 0.2;
  background: rgba(51, 51, 51, 0.3) !important;
  text-decoration: line-through;
  color: var(--muted);
  pointer-events: none;
}

.matchup-locked-label {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--text);
}

.live-matchup-row {
  grid-template-columns: 60px 1fr auto 1fr auto auto auto;
}

.live-matchup-row .matchup-label {
  min-width: 50px;
  text-align: right;
}

.suggestions {
  display: grid;
  gap: 10px;
}

.suggestion-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(46, 204, 113, 0.06);
  border: 1px solid rgba(46, 204, 113, 0.18);
  font-size: 13px;
}

/* Badge de synchronisation */
.pm-sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  font-size: 11px;
  font-weight: 700;
  color: #22c55e;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pm-sync-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  animation: pm-pulse 2s infinite;
  flex-shrink: 0;
}

@keyframes pm-pulse {
  0%   { opacity: 1;   transform: scale(1); }
  50%  { opacity: 0.5; transform: scale(0.85); }
  100% { opacity: 1;   transform: scale(1); }
}


/* -----------------------------------------------------------------------
   24. MODE GAMING LIVE — tableau de suivi
   ----------------------------------------------------------------------- */

/* Round buttons */
.pm-round-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pm-round-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted2);
  white-space: nowrap;
}

.pm-round-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.pm-round-btn {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: .04em;
}

.pm-round-btn:hover {
  background: var(--panel);
  color: var(--text);
  border-color: var(--accent);
}

.pm-round-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 99, 102, 241), 0.25);
}

/* Round timer */
.pm-round-timer {
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  font-size: 15px;
  font-weight: 800;
  font-family: monospace;
  letter-spacing: .08em;
  color: var(--text);
  min-width: 72px;
  text-align: center;
}

.pm-round-timer--urgent {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.pm-round-timer--done {
  color: var(--muted);
}

/* Sync badge animation */
.pm-sync-badge--active {
  color: #22c55e;
  animation: pm-sync-pulse 1.5s ease-out;
}

@keyframes pm-sync-pulse {
  0%   { opacity: 1; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}

/* Projection color variants */
.pm-projection-total-high { color: #22c55e; font-weight: 800; }
.pm-projection-total-mid  { color: #eab308; font-weight: 800; }
.pm-projection-total-low  { color: #ef4444; font-weight: 800; }

/* Gaming table */
.gaming-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1200px;
}

/* Transposed variant: rows become the stats, columns become matchups */
.gaming-table--transposed {
  min-width: unset;
  width: 100%;
}

.gaming-table--transposed th[scope="row"] {
  text-align: left;
  white-space: nowrap;
  background: var(--panel2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  position: sticky;
  left: 0;
  z-index: 2;
}

.gaming-table--transposed td.gaming-transposed-total {
  background: var(--panel2);
  font-weight: 700;
}

.gaming-table th,
.gaming-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: center;
  font-size: 13px;
}

.gaming-table th {
  background: var(--panel2);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

.gaming-table td:first-child,
.gaming-table td:nth-child(2) {
  text-align: left;
  font-weight: 600;
}

.gaming-table .computed-value {
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  min-width: 40px;
  display: inline-block;
}

.gaming-table .deployment-toggle,
.gaming-table .j1j2-toggle {
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  transition: all 0.2s ease;
  min-width: 44px;
}

.gaming-table .deployment-toggle.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  color: #22c55e;
}

.gaming-table .j1j2-toggle.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: #3b82f6;
  color: #3b82f6;
}

.gaming-table .cycle-btn {
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
  transition: all 0.2s ease;
  min-width: 60px;
}

.gaming-table .cycle-btn:hover {
  background: var(--panel2);
}

.gaming-table .cycle-btn.state-up {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.4);
}

.gaming-table .cycle-btn.state-down {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

.gaming-table .cycle-btn.state-empty {
  background: transparent;
  color: var(--muted2);
  border-color: var(--line);
  border-style: dashed;
  font-weight: 400;
}

.gaming-table .gaming-final-input {
  width: 60px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-align: center;
  font-weight: 700;
  transition: border-color 0.15s;
}

.gaming-table .gaming-final-input:focus {
  border-color: var(--accent);
  outline: none;
}

.gaming-table tfoot td {
  font-weight: 700;
  background: var(--panel2);
  color: var(--text);
}

/* Barre de présence utilisateurs connectés */
.pm-presence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  flex-wrap: wrap;
}
.pm-presence-bar__icon {
  color: var(--green, #22c55e);
}
.pm-presence-bar__label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.pm-presence-bar__list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pm-presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}
.pm-presence-chip__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

/* Pied de section Gaming Live */
.pm-gaming-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 8px;
}

.pm-gaming-footer .pm-sync-badge {
  font-size: 11px;
}


/* -----------------------------------------------------------------------
   25. VARIANTES DE CARTES MODE (hover spéciaux)
   ----------------------------------------------------------------------- */

/* Déjà définis en section 9, refs supplémentaires pour compatibilité */
.mode-card--live  { border-color: rgba( 34, 197,  94, 0.30); }
.mode-card--gaming { border-color: rgba(168,  85, 247, 0.30); }


/* -----------------------------------------------------------------------
   26. RESPONSIVE
   ----------------------------------------------------------------------- */

@media (max-width: 900px) {
  .pairing-matrix__row {
    grid-template-columns: 1fr;
  }

  .grid-2,
  .grid-3,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .saved-row {
    grid-template-columns: 1fr;
  }

  .matchup-row {
    grid-template-columns: 1fr;
  }

  .live-matchup-row {
    grid-template-columns: 1fr;
  }

  .live-split-zone {
    grid-template-columns: 1fr;
  }

  .suggestion-row {
    grid-template-columns: 1fr;
  }

  .total {
    text-align: left;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .pm-total-block {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 600px) {
  .panel {
    padding: 14px;
  }

  .mode-card {
    padding: 20px 18px;
  }

  .pm-help-section {
    padding: 20px;
  }
}


/* -----------------------------------------------------------------------
   27. CAPTAIN MODE — grille 8/4 colonnes + action grid + score ring
   ----------------------------------------------------------------------- */

.pm-captain-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.pm-action-grid {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pm-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.pm-action-btn .material-symbols-outlined {
  font-size: 22px;
  color: var(--muted);
  transition: color 0.2s;
}

.pm-action-btn:hover {
  border-color: var(--accent);
  background: var(--panel);
}

.pm-action-btn:hover .material-symbols-outlined {
  color: var(--text);
}

.pm-action-btn--primary {
  grid-column: 1 / -1;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  padding: 14px;
  font-size: 13px;
  flex-direction: row;
  gap: 10px;
}

.pm-action-btn--primary .material-symbols-outlined {
  color: #fff;
  font-size: 20px;
}

.pm-action-btn--primary:hover {
  background: var(--accent2);
  border-color: var(--accent2);
}

.pm-action-btn--danger {
  grid-column: 1 / -1;
  background: transparent;
  border-color: rgba(189, 15, 15, 0.3);
  color: rgba(189, 15, 15, 0.7);
  font-size: 11px;
  padding: 10px;
  flex-direction: row;
  gap: 8px;
}

.pm-action-btn--danger:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(189, 15, 15, 0.08);
}

.pm-action-btn--danger .material-symbols-outlined {
  color: inherit;
  font-size: 16px;
}

/* Score ring */
.pm-score-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  padding: 28px 24px;
  text-align: center;
}

.pm-score-panel__title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.pm-score-ring {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pm-score-ring__svg {
  position: absolute;
  top: 0;
  left: 0;
  transform: rotate(-90deg);
}

.pm-score-ring__track {
  fill: none;
  stroke: var(--panel2);
  stroke-width: 10;
}

.pm-score-ring__fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 376.99;
  stroke-dashoffset: 376.99;
  transition: stroke-dashoffset 0.4s ease, stroke 0.3s ease;
}

.pm-score-ring__value {
  font-size: 38px;
  font-weight: 900;
  font-style: italic;
  color: var(--text);
  line-height: 1;
}

.pm-score-ring__badge {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.pm-projection-badge {
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}

.pm-projection-badge--win {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
}

.pm-projection-badge--loss {
  background: rgba(189, 15, 15, 0.12);
  border: 1px solid rgba(189, 15, 15, 0.3);
  color: var(--accent);
}

.pm-projection-badge--pending {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.pm-score-minmax {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.pm-score-minmax__label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted2);
  display: block;
  margin-bottom: 4px;
}

.pm-score-minmax__value {
  font-size: 20px;
  font-weight: 700;
}

.pm-score-minmax__value--min { color: #ef4444; }
.pm-score-minmax__value--max { color: #22c55e; }

/* Matrix legend */
.pm-matrix-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.pm-matrix-legend__item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted2);
}

.pm-matrix-legend__item::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.pm-matrix-legend__item--low::before  { background: #ef4444; }
.pm-matrix-legend__item--mid::before  { background: #f59e0b; }
.pm-matrix-legend__item--good::before { background: #22c55e; }


/* -----------------------------------------------------------------------
   28. PLAYER MODE — contexte joueur, info box, progress, sticky save
   ----------------------------------------------------------------------- */

.pm-player-context {
  padding: 24px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(189, 15, 15, 0.14), transparent);
  border: 1px solid rgba(189, 15, 15, 0.3);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 640px) {
  .pm-player-context {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.pm-player-context__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}

.pm-player-context__title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.pm-player-context__title strong {
  color: var(--accent);
}

.pm-player-context__status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(18, 8, 8, 0.5);
  border: 1px solid rgba(189, 15, 15, 0.2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.pm-player-context__status .material-symbols-outlined {
  font-size: 16px;
  color: #22c55e;
}

html:not(.dark) .pm-player-context {
  background: linear-gradient(135deg, rgba(189, 15, 15, 0.08), rgba(248, 246, 246, 0));
}

html:not(.dark) .pm-player-context__status {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(189, 15, 15, 0.15);
}

.pm-info-box {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.07);
  border: 1px solid rgba(59, 130, 246, 0.28);
  color: #93c5fd;
  font-size: 13px;
}

.pm-info-box .material-symbols-outlined {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

html:not(.dark) .pm-info-box {
  background: rgba(59, 130, 246, 0.05);
  color: #1d4ed8;
}

/* Progress bar */
.pm-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.pm-progress__labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.pm-progress__bar {
  height: 5px;
  border-radius: 999px;
  background: var(--panel2);
  overflow: hidden;
}

.pm-progress__fill {
  height: 100%;
  border-radius: 999px;
  background: #22c55e;
}

/* Round card improved header */
.round-card__hd {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.round-card__title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.round-card__scenario {
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
}

/* Sticky save for player mode */
.pm-sticky-save {
  position: sticky;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 40px;
  padding: 16px;
}

.pm-sticky-save .btn {
  min-width: 280px;
  padding: 16px 32px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 8px 24px rgba(189, 15, 15, 0.35);
  transition: all 0.2s;
}

.pm-sticky-save .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(189, 15, 15, 0.45);
}

.pm-sticky-save .muted {
  font-size: 11px;
  padding: 4px 14px;
  background: rgba(18, 8, 8, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
}

html:not(.dark) .pm-sticky-save .muted {
  background: rgba(255, 255, 255, 0.95);
}


/* -----------------------------------------------------------------------
   29. LIVE MODE — meta bar, KPI bar, matchup cards, live footer
   ----------------------------------------------------------------------- */

.pm-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.pm-meta-bar__items {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.pm-meta-bar__item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pm-meta-bar__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted2);
}

.pm-meta-bar__value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.pm-meta-bar__value--accent {
  color: var(--accent);
  font-weight: 700;
}

.pm-meta-bar__sep {
  width: 1px;
  height: 20px;
  background: var(--line);
}

.pm-meta-bar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* KPI bar */
.pm-kpi-bar {
  display: flex;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
  padding: 16px 22px;
  background: rgba(189, 15, 15, 0.05);
  border: 1px solid rgba(189, 15, 15, 0.12);
  border-radius: 12px;
}

.pm-kpi-item__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted2);
  display: block;
  margin-bottom: 4px;
}

.pm-kpi-item__value {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  display: inline;
}

.pm-kpi-item__value--primary { color: var(--accent); }
.pm-kpi-item__value--optimal { color: #f59e0b; }

.pm-kpi-item__sub {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  font-weight: 400;
}

/* Live mode footer */
.pm-live-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pm-live-footer__status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pm-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  animation: pm-pulse 2s infinite;
  flex-shrink: 0;
}


/* -----------------------------------------------------------------------
   30. GAMING MODE — dashboard header, legend cards
   ----------------------------------------------------------------------- */

.pm-gaming-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

@media (min-width: 640px) {
  .pm-gaming-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

.pm-gaming-header__live {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.pm-gaming-header__title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.pm-gaming-header__sub {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 0;
}

.pm-gaming-header__sub strong {
  color: var(--text);
  font-style: italic;
}

.pm-gaming-header__actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* Legend cards */
.pm-legend-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.pm-legend-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.pm-legend-card__icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pm-legend-card__icon--red    { background: rgba(189,  15,  15, 0.1); color: var(--accent); }
.pm-legend-card__icon--green  { background: rgba( 34, 197,  94, 0.1); color: #22c55e; }
.pm-legend-card__icon--yellow { background: rgba(234, 179,   8, 0.1); color: #eab308; }

.pm-legend-card__icon .material-symbols-outlined { font-size: 22px; }

.pm-legend-card__label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted2);
  display: block;
  margin-bottom: 4px;
}

.pm-legend-card__value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.pm-legend-card__value--green  { color: #22c55e; }
.pm-legend-card__value--yellow { color: #eab308; }


/* -----------------------------------------------------------------------
   31. RESPONSIVE — nouveaux composants
   ----------------------------------------------------------------------- */

@media (max-width: 900px) {
  .pm-captain-grid {
    grid-template-columns: 1fr;
  }

  .pm-action-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pm-meta-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .pm-kpi-bar {
    gap: 24px;
  }

  .pm-legend-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .pm-action-grid {
    grid-template-columns: 1fr;
  }

  .pm-action-btn--primary,
  .pm-action-btn--danger {
    grid-column: auto;
  }

  .pm-sticky-save .btn {
    min-width: auto;
    width: 100%;
  }

  .pm-legend-cards {
    grid-template-columns: 1fr;
  }
}

/* ── Close round button (danger style for gaming page) ─── */
.pairing-page .btn.btn-danger {
  background: rgba(207, 23, 23, 0.15);
  border: 1px solid rgba(207, 23, 23, 0.5);
  color: #e87a90;
}
.pairing-page .btn.btn-danger:hover {
  background: rgba(207, 23, 23, 0.3);
  box-shadow: none;
}
html:not(.dark) .pairing-page .btn.btn-danger {
  background: rgba(207, 23, 23, 0.08);
  border: 1px solid rgba(207, 23, 23, 0.4);
  color: #b91c1c;
}
html:not(.dark) .pairing-page .btn.btn-danger:hover {
  background: rgba(207, 23, 23, 0.18);
}

/* --- Hub: context bar --- */
.pm-hub-context {
  margin-bottom: 16px;
}
.pm-hub-context__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}
.pm-hub-context__item {
  display: inline-flex;
  align-items: center;
  color: var(--text);
}
.pm-hub-context__sep {
  color: var(--muted);
  font-size: 10px;
}

/* --- Hub: disabled mode cards --- */
.mode-card--disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

/* Badge "Lecture seule" variant */
.mode-card__badge {
  background: #f59e0b;
  color: #1a0f00;
}

/* -----------------------------------------------------------------------
   OPPONENT PLAYER NAME INPUT (popup liste)
   ----------------------------------------------------------------------- */
.opponent-player-name-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg2, var(--panel2));
  color: var(--text);
}

/* -----------------------------------------------------------------------
   PREFERRED TABLE SELECT (mode joueur)
   ----------------------------------------------------------------------- */
.preferred-table-select {
  width: 56px;
  padding: 2px 4px;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg2, var(--panel2));
  color: var(--text);
  text-align: center;
}

/* -----------------------------------------------------------------------
   PREFERRED TABLE BADGE (captain/live/gaming)
   ----------------------------------------------------------------------- */
.pref-table-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 2px;
  vertical-align: super;
  line-height: 1;
}

.pref-table-hint {
  font-size: 0.7rem;
  color: #60a5fa;
  margin-left: 6px;
  font-style: italic;
}

/* ============================
   DECISION TREE — Flowchart cards
   ============================ */

/* --- Layout container --- */
.dtree {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}

.dtree + .dtree {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.dtree-no-tree {
  color: var(--muted);
  font-style: italic;
  padding: 20px 0;
  text-align: center;
}

/* --- Badges --- */
.dtree-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dtree-badge--def {
  background: rgba(59, 130, 246, 0.18);
  color: #3b82f6;
}

.dtree-badge--att {
  background: rgba(234, 179, 8, 0.18);
  color: #eab308;
}

/* --- Score pill --- */
.dtree-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 6px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

/* --- Suggest button --- */
.dtree-suggest {
  background: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--accent);
  cursor: pointer;
  font-size: 10px;
  padding: 2px 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}

.dtree-suggest:hover {
  background: var(--accent);
  color: #fff;
}

.dtree-suggest--blue {
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
}

.dtree-suggest--blue:hover {
  background: #3b82f6;
  color: #fff;
}

.dtree-suggest--neutral {
  color: var(--muted);
  border-color: var(--line);
}

.dtree-suggest--neutral:hover {
  background: var(--panel2);
  color: var(--text);
}

/* --- Select dropdown --- */
.dtree-select {
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  min-width: 130px;
  max-width: 200px;
  cursor: pointer;
  flex: 1;
}

.dtree-select:focus {
  border-color: #3b82f6;
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* --- Readonly label --- */
.dtree-readonly {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  flex: 1;
}

.dtree-readonly--empty {
  color: var(--muted);
  font-style: italic;
  font-weight: 400;
}

/* ========================================
   FLOWCHART CARD SYSTEM
   ======================================== */

/* A flow-row is one DEF1 scenario: DEF1 card → connector → DEF2 variant cards */
.dtree-flow-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  margin-bottom: 16px;
  position: relative;
}

.dtree-flow-row:last-child {
  margin-bottom: 0;
}

/* Center the DEF1 card vertically relative to DEF2 cards */
.dtree-flow-row > .dtree-card--def1 {
  align-self: center;
}

.dtree-flow-row--hidden {
  display: none !important;
}

.dtree-flow-row--confirmed > .dtree-card--def1 {
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

/* --- DEF1 card (left side) --- */
.dtree-card--def1 {
  width: 400px;
  min-width: 400px;
  max-width: 400px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px var(--shadow);
  flex-shrink: 0;
  overflow: hidden;
}

.dtree-card-hd {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--muted);
}

.dtree-card-hd .dtree-collapse-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  transition: transform 0.2s;
  line-height: 1;
  margin-left: auto;
}

.dtree-card-hd .dtree-collapse-btn:hover {
  color: var(--text);
}

.dtree-flow-row--collapsed .dtree-card-hd .dtree-collapse-btn {
  transform: rotate(-90deg);
}

.dtree-card-bd {
  padding: 6px 10px;
}

.dtree-card-opp-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* DEF2 per-row selector inside DEF1 card */
.dtree-card-def2-row {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dtree-card-def2-row .dtree-select {
  min-width: 80px;
  font-size: 11px;
  padding: 3px 5px;
}

/* --- Connector line between DEF1 card and DEF2 variants --- */
.dtree-flow-connector {
  width: 32px;
  flex-shrink: 0;
  position: relative;
  align-self: stretch;
  min-height: 40px;
}

.dtree-flow-connector::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 0;
  border-top: 2px solid var(--line);
}

/* --- DEF2 variants column --- */
.dtree-flow-variants {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  padding-left: 0;
}

/* Vertical connector line for siblings */
.dtree-flow-variants::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px solid var(--line);
}

/* --- DEF2 variant card --- */
.dtree-card--def2 {
  width: 400px;
  min-width: 400px;
  max-width: 400px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 1px 4px var(--shadow);
  position: relative;
  overflow: hidden;
}

.dtree-card--def2::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  width: 16px;
  height: 0;
  border-top: 2px solid var(--line);
  pointer-events: none;
}

.dtree-card--def2.dtree-card--hidden {
  display: none;
}

.dtree-card--def2.dtree-card--confirmed {
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.dtree-card--def2 .dtree-card-hd {
  background: rgba(59, 130, 246, 0.06);
  border-bottom: 1px solid rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  justify-content: space-between;
}

.dtree-card-opp-inline {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

/* --- ATT row inside DEF2 card --- */
.dtree-att-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.dtree-att-row + .dtree-att-row {
  border-top: 1px solid var(--line);
}

.dtree-att-row .dtree-badge {
  flex-shrink: 0;
}

.dtree-att-row .dtree-select {
  flex: 1;
  min-width: 100px;
}

.dtree-att-row .dtree-pill {
  flex-shrink: 0;
}

.dtree-att-row .dtree-suggest {
  flex-shrink: 0;
}

/* --- DEF3 section (8-player only) --- */
.dtree-def3-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.dtree-def3-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.dtree-def3-header .dtree-badge {
  font-size: 11px;
}

.dtree-def3-player {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.dtree-def3-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dtree-card--def3 {
  min-width: 200px;
  max-width: 260px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px var(--shadow);
  overflow: hidden;
}

.dtree-card--def3.dtree-card--hidden {
  display: none;
}

.dtree-card--def3.dtree-card--confirmed {
  border-color: rgba(34, 197, 94, 0.5);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
}

.dtree-card--def3 .dtree-card-hd {
  background: rgba(139, 92, 246, 0.06);
  border-bottom: 1px solid rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

/* --- Collapsed state --- */
.dtree-flow-row--collapsed .dtree-flow-connector,
.dtree-flow-row--collapsed .dtree-flow-variants {
  display: none !important;
}

/* --- Suggest bar above flow rows --- */
.dtree-suggest-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 10px;
  color: var(--muted);
}

/* --- DEF1 player reminder banner --- */
.dtree-def1-reminder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--surface-alt, #f0f4ff);
  border: 1px solid var(--accent, #4f6bed);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.dtree-def1-reminder-name {
  color: var(--text);
}

/* --- Live mode compact adjustments --- */
.dtree--live .dtree-card--def1 {
  min-width: 140px;
  max-width: 180px;
}

.dtree--live .dtree-card--def2 {
  min-width: 200px;
  max-width: 280px;
}

.dtree--live .dtree-card-opp-name {
  font-size: 12px;
}

.dtree--live .dtree-card-opp-faction {
  font-size: 10px;
}

.dtree--live .dtree-att-row {
  padding: 4px 0;
  gap: 6px;
}

.dtree--live .dtree-readonly {
  font-size: 11px;
}

.dtree--live .dtree-pill {
  font-size: 11px;
  min-width: 24px;
  height: 22px;
}

.dtree--live .dtree-flow-row {
  margin-bottom: 16px;
}

/* --- Vertical layout for live mode --- */
.dtree--live .dtree-flow-variants {
  flex-direction: column;
}

/* Live tree: full height, no internal scroll */
.dtree--live {
  max-height: none;
  overflow-y: visible;
}

/* ATT row already used (player locked in a matchup) */
.dtree-att-row--used {
  opacity: 0.35;
  text-decoration: line-through;
  pointer-events: none;
}

/* --- ATT x.3 optional row + toggle buttons --- */
.dtree-att3-row {
  border-top: 1px dashed var(--border, #ddd);
  opacity: 0.85;
}
.dtree-add-att3 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border, #ccc);
  background: var(--bg, #fff);
  color: var(--text, #333);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  margin-left: auto;
  transition: background 0.15s, color 0.15s;
}
.dtree-add-att3:hover {
  background: var(--accent, #3b82f6);
  color: #fff;
  border-color: var(--accent, #3b82f6);
}
.dtree-remove-att3 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border, #ccc);
  background: var(--bg, #fff);
  color: var(--text, #666);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 4px;
  transition: background 0.15s, color 0.15s;
}
.dtree-remove-att3:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}

/* =====================================================================
   CLÔTURE DE MATRICE
   ===================================================================== */

/* Bouton Clôturer — couleur rouge dans la grille d'actions */
.pm-close-btn.pm-action-btn {
  border-color: #ef4444;
  color: #ef4444;
}
.pm-close-btn.pm-action-btn .material-symbols-outlined {
  color: #ef4444;
}
.pm-close-btn.pm-action-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: #ef4444;
}

/* Bouton Réouvrir — couleur atténuée dans la grille d'actions */
.pm-reopen-btn.pm-action-btn {
  border-color: var(--muted, #888);
  color: var(--muted, #888);
}
.pm-reopen-btn.pm-action-btn .material-symbols-outlined {
  color: var(--muted, #888);
}
.pm-reopen-btn.pm-action-btn:hover {
  border-color: var(--text, #f1f1f1);
  color: var(--text, #f1f1f1);
}
.pm-reopen-btn.pm-action-btn:hover .material-symbols-outlined {
  color: var(--text, #f1f1f1);
}

/* Bouton Voir les stats — couleur verte dans la grille d'actions */
.pm-stats-btn.pm-action-btn {
  border-color: #22c55e;
  color: #22c55e;
  text-decoration: none;
}
.pm-stats-btn.pm-action-btn .material-symbols-outlined {
  color: #22c55e;
}
.pm-stats-btn.pm-action-btn:hover {
  background: rgba(34, 197, 94, 0.12);
  border-color: #22c55e;
}

/* =====================================================================
   LIAISON DE MATRICES
   ===================================================================== */

/* Link button */
.pm-link-btn.pm-action-btn {
  border-color: #6366f1;
  color: #6366f1;
}
.pm-link-btn.pm-action-btn .material-symbols-outlined {
  color: #6366f1;
}
.pm-link-btn.pm-action-btn:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: #6366f1;
}

/* Link indicator badge */
.pm-link-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.08);
  color: #a5b4fc;
  font-size: 13px;
  grid-column: 1 / -1;
}
.pm-link-indicator.hidden {
  display: none;
}
.pm-link-indicator .material-symbols-outlined {
  color: #6366f1;
  font-size: 18px;
}
.pm-link-unlink-btn {
  background: none;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 6px;
  color: #ef4444;
  cursor: pointer;
  padding: 2px 6px;
  margin-left: auto;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.pm-link-unlink-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}
.pm-link-unlink-btn .material-symbols-outlined {
  font-size: 16px;
}

/* Link modal */
.pm-link-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.pm-link-modal-overlay.hidden {
  display: none;
}
.pm-link-modal {
  background: var(--bg, #1e1212);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: 12px;
  width: 90%;
  max-width: 440px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}
.pm-link-modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}
.pm-link-modal-hd h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 1rem;
  color: var(--text, #c9b8b8);
}
.pm-link-modal-hd h3 .material-symbols-outlined {
  color: #6366f1;
}
.pm-link-modal-close {
  background: none;
  border: none;
  color: var(--text, #c9b8b8);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.pm-link-modal-bd {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pm-link-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  color: var(--text, #c9b8b8);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: left;
}
.pm-link-modal-item:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: #6366f1;
}
.pm-link-modal-item .material-symbols-outlined {
  color: #6366f1;
  font-size: 20px;
}

/* Stats merged badge */
.pm-stats-merged-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 12px;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.1);
  color: #a5b4fc;
  font-size: 12px;
  font-weight: 500;
}
.pm-stats-merged-badge.hidden {
  display: none;
}
.pm-stats-merged-badge .material-symbols-outlined {
  font-size: 16px;
  color: #6366f1;
}

/* Light mode overrides */
:root:not(.dark) .pm-link-indicator {
  background: rgba(99, 102, 241, 0.06);
  color: #4338ca;
}
:root:not(.dark) .pm-link-modal {
  background: #fff;
  border-color: #e5e7eb;
}
:root:not(.dark) .pm-link-modal-item {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #374151;
}
:root:not(.dark) .pm-link-modal-item:hover {
  background: rgba(99, 102, 241, 0.08);
}
:root:not(.dark) .pm-stats-merged-badge {
  background: rgba(99, 102, 241, 0.06);
  color: #4338ca;
}

/* =====================================================================
   PAGE STATISTIQUES
   ===================================================================== */

/* Header de la page stats */
.pm-stats-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.pm-stats-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text, #f1f1f1);
  margin: 0 0 4px;
}

.pm-stats-subtitle {
  font-size: 13px;
  margin: 0;
}

/* Bouton export image */
.pm-stats-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Conteneur des graphiques */
.pm-stats-chart-wrap {
  max-width: 800px;
  margin: 0 auto 8px;
  position: relative;
}
.pm-stats-chart-wrap--tall canvas {
  min-height: 260px;
}

/* Conteneur des tableaux */
.pm-stats-table-wrap {
  overflow-x: auto;
}

/* Tableaux de stats */
.pm-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.pm-stats-table th {
  padding: 8px 12px;
  border-bottom: 2px solid var(--line, rgba(255,255,255,0.1));
  text-align: center;
  color: var(--muted, #888);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}
.pm-stats-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line, rgba(255,255,255,0.06));
  text-align: center;
  color: var(--text, #f1f1f1);
}
.pm-stats-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}
.pm-stats-positive { color: #22c55e; font-weight: 600; }
.pm-stats-negative { color: #ef4444; font-weight: 600; }

/* ── Estimé vs Réel ────────────────────────────────────────── */
.pm-estimreal-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 640px) {
  .pm-estimreal-layout { grid-template-columns: 1fr; }
}

/* Visuel gauche */
.pm-er-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
}
.pm-er-delta-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 32px;
  font-weight: 800;
  padding: 14px 28px;
  border-radius: 16px;
  border: 2px solid;
}
.pm-er-delta-badge .material-symbols-outlined { font-size: 32px; }
.pm-er-delta-label {
  font-size: 12px;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}
.pm-er-compare {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}
.pm-er-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pm-er-col-label {
  font-size: 11px;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pm-er-col-value {
  font-size: 36px;
  font-weight: 800;
  line-height: 1;
}
.pm-er-bar-wrap {
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
}
.pm-er-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.7s ease;
}
.pm-er-vs {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted, #888);
  flex-shrink: 0;
}
.pm-er-precision {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 4px;
}
.pm-er-prec-label {
  font-size: 11px;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pm-er-prec-value {
  font-size: 28px;
  font-weight: 800;
}

/* Tableau droit */
.pm-er-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.pm-er-table th {
  padding: 8px 10px;
  border-bottom: 2px solid rgba(255,255,255,0.1);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted, #888);
}
.pm-er-table th:first-child { text-align: left; }
.pm-er-table td { padding: 10px 10px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
.pm-er-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.pm-er-row--empty td { opacity: 0.45; }

.pm-er-td-ronde { text-align: left; }
.pm-er-round-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.07);
  border-radius: 6px;
  padding: 2px 8px;
  margin-right: 6px;
  color: var(--text, #f1f1f1);
}
.pm-er-team { font-size: 12px; color: var(--muted, #888); }
.pm-er-td-num { text-align: center; font-size: 15px; font-weight: 700; }
.pm-er-td-delta { text-align: center; }
.pm-er-delta-cell {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 14px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}
.pm-er-row-total td {
  border-top: 2px solid rgba(255,255,255,0.12);
  border-bottom: none;
  font-size: 15px;
  text-align: center;
  padding: 12px 10px;
  background: rgba(255,255,255,0.03);
}
.pm-er-row-total td:first-child { text-align: left; }

/* ── Export : fonds solides pour html2canvas ────────────────── */
/* html.dark */
.pm-exporting .pm-kpi-card,
.pm-exporting .panel,
.pm-exporting .pm-lb-row,
.pm-exporting .pm-radar-card {
  background-color: #1e1212 !important;
  border-color: rgba(255,255,255,0.1) !important;
}
/* html sans .dark (light mode) */
html:not(.dark) .pm-exporting .pm-kpi-card,
html:not(.dark) .pm-exporting .panel,
html:not(.dark) .pm-exporting .pm-lb-row,
html:not(.dark) .pm-exporting .pm-radar-card {
  background-color: #ffffff !important;
  border-color: rgba(0,0,0,0.08) !important;
}

/* ── KPI Cards ─────────────────────────────────────────────── */
.pm-stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.pm-kpi-card {
  background: var(--card, rgba(255,255,255,0.04));
  border: 1px solid var(--line, rgba(255,255,255,0.08));
  border-radius: 12px;
  padding: 16px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color 0.2s;
}
.pm-kpi-card:hover { border-color: rgba(255,255,255,0.15); }
.pm-kpi-icon {
  font-size: 28px;
  flex-shrink: 0;
  margin-top: 2px;
}
.pm-kpi-label {
  font-size: 11px;
  color: var(--muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.pm-kpi-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 3px;
}
.pm-kpi-sub {
  font-size: 11px;
  color: var(--muted, #888);
}

/* ── Podium ────────────────────────────────────────────────── */
.pm-stats-podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 32px;
  padding: 0 16px;
}
.pm-podium-slot {
  flex: 1;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.pm-podium-slot--empty { opacity: 0.3; }
.pm-podium-medal { font-size: 28px; margin-bottom: 6px; }
.pm-podium-name {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 2px;
}
.pm-podium-pts {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 1px;
  color: var(--text, #f1f1f1);
}
.pm-podium-avg {
  font-size: 11px;
  color: var(--muted, #888);
  margin-bottom: 8px;
}
.pm-podium-base {
  width: 100%;
  height: 12px;
  border-radius: 4px 4px 0 0;
}

/* ── Leaderboard ───────────────────────────────────────────── */
.pm-stats-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pm-lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 14px;
  transition: background 0.15s;
}
.pm-lb-row:hover { background: rgba(255,255,255,0.05); }
.pm-lb-rank {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted, #888);
  min-width: 24px;
  text-align: center;
  flex-shrink: 0;
}
.pm-lb-info { flex: 1; min-width: 0; }
.pm-lb-top {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 4px;
}
.pm-lb-name { font-size: 14px; font-weight: 700; }
.pm-lb-faction { font-size: 11px; color: var(--muted, #888); }
.pm-lb-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.pm-lb-round-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid;
  font-weight: 600;
}
.pm-lb-round-badge--empty {
  background: rgba(255,255,255,0.04);
  color: var(--muted, #888);
  border-color: rgba(255,255,255,0.1);
}
.pm-lb-bar-wrap {
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  height: 4px;
  overflow: hidden;
}
.pm-lb-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.pm-lb-right {
  text-align: right;
  flex-shrink: 0;
}
.pm-lb-total { font-size: 20px; font-weight: 800; }
.pm-lb-avg   { font-size: 11px; color: var(--muted, #888); }

/* ── Heatmap ───────────────────────────────────────────────── */
.pm-stats-heatmap-wrap { overflow-x: auto; }
.pm-heatmap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 500px;
}
.pm-heatmap-header,
.pm-heatmap-row {
  display: flex;
  gap: 4px;
  align-items: stretch;
}
.pm-heatmap-cell {
  flex: 1;
  min-width: 70px;
  padding: 10px 8px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  border: 1px solid transparent;
  transition: transform 0.15s;
}
.pm-heatmap-cell--label {
  min-width: 130px;
  flex: 0 0 130px;
}
.pm-heatmap-cell--round {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted, #888);
  text-transform: uppercase;
}
.pm-heatmap-cell--round small { display: block; font-weight: 400; opacity: 0.7; }
.pm-heatmap-cell--player {
  min-width: 130px;
  flex: 0 0 130px;
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
  text-align: left;
  padding-left: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  font-weight: 700;
  font-size: 13px;
}
.pm-heatmap-cell--player small {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted, #888);
  display: block;
}
.pm-heatmap-cell--score {
  font-size: 16px;
  font-weight: 800;
}
.pm-heatmap-cell--score:hover { transform: scale(1.05); }
.pm-heatmap-cell--empty {
  background: rgba(255,255,255,0.02);
  color: var(--muted, #888);
  font-size: 11px;
}
.pm-heatmap-cell--total {
  min-width: 64px;
  flex: 0 0 64px;
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted, #888);
  text-transform: uppercase;
}
.pm-heatmap-cell--total-val {
  min-width: 64px;
  flex: 0 0 64px;
  font-size: 17px;
  font-weight: 800;
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
}

/* ── Radar profils ─────────────────────────────────────────── */
.pm-stats-radar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.pm-radar-card {
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: border-color 0.2s;
}
.pm-radar-card:hover { border-color: rgba(255,255,255,0.15); }
.pm-radar-title {
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.pm-radar-sub {
  font-size: 11px;
  color: var(--muted, #888);
  text-align: center;
  margin-bottom: 4px;
}
.pm-radar-canvas { width: 100% !important; max-width: 200px; }
.pm-radar-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  font-size: 11px;
  color: var(--muted, #888);
  margin-top: 4px;
}
.pm-radar-stats b { color: var(--text, #f1f1f1); }

/* --- DEF3 nested inside DEF2 (3-level tree) --- */
.dtree-def2-flow-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
}
/* Center the DEF2 card vertically relative to its DEF3 sub-branches */
.dtree-def2-flow-row > .dtree-card--def2 {
  align-self: center;
}
.dtree-def2-flow-row--collapsed .dtree-flow-connector--def3,
.dtree-def2-flow-row--collapsed .dtree-flow-variants--def3 {
  display: none !important;
}
.dtree-flow-connector--def3 {
  width: 24px;
  min-width: 24px;
  position: relative;
  align-self: stretch;
}
.dtree-flow-connector--def3::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 2px solid var(--line, #ccc);
}
.dtree-flow-variants--def3 {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  padding-left: 4px;
}
.dtree-flow-variants--def3::before {
  content: '';
  position: absolute;
  top: 20px;
  bottom: 20px;
  left: 0;
  border-left: 2px solid var(--line, #ccc);
}
.dtree-card--def3-nested {
  border: 1px solid var(--border, #ddd);
  border-radius: 8px;
  background: var(--bg, #fff);
  max-width: 320px;
  min-width: 180px;
  position: relative;
}
.dtree-card--def3-nested::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -4px;
  width: 4px;
  border-top: 2px solid var(--line, #ccc);
}
.dtree-card--def3-nested .dtree-card-hd {
  background: rgba(139, 92, 246, 0.06);
  border-bottom: 1px solid var(--border, #ddd);
  padding: 4px 8px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dtree-card--def3-nested .dtree-card-bd {
  padding: 6px 8px;
}
.dtree-def3-player-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line, #eee);
}
.dtree-def3-collapse-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted, #888);
  padding: 2px 4px;
  border-radius: 4px;
}
.dtree-def3-collapse-btn:hover {
  background: var(--hover-bg, rgba(0,0,0,0.05));
}
.dtree-suggest--purple {
  background: rgba(139, 92, 246, 0.1);
  color: #7c3aed;
  border-color: rgba(139, 92, 246, 0.3);
}
.dtree-suggest--purple:hover {
  background: #7c3aed;
  color: #fff;
}
.dtree-badge--def3 {
  background: rgba(139, 92, 246, 0.15);
  color: #7c3aed;
}

/* Live mode: DEF3 nested adjustments */
.dtree--live .dtree-def2-flow-row--collapsed .dtree-flow-connector--def3,
.dtree--live .dtree-def2-flow-row--collapsed .dtree-flow-variants--def3 {
  display: none !important;
}
.dtree--live .dtree-card--def3-nested {
  max-width: 280px;
}
