/* ===============================
   Jeu de Nim – styles spécifiques
   =============================== */

:root {
  --nm-bleu: #1f5fbf;
  --nm-bleu-fonce: #174a96;
  --nm-tapis: #1f6b45;
  --nm-tapis-fonce: #134a2f;
  --nm-bois: #e8c48a;
  --nm-bois-fonce: #b98a4c;
  --nm-tete: #d32f2f;
}

/* ---------- Configuration ---------- */

.nm-panel {
  max-width: 600px;
  margin: 14px auto 36px auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  padding: 22px 32px 30px 32px;
  box-sizing: border-box;
}

.nm-intro {
  color: #555;
  line-height: 1.5;
  margin-bottom: 20px;
}

.nm-row {
  margin-bottom: 18px;
}

.nm-label {
  font-weight: bold;
  font-size: 0.95em;
  margin-bottom: 10px;
  color: #3a4250;
}

.nm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.nm-chips button {
  border: 2px solid #d3dae2;
  background: #f5f7fa;
  color: #333;
  border-radius: 22px;
  padding: 9px 18px;
  font-size: 0.95em;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.nm-chips button:hover {
  border-color: #8fb1dc;
}

.nm-chips button.sel {
  background: var(--nm-bleu);
  border-color: var(--nm-bleu);
  color: #fff;
}

.nm-start-row {
  text-align: center;
  padding-top: 8px;
}

.nm-start-row .nm-play {
  font-size: 1.1em;
  padding: 8px 34px;
}

/* Bouton principal (Jouer, Rejouer…) */
.nm-play {
  font-family: "Madimi One", sans-serif;
  font-size: 1.3em;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--nm-bleu);
  border: none;
  border-radius: 30px;
  padding: 12px 54px;
  cursor: pointer;
  box-shadow:
    0 4px 0 var(--nm-bleu-fonce),
    0 6px 14px rgba(31, 95, 191, 0.35);
  transition:
    transform 0.1s,
    box-shadow 0.1s,
    background 0.15s;
}

.nm-play:hover {
  background: #2a6fd6;
}

.nm-play:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 var(--nm-bleu-fonce),
    0 2px 6px rgba(31, 95, 191, 0.3);
}

/* Boutons secondaires */
.nm-btn {
  font-size: 0.95em;
  color: var(--nm-bleu);
  background: #fff;
  border: 2px solid #c9d6e8;
  border-radius: 22px;
  padding: 8px 16px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    opacity 0.15s;
}

.nm-btn:hover:not(:disabled) {
  background: #eef4fc;
  border-color: var(--nm-bleu);
}

.nm-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.nm-btn-take {
  background: var(--nm-bleu);
  border-color: var(--nm-bleu);
  color: #fff;
}

.nm-btn-take:hover:not(:disabled) {
  background: #2a6fd6;
}

.nm-btn-danger {
  color: #c62828;
  border-color: #ecc4c4;
}

.nm-btn-danger:hover {
  background: #fdeeee;
  border-color: #c62828;
}

/* ---------- Écran de jeu ---------- */

/* Barre commune (css/games.css) aux couleurs du tapis */
.nm-jeu {
  --mg-jeu-largeur: 784px;
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(232, 196, 138, 0.25), transparent 55%),
    linear-gradient(120deg, var(--nm-tapis-fonce), var(--nm-tapis));
  --mgb-accent: var(--nm-bois);
  --mgb-titre: linear-gradient(100deg, #fff1d6, var(--nm-bois) 60%, #ff8a65);
  --mg-fs-fond: #eef2f7;
  --mg-bulle-fond: var(--nm-tapis-fonce);
}

.nm-jeu .nm-panel {
  width: 100%;
  margin: 0 auto 26px auto;
}

#nm-game {
  padding: 0 8px;
}

.nm-jeu.mg-fs {
  justify-content: center;
}

.nm-jeu.mg-fs #nm-game {
  width: 100%;
}
/* Plein écran : configuration et jeu centrés en hauteur */
.nm-jeu.mg-fs #nm-game,
.nm-jeu.mg-fs .nm-panel {
  margin-top: auto;
  margin-bottom: auto;
}
.nm-jeu.mg-fs .nm-table {
  width: 100%;
  max-width: 1200px;
}
.nm-jeu.mg-fs .nm-panel {
  max-width: 760px;
  font-size: 1.2em;
}

.nm-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  margin: 8px auto 0 auto;
  font-weight: bold;
  color: #333;
  text-align: center;
}

.nm-status.ordi {
  color: #6b7482;
}

.nm-status.erreur {
  color: #c62828;
}

.nm-status.aide {
  color: #b26a00;
}

/* Tapis de jeu */
.nm-table {
  max-width: 720px;
  margin: 6px auto 0 auto;
  padding: 26px 16px;
  box-sizing: border-box;
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 35%, var(--nm-tapis), var(--nm-tapis-fonce));
  box-shadow:
    inset 0 0 0 6px #6d4524,
    inset 0 0 0 8px #4e2f16,
    inset 0 0 40px rgba(0, 0, 0, 0.45),
    0 6px 18px rgba(0, 0, 0, 0.25);
  user-select: none;
  -webkit-user-select: none;
}

.nm-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.nm-heap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--gap, 14px);
  padding: 4px 34px 22px 34px;
  border-radius: 12px;
  transition: background 0.15s;
}

.nm-heap.vide {
  background: rgba(0, 0, 0, 0.12);
}

/* Nombre d'allumettes restantes dans la rangée */
.nm-count {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.8em;
  text-align: center;
}

/* Allumette : zone cliquable élargie autour du bâtonnet */
.nm-match {
  position: relative;
  width: calc(var(--w, 10px) + 8px);
  height: var(--h, 74px);
  cursor: pointer;
  transition:
    transform 0.35s ease-in,
    opacity 0.35s ease-in;
}

.nm-match::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: var(--w, 10px);
  height: 86%;
  transform: translateX(-50%);
  border-radius: 2px;
  background: linear-gradient(90deg, var(--nm-bois-fonce), var(--nm-bois) 45%, var(--nm-bois-fonce));
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.4);
}

.nm-match::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: calc(var(--w, 10px) * 1.45);
  height: 19%;
  transform: translateX(-50%);
  border-radius: 45%;
  background: radial-gradient(ellipse at 35% 30%, #ff7b6b, var(--nm-tete) 55%, #8e1b1b);
  box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.4);
}

/* Numéro sous chaque allumette */
.nm-num {
  position: absolute;
  left: 50%;
  top: 100%;
  margin-top: 6px;
  transform: translateX(-50%);
  font-size: var(--num, 12px);
  line-height: 1;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  pointer-events: none;
}

/* Aperçu de la prise (survol ou sélection) */
.nm-match.vise {
  transform: translateY(-10px);
}

.nm-match.vise::before,
.nm-match.vise::after {
  filter: brightness(1.2) drop-shadow(0 0 6px rgba(255, 235, 120, 0.9));
}

.nm-match.trop {
  transform: translateY(-4px);
}

.nm-match.trop::before,
.nm-match.trop::after {
  filter: drop-shadow(0 0 5px rgba(255, 80, 80, 0.95));
}

/* Coup joué par l'ordinateur ou indice */
.nm-match.ordi {
  transform: translateY(-10px);
}

.nm-match.ordi::before,
.nm-match.ordi::after {
  filter: brightness(1.1) drop-shadow(0 0 6px rgba(120, 200, 255, 0.95));
}

.nm-match.indice {
  animation: nm-indice 0.5s ease-in-out 4 alternate;
}

@keyframes nm-indice {
  to {
    transform: translateY(-12px);
    filter: drop-shadow(0 0 8px rgba(255, 190, 0, 1));
  }
}

/* Allumette retirée : garde sa place pour que le plateau ne bouge pas */
.nm-match.pris {
  opacity: 0;
  transform: translateY(-50px) rotate(25deg);
  pointer-events: none;
}

.nm-board.bloque .nm-match {
  cursor: default;
}

/* ---------- Barre d'outils ---------- */

.nm-tools {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px auto 8px auto;
}

.nm-rule {
  text-align: center;
  font-size: 0.85em;
  color: #777;
  margin: 0 auto 14px auto;
}

/* Nombres magiques : couleur du fond de page, révélés par la sélection */
.nm-secret {
  margin: -8px auto 14px auto;
  font-size: 0.85em;
  text-align: center;
  color: #f4f6f8;
  user-select: text;
  -webkit-user-select: text;
}

.nm-jeu.mg-fs .nm-secret {
  color: #eef2f7;
}

.nm-secret::selection {
  color: #fff;
  background: var(--nm-bleu);
}

/* ---------- Fenêtres (fin de partie, confirmation) ---------- */

.nm-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(15, 25, 45, 0.55);
  animation: nm-fade 0.25s ease-out;
}

.nm-modal-box {
  background: #fff;
  border-radius: 20px;
  padding: 24px 26px 22px 26px;
  width: 100%;
  max-width: 420px;
  box-sizing: border-box;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: nm-pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.nm-modal-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.nm-modal-btns .nm-play {
  font-size: 1.15em;
  padding: 10px 40px;
}

.nm-modal-btns2 {
  margin-top: 14px;
}

.nm-end-title {
  font-family: "Madimi One", sans-serif;
  font-size: 2.2em;
  line-height: 1.1;
  color: #2a2f38;
}

.nm-end-title.gagne {
  color: #2e7d32;
}

.nm-end-title.perdu {
  color: #c62828;
}

.nm-end-sub {
  margin-top: 8px;
  color: #555;
  line-height: 1.45;
}

.nm-confirm-txt {
  font-weight: bold;
  font-size: 1.05em;
  color: #333;
  line-height: 1.4;
}

@keyframes nm-fade {
  from {
    opacity: 0;
  }
}

@keyframes nm-pop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}

@media (max-width: 520px) {
  .nm-panel {
    padding: 16px 18px 24px 18px;
  }
  .nm-table {
    padding: 20px 6px;
  }
  .nm-heap {
    padding: 4px 28px 22px 6px;
  }
  .nm-btn {
    padding: 7px 12px;
    font-size: 0.9em;
  }
  .nm-end-title {
    font-size: 1.8em;
  }
}
