/* ---------------------------------------------------------------------------
   Life — page d'édition
   Chaleureux sans être criard : crème, vert sapin, corail, un jaune solaire.
   --------------------------------------------------------------------------- */

:root {
  --fond: #0e1a1d;
  --carte: #f3f8f5;
  --encre: #16262b;
  --encre-douce: #50666b;
  --sapin: #0f7b6c;
  --sapin-fonce: #0a5c51;
  --corail: #e8603f;
  --soleil: #ffd166;
  --ciel: #dff0f7;
  --trait: #c5d6d0;
  --erreur-fond: #fde5df;
  --erreur-trait: #e8603f;
  --conseil-fond: #e3f1f8;
  --conseil-trait: #3b82d6;
  --bien-fond: #e2f4ea;
  --partie-fond: #fff0bd;
  --rayon: 12px;
  --hauteur-ligne: 26px;
  --police: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", "Segoe UI", system-ui, -apple-system, sans-serif;
  --police-code: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font-family: var(--police);
  font-size: 17px;
  line-height: 1.45;
}

/* ---------------------------------------------------------------- entête */

.entete {
  background: var(--sapin);
  color: #fff;
  padding: 12px 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.entete-contenu {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  display: block;
  width: 52px;
  height: 52px;
  background: #fff;
  border-radius: 50%;
  flex: none;
  overflow: hidden;
}
.logo svg { display: block; width: 100%; height: 100%; }

.entete h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.1;
  letter-spacing: 0.01em;
}
.devise { margin: 2px 0 0; opacity: 0.9; font-size: 0.95rem; }

/* ----------------------------------------------------------------- page */

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.grille {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.carte {
  min-width: 0;
  background: var(--carte);
  border: 2px solid var(--trait);
  border-radius: var(--rayon);
  padding: 16px;
}

.carte h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}


.pied {
  color: var(--encre-douce);
  font-size: 0.9rem;
  text-align: center;
  margin: 18px 0 0;
}

/* ------------------------------------------------------------- boutons */

.bouton {
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--sapin);
  border: 0;
  border-bottom: 4px solid var(--sapin-fonce);
  border-radius: 14px;
  min-height: 46px;
  padding: 8px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  touch-action: manipulation;
}
.bouton:hover { background: #247f69; }
.bouton:active { transform: translateY(2px); border-bottom-width: 2px; }
.bouton:disabled { opacity: 0.45; cursor: default; transform: none; border-bottom-width: 4px; }
.bouton-de { background: var(--corail); border-bottom-color: #c44a2c; }
.bouton-de:hover { background: #ef6f4f; }
.bouton-discret {
  color: var(--encre);
  background: #e1ece8;
  border-bottom-color: #bfd1ca;
}
.bouton-discret:hover { background: #d3e3dd; }

.barre-outils {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 12px;
}
.barre-apercu { margin: 10px 0 0; justify-content: center; }

:focus-visible {
  outline: 3px solid var(--soleil);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--sapin);
}

/* ---------------------------------------------------------- bibliothèque */

.etiquette {
  margin: 0 0 6px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--encre-douce);
}

.bibliotheque { margin: 0 0 14px; }

.bibliotheque-liste {
  list-style: none;
  margin: 0;
  padding: 2px 2px 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.vignette {
  scroll-snap-align: start;
  flex: none;
  width: 92px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--encre);
  background: #e6f0ec;
  border: 2px solid var(--trait);
  border-radius: 10px;
  padding: 4px 4px 6px;
  cursor: pointer;
  text-align: center;
  touch-action: manipulation;
}
.vignette:hover { border-color: var(--sapin); background: #fff; }
.vignette[aria-pressed="true"] { border-color: var(--sapin); background: #fff; box-shadow: 0 0 0 2px var(--sapin) inset; }
.vignette svg { display: block; width: 100%; height: auto; aspect-ratio: 1; }

/* -------------------------------------------------------------- éditeur */

.editeur {
  display: flex;
  height: clamp(260px, 42vh, 460px);
  border: 2px solid var(--trait);
  border-radius: 14px;
  overflow: hidden;
  background: #f7fbf9;
}
.editeur:focus-within { border-color: var(--sapin); }

.gouttiere {
  flex: none;
  width: 44px;
  padding: 10px 6px 10px 0;
  overflow: hidden;
  text-align: right;
  color: #7f9892;
  background: #e3eeea;
  font-family: var(--police-code);
  font-size: 15px;
  user-select: none;
}
.gouttiere div { height: var(--hauteur-ligne); line-height: var(--hauteur-ligne); }
.gouttiere .erreur { color: #fff; background: var(--erreur-trait); font-weight: 700; }
.gouttiere .conseil { color: #fff; background: var(--conseil-trait); font-weight: 700; }

.zone-code { position: relative; flex: 1; min-width: 0; }

.surcouche {
  position: absolute;
  inset: 0;
  padding: 10px 0;
  overflow: hidden;
  pointer-events: none;
}
.surcouche div { height: var(--hauteur-ligne); }
.surcouche .erreur { background: var(--erreur-fond); box-shadow: inset 4px 0 0 var(--erreur-trait); }
.surcouche .conseil { background: var(--conseil-fond); box-shadow: inset 4px 0 0 var(--conseil-trait); }
.surcouche .partie { background: var(--partie-fond); }

#code {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--encre);
  font-family: var(--police-code);
  font-size: 16px;
  line-height: var(--hauteur-ligne);
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  caret-color: var(--corail);
}
#code:focus-visible { outline: 0; box-shadow: none; }

/* ------------------------------------------------------------- messages */

.messages { margin-top: 12px; display: grid; gap: 8px; }

.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  width: 100%;
  font: inherit;
  text-align: left;
  color: var(--encre);
  background: var(--erreur-fond);
  border: 2px solid var(--erreur-trait);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
}
.message.conseil { background: var(--conseil-fond); border-color: var(--conseil-trait); }
.message .ligne {
  flex: none;
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  background: var(--erreur-trait);
  border-radius: 999px;
  padding: 2px 9px;
  margin-top: 2px;
}
.message.conseil .ligne { background: var(--conseil-trait); }

.tout-va-bien {
  margin: 0;
  padding: 8px 12px;
  border: 2px solid #8fcfae;
  border-radius: 12px;
  background: var(--bien-fond);
  font-weight: 700;
}

/* -------------------------------------------------------------- l'aperçu */

.scene {
  position: relative;
  border: 2px solid var(--trait);
  border-radius: 16px;
  overflow: hidden;
}

.scene-apercu {
  /* le sol du vivarium, vu de dessus */
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 62%),
    radial-gradient(rgba(40, 110, 100, 0.14) 1.2px, transparent 1.4px) 0 0 / 22px 22px,
    #dbe8e3;
  display: grid;
  place-items: center;
  padding: 8px;
}

.apercu {
  width: 100%;
  max-width: 540px;
  aspect-ratio: 1;
}
.apercu svg { display: block; width: 100%; height: 100%; overflow: visible; }

.apercu [data-partie] { cursor: pointer; }
.apercu .surbrillance {
  filter: drop-shadow(0 0 2.5px rgba(255, 176, 0, 1)) drop-shadow(0 0 1.5px #fff);
}

.legende { margin: 10px 0 0; text-align: center; font-size: 1.1rem; }
.legende span { color: var(--encre-douce); }
.indice {
  margin: 4px 0 0;
  min-height: 2.9em;
  text-align: center;
  color: var(--encre-douce);
  font-size: 0.95rem;
}
.indice code {
  font-family: var(--police-code);
  background: var(--partie-fond);
  color: var(--encre);
  border-radius: 6px;
  padding: 1px 6px;
}

/* ---------------------------------------------------------- petits écrans */

@media (max-width: 900px) {
  .grille { grid-template-columns: minmax(0, 1fr); }
  .colonne-droite { display: contents; }
  .carte-vivarium { order: -2; }
  .carte-apercu { order: -1; }
  .editeur { height: clamp(220px, 34vh, 340px); }
  .panneau { max-height: none; }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .carte { padding: 12px; }
  .bouton { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===========================================================================
   Version 2 : vivarium, saisie guidée, boîtes de dialogue
   =========================================================================== */

.visuel-cache {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.colonne-droite { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.entete-titre { flex: 1; min-width: 0; }
.bouton-clair { background: #fff; color: var(--sapin-fonce); border-bottom-color: #cfe3dc; }
.bouton-clair:hover { background: #f2fbf7; }
.bouton-petit { min-height: 38px; padding: 4px 12px; font-size: 0.92rem; border-radius: 12px; border-bottom-width: 3px; }
.bouton-danger { background: #fff; color: #b3341c; border: 2px solid #f0b9ad; border-bottom-width: 3px; }
.bouton-danger:hover { background: var(--erreur-fond); }
.bouton:disabled { cursor: not-allowed; }

.bandeau {
  background: var(--soleil);
  color: var(--encre);
  padding: 8px 16px;
  display: flex; gap: 12px; justify-content: center; align-items: center;
  font-weight: 700;
}

.vide-code {
  margin: 0 0 14px;
  padding: 14px 16px;
  background: var(--ciel);
  border-radius: 14px;
  color: var(--encre);
}
.carte-code:not(.sans-creature) .vide-code { display: none; }
.carte-code.sans-creature #atelier { display: none; }

/* ---------------------------------------------------------------- onglets */

.onglets { display: flex; gap: 6px; margin: 0 0 10px; }
.onglet {
  flex: 1;
  font: inherit; font-weight: 800;
  color: var(--encre);
  background: #e1ece8;
  border: 2px solid transparent;
  border-radius: 14px;
  min-height: 46px;
  padding: 6px 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.onglet:hover { background: #d3e3dd; }
.onglet[aria-selected="true"] { background: var(--sapin); color: #fff; }

.carte-code[data-mode="guide"] #zone-ecrire .editeur { height: clamp(150px, 22vh, 220px); }
.carte-code[data-mode="guide"] #zone-ecrire .gouttiere { opacity: 0.8; }
.carte-code[data-mode="guide"] #code { background: rgba(220, 236, 230, 0.45); cursor: default; }
.carte-code[data-mode="guide"] .etiquette-code { margin-top: 12px; }
.carte-code[data-mode="ecrire"] .etiquette-code { display: none; }

/* ---------------------------------------------------------- saisie guidée */

.panneau {
  max-height: min(60vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  display: grid; gap: 8px;
  align-content: start;
}

.panneau-entete { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 2px 2px 4px; }

.sec { border: 2px solid var(--trait); border-radius: 14px; background: #f7fbf9; }
.sec[open] { border-color: #cfe3dc; }
.sec summary {
  list-style: none;
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 14px;
  min-height: 48px;
  cursor: pointer;
  font-weight: 800;
  border-radius: 12px;
}
.sec summary::-webkit-details-marker { display: none; }
.sec summary::after { content: "▾"; color: var(--encre-douce); margin-left: 4px; transition: transform 0.15s; }
.sec[open] summary::after { transform: rotate(180deg); }
.sec summary:hover { background: #eaf3ef; }
.sec-resume { margin-left: auto; font-weight: 600; color: var(--encre-douce); font-size: 0.92rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sec-contenu { padding: 4px 14px 14px; display: grid; gap: 12px; }

.reglage-titre { font-size: 0.88rem; font-weight: 800; color: var(--encre-douce); margin-bottom: 4px; display: block; }
.aide { margin: 0; color: var(--encre-douce); font-size: 0.9rem; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: inherit; font-weight: 700; font-size: 0.95rem;
  color: var(--encre);
  background: #fff;
  border: 2px solid var(--trait);
  border-radius: 999px;
  min-height: 44px;
  padding: 6px 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.chip:hover { border-color: var(--sapin); }
.chip[aria-pressed="true"] { background: var(--sapin); border-color: var(--sapin-fonce); color: #fff; }
.chip.defaut:not([aria-pressed="true"]) { border-style: dashed; border-color: #8fa8a1; }
.chip:disabled { opacity: 0.45; cursor: not-allowed; }
.chip-danger { color: #b3341c; border-color: #f0b9ad; }
.chip-danger:hover { background: var(--erreur-fond); border-color: var(--erreur-trait); }

.chip-forme { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 14px; padding: 4px 8px 6px; min-width: 76px; }
.vignette-forme { display: block; width: 56px; height: 56px; }
.vignette-forme svg { width: 100%; height: 100%; display: block; }

.pastilles { display: flex; flex-wrap: wrap; gap: 8px; }
.pastille {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--c);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px var(--trait);
  cursor: pointer;
  touch-action: manipulation;
  padding: 0;
}
.pastille:hover { box-shadow: 0 0 0 3px var(--sapin); }
.pastille[aria-pressed="true"] { box-shadow: 0 0 0 4px var(--sapin); }
.pastille.defaut:not([aria-pressed="true"]) { box-shadow: 0 0 0 2px #8fa8a1; border-style: dotted; border-color: rgba(255,255,255,0.7); }

.pas { display: inline-flex; align-items: center; gap: 8px; }
.pas output { min-width: 2ch; text-align: center; font-size: 1.3rem; font-weight: 800; }
.bouton-pas {
  font: inherit; font-size: 1.3rem; font-weight: 800; line-height: 1;
  width: 44px; height: 44px;
  border-radius: 50%;
  color: #fff; background: var(--sapin);
  border: 0; border-bottom: 3px solid var(--sapin-fonce);
  cursor: pointer;
  touch-action: manipulation;
}
.bouton-pas:hover { background: #247f69; }
.bouton-pas:disabled { opacity: 0.35; cursor: not-allowed; }
.bouton-corbeille { background: #fff; color: #b3341c; border: 2px solid #f0b9ad; font-size: 1.05rem; flex: none; }
.bouton-corbeille:hover { background: var(--erreur-fond); }

.curseur { width: 100%; height: 44px; accent-color: var(--sapin); cursor: pointer; margin: 0; touch-action: pan-y; }
.curseur.defaut { accent-color: #7f9892; }
.crans { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--encre-douce); margin-top: -4px; gap: 2px; }
.crans span { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.crans .ici { color: var(--sapin-fonce); font-weight: 800; }
.valeur-curseur { color: var(--sapin-fonce); text-transform: none; margin-left: 6px; }

.acc { border: 2px solid var(--trait); border-radius: 12px; }
.acc.present { border-color: #cfe3dc; background: #fbfdfc; }
.bascule {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  font: inherit; font-weight: 700; text-align: left;
  color: var(--encre); background: transparent;
  border: 0; border-radius: 12px;
  min-height: 48px; padding: 6px 12px;
  cursor: pointer;
  touch-action: manipulation;
}
.bascule:hover { background: #eaf3ef; }
.bascule-case {
  flex: none;
  width: 26px; height: 26px;
  border: 2px solid #8fa8a1; border-radius: 8px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; background: #fff;
}
.bascule[aria-pressed="true"] .bascule-case { background: var(--sapin); border-color: var(--sapin-fonce); }
.acc-corps { padding: 2px 14px 14px; display: grid; gap: 12px; }

.traits { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.trait {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 8px; align-items: center; text-align: left;
  font: inherit; color: var(--encre); background: #fff;
  border: 2px solid var(--trait); border-radius: 14px;
  padding: 8px 10px; min-height: 56px;
  cursor: pointer; touch-action: manipulation;
}
.trait:hover { border-color: var(--sapin); }
.trait[aria-pressed="true"] { background: var(--sapin); color: #fff; border-color: var(--sapin-fonce); }
.trait-icone { grid-row: 1 / 3; font-size: 1.6rem; }
.trait-nom { font-weight: 800; }
.trait-aide { font-size: 0.78rem; opacity: 0.8; }

.champ-nom { display: flex; gap: 8px; align-items: center; }
.champ-nom input, #pan-classe, .champ-lien {
  flex: 1; min-width: 0;
  font: inherit; color: var(--encre);
  background: #fff;
  border: 2px solid var(--trait); border-radius: 12px;
  padding: 8px 12px; min-height: 46px;
}
#pan-classe { width: 100%; margin-bottom: 8px; }
.champ-nom input:focus, #pan-classe:focus, .champ-lien:focus { border-color: var(--sapin); outline: none; }
.chips-suggestions .chip { min-height: 38px; padding: 4px 12px; font-size: 0.9rem; }

.attire { animation: attire 1.3s ease-out; }
@keyframes attire { 0%, 40% { background: var(--partie-fond); box-shadow: 0 0 0 6px var(--partie-fond); } 100% { background: transparent; box-shadow: none; } }

/* les phrases du comportement */
.regles { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.regle {
  display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center;
  padding: 8px 10px;
  background: #fff;
  border: 2px solid var(--trait); border-left-width: 6px;
  border-radius: 12px;
}
.regle-fond { border-left-color: var(--sapin); }
.regle-evenement { border-left-color: var(--corail); }
.regle-temps { border-left-color: var(--conseil-trait); }
.regle select, .regle input[type="number"] {
  font: inherit; color: var(--encre);
  background: #f7fbf9;
  border: 2px solid var(--trait); border-radius: 10px;
  min-height: 44px; padding: 4px 8px;
  max-width: 100%;
}
.regle input[type="number"] { width: 4.5em; }
.regle select:focus, .regle input:focus { border-color: var(--sapin); outline: none; }
.regle .mot { font-weight: 700; color: var(--encre-douce); }
.regle .fleche { font-weight: 800; color: var(--encre-douce); }
.regle .bouton-corbeille { margin-left: auto; }
.regle-ajout { margin-top: 2px; }

/* la ligne qui vient d'être écrite par un clic */
.surcouche .flash { background: var(--partie-fond); box-shadow: inset 4px 0 0 var(--soleil); animation: eclat 1.4s ease-out; }
@keyframes eclat { from { background: #ffe38f; } to { background: var(--partie-fond); } }

/* ------------------------------------------------------------- le vivarium */

.vivarium-entete { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.choix-vivarium {
  flex: 1 1 140px; min-width: 0;
  font: inherit; font-weight: 800; color: var(--encre);
  background: #fff;
  border: 2px solid var(--trait); border-radius: 12px;
  min-height: 46px; padding: 4px 10px;
}
.choix-vivarium:focus { border-color: var(--sapin); outline: none; }

.vivarium { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; touch-action: manipulation; }
.vivarium .vc { cursor: pointer; }
.vivarium .selection { stroke: var(--corail); }
.vivarium .emojis text { paint-order: stroke; stroke: rgba(255, 255, 255, 0.9); stroke-width: 4px; }

.scene-vide {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
  margin: 0; padding: 20px;
  font-size: 1.25rem; font-weight: 800; color: var(--encre-douce);
  pointer-events: none;
}
.scene.avec-creatures .scene-vide { display: none; }

.scene-outils { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 8px; }
.bouton-rond {
  width: 44px; height: 44px;
  border-radius: 50%;
  font-size: 1.15rem; line-height: 1;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid var(--trait);
  cursor: pointer;
  touch-action: manipulation;
}
.bouton-rond:hover { border-color: var(--sapin); background: #fff; }

.liste-entete { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; }
.compteur { font-size: 0.9rem; font-weight: 800; color: var(--encre-douce); }
.liste-creatures { list-style: none; margin: 0; padding: 2px 2px 6px; display: flex; gap: 8px; overflow-x: auto; min-height: 20px; }
.liste-creatures:empty::after { content: "Aucune créature pour l'instant."; color: var(--encre-douce); font-size: 0.92rem; }
.puce-creature {
  flex: none; width: 78px;
  font: inherit; font-size: 0.8rem; font-weight: 700; color: var(--encre);
  background: #e6f0ec;
  border: 2px solid var(--trait); border-radius: 10px;
  padding: 3px 3px 4px;
  cursor: pointer; text-align: center;
  touch-action: manipulation;
}
.puce-creature:hover { border-color: var(--sapin); background: #fff; }
.puce-creature[aria-pressed="true"] { border-color: var(--corail); background: #fff; box-shadow: 0 0 0 2px var(--corail) inset; }
.puce-creature svg { display: block; width: 100%; height: auto; aspect-ratio: 1; }
.puce-creature span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.statut { margin: 6px 0 0; min-height: 1.4em; font-weight: 700; color: var(--sapin-fonce); font-size: 0.95rem; }
.statut.alerte { color: #b3341c; }

/* la créature choisie, en grand */
.apercu-contenu { display: grid; grid-template-columns: minmax(150px, 230px) 1fr; gap: 14px; align-items: center; }
.apercu { max-width: none; }
.legende { text-align: left; margin: 0; }
.indice { text-align: left; min-height: 3.6em; }
.barre-apercu { justify-content: flex-start; margin: 8px 0 0; }
.carte-apercu h2 { margin-bottom: 10px; }
.carte-apercu.vide .apercu svg { opacity: 0.25; }

/* vivarium agrandi (surtout pour les téléphones) */
body.vivarium-agrandi { overflow: hidden; }
body.vivarium-agrandi .carte-vivarium {
  position: fixed; inset: 0; z-index: 50;
  border-radius: 0; border: 0;
  overflow: auto;
  display: flex; flex-direction: column;
  padding-top: max(12px, env(safe-area-inset-top));
}
body.vivarium-agrandi .carte-vivarium .scene { flex: none; }
/* agrandi : le vivarium prend toute la place disponible, sans dépasser l'écran (rapport 4 : 3) */
body.vivarium-agrandi .carte-vivarium .scene { width: min(100%, calc((100dvh - 190px) * 4 / 3)); margin-inline: auto; }
/* plein écran du navigateur (ordinateur, télé) : seul le vivarium reste, au plus grand */
body.plein-ecran .carte-vivarium {
  display: grid; grid-template-columns: clamp(250px, 26vw, 470px) minmax(0, 1fr); align-items: center;
  padding: 0; background: #0b1618; overflow: hidden;
}
body.plein-ecran .carte-vivarium .vivarium-entete,
body.plein-ecran .carte-vivarium .bandeau-salle,
body.plein-ecran .carte-vivarium .liste-entete,
body.plein-ecran .carte-vivarium .liste-creatures { display: none; }
body.plein-ecran .carte-vivarium .scene { grid-column: 2; width: min(100%, calc(100dvh * 4 / 3)); margin-inline: auto; border-radius: 0; border: 0; }

/* le panneau de gauche du plein écran : choix du vivarium, toutes les créatures, QR code de la salle */
.panneau-plein { display: none; }
body.plein-ecran .panneau-plein {
  display: flex; flex-direction: column; gap: 10px; grid-column: 1; grid-row: 1; align-self: stretch;
  box-sizing: border-box; padding: clamp(10px, 2vh, 22px); min-height: 0; overflow: hidden;
  background: linear-gradient(180deg, #102326, #0b1618); border-right: 2px solid #1d3a3d; color: #cfe9e2;
  font-size: clamp(13px, 1.9vh, 22px);
}
.pp-titre { margin: 0; font-weight: 800; font-size: 1.5em; color: #fff; letter-spacing: 0.02em; }
.panneau-plein .choix-vivarium { flex: none; width: 100%; height: auto; min-height: 0; font-size: 1em; padding: 6px 10px; }
.pp-compte { margin: 0; font-family: var(--police-code); color: #8fc7ba; font-size: 0.9em; }
.pp-liste { list-style: none; margin: 0; padding: 0; flex: 1 1 0; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr)); align-content: start; gap: 5px; }
.pp-puce {
  display: flex; align-items: center; gap: 6px; width: 100%; box-sizing: border-box; padding: 3px 6px 3px 3px; font-size: 0.9em;
  background: rgba(255, 255, 255, 0.07); border: 2px solid transparent; border-radius: 12px; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.pp-puce:hover { background: rgba(255, 255, 255, 0.13); }
.pp-puce[aria-pressed="true"] { border-color: var(--corail); background: rgba(255, 106, 61, 0.14); }
.pp-puce svg { flex: none; width: 2.6em; height: 2.6em; border-radius: 8px; background: rgba(255, 255, 255, 0.92); }
.pp-puce .pp-qui { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.pp-puce .pp-qui strong { font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-puce .pp-qui small { opacity: 0.7; font-size: 0.75em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-salle { flex: none; text-align: center; padding-top: 10px; border-top: 2px solid #1d3a3d; }
.pp-salle[hidden] { display: none; }
.pp-qr { display: grid; place-items: center; background: #fff; border-radius: 14px; padding: 8px; width: fit-content; margin: 0 auto; }
.pp-qr canvas { width: min(100%, 21vh, 280px); height: auto; aspect-ratio: 1; display: block; image-rendering: pixelated; min-width: 120px; }
.pp-nom { margin: 8px 0 0; font-weight: 800; color: #fff; font-size: 1.15em; }
.pp-code { margin: 2px 0 0; font-family: var(--police-code); font-size: 1.6em; letter-spacing: 0.25em; color: #7ef0bd; }
.pp-joueurs { margin: 2px 0 0; font-size: 0.9em; opacity: 0.8; }

/* ------------------------------------------------------------------ dialogues */

.dialogue {
  border: 0; border-radius: 20px; padding: 0;
  max-width: min(520px, calc(100vw - 24px));
  width: 100%;
  color: var(--encre);
  background: var(--carte);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.dialogue::backdrop { background: rgba(20, 40, 36, 0.55); }
.dialogue-corps { padding: 20px; display: grid; gap: 16px; }
.dialogue h2 { margin: 0; font-size: 1.3rem; }
.dialogue-bloc { display: grid; gap: 8px; }
.dialogue-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.champ-lien { width: 100%; font-family: var(--police-code); font-size: 0.8rem; }

@media (max-width: 520px) {
  .apercu-contenu { grid-template-columns: 110px 1fr; gap: 10px; }
  .vignette-forme { width: 48px; height: 48px; }
  .chip-forme { min-width: 66px; }
  .sec-resume { max-width: 45%; }
}

@media (prefers-reduced-motion: reduce) {
  .attire, .surcouche .flash { animation: none !important; }
}

/* petits écrans : le vivarium d'abord, puis la créature en grand, puis la zone de code
   (placé en fin de fichier pour l'emporter sur la disposition en colonnes) */
@media (max-width: 900px) {
  .colonne-droite { display: contents; }
}
.panneau { grid-template-columns: minmax(0, 1fr); }
.sec, .sec-contenu, .acc, .acc-corps, .reglage, .dialogue-bloc { min-width: 0; }

/* ------------------------------------------- aide à la saisie, vocabulaire */

.outils-code { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.interrupteur { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 700; font-size: 0.92rem; color: var(--encre); cursor: pointer; }
.interrupteur input { width: 22px; height: 22px; accent-color: var(--sapin); cursor: pointer; }
.aide-code { margin-top: 6px; font-size: 0.82rem; }
.carte-code[data-aide="non"] .aide-code { display: none; }

.editeur-boite { position: relative; }
.suggestions {
  position: absolute;
  z-index: 20;
  margin: 0;
  padding: 4px;
  list-style: none;
  min-width: 190px;
  max-width: min(360px, 92%);
  max-height: 230px;
  overflow-y: auto;
  background: #fff;
  border: 2px solid var(--sapin);
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(20, 40, 36, 0.22);
}
.suggestions li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--police-code);
  font-size: 15px;
  white-space: nowrap;
}
.suggestions li small { font-family: var(--police); font-size: 0.78rem; color: var(--encre-douce); overflow: hidden; text-overflow: ellipsis; }
.suggestions li[aria-selected="true"] { background: var(--sapin); color: #fff; }
.suggestions li[aria-selected="true"] small { color: #d8efe8; }

.dialogue-large { max-width: min(720px, calc(100vw - 24px)); width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.dialogue-large .dialogue-corps { max-height: calc(100dvh - 24px); grid-template-rows: auto auto auto auto minmax(0, 1fr) auto; }
.vocab-recherche input {
  width: 100%; font: inherit; padding: 10px 14px; min-height: 44px;
  border: 2px solid var(--trait); border-radius: 12px; background: #fff; color: var(--encre);
}
.vocab-recherche input:focus-visible { border-color: var(--sapin); outline: 0; }
.vocab-sujets { display: flex; flex-wrap: wrap; gap: 6px; }
.vocab-sujets button {
  font: inherit; font-size: 0.85rem; font-weight: 700; padding: 4px 12px; min-height: 36px;
  border: 2px solid var(--trait); border-radius: 999px; background: #fff; color: var(--encre); cursor: pointer;
}
.vocab-sujets button[aria-pressed="true"] { background: var(--sapin); border-color: var(--sapin-fonce); color: #fff; }
.vocab-liste { overflow-y: auto; min-height: 0; display: grid; gap: 18px; align-content: start; padding-right: 4px; }
.vocab-section { display: grid; gap: 8px; min-width: 0; }
.vocab-section h3 { margin: 0; font-size: 1.05rem; }
.vocab-groupe { display: grid; gap: 6px; }
.vocab-groupe h4 { margin: 0; font-size: 0.82rem; color: var(--encre-douce); text-transform: uppercase; letter-spacing: 0.05em; }
.vocab-mots { display: flex; flex-wrap: wrap; gap: 6px; }
.vocab-mot {
  font-family: var(--police-code); font-size: 0.92rem; padding: 4px 10px; min-height: 36px;
  border: 2px solid var(--trait); border-radius: 10px; background: #f7fbf9; color: var(--encre); cursor: pointer; text-align: left;
}
.vocab-mot:hover { border-color: var(--sapin); background: #fff; }
.vocab-mot small { font-family: var(--police); color: var(--encre-douce); margin-left: 4px; }
.vocab-vide { color: var(--encre-douce); }

/* bibliothèque repliable */
.bibliotheque > summary {
  display: flex; align-items: center; gap: 8px; margin: 0 0 8px; min-height: 36px;
  cursor: pointer; list-style: none; user-select: none;
}
.bibliotheque > summary::-webkit-details-marker { display: none; }
.bibliotheque > summary::before {
  content: ""; width: 0; height: 0; flex: none;
  border-left: 8px solid var(--encre-douce); border-top: 6px solid transparent; border-bottom: 6px solid transparent;
  transition: transform 0.15s;
}
.bibliotheque[open] > summary::before { transform: rotate(90deg); }
.bibliotheque:not([open]) > summary { margin-bottom: 0; }
.bibliotheque > summary:focus-visible { outline: 3px solid var(--soleil); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .bibliotheque > summary::before { transition: none; } }

/* ===========================================================================
   Laboratoire : une paillasse sombre, des instruments clairs, des étiquettes
   de spécimens. Mise en page resserrée : tout ce qui sert tient à l'écran.
   =========================================================================== */

body {
  background:
    linear-gradient(rgba(94, 242, 176, 0.045) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(94, 242, 176, 0.045) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(120% 80% at 50% 0%, #17302f 0%, #0e1a1d 60%) fixed,
    #0e1a1d;
  background-attachment: scroll, scroll, fixed, fixed;
  font-size: 16px;
}

/* ---- l'entête : une barre d'instrument */
.entete {
  background: linear-gradient(#142a2b, #0c1719);
  border-bottom: 3px solid #5ef2b0;
  position: relative;
  padding-block: 8px;
}
.entete::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -9px; height: 6px;
  background: repeating-linear-gradient(-45deg, #ffd24a 0 12px, #1a2a2c 12px 24px);
  opacity: 0.9;
}
.entete-contenu { max-width: 1560px; gap: 12px; }
.logo { width: 40px; height: 40px; background: #0b1416; box-shadow: 0 0 0 2px #5ef2b0, 0 0 14px rgba(94, 242, 176, 0.55); }
.entete h1 { font-family: var(--police-code); font-size: 1.2rem; letter-spacing: 0.14em; text-transform: uppercase; color: #5ef2b0; text-shadow: 0 0 10px rgba(94, 242, 176, 0.5); }
.devise { font-size: 0.85rem; color: #a9cfc6; opacity: 1; margin: 0; }
.entete-titre { min-width: 0; }
.entete .bouton-clair { margin-left: auto; }

/* ---- la page : plus large, moins de marges */
.page { max-width: 1560px; padding: 20px 10px 18px; }
.grille { gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.pied { color: #7fa59c; margin-top: 12px; font-size: 0.82rem; }

/* ---- les instruments (cartes) : coins vissés */
.carte {
  padding: 10px 12px 12px;
  border: 2px solid #2d4a4b;
  border-radius: 12px;
  background: linear-gradient(#f6faf8, #ebf3ef);
  box-shadow: 0 0 0 1px #0a1315, 0 10px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 #fff;
  position: relative;
}
.carte::before, .carte::after {
  content: ""; position: absolute; top: 7px; width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #9db3ad 55%, #6b827c);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.carte::before { left: 7px; }
.carte::after { right: 7px; }
.carte h2, .etiquette, .reglage-titre {
  font-family: var(--police-code);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.carte h2 { margin: 0 0 8px; padding: 0 16px; font-size: 0.82rem; font-weight: 800; color: #0a5c51; }
.etiquette { font-size: 0.74rem; color: #3f5c5a; }

/* ---- boutons plus nets */
.bouton { border-radius: 9px; min-height: 40px; padding: 5px 13px; font-size: 0.95rem; border-bottom-width: 3px; }
.bouton-petit { min-height: 34px; padding: 3px 11px; font-size: 0.88rem; }
.bouton-de { background: #ff6a3d; border-bottom-color: #c9461f; }
.barre-outils { gap: 8px; margin-bottom: 8px; }
.bouton-discret { background: #dfebe6; border-bottom-color: #bcd0c8; }

/* ---- la banque de spécimens : plus petite */
.bibliotheque { margin-bottom: 8px; }
.bibliotheque > summary { margin-bottom: 4px; min-height: 28px; }
.bibliotheque-liste { padding: 2px 2px 4px; gap: 6px; }
.vignette { width: 70px; font-size: 0.74rem; padding: 3px 3px 4px; border-radius: 9px; }
.puce-creature { width: 62px; font-size: 0.72rem; border-radius: 9px; }

/* ---- les onglets : un commutateur */
.onglets { gap: 0; margin-bottom: 8px; background: #cfdfd9; padding: 3px; border-radius: 11px; }
.onglet { min-height: 38px; border-radius: 8px; background: transparent; font-size: 0.92rem; }
.onglet:hover { background: rgba(255, 255, 255, 0.5); }
.onglet[aria-selected="true"] { background: #0f7b6c; box-shadow: 0 2px 0 #0a5c51, 0 0 12px rgba(94, 242, 176, 0.45); }

.panneau-entete { padding: 0 2px 2px; }
.sec { border-radius: 10px; }
.sec summary { padding-block: 8px; }
.sec-contenu { padding: 2px 12px 12px; }
.vide-code { margin: 4px 0 0; }

/* ---- le vivarium : un bac vitré */
.carte-vivarium {
  background: linear-gradient(#1a3133, #101f21);
  border-color: #3a6466;
  color: #cfe9e2;
}
.carte-vivarium .etiquette, .carte-vivarium .compteur { color: #8fc7ba; }
.vivarium-entete { margin-bottom: 8px; padding: 0 16px; }
.choix-vivarium { min-height: 38px; border-radius: 9px; background: #0c1719; color: #d8f4ec; border-color: #3a6466; font-family: var(--police-code); font-size: 0.9rem; }
.carte-vivarium .bouton-discret { background: #1f3d3f; color: #cfeee6; border-bottom-color: #0c1a1b; }
.carte-vivarium .bouton-discret:hover { background: #29504f; }
.carte-vivarium .scene {
  border: 3px solid #0a1315;
  border-radius: 10px;
  box-shadow: 0 0 0 2px #4b7f7f, inset 0 0 30px rgba(0, 0, 0, 0.35), 0 0 22px rgba(94, 242, 176, 0.12);
}
/* reflet de verre */
.carte-vivarium .scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 22%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.07) 100%);
}
.carte-vivarium .scene-outils { z-index: 2; }
.carte-vivarium .liste-entete { margin-top: 8px; }
.carte-vivarium .statut { margin-top: 2px; min-height: 1.2em; font-size: 0.88rem; color: #7ef0bd; }
.carte-vivarium .statut.alerte { color: #ff9a80; }
.carte-vivarium .liste-creatures:empty::after { color: #8fc7ba; }
.carte-vivarium .puce-creature { background: #223f41; border-color: #3a6466; color: #d8f4ec; }
.carte-vivarium .puce-creature[aria-pressed="true"] { border-color: #ff6a3d; box-shadow: 0 0 0 2px #ff6a3d inset; }
.carte-vivarium .puce-creature svg { background: #dfece7; border-radius: 6px; }
.scene-vide { color: #5a7a76; }
.bouton-rond { width: 38px; height: 38px; font-size: 1rem; background: rgba(12, 23, 25, 0.82); border-color: #3a6466; color: #fff; }
.bouton-rond:hover { background: #0c1719; border-color: #5ef2b0; }

/* ---- le spécimen choisi : une fiche compacte */
.carte-apercu h2 { margin-bottom: 6px; }
.apercu-contenu { grid-template-columns: 112px 1fr; gap: 12px; }
.scene-apercu { padding: 4px; }
.carte-apercu .scene { border-radius: 10px; }
.indice { min-height: 0; font-size: 0.9rem; }
.legende { font-size: 1rem; }
.barre-apercu { justify-content: flex-start; margin-top: 6px; }

/* ---- bureau : le vivarium reste en vue pendant qu'on règle la créature */
@media (min-width: 901px) {
  .colonne-droite { position: sticky; top: 14px; gap: 12px; max-height: calc(100dvh - 28px); }
  .carte-vivarium .scene { width: min(100%, calc((100dvh - 330px) * 4 / 3)); margin-inline: auto; }
  .carte-vivarium .vivarium { width: 100%; }
  .liste-creatures { padding-bottom: 2px; }
}
@media (min-width: 901px) and (max-height: 700px) {
  .carte-apercu .indice { display: none; }
}

@media (max-width: 900px) {
  .grille { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 14px 8px 14px; }
  .entete .devise { display: none; }
  .vivarium-entete { padding: 0 14px; }
}
@media (max-width: 520px) {
  .entete h1 { font-size: 1.05rem; letter-spacing: 0.1em; }
  .carte { padding: 10px; }
  .bouton { flex: 0 1 auto; }
  .barre-outils .bouton { flex: 1 1 auto; }
}

/* fiche du spécimen choisi : une seule rangée basse */
.carte-apercu { padding-block: 8px 10px; }
.apercu-contenu { grid-template-columns: 76px 1fr; gap: 10px; align-items: start; }
.carte-apercu .scene-apercu { padding: 2px; }
.apercu-texte { min-width: 0; }
.legende { margin: 0; line-height: 1.2; }
.indice { margin: 2px 0 0; font-size: 0.82rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.barre-apercu { margin-top: 4px; gap: 6px; }
.barre-apercu .bouton { min-height: 30px; padding: 2px 10px; font-size: 0.82rem; }
@media (min-width: 901px) {
  .carte-vivarium .scene { width: min(100%, calc((100dvh - 372px) * 4 / 3)); }
  .carte-apercu .indice { display: -webkit-box; }
}
@media (min-width: 901px) and (max-height: 700px) {
  .carte-apercu .indice { display: none; }
}

/* le compteur rejoint la barre du vivarium ; le message flotte sur la vitre */
.vivarium-entete .compteur { margin-left: auto; font-family: var(--police-code); font-size: 0.85rem; color: #8fc7ba; white-space: nowrap; }
.scene > .statut {
  position: absolute; left: 8px; bottom: 8px; z-index: 2; margin: 0;
  max-width: calc(100% - 150px); min-height: 0; padding: 4px 10px; border-radius: 8px;
  background: rgba(12, 23, 25, 0.88); color: #7ef0bd; font-size: 0.85rem; line-height: 1.25;
}
.scene > .statut.alerte { color: #ffb199; }
.scene > .statut:empty { display: none; }
.carte-vivarium .liste-creatures { margin-top: 8px; }
@media (min-width: 901px) {
  .carte-vivarium .scene { width: min(100%, calc((100dvh - 395px) * 4 / 3)); }
}

/* ---------------------------------------------------------- guide du laboratoire */
.entete .bouton-aide { margin-left: auto; min-height: 34px; padding: 2px 12px; font-size: 0.9rem; }
.entete .bouton-aide span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #0f7b6c; color: #fff; font-weight: 800; font-size: 0.8rem; }
.entete #bouton-installer:not([hidden]) + .bouton-aide { margin-left: 0; }
.entete .bouton-clair { margin-left: auto; }
.entete .bouton-clair + .bouton-aide { margin-left: 0; }

.dialogue-aide .dialogue-corps { max-height: calc(100dvh - 24px); grid-template-rows: auto auto minmax(0, 1fr) auto; }
.aide-texte { overflow-y: auto; min-height: 0; padding-right: 8px; max-width: 100%; }
.aide-texte:focus-visible { outline: 2px solid var(--sapin); box-shadow: none; outline-offset: 2px; }
.aide-texte section { display: grid; gap: 10px; padding-bottom: 22px; margin-bottom: 4px; border-bottom: 1px dashed var(--trait); }
.aide-texte section:last-child { border-bottom: 0; }
.aide-texte h3 { margin: 0; font-size: 1.15rem; color: var(--sapin-fonce); }
.aide-texte h4 { margin: 6px 0 0; font-family: var(--police-code); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--encre-douce); }
.aide-texte p, .aide-texte li, .aide-texte dd { max-width: 68ch; margin: 0; }
.aide-texte ul, .aide-texte ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.aide-texte code, .aide-texte kbd { font-family: var(--police-code); font-size: 0.9em; background: #e1ece8; border-radius: 5px; padding: 1px 6px; }
.aide-texte kbd { border: 1px solid #b7cbc4; border-bottom-width: 2px; background: #fff; }
.aide-texte pre.exemple {
  margin: 0; padding: 12px 14px; overflow-x: auto; border-radius: 10px;
  background: #112124; color: #d5f3ea; font-family: var(--police-code); font-size: 0.9rem; line-height: 1.5;
  border-left: 4px solid #5ef2b0;
}
.aide-essayer { justify-self: start; }
.mots { margin: 0; display: grid; grid-template-columns: minmax(90px, max-content) minmax(0, 1fr); gap: 6px 14px; }
.mots dt { font-family: var(--police-code); font-weight: 800; color: var(--sapin-fonce); font-size: 0.92rem; }
.mots dd { margin: 0; }
@media (max-width: 520px) {
  .mots { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .mots dd { margin-bottom: 8px; }
}
.dialogue-aide .vocab-sujets { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.dialogue-aide .vocab-sujets button { flex: none; white-space: nowrap; }

/* ------------------------------------------- barre de touches (sans clavier physique) */

.barre-touches {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px;
  margin-bottom: 6px;
  background: #e3eeea;
  border: 2px solid var(--trait);
  border-radius: 12px;
}
.touches-liste { display: contents; }
.touches-liste[hidden] { display: none !important; }
.touche {
  min-width: 40px;
  min-height: 40px;
  padding: 2px 10px;
  font: 700 1.05rem var(--police-code);
  color: var(--encre);
  background: #fff;
  border: 2px solid var(--trait);
  border-bottom-width: 4px;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.touche:active { transform: translateY(2px); border-bottom-width: 2px; }
.touche-mots, .touche[data-touche="tab"] { font-family: var(--police); font-size: 0.92rem; }
.touche-mots { background: var(--soleil); border-color: #e0b443; }
.touche-ok { font-family: var(--police); font-size: 0.92rem; background: var(--sapin); border-color: var(--sapin-fonce); color: #fff; }
.carte-code[data-aide="non"] .touche-mots { opacity: 0.75; }

/* sur un écran tactile, les raccourcis clavier ne servent à rien */
@media (hover: none) and (pointer: coarse) {
  .seulement-clavier { display: none; }
  .suggestions li { padding: 10px 12px; min-height: 40px; align-items: center; }
}
@media (hover: hover) and (pointer: fine) {
  .barre-touches { padding: 4px; gap: 4px; }
  .touche { min-height: 32px; min-width: 34px; font-size: 0.95rem; border-bottom-width: 3px; }
}

/* ---------------------------------------------------------- installer l'application */
.entete .bouton-installer { margin-left: auto; min-height: 34px; padding: 2px 12px; font-size: 0.9rem; white-space: nowrap; }
.entete .bouton-installer + .bouton-aide { margin-left: 0; }
.installer-court { display: none; }
@media (max-width: 640px) {
  .installer-long { display: none; }
  .installer-court { display: inline; }
}
@media (max-width: 420px) {
  .entete .devise { display: none; }
  .entete h1 { font-size: 1.05rem; letter-spacing: 0.06em; }
  .entete-contenu { gap: 8px; }
  .entete .bouton-installer, .entete .bouton-aide { padding: 2px 10px; }
}
.entete-titre { overflow: hidden; }
.installer-etapes, .installer-liste { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.installer-etapes li::marker { font-weight: 800; color: var(--sapin-fonce); }
.installer-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fff4d6; border-left: 4px solid #ffd24a; }
.installer-autres summary { cursor: pointer; font-weight: 700; color: var(--sapin-fonce); }
.installer-autres[open] summary { margin-bottom: 8px; }
@media (max-width: 360px) {
  .entete .installer-court { display: none; }
}

/* ---------------------------------------------------------- carte « installer l'appli » */
.carte-installer { max-width: 1560px; margin: 0 auto 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start; background: var(--ciel); border-radius: 14px; color: var(--encre); }
.carte-installer[hidden] { display: none; }
.carte-installer-texte { flex: 1; min-width: 0; }
.carte-installer-texte p { margin: 0 0 6px; }
.carte-installer-titre { font-weight: 800; }
.carte-installer-croix { flex: none; min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: inherit; font-size: 1.1rem; cursor: pointer; }
.carte-installer-croix:hover { background: rgba(0, 0, 0, 0.08); }

/* ---------------------------------------------------------- la saisie par blocs */
.carte-code[data-mode="ecrire"] #zone-blocs { display: none; }
@media (max-width: 480px) {
  .onglet { padding-inline: 4px; font-size: 0.8rem; }
}
.blocs { gap: 14px; }
.pile { display: grid; gap: 4px; align-content: start; min-width: 0; }
.blocs-regles { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bloc-regle { display: grid; gap: 0; min-width: 0; }
.bloc {
  --b: #3d8bd9; --b-fonce: #2a69a8;
  position: relative;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 8px 40px 10px 12px;
  background: var(--b); color: #fff;
  border-radius: 8px; border-bottom: 4px solid var(--b-fonce);
  min-width: 0;
}
.bloc-chapeau { --b: #e0a800; --b-fonce: #b38600; border-radius: 22px 22px 8px 8px; padding-right: 12px; color: #241a00; }
.bloc-corps { --b: #3d8bd9; --b-fonce: #2a69a8; }
.bloc-acc { --b: #2f9bb0; --b-fonce: #217587; }
.bloc-caractere { --b: #8a5fd6; --b-fonce: #6642a8; padding-right: 12px; }
.bloc-evenement { --b: #e0a800; --b-fonce: #b38600; border-radius: 18px 18px 8px 8px; color: #241a00; padding-right: 12px; flex-wrap: wrap; }
.bloc-regle-fond .bloc-evenement { --b: #2fae7a; --b-fonce: #1f8559; color: #fff; border-radius: 8px; }
.bloc-regle-temps .bloc-evenement { --b: #e8883f; --b-fonce: #b9631f; color: #fff; }
.bloc-action { --b: #e8603f; --b-fonce: #b9441f; margin-left: 22px; border-radius: 0 0 8px 8px; padding-right: 12px; }
.bloc-titre { font-weight: 800; font-size: 0.95rem; flex: none; }
.bloc-champs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 10px; min-width: 0; flex: 1; }
.bloc .champ { display: grid; gap: 1px; min-width: 0; }
.bloc .champ-nom { font-size: 0.7rem; font-weight: 700; opacity: 0.9; }
.bloc select, .bloc input[type="number"], .bloc input[type="text"] {
  font: inherit; font-size: 0.92rem; font-weight: 700; color: var(--encre);
  background: #fff; border: 2px solid rgba(0, 0, 0, 0.18); border-radius: 999px;
  min-height: 36px; padding: 2px 10px; max-width: 100%;
}
.bloc input[type="number"] { width: 4.5em; }
.bloc input[type="text"] { width: 10em; }
.bloc .pas { display: inline-flex; align-items: center; gap: 6px; background: #fff; color: var(--encre); border-radius: 999px; padding: 2px 4px; min-height: 36px; }
.bloc .pas output { min-width: 1.4em; text-align: center; font-weight: 800; }
.champ-nom-ligne { display: inline-flex; gap: 6px; align-items: center; }
.pastille-mini { align-self: flex-end; width: 22px; height: 22px; margin-bottom: 7px; border-radius: 50%; background: var(--c); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); flex: none; }
.bloc-retirer {
  position: absolute; top: 6px; right: 6px;
  min-width: 36px; min-height: 36px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.22); color: #fff; font-weight: 800; cursor: pointer;
}
.bloc-retirer:hover { background: rgba(0, 0, 0, 0.4); }
.bloc-outils { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; position: relative; padding-right: 0; }
.bloc-outils .bloc-retirer { position: static; }
.trait-bloc {
  font: inherit; font-weight: 800; font-size: 0.9rem; color: var(--encre);
  background: #fff; border: 2px solid rgba(0, 0, 0, 0.18); border-radius: 999px;
  min-height: 38px; padding: 2px 12px; cursor: pointer; touch-action: manipulation;
}
.trait-bloc[aria-pressed="true"] { background: #2b1859; color: #fff; border-color: #fff; }
.ajout-blocs { display: grid; gap: 6px; margin-top: 4px; }
.bloc.attire { animation: attire 1.3s ease-out; }
.bloc-outils { flex-basis: 100%; justify-content: flex-end; margin-left: 0; gap: 8px; }
.bloc .bouton-pas { min-width: 34px; min-height: 34px; width: 34px; height: 34px; padding: 0; }
.bloc-outils .bloc-retirer { min-width: 34px; min-height: 34px; width: 34px; height: 34px; }
.bloc-evenement .bloc-champs { flex: 1 1 60%; }
.bloc-evenement select, .bloc-action select { width: 100%; }
.bloc-evenement .champ, .bloc-action .champ { flex: 1 1 140px; }
@media (max-width: 560px) {
  .bloc-titre { flex-basis: 100%; }
}

.bloc-chapeau .champ-large { flex-basis: 100%; }
.bloc-chapeau .champ-large input { width: 100%; max-width: 20em; }
.bloc-chapeau .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }

.image-carte { display: block; width: 100%; max-width: 360px; height: auto; margin-inline: auto; border-radius: 14px; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.35); }
#dialogue-carte .dialogue-actions { flex-wrap: wrap; }

.apercu-recu { width: 180px; height: 150px; margin: 0 auto; background: #dfece7; border-radius: 16px; display: grid; place-items: center; }
.apercu-recu svg { width: 100%; height: 100%; display: block; }
#dialogue-creature-recue .choix-vivarium { width: 100%; }

/* larmes qui jaillissent quand une créature pleure */
.larme { animation: larme 1s ease-out infinite; opacity: 0; transform-box: fill-box; transform-origin: center; }
@keyframes larme {
  0% { transform: translate(0, 0) scale(0.4); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .larme { animation: none; opacity: 1; transform: translate(calc(var(--dx) * 0.35), calc(var(--dy) * 0.35)); }
}

/* l'onglet Blocs ne montre pas le code : on le retrouve dans « Écrire le code » */
.carte-code[data-mode="guide"] #zone-ecrire { display: none; }

/* blocs repliables */
.bloc-chevron { background: rgba(0, 0, 0, 0.22); color: inherit; border: 0; border-radius: 999px; width: 30px; height: 30px; min-width: 30px; padding: 0; margin-right: 4px; font-size: 0.95rem; line-height: 1; cursor: pointer; vertical-align: middle; }
.bloc-chevron:hover { background: rgba(0, 0, 0, 0.38); }
.bloc-resume { flex: 1 1 0; min-width: 0; font-size: 0.85rem; font-weight: 600; opacity: 0.92; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; align-self: center; }
.bloc-replie .bloc-champs { display: none; }
.bloc-regle-replie .bloc-action { display: none; }
.bloc-regle-replie .bloc-evenement { border-radius: 18px 18px 8px 8px; }
.bloc-regle-replie .bloc-outils { flex-basis: auto; margin-left: auto; }
@media (max-width: 560px) {
  .bloc-resume { flex-basis: 100%; white-space: normal; }
}
#dialogue-creature-recue .statut.alerte { background: #fde8e4; border-radius: 10px; padding: 8px 10px; }

#dialogue-qr .dialogue-actions { justify-content: center; }
#dialogue-qr .aide { text-align: center; }
.qr-grand { display: grid; place-items: center; background: #fff; border-radius: 16px; padding: 8px; }
.qr-canvas { width: min(86vw, 420px); height: auto; aspect-ratio: 1; image-rendering: pixelated; display: block; }

/* ---------------------------------------------------------- blocs : look moderne (1.9.3) */
.bloc {
  border-radius: 16px; border-bottom: 0;
  padding: 10px 42px 12px 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--b) 88%, #fff) 0%, var(--b) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 3px 0 var(--b-fonce), 0 8px 16px rgba(0, 0, 0, 0.18);
  transition: box-shadow 0.15s, transform 0.15s;
}
.bloc-chapeau { border-radius: 24px 24px 16px 16px; padding-right: 14px; }
.bloc-evenement { border-radius: 22px 22px 14px 14px; }
.bloc-regle-fond .bloc-evenement { border-radius: 16px; }
.bloc-action { margin-left: 26px; border-radius: 4px 4px 16px 16px; padding-right: 14px; }
.blocs-regles { gap: 14px; }
.bloc-regle { gap: 3px; }
.bloc-titre { font-size: 1rem; letter-spacing: 0.01em; }
.bloc .champ-nom { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.85; }
.bloc select, .bloc input[type="number"], .bloc input[type="text"] {
  border: 0; border-radius: 12px; min-height: 38px; padding: 2px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset;
}
.bloc select:focus-visible, .bloc input:focus-visible { outline: 3px solid rgba(255, 255, 255, 0.85); outline-offset: 1px; }
.bloc .pas { border-radius: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset; }
.bloc-retirer, .bloc-chevron { background: rgba(255, 255, 255, 0.22); backdrop-filter: blur(2px); transition: background 0.15s; }
.bloc-chapeau .bloc-retirer, .bloc-evenement .bloc-retirer, .bloc-chapeau .bloc-chevron, .bloc-evenement .bloc-chevron { background: rgba(0, 0, 0, 0.12); }
.bloc-retirer:hover, .bloc-chevron:hover { background: rgba(255, 255, 255, 0.4); }
.trait-bloc { border: 0; border-radius: 12px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) inset; }
.trait-bloc[aria-pressed="true"] { box-shadow: 0 0 0 2px #fff inset; }
.bloc-regle-replie .bloc-evenement { border-radius: 22px 22px 14px 14px; }
.pile { gap: 9px; }

/* ---------------------------------------------------------- blocs : style « pièces de puzzle » (1.9.5) */
.pile { gap: 0; }
.blocs-regles { gap: 18px; }
.bloc-regle { gap: 0; }
.bloc {
  --b: #4c97ff; --b-fonce: #3373cc;
  background: var(--b); background-image: none; color: #fff;
  border: 0; border-radius: 6px; box-shadow: none;
  padding: 12px 44px 14px 16px; margin-bottom: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
  filter: drop-shadow(1px 0 0 var(--b-fonce)) drop-shadow(-1px 0 0 var(--b-fonce)) drop-shadow(0 1px 0 var(--b-fonce)) drop-shadow(0 -1px 0 var(--b-fonce));
}
/* la languette qui s'emboîte dans le bloc suivant */
.bloc::after {
  content: ""; position: absolute; left: 18px; bottom: -7px; width: 34px; height: 7px;
  background: var(--b); z-index: 2; pointer-events: none;
  clip-path: polygon(0 0, 100% 0, calc(100% - 7px) 100%, 7px 100%);
}
.bloc-corps { --b: #4c97ff; --b-fonce: #3373cc; }
.bloc-acc { --b: #5cb1d6; --b-fonce: #2e8eb8; }
.bloc-caractere { --b: #9966ff; --b-fonce: #774dcb; }
.bloc-chapeau { --b: #ffbf00; --b-fonce: #cc9900; color: #fff; border-radius: 6px; padding-right: 16px; margin-top: 12px; }
.bloc-chapeau::before, .bloc-evenement::before {
  content: ""; position: absolute; left: 0; top: -14px; width: 96px; height: 15px; background: var(--b);
  border-radius: 80px 80px 0 0 / 15px 15px 0 0;
}
.bloc-evenement { --b: #ffbf00; --b-fonce: #cc9900; color: #fff; border-radius: 6px; margin-top: 14px; padding-right: 16px; }
.bloc-regle-fond .bloc-evenement { --b: #59c059; --b-fonce: #389438; border-radius: 6px; }
.bloc-regle-temps .bloc-evenement { --b: #ffab19; --b-fonce: #cf8b17; }
.bloc-regle-fond .bloc-evenement::before { display: none; }
.bloc-regle-fond .bloc-evenement { margin-top: 0; }
.bloc-action { --b: #ff8c1a; --b-fonce: #db6e00; margin-left: 0; border-radius: 6px; padding-right: 16px; }
.bloc-action::after { display: none; }
.bloc-regle-replie .bloc-evenement::after { display: none; }
.bloc-titre { font-size: 1rem; font-weight: 700; }
.bloc .champ-nom { text-transform: none; letter-spacing: 0; font-size: 0.72rem; font-weight: 600; opacity: 0.95; }
.bloc select, .bloc input[type="number"], .bloc input[type="text"] {
  background: #fff; color: var(--b-fonce); border: 1px solid var(--b-fonce); border-radius: 999px;
  box-shadow: none; text-shadow: none; font-weight: 700; min-height: 36px; padding: 2px 14px;
}
.bloc select { padding-right: 8px; }
.bloc .pas, .trait-bloc { background: #fff; color: var(--b-fonce); border: 1px solid var(--b-fonce); border-radius: 999px; box-shadow: none; text-shadow: none; }
.trait-bloc[aria-pressed="true"] { background: var(--b-fonce); color: #fff; box-shadow: none; border-color: #fff; }
.bloc-retirer, .bloc-chevron, .bloc-chapeau .bloc-retirer, .bloc-evenement .bloc-retirer, .bloc-chapeau .bloc-chevron, .bloc-evenement .bloc-chevron {
  background: rgba(0, 0, 0, 0.16); backdrop-filter: none; text-shadow: none;
}
.bloc-retirer:hover, .bloc-chevron:hover { background: rgba(0, 0, 0, 0.3); }
.bloc-chapeau .chips .trait-bloc { color: #cc9900; }
.bloc-regle > .bloc:last-child::after { display: none; }
.pile > .bloc:last-child::after { display: none; }
.pile { padding-top: 12px; }
.bloc::after { display: none !important; }
.bloc + .bloc::before, .bloc-regle > .bloc ~ .bloc::before {
  content: ""; position: absolute; left: 18px; top: 0; width: 34px; height: 7px; border-radius: 0;
  background: var(--b-fonce); clip-path: polygon(0 0, 100% 0, calc(100% - 7px) 100%, 7px 100%);
}

/* 1.9.5b : vraies encoches (languette en bas, pas d'ovale en haut) */
.bloc { filter: none; border: 1px solid var(--b-fonce); }
.bloc-chapeau::before, .bloc-evenement::before, .bloc-regle-fond .bloc-evenement::before { display: none; }
.bloc + .bloc::before, .bloc-regle > .bloc ~ .bloc::before { display: none; }
.bloc-chapeau, .bloc-evenement { margin-top: 0; }
.bloc::before, .bloc::after {
  content: ""; display: block !important; position: absolute; pointer-events: none;
  left: 16px; top: 100%; background: var(--b-fonce); border-radius: 0; width: 38px; height: 8px; z-index: 3;
  clip-path: polygon(0 0, 100% 0, calc(100% - 9px) 100%, 9px 100%);
}
.bloc::after { left: 17px; top: calc(100% - 1px); width: 36px; height: 8px; background: var(--b); z-index: 4;
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) calc(100% - 1px), 8px calc(100% - 1px)); }
.pile > .bloc:last-child::before, .pile > .bloc:last-child::after,
.bloc-regle > .bloc:last-child::before, .bloc-regle > .bloc:last-child::after,
.bloc-action::before, .bloc-action::after, .bloc-regle-replie .bloc-evenement::before, .bloc-regle-replie .bloc-evenement::after { display: none !important; }
.bloc-regle > .bloc + .bloc { margin-top: -1px; }
.pile > .bloc + .bloc { margin-top: -1px; }

/* 1.9.8 : boutons d'ajout = aperçu fidèle des blocs posés, avec encoches haut et bas */
.ajout-blocs .chips { gap: 16px 12px; padding-bottom: 10px; align-items: flex-start; }
.chip.chip-bloc, .chip.chip-pile { border: 0; box-shadow: none; background: none; padding: 0; min-height: 0; border-radius: 0; text-align: left; }
.chip.chip-bloc { --b: #5cb1d6; --b-fonce: #2e8eb8; position: relative; background: var(--b); color: #fff; font-weight: 700; padding: 11px 16px 11px 16px; border: 1px solid var(--b-fonce); border-radius: 6px; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.chip.chip-pile { display: inline-grid; position: relative; color: #fff; font-weight: 700; }
.pc { --b: #5cb1d6; --b-fonce: #2e8eb8; position: relative; display: block; background: var(--b); border: 1px solid var(--b-fonce); border-radius: 6px; padding: 11px 16px; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.pc + .pc { margin-top: -1px; }
.pc-fond { --b: #59c059; --b-fonce: #389438; }
.pc-ev { --b: #ffbf00; --b-fonce: #cc9900; }
.pc-temps { --b: #ffab19; --b-fonce: #cf8b17; }
.pc-act { --b: #ff8c1a; --b-fonce: #db6e00; }
/* languette en bas (::after) et creux en haut (::before) */
.chip.chip-bloc::after, .pc:not(:last-child)::after, .chip.chip-bloc::before, .pc-act::before {
  content: ""; position: absolute; left: 17px; width: 18px; height: 0; border-left: 8px solid transparent; border-right: 8px solid transparent; pointer-events: none;
}
.chip.chip-bloc::after, .pc:not(:last-child)::after {
  top: calc(100% - 1px); border-top: 7px solid var(--b); z-index: 2;
  filter: drop-shadow(0 1px 0 var(--b-fonce)) drop-shadow(1px 0 0 var(--b-fonce)) drop-shadow(-1px 0 0 var(--b-fonce));
}
.chip.chip-bloc::before, .pc-act::before { top: 0; border-top: 7px solid var(--b-fonce); z-index: 1; }
.chip.chip-bloc:hover:not(:disabled), .chip.chip-pile:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.chip.chip-bloc:active:not(:disabled), .chip.chip-pile:active:not(:disabled) { transform: translateY(1px); }
.chip.chip-bloc:disabled, .chip.chip-pile:disabled { opacity: 0.45; filter: grayscale(0.4); }
.bloc-regle-replie .bloc-evenement, .bloc-regle .bloc-evenement { border-radius: 6px; }

/* 1.11.0 : sauvegarde en ligne */
#bloc-sauvegarde { gap: 10px; }
.sv-accord { display: flex; gap: 8px; align-items: flex-start; font-size: 0.92rem; }
.sv-accord input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.sv-code { font-family: var(--police-code); font-size: 1.15rem; font-weight: 800; letter-spacing: 0.08em; word-break: break-all; margin: 0; padding: 8px 12px; background: var(--fond-doux, #eef3ef); border-radius: 10px; user-select: all; }
#sv-statut.alerte, #sv-remplacer-texte { color: #b3341c; }
#sv-statut:not(.alerte) { color: inherit; }
#bloc-sauvegarde .champ-nom input { flex: 1 1 0; min-width: 0; width: auto; }
#bloc-sauvegarde .champ-nom { min-width: 0; }

/* 1.12.0 : réglages et carte de sauvegarde */
.entete .bouton-reglages { min-height: 34px; padding: 2px 12px; font-size: 0.9rem; white-space: nowrap; margin-left: 0; }
.entete .bouton-reglages span { display: inline-grid; place-items: center; width: 20px; height: 20px; font-size: 1rem; }
@media (max-width: 420px) { .entete .bouton-reglages { padding: 2px 10px; } }
.carte-sauvegarde { background: #e3f4ec; }

/* ---------------------------------------------------------- 1.13.0 : interface modernisée (police des blocs, boutons plats) */
.entete h1 { font-family: var(--police); font-size: 1.35rem; font-weight: 800; letter-spacing: 0.01em; text-transform: none; color: #fff; text-shadow: none; }
.carte h2, .etiquette, .reglage-titre, .aide-texte h4 {
  font-family: var(--police); text-transform: none; letter-spacing: 0.01em; font-weight: 700;
}
.carte h2 { font-size: 0.95rem; }
.etiquette { font-size: 0.8rem; }
.aide-texte h4 { font-size: 0.9rem; color: var(--encre-douce); }
.choix-vivarium, .vivarium-entete .compteur { font-family: var(--police); }
.choix-vivarium { font-weight: 600; }

/* boutons plats, coins arrondis, sans bord épais */
.bouton {
  border: 0; border-radius: 10px; min-height: 42px; padding: 8px 16px; font-size: 0.95rem; font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: background-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.bouton:hover { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22); }
.bouton:active { transform: translateY(1px); box-shadow: 0 0 1px rgba(0, 0, 0, 0.3); border-bottom-width: 0; }
.bouton:disabled { border-bottom-width: 0; box-shadow: none; opacity: 0.45; }
.bouton-de { background: #ff6a3d; }
.bouton-de:hover { background: #f25a2b; }
.bouton-discret { background: #e4ede9; color: var(--encre); box-shadow: none; }
.bouton-discret:hover { background: #d6e4de; box-shadow: none; }
.bouton-clair { background: #fff; color: var(--sapin-fonce); }
.bouton-petit { min-height: 36px; padding: 4px 13px; font-size: 0.9rem; border-radius: 9px; }
.bouton-danger { border: 1px solid #f0b9ad; box-shadow: none; }
.chip { border: 1px solid var(--trait); border-radius: 10px; font-weight: 600; min-height: 40px; padding: 6px 14px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06); }
.chip:hover { border-color: var(--sapin); background: #f6fbf9; }
.chip-danger { border-color: #f0b9ad; }
.bouton-pas { box-shadow: none; }
.bouton-rond { border: 0; background: rgba(255, 255, 255, 0.94); color: var(--sapin-fonce); display: inline-grid; place-items: center; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28); }
.bouton-rond:hover { background: #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.34); }
.bouton-rond[aria-pressed="true"] { background: var(--sapin); color: #fff; }
.bouton-rond svg { display: block; }

/* onglets : un commutateur plat, l'onglet choisi est une pastille claire */
.onglets { background: #d3e1db; padding: 4px; border-radius: 12px; gap: 4px; }
.onglet { font-weight: 600; min-height: 38px; border-radius: 9px; color: var(--encre-douce); background: transparent; border: 0; }
.onglet:hover { background: rgba(255, 255, 255, 0.55); color: var(--encre); }
.onglet[aria-selected="true"] { background: #fff; color: var(--sapin-fonce); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22); font-weight: 700; }
.bouton-de svg circle { fill: #ff6a3d; }

/* ---------------------------------------------------- salle en direct (1.15) */

#sa-pseudo {
  width: 100%; font: inherit; color: var(--encre); background: #fff;
  border: 2px solid var(--trait); border-radius: 12px; padding: 8px 12px; min-height: 46px;
}
#sa-pseudo:focus { border-color: var(--sapin); outline: none; }
#dialogue-salle .champ-nom input { flex: 1 1 0; min-width: 0; text-transform: uppercase; letter-spacing: 0.2em; font-family: var(--police-code); }
.bandeau-salle {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  margin: 0 16px 8px; padding: 6px 10px; border-radius: 12px;
  background: rgba(143, 199, 186, 0.16); color: #cfe9e2; font-size: 0.9rem;
}
.bandeau-salle[hidden], .bandeau-salle [hidden] { display: none; }
.bandeau-salle .ba-code { font-family: var(--police-code); letter-spacing: 0.18em; color: #fff; }
.bandeau-salle .ba-joueurs { flex: 1 1 160px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bandeau-salle .ba-ligne { color: #ffc9a8; font-weight: 800; }
.bandeau-salle.hors-ligne { background: rgba(255, 140, 90, 0.18); }
.puce-creature small.puce-proprio { display: block; font-size: 0.72rem; font-weight: 600; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-salle { margin: 8px 0 0; padding: 8px 12px; border-radius: 10px; background: #fff4e0; color: #6a4a12; font-size: 0.9rem; font-weight: 700; }
.note-salle[hidden] { display: none; }
.carte-code.lecture-seule #code { background: #f3f1ea; color: #4a4a44; cursor: default; }
.carte-code.lecture-seule .zone-blocs,
.carte-code.lecture-seule .barre-touches,
.carte-code.lecture-seule .bibliotheque { opacity: 0.55; pointer-events: none; }
body.plein-ecran .bandeau-salle { display: none; }
.bandeau-salle .ba-nom { color: #fff; }
.bandeau-salle .ba-code { font-family: var(--police-code); letter-spacing: 0.18em; opacity: 0.8; }
#sa-nom { width: 100%; margin: 4px 0 8px; font: inherit; color: var(--encre); background: #fff; border: 2px solid var(--trait); border-radius: 12px; padding: 8px 12px; min-height: 46px; }
#sa-nom:focus { border-color: var(--sapin); outline: none; }
#nom-nouveau, #nom-vivarium-recu { width: 100%; margin: 4px 0 8px; font: inherit; color: var(--encre); background: #fff; border: 2px solid var(--trait); border-radius: 12px; padding: 8px 12px; min-height: 46px; }
#nom-nouveau:focus, #nom-vivarium-recu:focus { border-color: var(--sapin); outline: none; }
#dialogue-qr { width: min(94vw, 640px); }
#dialogue-qr .qr-canvas { width: min(76vw, calc(100dvh - 300px), 520px); min-width: 200px; }
.scan-video { width: 100%; max-height: 60vh; border-radius: 14px; background: #000; object-fit: cover; }
/* vivarium masqué sur cet appareil : il ne reste que la liste des créatures et le message d'état */
body.salle-sans-vivarium .carte-vivarium .scene { width: auto; aspect-ratio: auto; border: 0; background: none; overflow: visible; }
body.salle-sans-vivarium .carte-vivarium .scene > #vivarium,
body.salle-sans-vivarium .carte-vivarium .scene > .scene-outils,
body.salle-sans-vivarium .carte-vivarium .scene > .scene-vide { display: none; }
body.salle-sans-vivarium .carte-vivarium .scene > .statut { position: static; max-width: none; margin: 0 0 6px; }
.bandeau-salle .ba-limite { display: inline-flex; align-items: center; gap: 6px; }
.bandeau-salle .ba-limite select { font: inherit; padding: 2px 6px; border-radius: 8px; border: 0; background: #0f2427; color: #cfe9e2; }
#sa-limite { width: 100%; margin: 4px 0 8px; font: inherit; padding: 8px 12px; min-height: 46px; border-radius: 12px; border: 2px solid var(--trait); background: #fff; color: var(--encre); }

.panneau-plein .pp-qr .qr-canvas { width: min(100%, 21vh, 280px); }

.pp-liste.dense { grid-template-columns: repeat(auto-fill, minmax(6.8em, 1fr)); gap: 4px; }
.pp-liste.dense .pp-puce { font-size: 0.78em; padding: 2px 4px 2px 2px; gap: 4px; }
.pp-liste.dense .pp-puce svg { width: 2em; height: 2em; border-radius: 6px; }
.pp-liste.dense .pp-puce small { display: none; }

/* ------------------------------------------- plein écran : le laboratoire (1.22) */

/* en grand, on ne voit que le vivarium : plus rien de la page ne dépasse (plus de « parasites » sur les côtés) */
body.vivarium-agrandi *,
body.plein-ecran * { visibility: hidden; }
body.vivarium-agrandi .carte-vivarium, body.vivarium-agrandi .carte-vivarium *,
body.plein-ecran .carte-vivarium, body.plein-ecran .carte-vivarium *,
body.plein-ecran .entete, body.plein-ecran .entete *,
body.vivarium-agrandi dialog[open], body.vivarium-agrandi dialog[open] *,
body.plein-ecran dialog[open], body.plein-ecran dialog[open] * { visibility: visible; }

body.plein-ecran { --h-bandeau: 82px; }
/* le bandeau Life et sa rubalise restent en haut */
body.plein-ecran .entete { position: fixed; top: 0; left: 0; right: 0; z-index: 80; padding-block: 6px; }
body.plein-ecran .entete .bouton, body.plein-ecran .entete .bouton-clair { display: none; }
body.plein-ecran .entete-contenu { max-width: none; padding-inline: 14px; }

/* le mur du labo : carrelage, éclairage du plafond, paillasse en bas */
body.plein-ecran .carte-vivarium {
  box-sizing: border-box; padding-top: var(--h-bandeau); position: fixed; z-index: 50;
  background:
    radial-gradient(70% 55% at 50% 38%, rgba(94, 242, 176, 0.10), transparent 70%),
    linear-gradient(rgba(180, 235, 225, 0.05) 2px, transparent 2px) 0 0 / 96px 96px,
    linear-gradient(90deg, rgba(180, 235, 225, 0.05) 2px, transparent 2px) 0 0 / 96px 96px,
    linear-gradient(180deg, #12292c 0%, #0c1c1f 55%, #091416 100%);
}
/* une paillasse et des étagères de chaque côté du vivarium (elles ne passent jamais derrière lui) */
body.plein-ecran .carte-vivarium::before,
body.plein-ecran .carte-vivarium::after {
  content: ""; position: absolute; top: var(--h-bandeau); bottom: 0; pointer-events: none; z-index: 0;
  width: max(0px, calc((100% - var(--pg, 0px) - min(100% - var(--pg, 0px), (100dvh - var(--h-bandeau) - 40px) * 4 / 3)) / 2 - 8px));
  height: auto; border-radius: 0; box-shadow: none; background-repeat: no-repeat; background-size: auto 100%;
}
body.plein-ecran .carte-vivarium { --pg: clamp(250px, 26vw, 470px); }
body.plein-ecran .carte-vivarium::before { left: var(--pg); background-image: url(lab-gauche.svg); background-position: left center; }
body.plein-ecran .carte-vivarium::after { right: 0; background-image: url(lab-droite.svg); background-position: right center; }

/* le vivarium : une vitrine à cadre métallique, avec un reflet sur la vitre */
body.plein-ecran .carte-vivarium .scene {
  position: relative; z-index: 1; border: 0; border-radius: 14px;
  width: min(100% - 40px, calc((100dvh - var(--h-bandeau) - 40px) * 4 / 3));
  box-shadow: 0 0 0 6px #1d3a3d, 0 0 0 9px #4f8284, 0 0 0 11px #0a1517, 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 90px rgba(94, 242, 176, 0.13);
}
body.plein-ecran .carte-vivarium .scene::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.14) 0%, rgba(255, 255, 255, 0.04) 22%, transparent 38%, transparent 70%, rgba(255, 255, 255, 0.05) 100%);
}
/* le panneau de gauche : un pupitre en métal brossé */
body.plein-ecran .panneau-plein {
  z-index: 2; margin-top: 0;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 5px),
    linear-gradient(180deg, #17333a, #0d1c20);
  border-right: 3px solid #4f8284; box-shadow: 6px 0 24px rgba(0, 0, 0, 0.45);
}
body.plein-ecran .pp-titre { display: none; }
/* les étagères ne s'affichent que si les côtés du vivarium sont assez larges (écran très large) */
@media (max-aspect-ratio: 21 / 10) {
  body.plein-ecran .carte-vivarium::before, body.plein-ecran .carte-vivarium::after { display: none; }
}
.pp-regle { margin: 6px 0 0; font-size: 0.9em; opacity: 0.9; }
.pp-regle select { font: inherit; padding: 2px 6px; border-radius: 8px; border: 0; background: #0f2427; color: #cfe9e2; }
.pp-joueurs-liste { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; max-height: 5.6em; overflow-y: auto; font-size: 0.8em; }
.pp-joueurs-liste li { padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.09); white-space: nowrap; }
.pp-joueurs-liste li.moi { background: rgba(94, 242, 176, 0.2); color: #fff; }
.pp-qr canvas { width: min(100%, 17vh, 240px); }
.panneau-plein .pp-qr .qr-canvas { width: min(100%, 17vh, 240px); }

/* ---------------------------------------------------------- 1.30.0 : blocs plus compacts */
.bloc { padding: 6px 38px 7px 12px; gap: 3px 8px; border-radius: 8px; }
.bloc-chapeau, .bloc-evenement, .bloc-regle-fond .bloc-evenement, .bloc-regle-replie .bloc-evenement, .bloc-regle .bloc-evenement, .bloc-action { border-radius: 8px; }
.bloc-chapeau, .bloc-evenement, .bloc-action { padding-right: 12px; }
.bloc-titre { font-size: 0.95rem; }
.bloc-chevron { width: 24px; height: 24px; min-width: 24px; font-size: 0.8rem; margin-right: 6px; }
.bloc-retirer, .bloc-outils .bloc-retirer { min-width: 28px; min-height: 28px; width: 28px; height: 28px; font-size: 0.85rem; }
.bloc-retirer { top: 50%; right: 7px; transform: translateY(-50%); }
.bloc-outils .bloc-retirer { top: auto; right: auto; transform: none; }
.bloc .champ-nom { font-size: 0.66rem; }
.bloc-champs { gap: 3px 8px; }
.bloc select, .bloc input[type="number"], .bloc input[type="text"] { min-height: 30px; padding: 1px 10px; font-size: 0.88rem; }
.bloc .pas { min-height: 30px; padding: 1px 3px; gap: 4px; }
.bloc .bouton-pas { min-width: 26px; min-height: 26px; width: 26px; height: 26px; }
.trait-bloc { min-height: 30px; padding: 1px 10px; font-size: 0.85rem; }
.bloc-chapeau .chips { gap: 4px; margin-top: 2px; }
.bloc-outils { gap: 6px; }
.pastille-mini { width: 18px; height: 18px; margin-bottom: 6px; }
.blocs-regles { gap: 14px; }
.chip.chip-bloc { padding: 7px 14px; }
.pc { padding: 7px 14px; }
.ajout-blocs .chips { gap: 12px 10px; }

/* 1.32.0 : autorisations du vivarium en direct, banque en fenêtre */
.cases-modes { display: grid; gap: 6px; margin: 6px 0 10px; }
.cases-modes .interrupteur { display: flex; gap: 8px; align-items: center; }
#dialogue-banque { width: min(94vw, 720px); }
#dialogue-banque .bibliotheque-liste { max-height: 58vh; overflow: auto; }
