/* NeoGenesis : BACKGAMMON (module « backgammon », version de cache ?v=bgm1). Préfixe .bgm-.
   L'habillage suit les jetons du site (4 thèmes : sombre, clair, cyberpunk, forêt). Le PLATEAU, lui, garde une palette
   fixe de bois : ses couleurs sont mesurées pour que les dames claires ET foncées y tiennent au moins 3:1 quel que soit
   le thème (dame claire #f4efe4, dame foncée #241b15 avec un ANNEAU clair, qui les distingue aussi sans la couleur).
   Le cadre (#9c8460, ton moyen) se détache à plus de 3:1 des fonds sombres comme du fond clair.
   Trois dispositions, selon la largeur du CADRE (requête de conteneur ; le rail du site peut réduire la colonne de la
   page bien au-dessus de 600 px d'écran) ; la page lit --bgm-disposition (h, q, v) pour ses flèches du clavier :
   - h, horizontal (cadre >= 689 px : 12 x 44 + 48 + 52 + 13 écarts de 3 + 8 x 2 + 3 x 2) ;
   - q, quatre quarts (301 à 688 px) : chaque moitié du plateau se replie en deux rangées de 6 flèches, comme une ligne
     de texte trop longue ; la barre et les sorties forment la rangée du milieu ; environ 780 px de haut ;
   - v, une colonne (sous 301 px) : une flèche par rangée d'au moins 44 px.
   La place de chaque case vient de variables posées par la page (--bgm-hc/--bgm-hr, --bgm-qc/--bgm-qr).
   Aucun mouvement : rien n'est animé. */

/* ---------- onglets et panneaux ---------- */
.bgm-onglets{margin-top:.2rem}
@media(max-width:560px){.bgm-onglets{flex-wrap:wrap}.bgm-onglets .ng-tab{flex:1 1 40%;min-width:0}}
.bgm-panneau{padding:.3rem 0 0}
.bgm-panneau:focus{outline:none}

/* ---------- réglages et boutons ---------- */
.bgm-reglages{display:flex;flex-wrap:wrap;gap:.6rem .8rem;align-items:flex-end;margin:.2rem 0 .5rem}
.bgm-champ{display:flex;flex-direction:column;gap:.25rem;flex:1 1 150px;min-width:140px;max-width:240px;margin:0}
.bgm-champ-t{font-size:.8rem;font-weight:600;color:var(--muted)}
.bgm-champ select{min-height:44px;font:inherit;font-size:16px;padding:.4rem .6rem;border-radius:10px;border:1px solid var(--line);background:var(--bg-2);color:var(--text)}
.bgm-btn{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;min-height:44px;min-width:44px;padding:.5rem .95rem;border-radius:12px;border:1px solid var(--line);background:var(--panel-2);color:var(--text);font:inherit;font-size:.95rem;font-weight:700;line-height:1.2;cursor:pointer;text-align:center}
.bgm-btn:hover{border-color:var(--cyan)}
.bgm-btn-plein{background:rgba(var(--cyan-rgb),.16);border-color:rgba(var(--cyan-rgb),.55)}
.bgm-btn[aria-disabled="true"]{color:var(--muted);border-style:dashed;background:transparent;cursor:not-allowed}
.bgm-aide-niveau{margin:0 0 .4rem;color:var(--muted);font-size:.9rem;line-height:1.5;max-width:62rem}
.bgm-charge{padding:1.5rem 0;color:var(--muted)}
.bgm-message,.bgm-indispo{margin:.6rem 0;padding:.6rem .85rem;border:1px solid var(--line);border-radius:12px;background:var(--panel);color:var(--text);line-height:1.5}
.bgm-lien-cible{display:inline-flex;align-items:center;min-height:44px;color:var(--cyan);font-weight:700}
:root[data-theme="light"] .bgm-lien-cible{color:#0b5d75}

/* ---------- état de la partie : statut, dés, compte ---------- */
.bgm-etat{display:flex;flex-wrap:wrap;gap:.5rem 1rem;align-items:center;margin:.5rem 0 .4rem}
.bgm-statut{flex:1 1 260px;margin:0;font-weight:700;line-height:1.45;color:var(--text)}
.bgm-des{display:flex;gap:.5rem;align-items:flex-start;min-height:44px}
.bgm-de{display:flex;flex-direction:column;align-items:center;gap:.1rem}
.bgm-de svg{width:38px;height:38px;display:block}
.bgm-de-n{font-size:.85rem;font-weight:800;color:var(--text);line-height:1.1}
.bgm-de.bgm-joue svg{opacity:.45}
.bgm-de.bgm-joue .bgm-de-n{color:var(--muted);text-decoration:line-through}
.bgm-compte,.bgm-videau{margin:0;color:var(--muted);font-size:.92rem;line-height:1.4}
.bgm-raison{margin:.35rem 0 0;color:var(--text);font-size:.93rem;line-height:1.5}
.bgm-raison:empty{display:none}
.bgm-fin{margin:.6rem 0;padding:.65rem .95rem;border-radius:12px;border:1px solid var(--line);border-left:4px solid var(--cyan);background:var(--panel-2);color:var(--text);font-weight:800;font-size:1.02rem;line-height:1.45}
.bgm-fin.bgm-fane{border-left-color:var(--line);color:var(--muted)}

/* ---------- actions ---------- */
.bgm-actions{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;margin:.5rem 0}
.bgm-actions-partie{margin-top:.8rem}

/* ---------- le plateau ---------- */
.bgm-cadre{container-type:inline-size;margin:.35rem 0}
.bgm-plateau{
  display:grid;gap:3px;padding:8px;border-radius:14px;border:3px solid #9c8460;background:#5a4a38;
  grid-template-columns:repeat(6,minmax(44px,1fr)) minmax(48px,.8fr) repeat(6,minmax(44px,1fr)) minmax(52px,.9fr);
  grid-template-rows:minmax(196px,auto) minmax(196px,auto);
  --bgm-vertical:0;--bgm-disposition:h;
}
.bgm-pt{
  position:relative;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:2px;
  min-width:44px;min-height:44px;margin:0;padding:24px 2px 6px;border:0;border-radius:6px;background:#7d6b52;
  color:#f4efe4;font:inherit;cursor:pointer;overflow:hidden;-webkit-tap-highlight-color:transparent;
  grid-column:var(--bgm-hc);grid-row:var(--bgm-hr)
}
.bgm-pt.bgm-bas{flex-direction:column-reverse;padding:6px 2px 24px}
.bgm-fleche{position:absolute;left:5%;right:5%;top:0;height:84%;clip-path:polygon(0 0,100% 0,50% 100%);background:var(--bgm-t,#96603f);pointer-events:none}
.bgm-bas .bgm-fleche{top:auto;bottom:0;clip-path:polygon(0 100%,100% 100%,50% 0)}
.bgm-ton-a{--bgm-t:#96603f}
.bgm-ton-b{--bgm-t:#9c8460}
.bgm-num{position:absolute;top:3px;left:50%;transform:translateX(-50%);z-index:2;background:#2b2118;color:#f4efe4;border-radius:4px;padding:0 4px;font-size:.72rem;font-weight:800;line-height:1.35;pointer-events:none}
.bgm-bas .bgm-num{top:auto;bottom:3px}
.bgm-pile{position:relative;z-index:1;display:flex;flex-direction:inherit;align-items:center;gap:2px}
.bgm-dame{position:relative;display:flex;align-items:center;justify-content:center;width:min(34px,calc(100cqw / 15));min-width:28px;aspect-ratio:1;border-radius:50%;box-sizing:border-box;font-size:.8rem;font-weight:900;line-height:1}
.bgm-claire{background:#f4efe4;border:2px solid #2b2118;color:#1a130e}
.bgm-foncee{background:#241b15;border:2px solid #120d0a;color:#f4efe4;box-shadow:inset 0 0 0 3px #241b15,inset 0 0 0 5px #d9cbb3}
.bgm-barre,.bgm-sorties{background:#6f5d47}
.bgm-barre{justify-content:space-between;padding:24px 2px 24px}
.bgm-sorties{justify-content:space-between;padding:6px 2px}
.bgm-moitie{display:flex;flex-direction:column;align-items:center;gap:2px;position:relative;z-index:1}
.bgm-moitie-bas{flex-direction:column-reverse}
.bgm-etiq{font-size:.72rem;font-weight:800;color:#f4efe4;background:#2b2118;border-radius:4px;padding:0 4px;line-height:1.35}
.bgm-sortis-n{display:flex;align-items:center;gap:3px;font-size:.8rem;font-weight:900;color:#f4efe4}
.bgm-sortis-n .bgm-dame{width:22px;min-width:22px;font-size:0}
.bgm-marque{position:absolute;z-index:3;right:2px;bottom:2px;min-width:20px;padding:0 4px;border-radius:999px;background:#ffd36b;color:#1a130e;font-size:.72rem;font-weight:900;line-height:1.4;text-align:center;pointer-events:none}
.bgm-bas .bgm-marque{bottom:auto;top:2px}
.bgm-pt.bgm-choisi{outline:3px solid #ffd36b;outline-offset:-3px}
.bgm-pt.bgm-arrivee{outline:3px dashed #ffffff;outline-offset:-3px}
.bgm-plateau .bgm-pt:focus-visible{outline:3px solid #ffffff!important;outline-offset:-3px!important;box-shadow:inset 0 0 0 6px #000;border-radius:6px}
.bgm-plateau .bgm-pt.bgm-choisi:focus-visible{outline-color:#ffd36b!important}
.bgm-pt[aria-disabled="true"]{cursor:default}
.bgm-pt:hover:not([aria-disabled="true"]){filter:brightness(1.08)}

/* Le plateau en quatre quarts : 13 à 18, puis 19 à 24 (le côté de l'adversaire), la barre et les sorties, puis 12 à 7 et
   6 à 1 (ton jan, en bas à droite). Les dames d'une pile se recouvrent un peu pour garder des rangées basses. */
@container (max-width: 688.9px){
  .bgm-plateau{grid-template-columns:repeat(6,minmax(44px,1fr));grid-template-rows:minmax(150px,auto) minmax(150px,auto) minmax(84px,auto) minmax(150px,auto) minmax(150px,auto);--bgm-disposition:q}
  .bgm-plateau .bgm-pt{grid-column:var(--bgm-qc);grid-row:var(--bgm-qr)}
  .bgm-plateau .bgm-dame{width:30px;min-width:30px}
  .bgm-plateau .bgm-pile{gap:0}
  .bgm-plateau .bgm-pile .bgm-dame + .bgm-dame{margin-top:-4px}
  .bgm-plateau .bgm-bas .bgm-pile .bgm-dame + .bgm-dame{margin-top:0;margin-bottom:-4px}
  .bgm-plateau .bgm-barre{justify-content:center;gap:4px;padding:5px 4px}
  .bgm-plateau .bgm-barre .bgm-pile{flex-direction:row}
  .bgm-plateau .bgm-barre .bgm-pile .bgm-dame + .bgm-dame{margin:0 0 0 -10px}
  .bgm-plateau .bgm-sorties{justify-content:center;gap:4px;padding:5px 4px}
  .bgm-plateau .bgm-sortis-n .bgm-dame{width:22px;min-width:22px}
}

/* Le plateau à la verticale : une flèche par rangée, de la barre (en haut) à la sortie (en bas). */
@container (max-width: 300.9px){
  .bgm-plateau{grid-template-columns:minmax(0,1fr);grid-template-rows:none;gap:2px;padding:6px;--bgm-vertical:1;--bgm-disposition:v}
  .bgm-plateau .bgm-pt{grid-column:auto;grid-row:auto;flex-direction:row;justify-content:flex-start;align-items:center;min-height:46px;padding:3px 34px 3px 44px}
  .bgm-plateau .bgm-pt.bgm-bas{flex-direction:row;padding:3px 34px 3px 44px}
  .bgm-plateau .bgm-fleche{top:4px!important;bottom:4px!important;left:40px;right:auto;width:62%;height:auto;clip-path:polygon(0 0,100% 50%,0 100%)!important}
  .bgm-plateau .bgm-num,.bgm-plateau .bgm-bas .bgm-num{top:50%;bottom:auto;left:6px;transform:translateY(-50%)}
  .bgm-plateau .bgm-pile{flex-direction:row;gap:2px}
  .bgm-plateau .bgm-dame{width:32px;min-width:32px}
  .bgm-plateau .bgm-pile .bgm-dame + .bgm-dame,.bgm-plateau .bgm-bas .bgm-pile .bgm-dame + .bgm-dame,.bgm-plateau .bgm-barre .bgm-pile .bgm-dame + .bgm-dame{margin:0}
  .bgm-plateau .bgm-marque,.bgm-plateau .bgm-bas .bgm-marque{top:50%;bottom:auto;right:4px;transform:translateY(-50%)}
  .bgm-plateau .bgm-barre,.bgm-plateau .bgm-sorties{flex-direction:row;justify-content:flex-start;gap:.6rem;padding:3px 34px 3px 8px}
  .bgm-plateau .bgm-moitie,.bgm-plateau .bgm-moitie-bas{flex-direction:row}
}

/* ---------- journal des coups ---------- */
.bgm-journal{margin:.7rem 0;border:1px solid var(--line);border-radius:12px;background:var(--panel);padding:0 .85rem}
.bgm-journal summary{display:flex;align-items:center;min-height:44px;font-weight:700;cursor:pointer;color:var(--text)}
.bgm-journal ol{max-height:15rem;overflow:auto;margin:0 0 .6rem;padding-left:1.8rem;font-size:.9rem;line-height:1.6;color:var(--text)}
.bgm-journal li{overflow-wrap:anywhere}
.bgm-journal .bgm-vide{list-style:none;margin-left:-1.8rem;color:var(--muted)}

/* ---------- partie entre membres ---------- */
.bgm-partie-titre{font-size:1.1rem;font-weight:800;margin:.3rem 0 .2rem;overflow-wrap:anywhere}
.bgm-retour{margin:.4rem 0}

/* ---------- textes : règles, stratégie, histoire ---------- */
.bgm-texte h2{font-size:1.3rem;font-weight:800;margin:.6rem 0 .5rem;line-height:1.3}
.bgm-texte h3{font-size:1.04rem;font-weight:800;margin:1.15rem 0 .35rem;line-height:1.3}
.bgm-texte p,.bgm-texte li,.bgm-texte dd{color:var(--text);font-size:.95rem;line-height:1.65;max-width:72ch}
.bgm-texte p{margin:0 0 .6rem}
.bgm-texte ul{margin:0 0 .6rem;padding-left:1.3rem}
.bgm-texte li{margin:0 0 .3rem}
.bgm-texte a{color:var(--cyan);font-weight:600}
:root[data-theme="light"] .bgm-texte a{color:#0b5d75}
.bgm-mots{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:.3rem .9rem;margin:0 0 .6rem}
.bgm-mots dt{font-weight:800;color:var(--text)}
.bgm-mots dd{margin:0}
@media(max-width:480px){.bgm-mots{grid-template-columns:minmax(0,1fr)}.bgm-mots dd{margin:0 0 .4rem}}
.bgm-encadre{border:1px solid var(--line);border-left:4px solid var(--cyan);border-radius:12px;background:var(--panel);padding:.6rem .85rem}
.bgm-note,.bgm-source{color:var(--muted)!important;font-size:.88rem!important}
.bgm-table-zone{max-width:100%;overflow-x:auto;margin:.3rem 0 .7rem}
.bgm-table{border-collapse:collapse;min-width:16rem;max-width:34rem;width:100%;font-size:.92rem}
.bgm-table caption{text-align:left;font-weight:700;color:var(--muted);padding:0 0 .3rem;font-size:.88rem}
.bgm-table th,.bgm-table td{border-bottom:1px solid var(--line);padding:.35rem .6rem;text-align:left;color:var(--text)}
.bgm-table th{font-weight:800}
.bgm-sources{padding-left:1.3rem}
.bgm-sources a{display:inline-flex;align-items:center;min-height:44px;overflow-wrap:anywhere}
.bgm-clavier{margin:1rem 0 0;border:1px solid var(--line);border-radius:12px;background:var(--panel);padding:0 .85rem}
.bgm-clavier summary{display:flex;align-items:center;min-height:44px;font-weight:700;cursor:pointer;color:var(--text)}
.bgm-clavier ul{margin:0 0 .7rem;padding-left:1.2rem}
.bgm-clavier li{color:var(--text);font-size:.92rem;line-height:1.6;margin:0 0 .3rem}
.bgm-clavier kbd{display:inline-block;font:inherit;font-size:.84rem;font-weight:700;padding:.05rem .45rem;border:1px solid var(--line);border-bottom-width:2px;border-radius:6px;background:var(--bg-2);color:var(--text)}

/* ---------- aucun mouvement ---------- */
@media (prefers-reduced-motion: reduce){.bgm-jeu *,.bgm-onglets *{transition:none!important;animation:none!important}}
:root[data-calm="1"] .bgm-jeu *{transition:none!important;animation:none!important}
