/* Centrage et équilibrage des têtes de vache sur plusieurs lignes */
.card-bulls-flex {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 60px; /* largeur à ajuster selon la carte */
  margin: 0 auto;
}
.card-bulls-flex .bull {
  margin: 0 2px 2px 2px;
  font-size: 20px;
}
/* Permet d'avoir 3 ou 4 têtes max par ligne, à gérer côté JS/HTML avec des <br> ou des wrappers si besoin */
/* Décalage de 10px uniquement sur la première carte de chaque ligne du plateau */
#board .row .card:first-child,
#board .row .card-back:first-child {
  margin-left: 10px;
}

/* Décalage progressif des cartes du plateau vers la droite, sans espace supplémentaire */
#board .row {
  position: relative;
  display: flex;
  align-items: center;
}

#board .row .card,
#board .row .card-back {
  position: absolute;
}

#board .row .card:nth-child(1),
#board .row .card-back:nth-child(1) {
  left: 10px;
}

#board .row .card:nth-child(2),
#board .row .card-back:nth-child(2) {
  left: 100px;
}

#board .row .card:nth-child(3),
#board .row .card-back:nth-child(3) {
  left: 190px;
}

#board .row .card:nth-child(4),
#board .row .card-back:nth-child(4) {
  left: 280px;
}

#board .row .card:nth-child(5),
#board .row .card-back:nth-child(5) {
  left: 370px;
}

/* 6e carte décalée pour indiquer la zone de prise - bordée en rouge */
#board .row .card:nth-child(6),
#board .row .card-back:nth-child(6) {
  left: 490px;
}

#board .row .card-back:nth-child(6) {
  border-color: #d18484 !important;
  border-width: 3px !important;
}

#board .row .card,
#board .row .card-back {
  cursor: default !important;
  pointer-events: none;
  box-shadow: none !important;
  transform: none !important;
  transition: none !important;
}

#board .row .card:hover,
#board .row .card-back:hover {
  box-shadow: none !important;
  transform: none !important;
}

/* Exception pour la sélection de ligne */
/* Rangée à ramasser : vague orange sur les rangées. Le clignotement est porté
   par ::after, qui tourne sans interruption : le survol ne fait que le masquer,
   la vague reste donc synchronisée quand la souris repart */
#board .row.selectable {
  cursor: pointer !important;
  pointer-events: all !important;
  transition: background 0.2s, transform 0.2s;
}

#board .row.selectable::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  pointer-events: none;
  animation: row-choose 1.2s ease-in-out infinite;
}
#board .row-container:nth-child(2) .row.selectable::after {
  animation-delay: 0.15s;
}
#board .row-container:nth-child(3) .row.selectable::after {
  animation-delay: 0.3s;
}
#board .row-container:nth-child(4) .row.selectable::after {
  animation-delay: 0.45s;
}

/* Une rangée survolée : la vague s'arrête partout */
#board:has(.row.selectable:hover) .row.selectable::after {
  visibility: hidden;
}

#board .row.selectable:hover {
  background: #fff0d9;
  transform: scale(1.02);
  box-shadow: 0 0 0 3px #f39c12;
}

@keyframes row-choose {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(243, 156, 18, 0);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.9);
  }
}

div.game-container {
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  /* Largeur fixe (disposition), mise à l'échelle par fitToScreen() */
  width: 1000px;
  box-sizing: border-box;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
  transform-origin: top left;
}

.animation-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 1000;
}

/* Barre commune (css/games.css) aux couleurs du jeu ; scores des joueurs dedans */
#sqp-root {
  --mg-jeu-largeur: 1024px;
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(255, 255, 255, 0.18), transparent 55%),
    linear-gradient(120deg, #4b57c9, #764ba2);
  --mgb-texte: #fff;
  --mgb-doux: #d9dcff;
  --mgb-accent: #ffd166;
  --mgb-titre: linear-gradient(100deg, #ffffff, #ffd166);
  --mg-fs-fond: linear-gradient(135deg, #667eea, #764ba2);
  --mg-bulle-fond: #3b2f6b;
}

.scores {
  gap: 8px;
  flex-wrap: wrap;
}

.player-score {
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.player-score.current {
  background: #fff;
  color: #4b57c9;
}

.player-score.eliminated {
  background: rgba(255, 205, 210, 0.85);
  color: #c62828;
  text-decoration: line-through;
}

.game-area {
  display: flex;
  gap: 30px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.board {
  max-width: 585px;
  flex: 0 0 auto;
}

.played-cards-area {
  flex: 1;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  min-width: 300px;
}

.played-cards-area h3 {
  margin: 0 0 16px 0;
  font-size: 1.1em;
  color: #333;
  text-align: center;
}

.played-card-item {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.played-card-item .card {
  width: 50px;
  height: 72px;
  margin-right: 12px;
  flex-shrink: 0;
}

.played-card-item .card .card-number {
  font-size: 18px;
}

.played-card-item .card .card-bulls {
  font-size: 8px;
}

.played-card-info {
  flex: 1;
  font-weight: bold;
  color: #333;
}

.card-animation {
  position: absolute;
  z-index: 1001;
  pointer-events: none;
  transition: all 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card-animation.moving {
  transform: scale(0.8);
}

.row-container {
  margin-bottom: 10px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 5px;
  background: #e0e0e0;
  border-radius: 10px;
  padding: 8px 0 8px 0;
  min-height: 116px;
  position: relative;
  min-width: 580px;
}

.card-back {
  background: #bbb !important;
  border: 3px solid #888 !important;
  cursor: default !important;
  position: relative;
}

.card-back-bull {
  font-size: 35px;
  color: #222;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  line-height: 1;
  opacity: 0.2;
}

.card-back .card-number,
.card-back .card-bulls {
  display: none;
}

.card {
  width: 62px;
  height: 90px;
  background: #fff;
  border: 3px solid #333;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

/* Couleurs selon le nombre de têtes */
.card.bulls-1 {
  background: #ffffff;
  border-color: #706fdd;
}

.card.bulls-2 {
  background: #c7e1ff;
  border-color: #0b4b93;
}

.card.bulls-3 {
  background: #e8ffef;
  border-color: #1df500;
}

.card.bulls-5 {
  background: #ffccbc;
  border-color: #fa0e0e;
}

.card.bulls-7 {
  background: #fffc65;
  border-color: #c62828;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Carte sélectionnée : couleurs d'origine, surélevée au-dessus des autres */
.card.selected,
.card.selected:hover {
  transform: translateY(-16px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.35);
}
/* La main est redessinée à chaque sélection : la montée est animée à part */
.card.selected {
  animation: card-lift 0.18s ease-out;
}
@keyframes card-lift {
  from {
    transform: translateY(-5px);
  }
  to {
    transform: translateY(-16px);
  }
}

.card-number {
  font-size: 24px;
  margin-bottom: 5px;
}

.card-bulls {
  font-size: 10px;
  color: #d32f2f;
  line-height: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.card-bulls br {
  margin-top: 3px;
}

.card-bulls {
  line-height: 1.3;
}

.hand {
  background: #fff3e0;
  border-radius: 15px;
  padding: 0 16px;
}

.hand-flex {
  display: flex;
  flex-direction: row;
  align-items: center;
}
.hand-flex {
  gap: 16px;
  justify-content: center;
}

/* Emplacement d'une carte déjà jouée */
.hand .card.card-slot,
.hand .card.card-slot:hover {
  background: transparent;
  border: 3px dashed rgba(0, 0, 0, 0.25); /* même épaisseur que les cartes */
  box-shadow: none;
  transform: none;
  cursor: default;
}
.card-slot .card-back-bull {
  opacity: 0.15;
}

/* ---------- Bouton « Jouer » ---------- */
.sqp-play {
  flex: 0 0 auto;
  width: 124px;
  height: 90px;
  border: none;
  border-radius: 12px;
  background: #d9d9d9;
  color: #777;
  font-family: inherit;
  font-weight: bold;
  line-height: 1.15;
  cursor: not-allowed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
  transition: background 0.2s, color 0.2s, transform 0.1s;
}
.sqp-play-label {
  font-size: 14px;
}
.sqp-play-num {
  font-size: 32px;
  line-height: 1;
}
.sqp-play.ready {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 6px 16px rgba(102, 126, 234, 0.45);
  animation: play-pulse 1.6s ease-in-out infinite;
}
/* Le survol global des boutons du site (fond bleu) ne s'applique pas ici */
.sqp-play:disabled:hover {
  background: #d9d9d9;
  color: #777;
}
.sqp-play.choose-row:hover {
  background: #f39c12;
  color: #fff;
}
.sqp-play.ready:hover {
  filter: brightness(1.1);
}
.sqp-play.ready:active {
  transform: translateY(3px);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 3px 8px rgba(102, 126, 234, 0.45);
  animation: none;
}
@keyframes play-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.hand .row {
  justify-content: center;
  align-items: center;
  background: none;
  padding: 0;
}

.bull {
  display: inline-block;
  margin: 0 2px;
}
#confirm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#confirm-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  padding: 32px 24px 24px 24px;
  min-width: 300px;
  text-align: center;
}
#confirm-box p {
  font-size: 1.2em;
  margin-bottom: 20px;
}

/* ---------- Boutons (nouvelle partie, son, plein écran) ---------- */

/* ---------- Mise à l'échelle : le jeu tient dans la fenêtre ---------- */
.sqp-stage {
  margin: 0 auto;
}

/* Plein écran : le jeu, mis à l'échelle, est centré sous la barre */
#sqp-root.mg-fs .sqp-stage {
  margin: auto;
}

/* Disposition verticale (écrans étroits / portrait) : cartes jouées sous le plateau */

.game-container.tall .game-area {
  flex-direction: column;
  gap: 12px;
}
.game-container.tall .played-cards-area {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  min-height: 124px;
}
.game-container.tall .played-cards-area h3 {
  display: none;
}
.game-container.tall #played-cards {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.game-container.tall .played-card-item {
  flex-direction: column;
  margin: 0;
  padding: 6px 12px;
}
.game-container.tall .played-card-item .card {
  margin: 0 0 4px 0;
}
.game-container.tall .hand-flex {
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}
/* Hauteur fixe (2 lignes de cartes) : la disposition ne change pas en cours de manche */
.game-container.tall .hand .row {
  min-height: 190px;
  align-content: center;
}

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

/* ---------- Points perdus : animation du compteur ---------- */
.player-score {
  position: relative;
}
.player-score.hit {
  animation: score-hit 0.7s ease;
}
@keyframes score-hit {
  0% {
    transform: none;
  }
  15% {
    transform: scale(1.15) rotate(-4deg);
    background: #e74c3c;
    color: #fff;
  }
  30% {
    transform: scale(1.15) rotate(4deg);
    background: #e74c3c;
    color: #fff;
  }
  45% {
    transform: scale(1.1) rotate(-3deg);
  }
  60% {
    transform: scale(1.05) rotate(2deg);
  }
  100% {
    transform: none;
  }
}
.score-delta {
  position: absolute;
  left: 50%;
  top: 100%;
  z-index: 5;
  color: #e74c3c;
  font-size: 18px;
  font-weight: bold;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
  animation: score-delta 1.4s ease-out forwards;
}
@keyframes score-delta {
  0% {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.8);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, 2px) scale(1.25);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, 8px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 18px) scale(1);
  }
}

/* Bouton de jeu quand il faut ramasser une rangée */
.sqp-play.choose-row {
  background: #f39c12;
  color: #fff;
  animation: play-pulse 1.2s ease-in-out infinite;
}

/* ---------- Fin de partie ---------- */
.sqp-end {
  position: absolute;
  /* Sous la barre des scores : son et plein écran restent accessibles */
  inset: 76px 0 0 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 0 0 20px 20px;
}
.sqp-end[hidden] {
  display: none;
}
.sqp-end-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px 40px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  border-top: 8px solid #e74c3c;
  animation: end-pop 0.4s cubic-bezier(0.34, 1.5, 0.64, 1);
}
.sqp-end.win .sqp-end-box {
  border-top-color: #2ecc40;
}
.sqp-end-box p {
  margin: 0 0 20px;
  font-size: 30px;
  font-weight: bold;
  line-height: 1.3;
  color: #333;
}
.sqp-end-box small {
  font-size: 18px;
  font-weight: normal;
  color: #555;
}
.sqp-end-box .sqp-play {
  width: auto;
  height: auto;
  padding: 12px 36px;
  font-size: 20px;
  margin: 0 auto;
  animation: none;
}
@keyframes end-pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
