/* =============================================================================
   Défis 1 contre 1 — identité graphique commune à tous les jeux à défis.
   Règles : apascomptes/DEFIS.md. Composants : portal/defis.js.
   Les images sont déclarées dans SGD_IMAGES (defis.js).
   ============================================================================= */

.sgd {
  --sgd-fond: #170a10;
  --sgd-fond-2: #241019;
  --sgd-carte: #2c1520;
  --sgd-bord: #4d2233;
  --sgd-rouge: #e8323f;
  --sgd-rouge-sombre: #8f1a26;
  --sgd-or: #f3c14b;
  --sgd-acier: #a9b4c0;
  --sgd-texte: #f6eee9;
  --sgd-discret: #c9a9b0;
  --sgd-pale: #8a6872;
  color: var(--sgd-texte);
  font-family: Nunito, sans-serif;
}
.sgd-ecran { background: radial-gradient(ellipse at top, #3a0f1c, var(--sgd-fond) 62%); }

/* ── Tuile de Rejoindre : gyrophare (défi reçu) ── */
.sgd-gyro {
  position: absolute; right: -5px; top: -5px; width: 20px; height: 24px;
  pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
}
.sgd-gyro .sgd-gyro-feu { animation: sgd-gyro 0.9s steps(1, end) infinite; transform-origin: 10px 12px; }
.sgd-gyro .sgd-gyro-halo { animation: sgd-halo 0.9s ease-out infinite; transform-origin: 10px 11px; }
@keyframes sgd-gyro { 0% { fill: #ff2a3a; } 50% { fill: #8f0d18; } }
@keyframes sgd-halo { 0% { opacity: .85; transform: scale(.6); } 50% { opacity: 0; transform: scale(1.5); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sgd-gyro .sgd-gyro-feu { animation: none; }
  .sgd-gyro .sgd-gyro-halo { animation: none; opacity: .5; }
}

/* ── Bandeau de Rejoindre ── */
.sgd-bandeau {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: linear-gradient(90deg, #5a0f1c, #2c1520); border: 1px solid #e8323f;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.sgd-bandeau b { font-size: 13px; font-weight: 900; color: #fff; display: block; line-height: 1.25; }
.sgd-bandeau span { font-size: 11px; color: #f0c7cd; display: block; line-height: 1.3; }
.sgd-bandeau i { font-style: normal; color: #f3c14b; font-size: 22px; margin-left: auto; }

/* ── Fenêtres ── */
.sgd-voile {
  position: fixed; inset: 0; z-index: 2000; background: rgba(8, 2, 5, .82);
  display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box;
}
.sgd-voile.sgd-dans-jeu { position: absolute; }
.sgd-fenetre {
  width: 100%; max-width: 340px; max-height: 100%; overflow: hidden; box-sizing: border-box;
  background: linear-gradient(180deg, var(--sgd-fond-2), var(--sgd-fond)); border: 1px solid var(--sgd-rouge);
  border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 14px 50px #000c, 0 0 0 1px #000 inset;
}
.sgd-fenetre h2 { margin: 0; font-size: 20px; font-weight: 900; color: var(--sgd-or); letter-spacing: .02em; text-align: center; }
.sgd-fenetre p { margin: 0; font-size: 13px; line-height: 1.45; color: var(--sgd-texte); }
.sgd-fenetre ul { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.4; color: var(--sgd-texte); }
.sgd-fenetre li { margin: 1px 0; }
.sgd-image { width: 100%; height: 120px; object-fit: cover; border-radius: 12px; display: block; background: #2c1520; }

/* ── Boutons ── */
/* Sélecteurs doublés (.sgd .sgd-btn) : ils doivent l'emporter sur les feuilles
   des jeux, qui stylent souvent `button` (ex. `button:not(.cell)`). */
.sgd-btn, .sgd .sgd-btn {
  all: unset; min-height: 0; box-shadow: none; transform: none; box-sizing: border-box; display: block; width: 100%; text-align: center; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  padding: 11px 8px; border-radius: 10px; font: 900 14px Nunito, sans-serif;
  background: var(--sgd-carte); color: var(--sgd-texte); border: 1px solid var(--sgd-bord);
}
.sgd-btn.sgd-primaire, .sgd .sgd-btn.sgd-primaire { background: var(--sgd-rouge); border-color: var(--sgd-rouge); color: #fff; }
.sgd-btn.sgd-or, .sgd .sgd-btn.sgd-or { background: var(--sgd-or); border-color: var(--sgd-or); color: #2a1206; }
.sgd-btn.sgd-petit, .sgd .sgd-btn.sgd-petit { padding: 7px 10px; font-size: 12px; width: auto; }
.sgd-btn[disabled], .sgd .sgd-btn[disabled] { opacity: .4; pointer-events: none; }

/* ── Page Défis ── */
.sgd-page { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 100%; box-sizing: border-box; }
.sgd-titre { display: flex; align-items: center; gap: 10px; }
.sgd-titre img { width: 46px; height: 46px; flex: none; }
.sgd-titre b { display: block; font-size: 22px; font-weight: 900; letter-spacing: .14em; color: var(--sgd-rouge); line-height: 1; }
.sgd-titre span { display: block; font-size: 12px; color: var(--sgd-discret); margin-top: 3px; }
.sgd-carte { background: var(--sgd-carte); border: 1px solid var(--sgd-bord); border-radius: 12px; padding: 10px 12px; box-sizing: border-box; }
.sgd-moi { display: flex; align-items: center; gap: 10px; }
.sgd-note { margin-left: auto; text-align: right; }
.sgd-note b { display: block; font-size: 24px; font-weight: 900; color: var(--sgd-or); line-height: 1; font-variant-numeric: tabular-nums; }
.sgd-note span { display: block; font-size: 10px; color: var(--sgd-discret); margin-top: 2px; letter-spacing: .06em; }
.sgd-avatar { border-radius: 50%; flex: none; background: #3a1d28; display: block; }
.sgd-section { font-size: 10.5px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--sgd-rouge); margin-top: 4px; }
.sgd-ligne { display: flex; align-items: center; gap: 10px; }
.sgd-ligne .sgd-qui { flex: 1; min-width: 0; }
.sgd-ligne .sgd-qui b { display: block; font-size: 14px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgd-ligne .sgd-qui span { display: block; font-size: 11px; color: var(--sgd-discret); line-height: 1.3; }
.sgd-actions { display: flex; gap: 6px; margin-top: 8px; }
.sgd-actions .sgd-btn { flex: 1; }
.sgd-note-info { font-size: 12px; line-height: 1.45; color: var(--sgd-discret); }
.sgd-vide { font-size: 12px; color: var(--sgd-pale); text-align: center; padding: 6px 0; }
.sgd-issue-victoire { color: var(--sgd-or); }
.sgd-issue-defaite { color: #ff7d88; }
.sgd-issue-nul { color: var(--sgd-acier); }
.sgd-delta { font-weight: 900; font-variant-numeric: tabular-nums; }
.sgd-rang { width: 22px; text-align: center; font-weight: 900; color: var(--sgd-discret); flex: none; font-variant-numeric: tabular-nums; }
.sgd-moi-ligne { border-color: var(--sgd-or); }
.sgd-refus { font-size: 10.5px; color: var(--sgd-pale); }

/* ── Entête adversaire pendant la partie ── */
.sgd-adversaire {
  width: 100%; display: flex; align-items: center; gap: 10px; box-sizing: border-box; padding: 6px 10px;
  border-radius: 12px; background: linear-gradient(90deg, #3a0f1c, #241019); border: 1px solid var(--sgd-rouge);
}
.sgd-adversaire .sgd-qui { flex: 1; min-width: 0; }
.sgd-adversaire .sgd-qui span { display: block; font-size: 10px; letter-spacing: .12em; color: #f0a5ae; font-weight: 900; }
.sgd-adversaire .sgd-qui b { display: block; font-size: 15px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.sgd-adversaire .sgd-chrono { font: 900 20px Nunito, sans-serif; color: var(--sgd-or); font-variant-numeric: tabular-nums; }

/* ── Animation de résultat ── */
.sgd-resultat {
  position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; padding: 16px; box-sizing: border-box; overflow: hidden;
  background: radial-gradient(ellipse at center, #3a0f1c, #0d0408 70%);
}
.sgd-duel { display: flex; width: 100%; align-items: stretch; gap: 8px; }
.sgd-duelliste {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px;
  border-radius: 14px; background: #241019; border: 2px solid #4d2233; transition: border-color .3s, box-shadow .3s, transform .3s;
}
.sgd-duelliste b { font-size: 14px; font-weight: 900; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgd-duelliste .sgd-chrono { font: 900 22px Nunito, sans-serif; font-variant-numeric: tabular-nums; color: #fff; }
.sgd-duelliste.sgd-arrive { border-color: var(--sgd-acier); }
.sgd-duelliste.sgd-gagne { border-color: var(--sgd-or); box-shadow: 0 0 24px #f3c14b88; transform: scale(1.04); }
.sgd-duelliste.sgd-gagne .sgd-chrono { color: var(--sgd-or); }
.sgd-versus { align-self: center; font: 900 18px Nunito, sans-serif; color: var(--sgd-rouge); }
.sgd-verdict { display: flex; flex-direction: column; align-items: center; gap: 6px; opacity: 0; }
.sgd-verdict img { width: 200px; height: 110px; object-fit: contain; }
.sgd-verdict h2 { margin: 0; font: 900 34px Nunito, sans-serif; letter-spacing: .08em; }
.sgd-verdict p { margin: 0; font-size: 13px; color: var(--sgd-discret); text-align: center; line-height: 1.4; }
.sgd-elo { display: flex; align-items: baseline; gap: 8px; opacity: 0; }
.sgd-elo b { font: 900 30px Nunito, sans-serif; color: var(--sgd-texte); font-variant-numeric: tabular-nums; }
.sgd-elo span { font: 900 16px Nunito, sans-serif; font-variant-numeric: tabular-nums; }
.sgd-boutons-fin { width: 100%; display: flex; flex-direction: column; gap: 8px; opacity: 0; }

/* ── Bouton « Défis » d'un accueil de jeu (sgdBoutonDefis) ── */
.sgd-accueil {
  position: relative; overflow: visible !important;
  background: #8f1a26 !important; color: #fff !important; border: 1px solid #e8323f !important;
  font-family: Nunito, sans-serif; font-weight: 900; cursor: pointer; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.sgd-accueil .sgd-bulle {
  display: none; position: absolute; right: -6px; top: -7px; min-width: 20px; height: 20px; padding: 0 6px;
  box-sizing: border-box; border-radius: 10px; background: #f3c14b; color: #2a1206; font: 900 12px/20px Nunito, sans-serif;
  font-style: normal; box-shadow: 0 1px 3px #000a; text-align: center;
}
/* Page Défis dans un jeu : fond de l'identité des défis sur toute la zone. */
.sgd-page { background: radial-gradient(ellipse at top, #3a0f1c, #170a10 62%); }
/* Entête adversaire compacte, pour les jeux dont le plateau occupe tout l'écran. */
.sgd-adversaire.sgd-compact { padding: 2px 8px; gap: 8px; border-radius: 10px; }
.sgd-adversaire.sgd-compact .sgd-avatar { width: 28px !important; height: 28px !important; }
.sgd-adversaire.sgd-compact .sgd-qui span { font-size: 9px; }
.sgd-adversaire.sgd-compact .sgd-qui b { font-size: 13px; line-height: 1.1; }
.sgd-adversaire.sgd-compact .sgd-chrono { font-size: 17px; }

/* ── Courbe de la note Elo (sgdCourbeElo) ── */
.sgd-courbe { position: relative; padding: 6px 0 2px; }
.sgd-courbe svg { display: block; width: 100%; height: 92px; }
.sgd-courbe.vide { padding: 10px 4px; color: #9d7d86; font-size: 10.5px; text-align: center; }
.sgd-courbe-legende { display: flex; gap: 10px; margin-top: 3px; color: #8a6872; font-size: 9px; font-weight: 800; }
.sgd-courbe-legende b { margin-left: auto; color: #f3c14b; font-size: 11px; }
.sgd-page > .sgd-courbe { background: var(--sgd-carte); border: 1px solid var(--sgd-bord); border-radius: 12px; padding: 8px 10px; }
.sgd .sgd-btn.sgd-courbe-btn { flex: none; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; margin-left: 8px; }
.sgd .sgd-btn.sgd-courbe-btn.active { border-color: var(--sgd-or); background: #3a1d28; }

/* En tête de l'animation de résultat : le jeu et qui a lancé le défi. */
.sgd-resultat-contexte { display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.sgd-resultat-contexte b { font: 900 22px Nunito, sans-serif; letter-spacing: .04em; color: var(--sgd-or); }
.sgd-resultat-contexte span { font-size: 12.5px; font-weight: 700; color: var(--sgd-discret); }
