/* Barre commune (css/games.css) aux couleurs du tapis */
.yz-jeu {
  --mg-jeu-largeur: 824px;
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(255, 255, 255, 0.18), transparent 55%),
    linear-gradient(120deg, #0f3d6b, #1a5e9a);
  --mgb-accent: #ffd54f;
  --mgb-titre: linear-gradient(100deg, #ffffff, #ffd54f);
  --mg-fs-fond: radial-gradient(ellipse at 30% 40%, #fdfdff, #e2e7f1);
  --mg-bulle-fond: #0f3d6b;
}

#yahtzee-game {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto 12px auto;
  background: #f8f8ff;
  border-radius: 12px;
  box-shadow: 0 2px 12px #0002;
  padding: 16px 16px 18px;
}

/* Zone des dés */
#dice-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
}
#dice-container {
  --taille-de: clamp(38px, 10vw, 60px); /* 5 dés : plus petits sur mobile */
  width: min(100%, 660px);
  min-height: 210px;
  gap: clamp(12px, 4vw, 36px);
  margin: 4px 0 24px; /* sous le plateau : son épaisseur et son ombre */
  box-sizing: border-box;
}
/* Textes peints sur le tapis, comme les inscriptions d'une table de casino */
.yz-qui {
  min-width: 9em; /* « Partie terminée » sans faire bouger la barre */
}
.yz-message {
  position: absolute;
  left: 12%;
  right: 12%;
  z-index: 2;
  text-align: center;
  color: #f4e6b0;
  text-shadow: 0 1px 2px #0009;
  line-height: 1.25;
  pointer-events: none;
}
/* Tour : pastille vert sombre cerclée d'or, bien lisible sur le tapis */
.yz-message {
  bottom: 34px; /* reste dans le feutre, au-dessus du cadre */
  font-size: 0.92em;
}
.yz-message b {
  color: #fff;
}
@media (max-width: 480px) {
  #dice-container {
    min-height: 170px;
  }
  .yz-message {
    left: 8%;
    right: 8%;
  }
  .yz-message {
    font-size: 0.8em;
  }
}
/* Points des lancers, bouton Lancer en dessous */
.yz-commandes {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
/* Lancers utilisés : un point par lancer */
.yz-lancers {
  display: flex;
  gap: 6px;
}
.yz-lancers span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #1a5e9a;
}
.yz-lancers span.utilise {
  background: #1a5e9a;
}

/* Grilles de score */
#score-section {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.score-table {
  flex: 1 1 300px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 6px #0001;
  padding: 6px 10px 10px;
  transition: box-shadow 0.2s;
}
.score-table.actif {
  box-shadow:
    0 0 0 2px #1a5e9a,
    0 1px 6px #0001;
}
.score-table h3 {
  margin: 0 0 4px;
  font-size: 1.1em;
  line-height: 1.3;
  text-align: center;
}
.score-table table {
  margin: 0;
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.score-table td {
  height: 32px;
  border: 1px solid #ddd;
  padding: 1px 4px;
  text-align: center;
}
.nom-cell {
  background: #fafafa;
}
.yz-icone {
  width: 27px;
  height: 27px;
  object-fit: contain;
  vertical-align: middle;
}
/* Petit dé en 2D pour la partie haute et les règles */
.yz-icone-de {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  padding: 2px;
  vertical-align: middle;
  background: #fff;
  border: 1.5px solid #888;
  border-radius: 5px;
}
.yz-icone-de i {
  width: 4px;
  height: 4px;
  margin: auto;
  border-radius: 50%;
}
.yz-icone-de i.pt {
  background: #222;
}
.yz-icone-de.petit {
  width: 22px;
  height: 22px;
  margin: 0 1px;
}

/* Cases de score */
.score-cell {
  font-size: 1.05em;
}
.score-cell.rempli {
  font-weight: bold;
  color: #222;
  background: #f1f4f8;
}
.score-cell.jouable {
  background: #eaf4fd;
  color: #8a9aab;
  font-style: italic;
  cursor: pointer;
}
.score-cell.jouable.nul {
  background: #f2f2f2;
  color: #b5b5b5;
}
.score-cell.jouable:hover {
  background: #1a5e9a;
  color: #fff;
  font-style: normal;
  font-weight: bold;
}
.score-cell.dernier {
  animation: yz-dernier 1.6s ease-out;
  background: #fff3c4;
}
@keyframes yz-dernier {
  0%,
  30% {
    background: #ffd84a;
  }
}
.bonus-cell small {
  color: #999;
  font-size: 0.8em;
}
.total-cell {
  text-align: right !important;
  font-weight: bold;
  padding: 4px 8px !important;
  background: #e0e0e0;
}
.total-cell small {
  font-weight: normal;
  color: #555;
}

/* Bouton et modale des règles */

/* ---------- Plein écran : plateau à gauche, grands marquoirs à droite ---------- */
.yz-jeu.mg-fs #yahtzee-game {
  flex: 1;
  min-height: 0;
  margin: 0;
  box-shadow: none;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  align-items: center;
  gap: 2.5vw;
  padding: 2vh 2.5vw;
  overflow: auto;
  background: none;
}
.yz-jeu.mg-fs #yahtzee-game #dice-section {
  margin: 0;
  gap: 10px;
}
.yz-jeu.mg-fs #yahtzee-game #dice-container {
  --taille-de: clamp(40px, 4.6vw, 84px);
  width: 100%;
  min-height: clamp(210px, 40vh, 400px);
}
.yz-jeu.mg-fs #yahtzee-game .yz-message {
  font-size: clamp(0.9em, 1.1vw, 1.2em);
}
.yz-jeu.mg-fs #yahtzee-game #score-section {
  flex-wrap: nowrap;
}
.yz-jeu.mg-fs #yahtzee-game .score-table {
  flex-basis: 0;
}
.yz-jeu.mg-fs #yahtzee-game .score-table h3 {
  font-size: clamp(1.1em, 2.4vh, 1.6em);
}
/* 8 lignes par marquoir : elles se partagent la hauteur de l'écran */
.yz-jeu.mg-fs #yahtzee-game .score-table td {
  height: clamp(32px, calc((100vh - 190px) / 8), 84px);
  font-size: clamp(1em, 2.6vh, 1.7em);
}
.yz-jeu.mg-fs #yahtzee-game .yz-icone {
  width: clamp(27px, 5.2vh, 56px);
  height: clamp(27px, 5.2vh, 56px);
}
.yz-jeu.mg-fs #yahtzee-game .nom-cell .yz-icone-de {
  width: clamp(24px, 4.6vh, 50px);
  height: clamp(24px, 4.6vh, 50px);
  padding: 8%;
  border-radius: 18%;
}
.yz-jeu.mg-fs #yahtzee-game .nom-cell .yz-icone-de i {
  width: 60%;
  height: 60%;
}
/* Écran en hauteur (téléphone) : tout sur une colonne */
@media (orientation: portrait) {
  .yz-jeu.mg-fs #yahtzee-game {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
  }
  .yz-jeu.mg-fs #yahtzee-game #dice-container {
    --taille-de: clamp(38px, 10vw, 70px);
    min-height: clamp(170px, 26vh, 300px);
  }
  .yz-jeu.mg-fs #yahtzee-game #score-section {
    flex-wrap: wrap;
  }
  .yz-jeu.mg-fs #yahtzee-game .score-table td {
    height: clamp(32px, 4.2vh, 60px);
  }
}
.yz-regles {
  /* centrage forcé : la feuille du site remet les marges à zéro */
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(900px, calc(100vw - 32px));
  height: fit-content;
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 0;
  border: none;
  border-radius: 14px;
  box-shadow: 0 10px 40px #0005;
  color: #222;
  background: #fff;
}
.yz-regles::backdrop {
  background: #0008;
}
.yz-regles-contenu {
  padding: 16px 24px;
  line-height: 1.45;
}
.yz-regles h2 {
  margin: 0 0 4px;
  font-size: 1.35em;
  color: #1a5e9a;
  text-align: center;
}
.yz-regles-but {
  margin: 0 0 10px;
  text-align: center;
  font-style: italic;
  color: #555;
}
.yz-regles h3 {
  margin: 10px 0 4px;
  font-size: 1.05em;
  color: #1a5e9a;
}
.yz-regles p {
  margin: 0 0 8px;
}
.yz-combis {
  width: 100%;
  border-collapse: collapse;
}
.yz-combis td {
  padding: 2px 8px;
  line-height: 1.25;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.yz-combis tr:nth-child(odd) {
  background: #f7f9fc;
}
/* description sur la même ligne que le nom : une seule ligne par combinaison */
.yz-combis td small {
  margin-left: 6px;
  font-size: 0.82em;
  color: #777;
}
.yz-combis .yz-icone-de.petit {
  width: 20px;
  height: 20px;
}
.yz-combis td[data-des] {
  white-space: nowrap;
}
.yz-combis .val {
  text-align: center;
  font-weight: bold;
  color: #b8860b;
}
.yz-regles-fermer {
  margin: 10px 0 0;
  text-align: center;
}

/* Fin de partie */
.yz-fin {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0008;
}
.yz-fin[hidden] {
  display: none;
}
.yz-fin-boite {
  min-width: 280px;
  padding: 28px 32px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 32px #0003;
  text-align: center;
}
.yz-fin-message {
  font-size: 1.4em;
  font-weight: bold;
}
.yz-fin.gagne .yz-fin-message {
  color: #1a7e1a;
}
.yz-fin.perdu .yz-fin-message {
  color: #c62828;
}
.yz-fin-detail {
  margin: 8px 0 18px;
  color: #555;
}

@media (max-width: 420px) {
  .yz-regles-contenu {
    padding: 16px;
  }
}
