/*  sommes.css — un registre de comptes ancien dans la nuit du manoir : des
 *  cases de papier crème où l'on écrit à l'encre, des cases de cuir sombre
 *  qui portent leurs sommes en or, et rien qui ne tienne qu'à sa teinte.
 *
 *  ═══ LA GRILLE EST EN DOM ═══
 *
 *  Une grille CSS engendrée par le script : c'est un jeu de SAISIE, le
 *  clavier (chaque case blanche est un bouton), le lecteur d'écran et le
 *  zoom naturel du navigateur comptent plus qu'un canvas. `touch-action:
 *  manipulation` : pas de zoom au double-toucher, le pincement reste. La
 *  taille d'une case est publiée par le script dans `--so-case` (mesurée à
 *  chaque redimensionnement : 36 px au moins en 8 × 8 debout sur 390 px,
 *  28 en 10 et 12).
 *
 *  ═══ L'ÉTAT N'EST JAMAIS PORTÉ PAR LA SEULE COULEUR ═══
 *
 *  Une suite complète et fausse porte un liseré rouge ET ses chiffres sont
 *  soulignés ; une case marquée par Vérifier est rouge ET barrée d'un
 *  soulignement ondulé ; une case révélée par un indice est bleue ET en
 *  italique, avec un point ; la case choisie a un liseré d'or ET un fond
 *  plus clair ; une suite juste s'illumine ET ses chiffres se graissent. Les
 *  jetons `--so-*` sont MESURÉS par le banc : 4,5:1 pour les textes (le
 *  chiffre sur le papier, l'indice sur le cuir, le crayon), 3:1 pour les
 *  repères (les liserés).
 */

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

  /*  Le registre : le papier, l'encre, le cuir, l'or des sommes. */
  --so-papier:       #f3e8cf;   /* une case blanche : papier crème */
  --so-papier-vif:   #fff8e3;   /* la case choisie */
  --so-papier-suite: #e9d9b1;   /* les deux suites de la case choisie */
  --so-papier-juste: #e2efc6;   /* une suite complète et juste */
  --so-encre:        #2a1f33;   /* le chiffre écrit, à l'encre */
  --so-crayon:       #5a4a6a;   /* les candidats notés au crayon */
  --so-revele:       #1f5f8b;   /* un chiffre révélé par un indice : encre bleue */
  --so-faute:        #a3202a;   /* un chiffre marqué faux */
  --so-rouge:        #c0392b;   /* le liseré d'une suite fausse, sur le papier */
  --so-choix:        #8a6a12;   /* le liseré de la case choisie : un or foncé, lisible sur le papier (3:1 mesuré) */
  --so-cuir:         #2b1d1a;   /* une case noire : cuir sombre */
  --so-cuir-b:       #1a100e;   /* le cuir, côté ombre (la diagonale) */
  --so-cuir-c:       #4a332c;   /* le cuir, côté lumière (le grain) */
  --so-reglure:      #b9a98a;   /* les traits entre les cases de papier (repère, 3:1 sur le papier) */
  --so-sur:          #7fd39a;   /* le verdict « bon », la grille résolue */
  --so-alerte:       #ef8a8a;   /* le verdict « refusé », le chrono qui presse */
  --so-bord:         #8a78b0;   /* le bord des commandes et des puces (3:1 sur les fonds, mesuré) */
  --so-cadre:        #4b3a63;   /* le bord du cadre, côté lumière */
  --so-cadre-b:      #2b2140;   /* le bord du cadre, côté ombre */

  /*  Les commandes, en couleurs opaques — reprises des Alvéoles, mesurées. */
  --so-ctl:        #231b2d;
  --so-ctl-vif:    #31293a;
  --so-ctl-or:     #3d3033;
  --so-ctl-or-vif: #4e413b;

  --so-case: 44px;
}

/* ═══════════════════════════════════ 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(--so-liseré); margin: 0 2px; }

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

.bar button, .so-commandes button, .so-groupe button, .so-pave button, .so-combos-ferme {
  font-family: inherit; font-size: 13px; color: var(--so-texte);
  background: var(--so-ctl);
  border: 1px solid var(--so-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), .so-commandes button:hover:not(:disabled), .so-groupe button:hover:not(:disabled), .so-pave button:hover:not(:disabled) { background: var(--so-ctl-vif); border-color: var(--so-or); }
.bar button:active:not(:disabled), .so-commandes button:active:not(:disabled), .so-pave button:active:not(:disabled) { transform: translateY(1px); }
.bar button:focus-visible, .so-commandes button:focus-visible, .so-groupe button:focus-visible, .so-pave button:focus-visible { outline: 3px solid var(--so-or); outline-offset: 2px; }
@media (pointer: coarse) { .bar button, .so-commandes button, .so-groupe button, .so-pave button { min-height: 44px; } }

.so-commandes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.so-commandes button kbd {
  font: 11px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--so-doux);
  border: 1px solid var(--so-bord); border-radius: 4px; padding: 1px 4px; margin-left: 2px;
}
.so-commandes button.gold { background: var(--so-ctl-or); border-color: var(--so-or); font-weight: bold; }
.so-commandes button.gold:hover:not(:disabled) { background: var(--so-ctl-or-vif); }
/*  Un refus se voit avant le clic : liseré en pointillé. */
.bar button:disabled, .so-commandes button:disabled, .so-pave button:disabled {
  background: transparent; color: var(--so-doux);
  border-style: dashed; cursor: not-allowed; font-weight: normal;
}
.so-commandes button[hidden] { display: none; }

body.ludi-scene { background: var(--so-nuit); color: var(--so-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(--so-panneau); border: 1px solid var(--so-liseré);
  border-radius: 10px; color: var(--so-doux); font-size: .94rem;
}
.etat b { color: var(--so-texte); font-variant-numeric: tabular-nums; }

/*  ═══ LES JETONS DU BANDEAU ═══ le niveau, les cases, le temps, le chrono,
    le record. Chaque jeton porte un `title` ET un libellé. */
.so-jeton {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 4px; border-radius: 999px;
  background: var(--so-ctl); border: 1px solid var(--so-bord);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 3px rgba(0, 0, 0, .45);
  color: var(--so-doux); font-size: .88rem; white-space: nowrap;
}
.so-jeton b { font-size: 1rem; min-width: 1.2em; text-align: center; }
.so-jeton[hidden] { display: none; }
/*  Le chrono de la nuit : or, puis alerte (ET un sablier qui clignote)
    quand il reste moins de deux minutes. */
.so-jeton-chrono { border-color: var(--so-or); }
.so-jeton-chrono.presse { border-color: var(--so-alerte); }
.so-jeton-chrono.presse b { color: var(--so-alerte); }
.so-jeton-chrono.presse .so-ico { animation: so-cligne 1s steps(2) infinite; }
@keyframes so-cligne { 50% { opacity: .35; } }
.so-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(--so-or);
  background: radial-gradient(circle at 35% 30%, #5a4a78, var(--so-ctl-or) 70%);
  border: 1px solid var(--so-or);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), inset 0 -2px 0 rgba(0, 0, 0, .35);
}

.so-choix { display: inline-flex; gap: 8px; align-items: center; position: relative; }
.so-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(--so-panneau); border: 1px solid var(--so-or); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); color: var(--so-texte); font-size: 14px;
}
.so-options[hidden] { display: none; }
.so-options h4 { margin: 0 0 2px; font-size: 13px; color: var(--so-or); text-transform: uppercase; letter-spacing: .04em; }
.so-options .so-option { display: flex; align-items: center; gap: 8px; cursor: pointer; min-height: 28px; }
.so-options .so-option input { accent-color: var(--so-or); width: 18px; height: 18px; margin: 0; }
.so-groupe { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.so-groupe span { color: var(--so-doux); font-size: 13px; margin-right: 2px; min-width: 52px; }
.so-groupe button { min-width: 40px; padding: 5px 9px; min-height: 36px; }
.so-groupe input[type="number"] {
  width: 5em; font: inherit; color: var(--so-texte); background: var(--so-ctl);
  border: 1px solid var(--so-bord); border-radius: 8px; padding: 6px 8px; min-height: 36px; box-sizing: border-box;
}
.so-groupe input[type="number"]:focus-visible { outline: 3px solid var(--so-or); outline-offset: 2px; }
.so-puce {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
  background: var(--so-ctl-or); border: 1px solid var(--so-or); color: var(--so-texte);
  font: inherit; font-size: .92rem; font-weight: 600;
}
.so-puce:hover { background: var(--so-ctl-or-vif); }
.so-puce:focus-visible { outline: 3px solid var(--so-or); outline-offset: 2px; }
@media (pointer: coarse) { .so-puce { min-height: 44px; } }
.so-chevron { color: var(--so-or); font-size: .8em; }

/*  ═══ LE VERDICT FLOTTE SUR LA LIGNE DES VOIX ═══ */
.so-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(--so-panneau); border: 1px solid var(--so-or);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .55); overflow: hidden;
}
#verdict.bon   { color: var(--so-sur); }
#verdict.tiede { color: var(--so-or); }
#verdict.dur   { color: var(--so-alerte); }

/* ─────────────────────────────────────────────────────────────── 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);
}
.so-colonne { display: flex; flex-direction: column; gap: 8px; align-items: center; min-width: 0; max-width: 100%; position: relative; width: 100%; }

/*  Le cadre : du cuir, deux lumières, un liseré. La grille dedans, dimensionnée
    par le script — le cadre épouse la grille, jamais l'inverse. */
.so-cadre {
  position: relative; box-sizing: border-box; max-width: 100%; overflow: hidden;
  display: inline-block;
  padding: 6px; border-radius: 12px;
  background: linear-gradient(145deg, var(--so-cadre), var(--so-cadre-b));
  border: 2px solid var(--so-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;
}
.so-cadre.gagne { box-shadow: 0 0 0 2px var(--so-or), 0 0 22px rgba(240, 214, 138, .45), 0 10px 28px rgba(0, 0, 0, .55); }
.so-cadre.refus { animation: so-refus .3s ease; }
@keyframes so-refus {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-4px); }
  70% { transform: translateX(4px); }
}

/*  ═══ LA GRILLE ═══ n colonnes de --so-case ; les traits de réglure entre
    les cases de papier sont le fond du cuir qui passe entre elles. */
.so-grille {
  display: grid; grid-template-columns: repeat(var(--so-n, 8), var(--so-case));
  grid-auto-rows: var(--so-case); gap: 1px;
  background: var(--so-cuir-b); border: 1px solid var(--so-cuir-b); border-radius: 6px; overflow: hidden;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
  font-variant-numeric: tabular-nums;
}
.so-case { position: relative; box-sizing: border-box; width: var(--so-case); height: var(--so-case); margin: 0; padding: 0; border: 0; font-family: Georgia, 'Times New Roman', serif; }
/*  Une case noire : le cuir, la diagonale, deux indices en or — celui du
    haut à droite (la somme À DROITE), celui du bas à gauche (la somme EN
    BAS). Chaque indice est un bouton : le toucher ouvre les combinaisons. */
.so-case.noire {
  background:
    linear-gradient(to top right, transparent calc(50% - .6px), var(--so-cuir-b) calc(50% - .6px), var(--so-cuir-b) calc(50% + .6px), transparent calc(50% + .6px)),
    radial-gradient(circle at 30% 25%, var(--so-cuir-c), var(--so-cuir) 60%);
}
.so-case.noire.vide { background: radial-gradient(circle at 30% 25%, var(--so-cuir-c), var(--so-cuir) 60%); }
.so-indice {
  position: absolute; margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer;
  color: var(--so-or); font: 700 calc(var(--so-case) * .34) / 1 Georgia, 'Times New Roman', serif;
  font-variant-numeric: tabular-nums; line-height: 1;
  width: 60%; height: 50%; display: flex; align-items: center; justify-content: center;
  border-radius: 4px;
}
.so-indice.droite { top: 2%; right: 2%; align-items: flex-start; justify-content: flex-end; padding: 6% 6% 0 0; box-sizing: border-box; }
.so-indice.bas { bottom: 2%; left: 2%; align-items: flex-end; justify-content: flex-start; padding: 0 0 6% 6%; box-sizing: border-box; }
.so-indice:hover, .so-indice.ouvert { text-decoration: underline; text-decoration-color: var(--so-or); text-underline-offset: 2px; }
.so-indice:focus-visible { outline: 2px solid var(--so-or); outline-offset: -2px; }
.so-indice.eclaire { text-shadow: 0 0 6px rgba(240, 214, 138, .9); }
/*  Une case blanche : du papier, un chiffre à l'encre, ou des candidats au
    crayon (petits, en grille de trois par trois). */
.so-case.blanche {
  background: var(--so-papier); color: var(--so-encre); cursor: pointer;
  font-size: calc(var(--so-case) * .58); font-weight: 400;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, box-shadow .12s;
}
.so-case.blanche.suite { background: var(--so-papier-suite); }
.so-case.blanche.choisie { background: var(--so-papier-vif); box-shadow: inset 0 0 0 3px var(--so-choix); z-index: 2; }
.so-case.blanche:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--so-choix); }
.so-case.blanche.juste { background: var(--so-papier-juste); font-weight: 700; }
.so-case.blanche.juste.choisie { background: var(--so-papier-vif); }
/*  Une suite complète et FAUSSE : liseré rouge ET chiffres soulignés. */
.so-case.blanche.fausse { box-shadow: inset 0 0 0 2px var(--so-rouge); text-decoration: underline; text-decoration-color: var(--so-rouge); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.so-case.blanche.fausse.choisie { box-shadow: inset 0 0 0 3px var(--so-choix), inset 0 0 0 5px var(--so-rouge); }
/*  Une case marquée par Vérifier (ou par la nuit) : rouge ET ondulée. */
.so-case.blanche.erreur { color: var(--so-faute); text-decoration: underline wavy var(--so-faute); text-underline-offset: 3px; }
/*  Une case révélée par un indice : encre bleue ET italique ET un point. */
.so-case.blanche.revelee { color: var(--so-revele); font-style: italic; cursor: default; }
.so-case.blanche.revelee::after { content: ''; position: absolute; right: 8%; bottom: 8%; width: 12%; height: 12%; border-radius: 50%; background: var(--so-revele); }
/*  La plume qui écrit : un petit trait qui s'efface à la saisie. */
.so-case.blanche.ecrit { animation: so-plume .28s ease-out; }
@keyframes so-plume {
  0% { transform: scale(.6) rotate(-8deg); opacity: .2; }
  60% { transform: scale(1.12) rotate(2deg); opacity: 1; }
  100% { transform: none; }
}
.so-case.blanche .so-plume { position: absolute; right: 4%; top: 2%; font-size: calc(var(--so-case) * .34); line-height: 1; opacity: 0; pointer-events: none; }
.so-case.blanche.ecrit .so-plume { animation: so-trait .4s ease-out; }
@keyframes so-trait { 0% { opacity: 1; transform: translate(-40%, 40%) rotate(-20deg); } 100% { opacity: 0; transform: translate(0, 0) rotate(0); } }
/*  Les candidats au crayon : jusqu'à neuf, en trois rangées. */
.so-crayon {
  position: absolute; inset: 4%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  color: var(--so-crayon); font: 700 calc(var(--so-case) * .24) / 1 Georgia, serif; text-align: center; align-items: center;
}
.so-crayon i { font-style: normal; }
/*  Une suite juste qui vient de se boucler : une lueur qui passe. */
.so-case.blanche.lueur { animation: so-lueur .9s ease-out; }
@keyframes so-lueur { 0% { box-shadow: inset 0 0 0 40px rgba(240, 214, 138, .55); } 100% { box-shadow: inset 0 0 0 0 rgba(240, 214, 138, 0); } }

/*  ═══ LE REGISTRE SE FERME ═══ une couverture de cuir qui descend sur la
    grille à la fin, avec le sceau du manoir. */
.so-registre {
  position: absolute; inset: 0; z-index: 8; pointer-events: none; opacity: 0; transform: translateY(-100%);
  background: linear-gradient(160deg, var(--so-cuir-c), var(--so-cuir) 45%, var(--so-cuir-b));
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 3px var(--so-or), inset 0 0 0 6px var(--so-cuir-b);
}
.so-registre.on { animation: so-ferme .9s cubic-bezier(.3, .8, .3, 1) forwards; }
@keyframes so-ferme { 0% { opacity: 0; transform: translateY(-100%); } 40% { opacity: 1; } 100% { opacity: 1; transform: translateY(0); } }
.so-couverture { text-align: center; color: var(--so-or); }
.so-sceau {
  width: clamp(60px, 22vmin, 120px); height: clamp(60px, 22vmin, 120px); margin: 0 auto 8px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: clamp(30px, 11vmin, 60px);
  background: radial-gradient(circle at 35% 30%, #b8922e, #7a5a14 70%); border: 3px solid var(--so-or);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .6), inset 0 2px 0 rgba(255, 255, 255, .3);
  transform: scale(0);
}
.so-registre.on .so-sceau { animation: so-sceau .5s .8s cubic-bezier(.2, 1.4, .4, 1) forwards; }
@keyframes so-sceau { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }
.so-titre-sceau { font: 700 clamp(14px, 3.4vmin, 22px) Fraunces, Georgia, serif; letter-spacing: .12em; text-transform: uppercase; }

/*  ═══ L'ANNONCE TRAVERSE LA GRILLE ═══ (résolu, faux, chrono) */
.so-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(--so-or);
  letter-spacing: .04em; text-shadow: 0 0 16px rgba(0, 0, 0, .9), 0 2px 0 var(--so-cuir-b);
  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(--so-or); border-bottom: 1px solid var(--so-or);
}
.so-annonce.dur { color: var(--so-alerte); border-color: var(--so-alerte); }
.so-annonce.on { animation: so-annonce 1.6s linear forwards; }
@keyframes so-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%); }
}

/*  Ce qui reste aux deux suites de la case choisie. */
.so-reste { min-height: 1.3em; font: 700 .9rem/1.3 Georgia, serif; color: var(--so-or); text-align: center; font-variant-numeric: tabular-nums; }
.so-reste:empty { display: none; }
.so-reste .h, .so-reste .v { display: inline-block; margin: 0 8px; }
.so-reste small { color: var(--so-doux); font-weight: 400; }

/*  ═══ LE PAVÉ ═══ 1 à 9, effacer, le crayon, les combinaisons. Sur un
    ordinateur : une rangée sous la grille. */
.so-pave { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 100%; }
.so-pave button { min-width: 44px; min-height: 44px; font-size: 1.15rem; font-weight: 700; padding: 6px 10px; }
.so-pave button[data-crayon][aria-pressed="true"] { background: var(--so-ctl-or); border-color: var(--so-or); box-shadow: inset 0 0 0 1px var(--so-or); }
.so-pave button .lib { font-size: .8rem; font-weight: 400; }

/*  ═══ LES COMBINAISONS ═══ une boîte au-dessus de la ligne des voix. */
.so-combos {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 20;
  width: min(92vw, 420px); max-height: min(60vh, 380px); overflow: auto; box-sizing: border-box;
  background: var(--so-panneau); border: 1px solid var(--so-or); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .6); color: var(--so-texte);
}
.so-combos[hidden] { display: none; }
.so-combos-tete { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.so-combos-tete b { color: var(--so-or); font-size: 1rem; }
.so-combos-ferme { min-height: 36px; min-width: 36px; padding: 4px 10px; }
.so-combos-liste { display: flex; flex-wrap: wrap; gap: 6px; }
.so-combos-liste span {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border-radius: 8px;
  background: var(--so-ctl); border: 1px solid var(--so-bord); font: 700 .98rem/1 Georgia, serif; letter-spacing: .06em;
  color: var(--so-texte);
}
.so-combos-liste span.exclue { color: var(--so-doux); border-style: dashed; text-decoration: line-through; font-weight: 400; }
.so-combos-liste span.seule { border-color: var(--so-or); color: var(--so-or); }
.so-combos-note { width: 100%; color: var(--so-doux); font-size: .84rem; margin-top: 4px; }
.so-combos-groupe { width: 100%; color: var(--so-doux); font-size: .86rem; margin: 6px 0 2px; }

/*  ═══ LA TABLE DE L'APPRENTI ═══ chaque indice et ses combinaisons, en
    permanence, à côté (ou sous) la grille. */
.so-table { display: none; box-sizing: border-box; max-width: 100%; width: 100%; max-height: 300px; overflow: auto;
  background: var(--so-panneau); border: 1px solid var(--so-liseré); border-radius: 10px; padding: 8px 10px; color: var(--so-doux); font-size: .86rem; }
.so-table.on { display: block; }
.so-table h4 { margin: 0 0 6px; font-size: 12px; color: var(--so-or); text-transform: uppercase; letter-spacing: .04em; }
.so-table div { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; padding: 2px 0; border-bottom: 1px dashed rgba(138, 120, 176, .35); }
.so-table div.eclaire { color: var(--so-texte); background: var(--so-ctl-or); border-radius: 6px; padding: 2px 4px; }
.so-table b { color: var(--so-or); min-width: 4.4em; font-variant-numeric: tabular-nums; }
.so-table i { font-style: normal; color: var(--so-texte); }

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

/*  La légende : les sommes, juste, fausse, les touches. */
.so-legende { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .84rem; color: var(--so-doux); justify-content: center; }
.so-legende span { display: inline-flex; align-items: center; gap: 7px; }
.so-legende i {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 4px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; font-style: normal;
  font: 700 11px/1 Georgia, serif;
}
.so-legende i.so-leg-noire { background: var(--so-cuir); color: var(--so-or); border: 1px solid var(--so-cuir-c); }
.so-legende i.so-leg-juste { background: var(--so-papier-juste); color: var(--so-encre); }
.so-legende i.so-leg-fausse { background: var(--so-papier); color: var(--so-encre); box-shadow: inset 0 0 0 2px var(--so-rouge); text-decoration: underline; text-decoration-color: var(--so-rouge); }
.so-legende kbd {
  font: 11px/1 ui-monospace, Menlo, Consolas, monospace; color: var(--so-doux);
  border: 1px solid var(--so-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) {
  .so-voix, .so-legende, .so-table { 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; }
  .so-jeton { padding: 3px 8px 3px 3px; }
  .so-jeton .so-lib { display: none; }
  .so-commandes { gap: 6px; }
  .so-commandes button kbd { display: none; }
}
@media (max-height: 860px) {
  .so-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, la grille de huit veut
    ses trente-six pixels par case et le pavé reste FIXÉ EN BAS : la barre
    s'efface, le titre se serre, le bandeau 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; }
  .so-jeton { padding: 1px 6px 1px 2px; font-size: 12px; gap: 3px; }
  .so-jeton .so-lib { display: none; }
  .so-jeton b { font-size: 13px; min-width: 0; }
  .so-ico { width: 18px; height: 18px; font-size: 10px; }
  #jeton-meilleur { display: none; }
  .so-commandes { margin-left: 0; gap: 5px; }
  .so-commandes button kbd { display: none; }
  .so-commandes button .lib { display: none; }
  .so-commandes button { padding: 7px 10px; min-width: 44px; }
  .so-groupe button { min-width: 44px; min-height: 44px; }
  .so-choix { order: 5; }
  .so-puce#variantes { max-width: min(46vw, 220px); }
  .so-puce#variantes #titre-variante { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .so-puce#options { padding-left: 8px; padding-right: 8px; }
  .so-options { right: auto; left: 0; min-width: min(92vw, 340px); }
  .so-legende { display: none; }
  .plateau { gap: 4px; max-width: none; width: calc(100% + 16px); margin-left: -8px; }
  .so-colonne { width: 100%; gap: 4px; }
  .so-cadre { padding: 2px; border-radius: 8px; }
  .so-reste { font-size: .82rem; }
  .so-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;
  }
  .so-voix { max-width: calc(100vw - 8px); }
  #verdict:not(:empty) { font-size: 12px; padding: 4px 8px; }
  .so-dit, #verdict:not(:empty) { padding-right: 112px; }
  .so-table { max-height: 160px; font-size: .8rem; }
  .so-combos { top: auto; bottom: calc(var(--so-pave-h, 104px) + 8px); position: fixed; }
}
.so-saut { display: none; }
@media (max-width: 640px) and (orientation: portrait) {
  .so-jeton:has(#temps) { display: none; }
  .so-saut { display: block; flex-basis: 100%; height: 0; order: 1; }
  .so-commandes { order: 2; }
  /*  Le pavé fixé en bas : deux rangées de six, 44 px chacune, sur le fond
      du panneau ; le corps de la page garde la place dessous. */
  .so-pave {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    background: var(--so-panneau); border-top: 1px solid var(--so-liseré); box-shadow: 0 -6px 18px rgba(0, 0, 0, .5);
  }
  .so-pave button { min-width: 0; padding: 4px 2px; font-size: 1.2rem; }
  .so-pave button .lib { display: none; }
  body.ludi-scene { padding-bottom: var(--so-pave-h, 104px); }
  /*  Le bouton « Plein écran » du site flotte en bas à droite : il
      recouvrait le crayon et les combinaisons du pavé (MESURÉ par
      elementsFromPoint). Il remonte au-dessus du pavé. */
  #ludiPlein { bottom: calc(var(--so-pave-h, 104px) + 8px) !important; }
}

/*  ═══ LE TÉLÉPHONE TOURNÉ ═══
    375 px de haut : le titre s'efface, le bandeau se serre À GAUCHE, la
    grille au centre, le pavé À DROITE en colonne (trois par rangée), la
    ligne des voix sous le bandeau. */
@media (max-height: 480px) and (orientation: landscape) {
  h1 { display: none; }
  .plateau {
    display: grid; grid-template-columns: 150px auto 150px;
    grid-template-areas: "etat grille pave" "dit grille pave" "dit grille reste"; column-gap: 6px; row-gap: 4px;
    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 .so-choix { width: 100%; flex-wrap: wrap; gap: 4px; }
  .etat .so-puce#variantes { max-width: 100%; }
  .etat .so-commandes { width: 100%; gap: 4px; }
  .so-options { left: 0; right: auto; }
  .so-colonne { display: contents; }
  .so-cadre { grid-area: grille; justify-self: center; }
  .so-pave { grid-area: pave; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; align-self: start; position: static; }
  .so-pave button { min-width: 0; padding: 4px 2px; }
  .so-pave button .lib { display: none; }
  .so-reste { grid-area: reste; font-size: .78rem; }
  .so-voix { grid-area: dit; width: auto; max-width: none; align-self: stretch; }
  .so-dit { width: auto; max-width: none; min-height: 0; height: 100%; -webkit-line-clamp: 8; font-size: 12px; }
  .so-table { display: none !important; }
  .so-combos { position: fixed; top: 8px; bottom: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .so-cadre.refus, .so-case.blanche.ecrit, .so-case.blanche.ecrit .so-plume, .so-case.blanche.lueur, .so-jeton-chrono.presse .so-ico { animation: none; }
  .so-annonce.on { animation: none; opacity: 1; transform: none; }
  .so-registre.on { animation: none; opacity: 1; transform: none; }
  .so-registre.on .so-sceau { animation: none; transform: none; }
  .so-cadre, .bar button, .bar a, .so-dit, .so-case.blanche { transition: none; }
}

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