/* ===============================
   Éprouvettes – styles spécifiques
   =============================== */

.ep-jeu {
  --mg-jeu-largeur: 1204px; /* zone de jeu aussi large que la barre (1180 px + marges de 12 px) */
  --ep-menthe: #36e2b4;
  --ep-menthe-fonce: #12a985;
  --ep-violet: #7c5cff;
  --ep-violet-clair: #a891ff;
  --ep-or: #ffc23d;
  --ep-encre: #0b1424;
  --ep-panneau: #122036;
  --ep-ligne: rgba(255, 255, 255, 0.09);
  --ep-texte: #e6f4ff;
  --ep-texte-doux: #93a8c4;
  /* Barre commune (css/games.css) aux couleurs du labo */
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(54, 226, 180, 0.22), transparent 55%),
    linear-gradient(120deg, #0f2236, #241f52);
  --mgb-texte: var(--ep-texte);
  --mgb-doux: var(--ep-texte-doux);
  --mgb-accent: var(--ep-menthe);
  --mgb-titre: linear-gradient(100deg, #5affc8, #36c9e2 40%, #a891ff 75%, #ff6ec7);
  --mgb-ombre: 0 4px 18px rgba(10, 30, 60, 0.28);
  --mg-fs-fond: #060c18;
  --mg-bulle-fond: #102038;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Bandeau : statistiques ---------- */

/* Libellés alignés en haut, même sous Potions (barre de progression) */
.ep-stats {
  align-items: flex-start;
}

/* Objectif « trois étoiles », à côté du nombre de coups */
.ep-objectif {
  color: var(--ep-or) !important;
}

.ep-objectif.rate {
  color: var(--ep-texte-doux) !important;
  text-decoration: line-through;
}

/* Particularités du niveau (brouillard, grandes éprouvettes) */
.ep-tags {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
  align-self: center;
}

.ep-tag {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7em;
  font-weight: 800;
}

.ep-tag.brouillard,
.ep-pastille.brouillard {
  background: #3a3158;
  color: #cfc6ff;
  box-shadow: inset 0 0 0 1px rgba(207, 198, 255, 0.35);
}

.ep-tag.grand,
.ep-pastille.grand {
  background: rgba(54, 226, 180, 0.2);
  color: var(--ep-menthe);
  box-shadow: inset 0 0 0 1px rgba(54, 226, 180, 0.45);
}

/* Barre de progression sous le nombre de potions */
.ep-progres {
  display: block;
  width: 100%;
  min-width: 70px;
  height: 4px;
  margin-top: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.ep-progres span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ep-menthe), var(--ep-violet-clair));
  transition: width 0.35s ease;
}

/* ---------- Boutons ---------- */

.ep-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ep-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ep-violet), #5f3ff0);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.95em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(95, 63, 240, 0.3);
  transition:
    transform 0.1s,
    box-shadow 0.15s,
    filter 0.15s,
    opacity 0.15s;
}

.ep-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 6px 18px rgba(95, 63, 240, 0.4);
}

.ep-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.ep-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.ep-btn.clair {
  background: #f0edff;
  color: var(--ep-violet);
  box-shadow: none;
}

.ep-btn.clair:hover:not(:disabled) {
  background: #e4dfff;
}

.ep-btn-jour {
  background: linear-gradient(135deg, #ff6ec7, #d63fa0);
  box-shadow: 0 4px 12px rgba(214, 63, 160, 0.28);
}

.ep-btn-jour:hover:not(:disabled) {
  box-shadow: 0 6px 18px rgba(214, 63, 160, 0.38);
}

.ep-btn-indice {
  background: linear-gradient(135deg, #ffb547, #f08c00);
  box-shadow: 0 4px 12px rgba(240, 140, 0, 0.28);
}

.ep-btn-indice:hover:not(:disabled) {
  box-shadow: 0 6px 18px rgba(240, 140, 0, 0.38);
}

.ep-btn-ajout {
  background: linear-gradient(135deg, #2fd9a9, #12a985);
  box-shadow: 0 4px 12px rgba(18, 169, 133, 0.28);
}

.ep-btn-ajout:hover:not(:disabled) {
  box-shadow: 0 6px 18px rgba(18, 169, 133, 0.38);
}

/* Coût d'un coup de pouce, en pastille */
.ep-cout {
  padding: 1px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.24);
  font-size: 0.8em;
  font-variant-numeric: tabular-nums;
}

/* Potion du jour déjà réussie */
.ep-coche {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d63fa0' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

.ep-coche[hidden] {
  display: none;
}

.ep-btn:focus-visible,
.ep-case:focus-visible {
  outline: 3px solid var(--ep-violet-clair);
  outline-offset: 2px;
}

/* ---------- Commandes ---------- */

/* ---------- Plateau ---------- */

.ep-scene {
  position: relative;
  min-height: 0;
  /* Même largeur que la barre (css/games.css), sauf en plein écran */
  box-sizing: border-box;
  align-self: center;
  width: min(var(--mg-barre-largeur, 1180px), calc(100vw - 24px));
}

.ep-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  background: var(--ep-encre);
  box-shadow:
    0 2px 6px rgba(23, 20, 46, 0.12),
    0 24px 50px -22px rgba(23, 20, 46, 0.55);
  touch-action: manipulation;
  outline: none;
}

.ep-canvas:focus-visible {
  box-shadow:
    0 0 0 3px var(--ep-violet-clair),
    0 24px 50px -22px rgba(23, 20, 46, 0.55);
}

/* Messages éphémères, en haut du plateau */
.ep-toasts {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 5;
}

.ep-toast {
  padding: 8px 16px;
  border-radius: 99px;
  background: rgba(14, 26, 48, 0.94);
  border: 1px solid rgba(54, 226, 180, 0.25);
  color: #fff;
  font-size: 0.9em;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  animation: ep-toast-entree 0.25s ease;
  transition:
    opacity 0.35s,
    transform 0.35s;
}

.ep-toast.alerte {
  border-color: rgba(255, 110, 140, 0.55);
}

.ep-toast.sort {
  opacity: 0;
  transform: translateY(-6px);
}

@keyframes ep-toast-entree {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ---------- Fenêtres ---------- */

.ep-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 16, 32, 0.58);
  backdrop-filter: blur(4px);
  animation: ep-fondu 0.2s ease;
}

.ep-modal[hidden] {
  display: none;
}

@keyframes ep-fondu {
  from {
    opacity: 0;
  }
}

.ep-modal-box {
  width: min(540px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  box-sizing: border-box;
  padding: 26px 28px 22px;
  border-radius: 22px;
  background: #fff;
  color: var(--mg-texte, #25233d);
  box-shadow: 0 30px 70px -20px rgba(8, 16, 32, 0.6);
  animation: ep-apparition 0.35s
    var(--mg-ressort, cubic-bezier(0.34, 1.56, 0.64, 1));
  user-select: text;
  -webkit-user-select: text;
}

@keyframes ep-apparition {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(12px);
  }
}

.ep-modal-titre {
  font-family: "Madimi One", sans-serif;
  font-size: 1.9em;
  line-height: 1.1;
  background: linear-gradient(
    100deg,
    #12a985,
    #36a3e2 40%,
    #7c5cff 75%,
    #e0447a
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.ep-modal-sous {
  margin: 4px 0 14px;
  color: var(--mg-doux, #6c6a88);
  font-weight: 500;
}

.ep-modal-box p {
  margin: 12px 0;
  line-height: 1.5;
}

/* Règles */
.ep-regles-box {
  width: min(720px, 100%);
}

.ep-regles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ep-regle {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  line-height: 1.45;
}

.ep-regle b {
  display: block;
  margin-bottom: 1px;
}

.ep-regle-ico {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
}

.ep-regle-ico .fond {
  fill: var(--ep-encre);
}

.ep-regle-ico .verre {
  fill: rgba(255, 255, 255, 0.06);
  stroke: #cfe3ff;
  stroke-width: 1.6;
}

.ep-regle-ico .fleche {
  fill: none;
  stroke: #ffe066;
  stroke-width: 2;
  stroke-linecap: round;
}

.ep-regle-ico .ok,
.ep-regle-ico .non {
  fill: none;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ep-regle-ico .ok {
  stroke: #4ade80;
}

.ep-regle-ico .non {
  stroke: #ff5470;
}

.ep-raccourcis {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-top: 6px;
  font-size: 0.88em;
  color: var(--mg-doux, #6c6a88);
}

.ep-raccourcis kbd,
.ep-modal-box kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1px solid rgba(35, 33, 61, 0.15);
  border-bottom-width: 2px;
  background: #f7f6fd;
  color: #3d3a5c;
  font: inherit;
  font-weight: 700;
  text-align: center;
}

.ep-modal-btns {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* Choix du niveau */
.ep-niveaux-box {
  width: min(640px, 100%);
}

.ep-grille-niveaux {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 8px;
  max-height: min(52vh, 420px);
  overflow: auto;
  padding: 4px;
  margin: 0 -4px;
}

.ep-case {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 62px;
  border-radius: 14px;
  background: #f1f6fb;
  color: #2a3550;
  font: inherit;
  cursor: pointer;
  transition:
    transform 0.12s,
    background 0.15s,
    box-shadow 0.15s;
}

.ep-case b {
  color: inherit;
  font-size: 1.15em;
  font-variant-numeric: tabular-nums;
}

.ep-case:hover:not(:disabled) {
  background: #e3f7f1;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px -8px rgba(18, 169, 133, 0.6);
}

.ep-case.courant {
  background: linear-gradient(135deg, var(--ep-violet), #5f3ff0);
  color: #fff;
}

.ep-case.prochain {
  box-shadow: inset 0 0 0 2px var(--ep-menthe);
}

.ep-case:disabled {
  cursor: default;
  background: #f4f4f8;
  color: #b9b8cc;
}

.ep-case.ep-case-infini {
  background: linear-gradient(135deg, #e3f7f1, #ece8ff);
  color: var(--ep-menthe-fonce);
}

.ep-case-infini b {
  font-size: 1.7em;
}

.ep-case-etoiles {
  font-size: 0.72em;
  letter-spacing: 1px;
  line-height: 1;
  color: #d9d7e8;
}

.ep-case-etoiles .on {
  color: #ffb400;
}

.ep-case.courant .ep-case-etoiles {
  color: rgba(255, 255, 255, 0.4);
}

.ep-case.courant .ep-case-etoiles .on {
  color: #ffd34d;
}

.ep-case svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
}

/* Particularités, en coin de case */
.ep-case-tags {
  position: absolute;
  top: 5px;
  right: 5px;
  display: flex;
  gap: 2px;
}

.ep-pastille {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.ep-legende {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 12px;
  font-size: 0.86em;
  color: var(--mg-doux, #6c6a88);
}

.ep-legende span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Confirmation */
.ep-confirm {
  width: min(500px, 100%);
}

.ep-confirm .ep-modal-btns {
  flex-wrap: nowrap;
}

/* Trop étroit pour deux boutons côte à côte : l'un sous l'autre, pleine largeur */
@media (max-width: 520px) {
  .ep-confirm .ep-modal-btns {
    flex-direction: column-reverse;
  }

  .ep-confirm .ep-modal-btns .ep-btn {
    justify-content: center;
  }
}

.ep-confirm .ep-modal-titre {
  font-size: 1.6em;
}

.ep-confirm p {
  color: var(--mg-doux, #6c6a88);
}

/* Victoire */
.ep-victoire {
  text-align: center;
}

.ep-victoire .ep-modal-btns {
  justify-content: center;
}

.ep-etoiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 2.6em;
  line-height: 1;
}

.ep-etoiles span {
  color: #e4e1f3;
}

.ep-etoiles span.on {
  color: #ffc23d;
  text-shadow: 0 4px 14px rgba(255, 170, 30, 0.45);
  animation: ep-etoile 0.5s var(--mg-ressort, cubic-bezier(0.34, 1.56, 0.64, 1))
    both;
  animation-delay: calc(0.25s + var(--i) * 0.15s);
}

@keyframes ep-etoile {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-40deg);
  }
}

.ep-v-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 6px;
}

.ep-v-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 6px;
  border-radius: 14px;
  background: #f1f6fb;
}

.ep-v-stat span {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--mg-doux, #6c6a88);
}

.ep-v-stat b {
  font-size: 1.45em;
  font-variant-numeric: tabular-nums;
  color: var(--mg-encre, #17142e);
}

.ep-v-stat small {
  font-size: 0.8em;
  color: var(--mg-doux, #6c6a88);
  font-variant-numeric: tabular-nums;
}

.ep-v-stat em {
  font-style: normal;
  font-weight: 700;
  color: #e0447a;
}

/* ---------- Infobulle (attribut data-bulle) ---------- */

/* ---------- Plein écran ---------- */

/* Plein écran commun (css/games.css) : rangée des commandes dans les tons du labo */
.ep-jeu.mg-fs {
  --mgc-fond: var(--ep-panneau);
  --mgc-bord: var(--ep-ligne);
  --mgc-texte: var(--ep-texte-doux);
}

.ep-jeu.mg-fs > * {
  flex-shrink: 0;
}

.ep-jeu.mg-fs .ep-scene {
  align-self: stretch;
  width: auto;
  flex: 1 1 auto;
  height: auto;
  min-height: 200px;
}

.ep-jeu.mg-fs .ep-canvas {
  box-shadow: none;
}

/* Le pied de page du site est fixe : inutile de garder 60 px de vide sous le jeu */
body:has(#ep-jeu) {
  padding-bottom: 34px;
}

/* ---------- Petits écrans ---------- */

@media (max-height: 760px) {
  .ep-jeu {
    margin-top: 8px;
    gap: 8px;
  }

  

  
}

@media (max-width: 1360px) {
  .ep-btn-indice span:not(.ep-cout),
  .ep-btn-ajout span:not(.ep-cout) {
    display: none;
  }
}

@media (max-width: 860px) {
  .ep-btn {
    padding: 0 13px;
  }

  .ep-btn-indice span:not(.ep-cout),
  .ep-btn-ajout span:not(.ep-cout) {
    display: none;
  }
}

@media (max-width: 760px) {
  .ep-jeu {
    padding: 0;
  }

  

  

  

  

  .ep-progres {
    min-width: 0;
  }

  

  .ep-canvas {
    border-radius: 12px;
  }

  .ep-v-stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  

  .ep-btn-jour span:not(.ep-coche),
  #ep-btn-niveaux span {
    display: none;
  }

  
}
