/* ===============================
   Le jeu de la vie – styles spécifiques
   =============================== */

.jv-jeu {
  --jv-violet: #7c5cff;
  --jv-violet-clair: #a891ff;
  --jv-cyan: #5affe1;
  --jv-encre: #0b0f1f;
  --jv-panneau: #151a33;
  --jv-ligne: rgba(255, 255, 255, 0.09);
  --jv-texte: #e8e9ff;
  --jv-texte-doux: #9aa0c8;
  /* Barre commune (css/games.css) aux couleurs de la simulation */
  --mg-jeu-largeur: 1100px;
  --mgb-fond: linear-gradient(120deg, #1b1f3f, #2a1f55);
  --mgb-texte: var(--jv-texte);
  --mgb-doux: var(--jv-texte-doux);
  --mgb-accent: var(--jv-cyan);
  --mgb-titre: var(--mg-degrade, linear-gradient(100deg, #ffb547, #ff4f9a 45%, #a891ff));
  --mgb-ombre: 0 4px 18px rgba(30, 20, 80, 0.25);
  --mgc-bord: #e7e3fb;
  --mg-fs-fond: #0a0d1c;
  --mg-bulle-fond: var(--jv-panneau);
  user-select: none;
  -webkit-user-select: none;
}

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

/* Titre de la page, à gauche du bandeau */

.jv-stats {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.jv-stat-record b {
  color: #ffd36b;
}

.jv-courbe {
  width: 140px;
  height: 34px;
  margin-left: auto;
}

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

/* Version claire, dans la barre de commandes */

/* Gros bouton lecture / pause */
.jv-play {
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #2fd6b4, #1aa88d);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 4px 14px rgba(26, 168, 141, 0.45);
  transition:
    transform 0.12s,
    box-shadow 0.2s,
    background 0.2s;
}

.jv-play:hover {
  transform: scale(1.06);
}

.jv-play:active {
  transform: scale(0.94);
}

.jv-play.en-marche {
  background: linear-gradient(135deg, #ff7aa8, #e2457d);
  box-shadow: 0 4px 14px rgba(226, 69, 125, 0.45);
  animation: jv-pulse 1.6s ease-in-out infinite;
}

.jv-play svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

@keyframes jv-pulse {
  50% {
    box-shadow: 0 0 0 8px rgba(226, 69, 125, 0.12);
  }
}

/* Petite puce texte (pose de modèle, messages) */
.jv-puce {
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 0.85em;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.jv-puce:hover {
  background: var(--jv-violet);
}

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

.jv-commandes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e7e3fb;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(60, 40, 140, 0.06);
}

.jv-reglage,
.jv-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0; /* annule la marge des label du site */
  font-size: 0.9em;
  color: #555a7a;
  cursor: pointer;
}

.jv-reglage input[type="range"] {
  width: 100px;
  accent-color: var(--jv-violet);
  cursor: pointer;
}

.jv-reglage b {
  min-width: 1.6em;
  font-variant-numeric: tabular-nums;
  color: var(--jv-violet);
}

.jv-themes {
  display: flex;
  gap: 7px;
  margin-left: auto;
}

.jv-pastille {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid var(--fond);
  outline: 2px solid transparent;
  padding: 0;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.15s,
    outline-color 0.15s;
}

.jv-pastille:hover {
  transform: scale(1.12);
}

.jv-pastille[aria-pressed="true"] {
  outline-color: var(--jv-violet);
  outline-offset: 2px;
}

/* ---------- Plateau et modèles ---------- */

/* La hauteur est ajustée en JS pour que le jeu tienne dans la fenêtre */
.jv-corps {
  display: flex;
  gap: 10px;
  height: clamp(360px, 62vh, 640px);
}

.jv-scene {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 16px;
  overflow: hidden;
  background: var(--jv-encre);
  box-shadow:
    0 8px 30px rgba(30, 20, 80, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.jv-jeu[data-theme="bonbon"] .jv-scene,
.jv-jeu[data-theme="classique"] .jv-scene {
  box-shadow:
    0 6px 22px rgba(30, 20, 80, 0.14),
    inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.jv-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.jv-canvas.en-pose {
  cursor: copy;
}

/* Bandeau « posez le modèle » */
.jv-pose {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 20px);
  box-sizing: border-box;
  padding: 6px 6px 6px 14px;
  border-radius: 999px;
  background: rgba(20, 16, 50, 0.85);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.88em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: jv-glisse 0.25s ease-out;
}

.jv-pose[hidden] {
  display: none;
}

.jv-pose b {
  color: var(--jv-cyan);
}

#jv-pose-texte {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Messages éphémères */
.jv-toasts {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  pointer-events: none;
}

.jv-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 520px;
  padding: 9px 10px 9px 16px;
  border-radius: 14px;
  background: rgba(20, 16, 50, 0.9);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 0.92em;
  line-height: 1.35;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: jv-monte 0.3s cubic-bezier(0.2, 1.3, 0.4, 1);
  transition:
    opacity 0.3s,
    transform 0.3s;
}

.jv-toast.sortie {
  opacity: 0;
  transform: translateY(8px);
}

@keyframes jv-monte {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
}

@keyframes jv-glisse {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

/* ---------- Modèles ---------- */

/* Colonne de droite : tout tient dans la hauteur, sans ascenseur */
.jv-modeles {
  flex: 0 0 clamp(214px, 17vw, 260px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  padding: 10px;
  background: #fff;
  border: 1px solid #e7e3fb;
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(60, 40, 140, 0.06);
}

.jv-modeles-titre {
  margin: 0 0 8px 2px;
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8a86ad;
}

.jv-familles {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.jv-famille {
  border: none;
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 0.8em;
  font-weight: 600;
  background: #f0edff;
  color: var(--jv-violet);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.jv-famille:hover {
  background: #e2dbff;
}

.jv-famille.actif {
  background: var(--jv-violet);
  color: #fff;
}

/* Les cartes rétrécissent si la place manque (jusqu'à 96 px de haut sinon) */
.jv-cartes {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(0, 104px);
  align-content: start;
  gap: 8px;
  padding: 2px;
}

.jv-carte {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  padding: 6px;
  border: 2px solid #ece8fd;
  border-radius: 14px;
  background: #faf9ff;
  font: inherit;
  cursor: pointer;
  transition:
    transform 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
}

.jv-carte[hidden] {
  display: none;
}

.jv-carte:hover {
  transform: translateY(-2px);
  border-color: var(--jv-violet-clair);
  box-shadow: 0 6px 14px rgba(124, 92, 255, 0.18);
}

.jv-carte.actif {
  border-color: var(--jv-violet);
  background: #f0edff;
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2);
}

.jv-carte-mini {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border-radius: 8px;
  background: var(--jv-fond, #0b0f1f);
  object-fit: contain;
}

.jv-carte-nom {
  font-size: 0.78em;
  font-weight: 600;
  line-height: 1.15;
  color: #3d3a5c;
  text-align: center;
  hyphens: auto;
  overflow-wrap: break-word;
  /* deux lignes au plus */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  flex-shrink: 0;
}

/* ---------- Fenêtre d'explication ---------- */

.jv-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(12, 8, 40, 0.6);
  backdrop-filter: blur(3px);
  animation: jv-fondu 0.25s ease-out;
}

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

.jv-modal-box {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-sizing: border-box;
  padding: 26px 28px 22px 28px;
  background: #fff;
  border-radius: 22px;
  color: #3d3a5c;
  line-height: 1.5;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.4);
  animation: jv-pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
  user-select: text;
  -webkit-user-select: text;
}

.jv-modal-box p {
  margin: 0 0 12px 0;
}

.jv-modal-titre {
  font-family: "Madimi One", sans-serif;
  font-size: 2em;
  line-height: 1.1;
  text-align: center;
  color: var(--jv-violet);
}

.jv-modal-sous {
  margin: 4px 0 16px 0;
  text-align: center;
  font-weight: 700;
  font-size: 1.1em;
  color: #e2457d;
}

.jv-regles {
  display: grid;
  gap: 8px;
  margin: 4px 0 14px 0;
}

.jv-regle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f6f4ff;
  font-size: 0.92em;
}

.jv-regle b {
  display: block;
  color: #2b2850;
}

/* Petite grille 3×3 illustrant chaque règle */
.jv-regle-ico {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background-color: var(--jv-encre);
  background-size: 12px 12px;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  position: relative;
}

.jv-regle-ico::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* 3 voisines autour d'une case qui naît */
.jv-regle-ico.naissance::after {
  background: var(--jv-cyan);
  box-shadow:
    24px 0 var(--jv-cyan),
    0 24px var(--jv-cyan),
    12px 12px 0 0 rgba(90, 255, 225, 0.45);
}

/* 2 voisines : la cellule du milieu survit */
.jv-regle-ico.survie::after {
  background: #ff46c8;
  box-shadow:
    12px 12px #ff46c8,
    24px 24px #ff46c8;
}

/* Seule au milieu : elle meurt */
.jv-regle-ico.mort::after {
  left: 14px;
  top: 14px;
  background: rgba(255, 255, 255, 0.25);
}

.jv-raccourcis {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 4px 0 6px 0;
  font-size: 0.82em;
  color: #6b6890;
}

.jv-raccourcis kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 1px 6px;
  margin-right: 3px;
  border-radius: 5px;
  border: 1px solid #d9d4f5;
  border-bottom-width: 2px;
  background: #faf9ff;
  font-family: inherit;
  font-size: 0.95em;
  text-align: center;
  color: #3d3a5c;
}

.jv-modal-btns {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.jv-play-texte {
  border: none;
  border-radius: 999px;
  padding: 11px 24px;
  font: inherit;
  font-weight: 700;
  background: linear-gradient(135deg, var(--jv-violet), #5f3ff0);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(95, 63, 240, 0.4);
  transition: transform 0.12s;
}

.jv-play-texte:focus-visible {
  outline: 3px solid #c9bcff;
  outline-offset: 2px;
}

.jv-play-texte:hover {
  transform: translateY(-1px) scale(1.03);
}

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

@keyframes jv-pop {
  from {
    opacity: 0;
    transform: scale(0.85) translateY(10px);
  }
}

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

/* Pointe vers l'élément survolé */

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

/* Plein écran commun (css/games.css) : commandes dans les tons de la simulation */
.jv-jeu.mg-fs {
  --mgc-fond: var(--jv-panneau);
  --mgc-bord: var(--jv-ligne);
  --mgc-texte: var(--jv-texte-doux);
}

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

.jv-jeu.mg-fs .jv-corps {
  flex: 1 1 auto;
  height: auto;
  min-height: 200px;
}

.jv-jeu.mg-fs .jv-commandes,
.jv-jeu.mg-fs .jv-modeles {
  background: var(--jv-panneau);
  border-color: var(--jv-ligne);
  color: var(--jv-texte);
}

.jv-jeu.mg-fs .jv-reglage,
.jv-jeu.mg-fs .jv-option {
  color: var(--jv-texte-doux);
}

.jv-jeu.mg-fs .jv-reglage b {
  color: var(--jv-violet-clair);
}

.jv-jeu.mg-fs .jv-famille {
  background: rgba(255, 255, 255, 0.08);
  color: var(--jv-texte);
}

.jv-jeu.mg-fs .jv-famille.actif {
  background: var(--jv-violet);
  color: #fff;
}

.jv-jeu.mg-fs .jv-carte {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--jv-ligne);
}

.jv-jeu.mg-fs .jv-carte.actif {
  border-color: var(--jv-violet);
  background: rgba(124, 92, 255, 0.18);
}

.jv-jeu.mg-fs .jv-carte-nom {
  color: var(--jv-texte);
}

.jv-jeu.mg-fs .jv-modeles-titre {
  color: var(--jv-texte-doux);
}

/* Le pied de page du site est fixe et ne fait que ~22 px : inutile de garder
   60 px de vide sous le jeu, qui doit tenir dans la fenêtre */
body:has(#jv-jeu) {
  padding-bottom: 34px;
}

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

/* Fenêtre moyenne : barre de commandes resserrée pour tenir sur une ligne */
@media (max-width: 1100px) {
  .jv-commandes {
    gap: 8px 10px;
  }

  .jv-reglage input[type="range"] {
    width: 72px;
  }

  .jv-play {
    width: 44px;
    height: 44px;
  }

  .jv-themes {
    gap: 5px;
  }
}

/* Fenêtre peu haute : on gagne quelques pixels pour le plateau */
@media (max-height: 760px) {
  .jv-jeu {
    margin-top: 8px;
    gap: 8px;
  }

  

  .jv-commandes {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .jv-modeles-titre {
    display: none;
  }
}

/* Écran étroit : les modèles passent sous le plateau */
@media (max-width: 760px) {
  .jv-corps {
    flex-direction: column;
    height: auto;
  }

  .jv-scene {
    height: 60vh;
  }

  .jv-modeles {
    flex-basis: auto;
  }

  .jv-cartes {
    grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
    grid-auto-rows: 88px;
  }

  .jv-jeu.mg-fs .jv-scene {
    height: auto;
    flex: 1 1 auto;
    min-height: 200px;
  }

  .jv-jeu.mg-fs .jv-cartes {
    grid-auto-rows: 70px;
  }
}

@media (max-width: 720px) {
  

  .jv-stats {
    gap: 14px;
  }

  .jv-courbe {
    display: none;
  }

  .jv-themes {
    margin-left: 0;
  }
}

/* Titre seul sur la première ligne, compteurs et boutons dessous */

@media (max-width: 480px) {
  .jv-jeu {
    padding: 0 8px;
  }

  

  

  .jv-stat-record {
    display: none;
  }

  .jv-modal-box {
    padding: 22px 18px 18px 18px;
  }

  .jv-pose {
    font-size: 0.8em;
  }
}
