/*  alveoles.css — un nid d'abeille de cire sombre dans la nuit du manoir,
 *  des pierres d'or et de bleu-os peintes au canvas, et rien qui ne tienne
 *  qu'à sa teinte.
 *
 *  ═══ LE LOSANGE EST UN CANVAS ═══
 *
 *  Le script le peint : les alvéoles de cire, les quatre bords colorés ET
 *  leur icône (⚜ pour Oscar, 💀 pour Skelet — jamais la couleur seule), les
 *  pierres bombées avec leur reflet et leur MONOGRAMME (O sur l'or, S sur le
 *  bleu), la pose animée, la dernière pierre cerclée, le curseur du clavier,
 *  le chemin gagnant qui s'illumine case après case, la brume. La feuille ne
 *  pose que le CADRE et ses états, la ligne où parlent Oscar et Skelet, le
 *  bandeau d'état et ses commandes, le panneau des options. Les jetons
 *  `--al-*` sont LUS par le script (`getPropertyValue`) : une couleur vit
 *  ici, et une seule fois.
 *
 *  ═══ L'ÉTAT N'EST JAMAIS PORTÉ PAR LA SEULE COULEUR ═══
 *
 *  Une pierre porte son monogramme ; un bord porte son icône ; la dernière
 *  pierre est cerclée ; le curseur est un hexagone en pointillé ; le chemin
 *  gagnant est un halo ET une annonce. Le banc mesure les couples de la
 *  feuille à 4,5:1 (textes, dont les deux monogrammes) et 3:1 (repères).
 */

:root {
  /*  Les six jetons communs aux salons récents, gardés tels quels. */
  --al-nuit:     #1b1526;
  --al-panneau:  #2a2338;
  --al-liseré:   #6b5a90;
  --al-texte:    #f0ead9;
  --al-doux:     #c9c0dc;
  --al-or:       #f0d68a;

  /*  Le nid, les pierres, ce qui s'y peint — lus par le script. */
  --al-cire:       #3d2c1c;   /* l’alvéole de cire, côté lumière */
  --al-cire-b:     #22170e;   /* les cloisons entre les alvéoles, et le fond du nid */
  --al-cire-c:     #6a4f2e;   /* le rebord clair d’une alvéole */
  --al-bleu:       #7fa8d6;   /* la pierre de Skelet : bleu-os */
  --al-bleu-b:     #4f78a6;   /* la pierre de Skelet, côté ombre */
  --al-or-b:       #b8922e;   /* la pierre d’Oscar, côté ombre */
  --al-encre:      #241a2e;   /* l’encre sombre : les monogrammes, l’icône ⚜ sur l’or */
  --al-cercle:     #f0ead9;   /* le cercle de la dernière pierre, sur la cire */
  --al-chemin:     #fff3c4;   /* le halo du chemin gagnant */
  --al-brume:      #c9c0dc;   /* la brume (posée en transparence) */
  --al-sur:        #7fd39a;   /* le verdict « bon », la victoire */
  --al-rouge:      #ef8a8a;   /* le verdict « refusé », la défaite */
  --al-bord:       #8a78b0;   /* le bord des commandes et des puces (3:1 sur les fonds, mesuré) */
  --al-cadre:      #4b3a63;   /* le bord du cadre, côté lumière */
  --al-cadre-b:    #2b2140;   /* le bord du cadre, côté ombre */

  /*  Les commandes, en couleurs opaques — reprises de la Tour, mesurées. */
  --al-ctl:        #231b2d;
  --al-ctl-vif:    #31293a;
  --al-ctl-or:     #3d3033;
  --al-ctl-or-vif: #4e413b;
}

/* ═══════════════════════════════════ LA BARRE, ET SES COMMANDES ═════════ */

/*  `theme-manoir.css` peint `body.theme-manoir .bar` avec `!important` :
 *  fond, bordure, ombres. Déclarer ici un fond de barre serait du code mort. */
.bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px clamp(10px, 2vw, 16px);
}
.sep { width: 1px; align-self: stretch; background: var(--al-liseré); margin: 0 2px; }

.bar a {
  font-size: 13px; color: var(--al-texte); text-decoration: none;
  border: 1px solid var(--al-bord); border-radius: 8px;
  padding: 7px 11px;
  transition: background .16s, border-color .16s;
}
.bar a:hover { background: var(--al-ctl-vif); border-color: var(--al-or); }
.bar a:focus-visible { outline: 3px solid var(--al-or); outline-offset: 2px; }

.bar button, .al-commandes button, .al-groupe button {
  font-family: inherit; font-size: 13px; color: var(--al-texte);
  background: var(--al-ctl);
  border: 1px solid var(--al-bord); border-radius: 8px;
  padding: 7px 11px; cursor: pointer; min-height: 40px;
  transition: background .16s, border-color .16s, transform .1s;
}
.bar button:hover:not(:disabled), .al-commandes button:hover:not(:disabled), .al-groupe button:hover:not(:disabled) { background: var(--al-ctl-vif); border-color: var(--al-or); }
.bar button:active:not(:disabled), .al-commandes button:active:not(:disabled) { transform: translateY(1px); }
.bar button:focus-visible, .al-commandes button:focus-visible, .al-groupe button:focus-visible { outline: 3px solid var(--al-or); outline-offset: 2px; }
@media (pointer: coarse) { .bar button, .al-commandes button, .al-groupe button { min-height: 44px; } }

.al-commandes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.al-commandes button kbd {
  font: 11px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--al-doux);
  border: 1px solid var(--al-bord); border-radius: 4px; padding: 1px 4px; margin-left: 2px;
}
.al-commandes button.gold { background: var(--al-ctl-or); border-color: var(--al-or); font-weight: bold; }
.al-commandes button.gold:hover:not(:disabled) { background: var(--al-ctl-or-vif); }
/*  Échanger, quand il est offert : mis en avant, il ne dure qu'un coup. */
.al-commandes button[data-cmd="echanger"] { background: var(--al-ctl-or); border-color: var(--al-or); font-weight: bold; }
/*  Un refus se voit avant le clic : liseré en pointillé. */
.bar button:disabled, .al-commandes button:disabled {
  background: transparent; color: var(--al-doux);
  border-style: dashed; cursor: not-allowed; font-weight: normal;
}
.al-commandes button[hidden] { display: none; }

body.ludi-scene { background: var(--al-nuit); color: var(--al-texte); }
h1 { font-family: Fraunces, Georgia, 'Times New Roman', serif; letter-spacing: .3px; }

/* ─────────────────────────────────────────────────────── le bandeau d’état ── */

.etat {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  flex: 0 0 100%; box-sizing: border-box;
  margin: 0 auto 10px; max-width: 1100px; padding: 6px 14px;
  background: var(--al-panneau); border: 1px solid var(--al-liseré);
  border-radius: 10px; color: var(--al-doux); font-size: .94rem;
}
.etat b { color: var(--al-texte); font-variant-numeric: tabular-nums; }

/*  ═══ LES JETONS DU BANDEAU ═══
    Le trait, les pierres des deux couleurs, le numéro du coup et le côté,
    le record. Chaque jeton porte un `title` ET un libellé : l'icône seule
    ne dit rien. */
.al-jeton {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 4px; border-radius: 999px;
  background: var(--al-ctl); border: 1px solid var(--al-bord);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 3px rgba(0, 0, 0, .45);
  color: var(--al-doux); font-size: .88rem; white-space: nowrap;
}
.al-jeton b { font-size: 1rem; min-width: 1.2em; text-align: center; }
.al-jeton[hidden] { display: none; }
/*  Le jeton du trait change de bord avec la couleur : or pour Oscar, bleu
    pour Skelet — et son icône change aussi (⚜ / 💀). */
.al-jeton-trait.skelet { border-color: var(--al-bleu); }
.al-jeton-trait.oscar { border-color: var(--al-or); }
.al-jeton-trait.ordi b::after { content: ' ⏳'; font-weight: normal; }
.al-ico {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 12px/1 Georgia, 'Times New Roman', serif; font-style: normal; color: var(--al-or);
  background: radial-gradient(circle at 35% 30%, #5a4a78, var(--al-ctl-or) 70%);
  border: 1px solid var(--al-or);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), inset 0 -2px 0 rgba(0, 0, 0, .35);
}
.al-ico-or { background: radial-gradient(circle at 35% 30%, #fff1c0, var(--al-or) 45%, var(--al-or-b)); color: var(--al-encre); font-size: 13px; }
.al-ico-bleu { background: radial-gradient(circle at 35% 30%, #d6e8fb, var(--al-bleu) 45%, var(--al-bleu-b)); color: var(--al-encre); border-color: var(--al-bleu); font-size: 13px; }

.al-choix { display: inline-flex; gap: 8px; align-items: center; position: relative; }
.al-options {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 270px;
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  background: var(--al-panneau); border: 1px solid var(--al-or); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); color: var(--al-texte); font-size: 14px;
}
.al-options[hidden] { display: none; }
.al-options h4 { margin: 0 0 2px; font-size: 13px; color: var(--al-or); text-transform: uppercase; letter-spacing: .04em; }
.al-options .al-option { display: flex; align-items: center; gap: 8px; cursor: pointer; min-height: 28px; }
.al-options .al-option input { accent-color: var(--al-or); width: 18px; height: 18px; margin: 0; }
.al-options .al-option.eteinte { opacity: .55; cursor: not-allowed; }
/*  L'adversaire, le niveau, le côté : des boutons engendrés par le script,
    pas une liste déroulante — la liste ouverte ne se style pas (mémoire du
    12/09). */
.al-groupe { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.al-groupe span { color: var(--al-doux); font-size: 13px; margin-right: 2px; min-width: 66px; }
.al-groupe button { min-width: 40px; padding: 5px 9px; min-height: 36px; }
.al-groupe button[aria-pressed="true"] { background: var(--al-ctl-or); border-color: var(--al-or); font-weight: 700; }
.al-groupe[hidden] { display: none; }
.al-puce {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  background: var(--al-ctl-or); border: 1px solid var(--al-or); color: var(--al-texte);
  font: inherit; font-size: .92rem; font-weight: 600;
}
.al-puce:hover { background: var(--al-ctl-or-vif); }
.al-puce:focus-visible { outline: 3px solid var(--al-or); outline-offset: 2px; }
@media (pointer: coarse) { .al-puce { min-height: 44px; } }
.al-chevron { color: var(--al-or); font-size: .8em; }

/*  ═══ LE VERDICT FLOTTE SUR LA LIGNE DES VOIX ═══ */
.al-voix { position: relative; width: 100%; max-width: 100%; }
#verdict { display: none; }
#verdict:not(:empty) {
  display: flex; align-items: center; box-sizing: border-box;
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; z-index: 6;
  padding: 5px 10px; border-radius: 9px; font-weight: 700; font-size: .9rem; line-height: 1.3;
  background: var(--al-panneau); border: 1px solid var(--al-or);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .55); overflow: hidden;
}
#verdict.bon   { color: var(--al-sur); }
#verdict.tiede { color: var(--al-or); }
#verdict.dur   { color: var(--al-rouge); }

/* ─────────────────────────────────────────────────────────────── le plateau ── */

.plateau {
  display: flex; flex-wrap: wrap; gap: clamp(10px, 2vw, 20px);
  justify-content: center; align-items: flex-start; align-content: flex-start;
  margin: 0 auto; max-width: min(1500px, 98vw);
  min-height: var(--plateau, auto);
}
.al-colonne { display: flex; flex-direction: column; gap: 8px; align-items: center; min-width: 0; max-width: 100%; position: relative; width: 100%; }

/*  Le cadre : un bord épais, deux lumières, un liseré. Le canvas dedans,
    dimensionné par le script — le cadre épouse le canvas, jamais l'inverse. */
.al-cadre {
  position: relative; box-sizing: border-box; max-width: 100%; overflow: visible;
  display: inline-block;
  padding: 6px; border-radius: 12px;
  background: linear-gradient(145deg, var(--al-cadre), var(--al-cadre-b));
  border: 2px solid var(--al-liseré);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .16),
    inset 0 -3px 0 rgba(0, 0, 0, .45),
    0 10px 28px rgba(0, 0, 0, .55);
  transition: box-shadow .2s;
}
.al-cadre canvas {
  display: block; border-radius: 6px; background: var(--al-cire-b);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, .6);
  /*  `touch-action: none` : depuis le losange, ni défilement, ni zoom au
      double-toucher — le doigt pose une pierre, c'est un coup. */
  cursor: pointer; touch-action: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  max-width: 100%;
}
.al-cadre canvas:focus-visible { outline: 3px solid var(--al-or); outline-offset: 3px; }
.al-cadre.gagne { box-shadow: 0 0 0 2px var(--al-or), 0 0 22px rgba(240, 214, 138, .45), 0 10px 28px rgba(0, 0, 0, .55); }
.al-cadre.gagne.skelet { box-shadow: 0 0 0 2px var(--al-bleu), 0 0 22px rgba(127, 168, 214, .45), 0 10px 28px rgba(0, 0, 0, .55); }
.al-cadre.refus { animation: al-refus .3s ease; }
@keyframes al-refus {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  70% { transform: translateX(4px); }
}
/*  Sous la brume, le cadre s'embrume lui aussi : un liseré doux. */
.al-cadre.brume { border-color: var(--al-doux); }

/*  ═══ L'ANNONCE TRAVERSE LE LOSANGE ═══ (relié, échange, refusé) */
.al-annonce {
  position: absolute; left: 0; right: 0; top: 40%; z-index: 5;
  transform: translateX(-100%); opacity: 0; pointer-events: none; text-align: center;
  font: 700 clamp(1.2rem, 4.2vw, 2rem)/1 Fraunces, Georgia, 'Times New Roman', serif; color: var(--al-or);
  letter-spacing: .04em; text-shadow: 0 0 16px rgba(0, 0, 0, .9), 0 2px 0 var(--al-encre);
  padding: 10px 0;
  background: linear-gradient(90deg, rgba(27, 21, 38, 0), rgba(27, 21, 38, .94) 12%, rgba(27, 21, 38, .94) 88%, rgba(27, 21, 38, 0));
  border-top: 1px solid var(--al-or); border-bottom: 1px solid var(--al-or);
}
.al-annonce.dur { color: var(--al-rouge); border-color: var(--al-rouge); }
.al-annonce.bleu { color: var(--al-bleu); border-color: var(--al-bleu); }
.al-annonce.on { animation: al-annonce 1.6s linear forwards; }
@keyframes al-annonce {
  0%      { opacity: 0; transform: translateX(-100%); animation-timing-function: cubic-bezier(.2, .8, .3, 1); }
  18%     { opacity: 1; transform: translateX(0); }
  82%     { opacity: 1; transform: translateX(0); animation-timing-function: cubic-bezier(.6, 0, .8, .4); }
  100%    { opacity: 0; transform: translateX(100%); }
}

/*  La ligne où parlent Oscar et Skelet, sous le losange. */
.al-dit {
  box-sizing: border-box; width: 100%; max-width: 100%; min-height: 2.6em;
  padding: 5px 10px; border-radius: 9px;
  background: var(--al-panneau); border: 1px dashed var(--al-bord);
  color: var(--al-doux); font: 13.5px/1.35 Georgia, 'Times New Roman', serif;
  transition: border-color .3s, color .3s;
}
.al-dit b { color: var(--al-or); font-weight: 700; margin-right: 4px; }
.al-dit.skelet b { color: var(--al-bleu); }
.al-dit.on { border-style: solid; border-color: var(--al-or); color: var(--al-texte); }
.al-dit.on.skelet { border-color: var(--al-bleu); }

/*  La légende : les bords, la cerclée, les touches. */
.al-legende { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .84rem; color: var(--al-doux); justify-content: center; }
.al-legende span { display: inline-flex; align-items: center; gap: 7px; }
.al-legende i {
  flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; font-style: normal;
  border: 2px dashed var(--al-cercle); color: var(--al-or); font: 700 11px/1 Georgia, serif;
}
.al-legende i.plein { border-style: solid; }
.al-legende i.al-leg-or { border: none; background: var(--al-or); color: var(--al-encre); }
.al-legende i.al-leg-bleu { border: none; background: var(--al-bleu); color: var(--al-encre); font-size: 12px; }
.al-legende kbd {
  font: 11px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--al-doux);
  border: 1px solid var(--al-bord); border-radius: 4px; padding: 1px 4px;
}

/*  Au-dessus de 1 081 px, LudiDuo pose ses deux tribunes dans les coins du
    bas : la ligne des voix et la légende leur laissent la place. */
@media (min-width: 1081px) {
  .al-voix, .al-legende { max-width: calc(100vw - 360px); }
}

/*  ═══ LA HAUTEUR EST COMPTÉE ═══ sous 1 500 px, les libellés des jetons
    et les rappels de touches s'effacent — l'icône et le `title` restent. */
@media (max-width: 1500px) {
  .etat { gap: 6px 8px; padding: 6px 10px; }
  .al-jeton { padding: 3px 8px 3px 3px; }
  .al-jeton .al-lib { display: none; }
  .al-commandes { gap: 6px; }
  .al-commandes button kbd { display: none; }
}
@media (max-height: 860px) {
  .al-legende { display: none; }
}

/*  Le pied « Sur Ludicademy » : un séparateur en bloc en ligne. */
.lb-sur .lb-sep { display: inline-block; }

/* ─────────────────────────────────────────────────────────── petits écrans ── */

/*  Un téléphone : étroit, OU bas (tourné, 812 × 375 n'est pas étroit). Le
    script dit la même chose (`telephone()`). Debout, le losange de onze
    veut des cases de trente pixels : la barre s'efface (le lien du salon
    vit aussi dans le bandeau), le titre se serre, le bandeau d'état tient
    sur une rangée. */
@media (max-width: 640px), (max-height: 480px) {
  h1 { font-size: 1.05rem; margin: 4px 0 4px; }
  .bar { display: none; }
  .etat { font-size: 13px; gap: 3px 5px; padding: 3px 6px 3px; margin-bottom: 4px; }
  .al-jeton { padding: 1px 6px 1px 2px; font-size: 12px; gap: 3px; }
  .al-jeton .al-lib { display: none; }
  .al-jeton b { font-size: 13px; min-width: 0; }
  .al-ico { width: 18px; height: 18px; font-size: 10px; }
  #jeton-meilleur { display: none; }
  .al-commandes { margin-left: 0; gap: 5px; }
  .al-commandes button kbd { display: none; }
  .al-commandes button .lib { display: none; }
  .al-commandes button { padding: 7px 10px; min-width: 44px; }
  .al-groupe button { min-width: 44px; min-height: 44px; }
  .al-choix { order: 5; }
  .al-puce#variantes { max-width: min(46vw, 220px); }
  .al-puce#variantes #titre-variante { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .al-puce#options { padding-left: 8px; padding-right: 8px; }
  .al-options { right: auto; left: 0; min-width: min(92vw, 340px); }
  .al-legende { display: none; }
  /*  Le losange prend toute la largeur de l'écran. Pas `100vw` : il compte
      la barre de défilement quand elle existe. */
  .plateau { gap: 4px; max-width: none; width: calc(100% + 16px); margin-left: -8px; }
  .al-colonne { width: 100%; gap: 4px; }
  .al-cadre { padding: 2px; border-radius: 8px; }
  .al-dit {
    max-width: calc(100vw - 8px); font-size: 12px; line-height: 1.25;
    min-height: 0; height: calc(2 * 1.25em + 8px); padding: 4px 8px; overflow: hidden;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  }
  .al-voix { max-width: calc(100vw - 8px); }
  #verdict:not(:empty) { font-size: 12px; padding: 4px 8px; }
  /*  Le bandeau replié laisse son bouton ☰ en haut à droite (44 px), et le
      bouton « Plein écran » flotte en bas à droite : la première rangée du
      bandeau d'état s'arrête avant (le jeton du coup s'efface, debout : le
      numéro du coup est dans la puce), la ligne des voix laisse la place
      (mesuré sur l'iPhone 13 — une rangée de plus coûtait 3 px par case). */
  .al-dit, #verdict:not(:empty) { padding-right: 112px; }
}
.al-saut { display: none; }
@media (max-width: 640px) and (orientation: portrait) {
  .al-jeton:has(#coup) { display: none; }
  .al-saut { display: block; flex-basis: 100%; height: 0; order: 1; }
  .al-commandes { order: 2; }
}

/*  ═══ LE TÉLÉPHONE TOURNÉ ═══
    375 px de haut : le titre s'efface, le bandeau se serre À GAUCHE, le
    losange au centre, la ligne des voix à droite — le losange reçoit toute
    la hauteur (même remède que la Tour, mesuré). */
@media (max-height: 480px) and (orientation: landscape) {
  h1 { display: none; }
  .plateau {
    display: grid; grid-template-columns: 150px auto minmax(100px, 130px);
    grid-template-areas: "etat losange dit"; column-gap: 6px; row-gap: 0;
    align-items: start; justify-content: center; width: calc(100% + 16px); margin-left: -8px;
  }
  .etat {
    grid-area: etat; margin: 0; max-width: none; padding: 4px 6px; gap: 4px;
    flex-wrap: wrap; align-content: start;
  }
  .etat .al-choix { width: 100%; flex-wrap: wrap; gap: 4px; }
  .etat .al-puce#variantes { max-width: 100%; }
  .etat .al-commandes { width: 100%; gap: 4px; }
  .al-options { left: 0; right: auto; }
  .al-colonne { display: contents; }
  .al-cadre { grid-area: losange; justify-self: center; }
  .al-voix { grid-area: dit; width: auto; max-width: none; align-self: stretch; }
  .al-dit { width: auto; max-width: none; min-height: 0; height: 100%; -webkit-line-clamp: 8; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .al-cadre.refus { animation: none; }
  .al-annonce.on { animation: none; opacity: 1; transform: none; }
  .al-cadre, .bar button, .bar a, .al-dit { transition: none; }
}

/*  L'aide à cocher, dans la barre avant que le panneau ne l'adopte. */
.bar .al-option { display: inline-flex; align-items: center; gap: 5px; color: var(--al-doux); font-size: 13px; cursor: pointer; white-space: nowrap; }
.bar .al-option input { accent-color: var(--al-or); width: 16px; height: 16px; margin: 0; }
