/* =====================================================================
   Number Match — styles propres au jeu (préfixe nb-)
   La barre, le plein écran et les infobulles sont dans css/games.css.
   ===================================================================== */

/* Barre commune aux couleurs du jeu : bonbons acidulés sur fond d'encre */
.nb-jeu {
  --mg-jeu-largeur: 1204px; /* barre de 1180 px + marges de 12 px : ne pas changer */
  --mgb-fond: radial-gradient(120% 180% at 0% 0%, rgba(255, 169, 77, 0.3), transparent 50%),
    radial-gradient(120% 180% at 100% 100%, rgba(116, 143, 252, 0.35), transparent 55%),
    linear-gradient(120deg, #2b1d4e, #3d2a6e);
  --mgb-accent: #ffd43b;
  --mgb-titre: linear-gradient(100deg, #ff8787, #ffd43b 35%, #69db7c 60%, #74c0fc);
  --mgb-police-titre: "Fredoka", sans-serif;
  --mg-fs-fond: #fdf4ea;
  --mg-bulle-fond: #2b1d4e;
  --nb-cel: 56px;
  --nb-encre: #2b1d4e;
  --nb-papier: #fffdf8;
  /* Tous les chiffres dans le même bleu */
  --nb-bleu: #5c7cfa;
  --c1: var(--nb-bleu);
  --c2: var(--nb-bleu);
  --c3: var(--nb-bleu);
  --c4: var(--nb-bleu);
  --c5: var(--nb-bleu);
  --c6: var(--nb-bleu);
  --c7: var(--nb-bleu);
  --c8: var(--nb-bleu);
  --c9: var(--nb-bleu);
}

.nb-jeu .mg-barre-titre {
  font-weight: 700;
}

.nb-jeu [hidden] {
  display: none !important;
}

/* Zone de jeu : même largeur que la barre (css/games.css), hauteur posée par game.js (ajuster) */
.nb-zone {
  position: relative;
  box-sizing: border-box;
  align-self: center;
  display: flex;
  gap: 18px;
  justify-content: center;
  width: min(var(--mg-barre-largeur, 1180px), calc(100vw - 24px));
  padding: 16px;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(40% 60% at 8% 10%, rgba(255, 169, 77, 0.22), transparent 70%),
    radial-gradient(40% 60% at 95% 90%, rgba(116, 143, 252, 0.22), transparent 70%),
    radial-gradient(30% 40% at 85% 12%, rgba(105, 219, 124, 0.18), transparent 70%),
    #fdf4ea;
  box-shadow: 0 18px 40px -20px rgba(43, 29, 78, 0.45);
  font-family: "Fredoka", "Outfit", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* Plein écran : la zone prend toute la place sous la barre */
.nb-jeu.mg-fs .nb-zone {
  align-self: stretch;
  width: auto;
  flex: 1;
  min-height: 0;
}

/* ---------- Plateau : la grille défile si elle s'allonge ---------- */
.nb-plateau {
  position: relative;
  flex-shrink: 0;
  box-sizing: border-box;
  width: calc(var(--nb-cel) * 9 + 8px * 2 + 8px);
  max-height: 100%;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  box-shadow:
    inset 0 0 0 1px rgba(43, 29, 78, 0.06),
    0 10px 30px -18px rgba(43, 29, 78, 0.5);
  /* Emplacements des futures lignes : un point discret par case */
  background-image: radial-gradient(circle, rgba(43, 29, 78, 0.1) 2px, transparent 2.6px);
  background-size: var(--nb-cel) var(--nb-cel);
  background-position: 8px 8px;
  background-attachment: local;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(43, 29, 78, 0.25) transparent;
}

.nb-grille {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, var(--nb-cel));
  grid-auto-rows: var(--nb-cel);
}

/* Lignes de fond légères, une ligne sur deux */
.nb-ligne-fond {
  grid-column: 1 / -1;
  pointer-events: none;
}

.nb-case {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 3px;
  padding: 0;
  border: none;
  border-radius: calc(var(--nb-cel) * 0.26);
  background: var(--nb-papier);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 3px 0 rgba(43, 29, 78, 0.08),
    0 6px 14px -8px rgba(43, 29, 78, 0.35);
  color: var(--c);
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: calc(var(--nb-cel) * 0.5);
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.15s,
    color 0.15s,
    box-shadow 0.15s,
    opacity 0.3s;
}

.nb-case:hover:not(.vide) {
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 5px 0 rgba(43, 29, 78, 0.08),
    0 10px 18px -8px rgba(43, 29, 78, 0.4);
}

.nb-case:focus-visible {
  outline: 3px solid var(--c);
  outline-offset: 1px;
}

.nb-case.choisie {
  background: var(--c);
  color: #fff;
  transform: scale(1.08);
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 6px var(--c),
    0 12px 22px -8px var(--c);
  z-index: 2;
}

/* Case vidée : un fantôme du chiffre reste visible */
.nb-case.vide {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(43, 29, 78, 0.05);
  color: rgba(43, 29, 78, 0.13);
  cursor: default;
}

.nb-case.part {
  animation: nb-part 0.42s ease-out;
}

@keyframes nb-part {
  0% {
    transform: scale(1.1);
    background: var(--c);
    color: #fff;
  }
  40% {
    transform: scale(1.25);
    background: var(--c);
    color: #fff;
  }
  100% {
    transform: scale(1);
  }
}

.nb-case.erreur {
  animation: nb-non 0.35s;
}

@keyframes nb-non {
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

/* Indice : toujours bien visible (fond et anneau dorés), avec un halo qui pulse */
.nb-case.indice {
  background: #fff3bf;
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 6px #fab005,
    0 0 16px 4px rgba(250, 176, 5, 0.45);
  animation: nb-indice 0.9s ease-in-out infinite;
  z-index: 1;
}

@keyframes nb-indice {
  50% {
    box-shadow:
      0 0 0 3px #fff,
      0 0 0 8px #fab005,
      0 0 30px 10px rgba(250, 176, 5, 0.7);
    transform: scale(1.08);
  }
}

.nb-case.nouvelle {
  animation: nb-arrivee 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes nb-arrivee {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.6);
  }
}

/* Ligne vidée : elle se replie avant de disparaître */
.nb-case.repli {
  animation: nb-repli 0.35s ease-in forwards;
}

@keyframes nb-repli {
  to {
    opacity: 0;
    transform: scaleY(0.2);
  }
}

/* Lien tracé entre les deux chiffres d'une paire */
.nb-liens {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.nb-liens line {
  stroke-width: 6;
  stroke-linecap: round;
  animation: nb-lien 0.5s ease-out forwards;
}

@keyframes nb-lien {
  0% {
    opacity: 0.9;
    stroke-dashoffset: var(--lg);
  }
  45% {
    opacity: 0.9;
    stroke-dashoffset: 0;
  }
  100% {
    opacity: 0;
    stroke-dashoffset: 0;
  }
}

.nb-eclat {
  position: absolute;
  z-index: 5;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  animation: nb-eclat 0.7s ease-out forwards;
}

@keyframes nb-eclat {
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) rotate(260deg) scale(0.4);
  }
}

.nb-gain {
  position: absolute;
  z-index: 6;
  font-family: "Fredoka", sans-serif;
  font-weight: 700;
  font-size: 1.15em;
  color: var(--nb-encre);
  text-shadow: 0 2px 0 #fff;
  pointer-events: none;
  animation: nb-gain 0.9s ease-out forwards;
  white-space: nowrap;
}

@keyframes nb-gain {
  from {
    opacity: 1;
    transform: translate(-50%, 0) scale(0.8);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -40px) scale(1.15);
  }
}

/* ---------- Panneau de côté ---------- */
.nb-cote {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 210px;
  flex-shrink: 0;
}

.nb-cote b {
  color: inherit;
}

.nb-carte {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 8px 22px -14px rgba(43, 29, 78, 0.5);
  color: var(--nb-encre);
}

.nb-carte-lib {
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b7fae;
}

.nb-progres-val b,
.nb-combo-val {
  color: var(--nb-encre);
  font-size: 2em;
  font-weight: 700;
  line-height: 1.1;
}

.nb-combo-val {
  color: #c2a0ff;
  transition:
    color 0.2s,
    transform 0.2s;
}

.nb-combo.actif .nb-combo-val {
  color: #ff6b6b;
}

.nb-combo.pop .nb-combo-val {
  transform: scale(1.25);
}

.nb-barre-prog {
  position: relative;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(43, 29, 78, 0.08);
  overflow: hidden;
}

.nb-barre-prog i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--c1), var(--c3), var(--c4), var(--c6), var(--c8));
  transition: width 0.35s;
}

.nb-combo-temps i {
  background: linear-gradient(90deg, #ff6b6b, #ffd43b);
  transition: none;
}

.nb-action {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 12px 16px;
  border: none;
  border-radius: 18px;
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 1.15em;
  cursor: pointer;
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    filter 0.15s,
    opacity 0.15s;
}

.nb-ajouter {
  background: linear-gradient(135deg, #5c7cfa, #ae3ec9);
  box-shadow: 0 12px 24px -12px rgba(92, 124, 250, 0.9);
}

.nb-indice {
  background: linear-gradient(135deg, #ffa94d, #f2b705);
  box-shadow: 0 12px 24px -12px rgba(242, 183, 5, 0.9);
}

.nb-action:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.nb-action:active:not(:disabled) {
  transform: scale(0.97);
}

.nb-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.nb-action:focus-visible {
  outline: 3px solid var(--nb-encre);
  outline-offset: 2px;
}

.nb-action-icone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 1.5em;
  line-height: 1;
}

.nb-action-icone svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nb-pastille {
  margin-left: auto;
  min-width: 28px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff;
  color: var(--nb-encre);
  font-weight: 700;
  text-align: center;
}

/* Bloqué : le bouton Ajouter appelle */
.nb-ajouter.appel {
  animation: nb-appel 1.2s ease-in-out infinite;
}

@keyframes nb-appel {
  50% {
    box-shadow:
      0 0 0 8px rgba(174, 62, 201, 0.3),
      0 0 30px 6px rgba(174, 62, 201, 0.55);
    transform: scale(1.06);
  }
}

/* Bandeau « plus aucune paire » */
.nb-bloque {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  padding: 12px 14px 12px 14px;
  border-radius: 22px;
  background: linear-gradient(135deg, #2b1d4e, #4b2f86);
  box-shadow:
    0 0 0 3px #fff,
    0 0 0 7px rgba(174, 62, 201, 0.5),
    0 22px 40px -12px rgba(43, 29, 78, 0.75);
  color: #fff;
  font-family: "Fredoka", "Outfit", sans-serif;
  transform: translateX(-50%);
  animation:
    nb-bloque-entree 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
    nb-bloque-respire 1.6s ease-in-out 0.5s infinite;
}

@keyframes nb-bloque-entree {
  from {
    opacity: 0;
    transform: translate(-50%, 40px) scale(0.8);
  }
}

@keyframes nb-bloque-respire {
  50% {
    transform: translateX(-50%) scale(1.03);
  }
}

.nb-bloque-icone {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffd43b;
  color: #2b1d4e;
  font-weight: 700;
  font-size: 1.6em;
}

.nb-bloque-txt {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.nb-bloque-txt b {
  color: #fff;
  font-size: 1.2em;
}

.nb-bloque-txt small {
  color: #d9ccff;
  font-size: 0.9em;
}

.nb-bloque-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 10px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #5c7cfa, #ae3ec9);
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 1.05em;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.15s;
}

.nb-bloque-btn:hover {
  transform: scale(1.05);
}

.nb-bloque-btn span {
  display: inline-block;
  min-width: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #fff;
  color: #2b1d4e;
}

/* ---------- Fenêtres : dans la zone, la barre reste visible ---------- */
.nb-voile {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(43, 29, 78, 0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.nb-fen {
  box-sizing: border-box;
  width: min(430px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 24px 24px 18px 24px;
  border-radius: 26px;
  background: var(--nb-papier);
  box-shadow: 0 30px 60px -20px rgba(43, 29, 78, 0.6);
  color: var(--nb-encre);
  font-family: "Fredoka", "Outfit", sans-serif;
  text-align: center;
  animation: nb-fen 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes nb-fen {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
}

.nb-fen-titre {
  font-weight: 700;
  font-size: 1.9em;
  line-height: 1.1;
  background: linear-gradient(100deg, var(--c1), var(--c2) 30%, var(--c8) 70%, var(--c7));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.nb-fen-sous {
  margin: 8px 0;
  color: #6f6491;
}

.nb-fen-sous b {
  color: var(--nb-encre);
}

.nb-petit {
  font-size: 0.9em;
}

.nb-fen-boutons {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}

.nb-fen .btn-vert {
  min-width: 150px;
  background: linear-gradient(135deg, #5c7cfa, #ae3ec9);
}

.nb-fin-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 8px 0;
}

.nb-fin-stats div {
  display: flex;
  flex-direction: column;
  min-width: 92px;
  padding: 8px 10px;
  border-radius: 16px;
  background: #f4effc;
}

.nb-fin-stats span {
  font-size: 0.75em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b7fae;
}

.nb-fin-stats b {
  font-size: 1.5em;
}

/* ---------- Écran étroit : panneau en bandeau sous la grille ---------- */
@media (max-width: 760px) {
  .nb-zone {
    flex-direction: column;
    align-items: center;
    padding: 10px;
    gap: 10px;
  }

  .nb-plateau {
    flex: 1;
    min-height: 0;
  }

  .nb-cote {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    gap: 8px;
  }

  .nb-carte {
    flex: 1;
    padding: 8px 10px;
  }

  .nb-progres-val b,
  .nb-combo-val {
    font-size: 1.4em;
  }

  .nb-action {
    flex: 1;
    padding: 8px 10px;
    font-size: 1em;
  }

  .nb-action-icone {
    width: 28px;
    height: 28px;
  }

  .nb-fin-stats div {
    min-width: 0;
    flex: 1;
  }

  /* Bandeau de blocage : au milieu de la grille, sur toute la largeur */
  .nb-bloque {
    top: 38%;
    bottom: auto;
    width: calc(100% - 28px);
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 12px;
    padding: 12px;
    text-align: center;
  }

  .nb-bloque-icone {
    width: 34px;
    height: 34px;
    font-size: 1.3em;
  }

  .nb-bloque-txt b {
    font-size: 1.05em;
  }
}
