/* ============================================================================
   ÉCRAN DE JEU
   ============================================================================ */

.game-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#game-root {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ----------------------------------------------------------------------
   Barre de tour : noms des joueurs dans l'ordre, dés sous chaque nom
   ---------------------------------------------------------------------- */
.turn-bar {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  overflow-x: auto;
}

.turn-bar-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  min-width: 84px;
  flex-shrink: 0;
}

.turn-bar-player-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: center;
  white-space: nowrap;
}

.turn-bar-player.is-active .turn-bar-player-name {
  color: var(--ink);
  font-weight: 800;
  font-size: 0.95rem;
}

.turn-bar-player-arrow {
  font-size: 0.7rem;
  color: var(--focus-ring);
}

.turn-bar-roll-btn {
  padding: var(--space-2) var(--space-4);
}

/* ----------------------------------------------------------------------
   Popup "à qui de jouer" + animation de lancer (demande)
   ---------------------------------------------------------------------- */
.roll-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 43, 43, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: var(--space-4);
}

.roll-popup-card {
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  min-width: 260px;
  box-shadow: var(--shadow-raised);
  animation: roll-popup-pop 0.25s ease-out;
}

@keyframes roll-popup-pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.roll-popup-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: var(--space-4);
}

.roll-popup-winner {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--paper);
  border-radius: var(--radius-sm);
}

.roll-popup-btn {
  font-size: 1.05rem;
  padding: var(--space-3) var(--space-6);
}

/* ----------------------------------------------------------------------
   Écran de tirage au sort du premier joueur
   ---------------------------------------------------------------------- */
.draw-card {
  max-width: 560px;
  margin: var(--space-8) auto 0;
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  box-shadow: var(--shadow-card);
}

.draw-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  margin-bottom: var(--space-2);
}

.draw-subtitle {
  color: var(--ink-soft);
  margin-bottom: var(--space-6);
}

.draw-players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-4);
}

.draw-player-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--line);
  background: var(--paper);
}

.draw-player-cell.is-out {
  opacity: 0.5;
}

.draw-player-name {
  font-weight: 700;
}

.draw-player-cell .die-svg {
  width: 48px;
  height: 48px;
}

.draw-waiting-tag,
.draw-out-tag {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.draw-out-tag {
  color: var(--danger);
}

/* Alerte FORTE (vs. le badge discret permanent) : affichée juste sous la
   barre de tour uniquement quand CE lancer permet réellement de fermer
   une ligne -- demande explicite "plus warning en haut à côté des dés". */
.close-warning-banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--danger-bg);
  border: 2px solid var(--danger);
  font-weight: 700;
  font-size: 0.88rem;
  color: #8a3700;
  animation: close-warning-pop 0.3s ease-out;
}

@keyframes close-warning-pop {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.close-warning-banner .icon {
  font-size: 1.1rem;
}

/* ----------------------------------------------------------------------
   Dés -- de vrais dés (carrés avec points), pas de chiffres
   ---------------------------------------------------------------------- */
.dice-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.die-svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.die-svg.is-locked {
  opacity: 0.3;
}

/* ----------------------------------------------------------------------
   Fiches de score (une par joueur). Le joueur courant est toujours en
   première position (géré côté JS, pas CSS).
   ---------------------------------------------------------------------- */
.sheets-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sheet {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4);
  box-shadow: var(--shadow-card);
}

.sheet.is-active-player {
  border-color: var(--ink);
  box-shadow: var(--shadow-raised);
}

.sheet.is-me {
  border-width: 2px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.sheet-head-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.sheet-head-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sheet-player-name {
  font-weight: 800;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
}

.sheet-player-name .you-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-soft);
  margin-left: var(--space-2);
}

.sheet-validated-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--success);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sheet-score {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 1.4rem;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.sheet-score-label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.dice-row-small .die-svg {
  width: 22px;
  height: 22px;
}

.dice-row-small {
  gap: 3px;
}

.mark-style-btn {
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mark-style-btn:hover {
  border-color: var(--ink);
}

.mark-style-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-raised);
  padding: var(--space-2);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 180px;
}

.mark-style-option {
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mark-style-option.is-selected {
  border-color: var(--ink);
}

.mark-style-preview {
  width: 32px;
  height: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.95rem;
  position: relative;
  background-color: var(--row-cell-bg);
  border: 1.5px solid var(--line-strong);
}

.sheet-rows {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sheet-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-2);
  padding: 6px;
  border-radius: var(--radius-md);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Badge discret "!" près du cadenas dès que la ligne devient clôturable
   (5+ cases cochées) -- remplace l'ancien cadre coloré jugé trop voyant. */
.row-closeable-flag {
  position: absolute;
  top: -6px;
  right: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--row-color, var(--ink));
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  z-index: 1;
}

.sheet-row-cells {
  display: flex;
  gap: 3px;
  flex-wrap: nowrap;
  align-items: center;
}

.cell {
  width: 30px;
  height: 36px;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--row-color, var(--ink-soft));
  position: relative;
  flex-shrink: 0;
  background-color: var(--row-cell-bg, var(--paper));
}

.cell.is-final {
  width: 30px;
}

.cell.is-bonus-lock {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 0.95rem;
  margin-left: 2px;
  background: var(--paper-raised) !important;
}

.cell.is-checked {
  position: relative;
}

.cell.is-checked-solid {
  background: var(--row-color, var(--ink)) !important;
  color: white;
  border-color: var(--row-color, var(--ink));
}

.cell.is-checked-scribble {
  background: var(--row-cell-bg, var(--paper)) !important;
  color: var(--row-color, var(--ink));
  border-color: var(--row-color, var(--ink));
}

.cell-scribble-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.cell-scribble-overlay svg {
  width: 100%;
  height: 100%;
}

.cell.is-bonus-lock.is-checked-solid {
  background: #3a3631 !important;
  border-color: #3a3631;
  color: white;
}

.cell.is-bonus-lock.is-checked-scribble {
  background: var(--paper-raised) !important;
}

/* Une fois la ligne fermée, le cadenas (coché ou pas) reste affiché mais
   en lecture seule -- le contour utilise le gris neutre au lieu de la
   couleur de la rangée, pour bien marquer "ligne terminée" (demande). */
.sheet-row.is-row-closed .cell.is-bonus-lock:not(.is-checked-solid):not(.is-checked-scribble) {
  border-color: var(--line-strong) !important;
  color: var(--line-strong) !important;
  opacity: 0.6;
}

.cell.is-skipped {
  background-color: var(--row-cell-bg, var(--paper)) !important;
  color: var(--row-color, var(--ink-soft));
  opacity: 0.5;
}

/* Une ligne fermée : les cases jamais cochées sont barrées en noir neutre
   plutôt qu'avec la couleur de la rangée, pour bien signaler "terminé". */
.sheet-row.is-row-closed .cell.is-skipped {
  color: var(--ink-soft);
  opacity: 0.55;
}

.cell.is-skipped::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 2px;
  background: currentColor;
  transform: translateY(-50%);
}

.sheet-row.is-row-closed .cell.is-skipped::after {
  background: var(--ink);
}

.cell.is-disabled-final {
  opacity: 0.4;
}

/* Sélectionnable avec les dés BLANCS : halo blanc bien visible autour de
   la case, peu importe la couleur de la rangée (signale "n'importe quelle
   rangée peut recevoir ce chiffre via les blancs"). */
.cell.is-selectable {
  cursor: pointer;
  border-color: var(--row-color, var(--ink));
  border-width: 2px;
  color: var(--row-color, var(--ink));
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px var(--row-color, var(--ink));
  animation: selectable-pulse 1.6s ease-in-out infinite;
}

/* Sélectionnable avec BLANC + COULEUR : halo dans la couleur de la rangée
   uniquement (pas de blanc), pour bien distinguer des cases "blanc seul". */
.cell.is-selectable-color {
  cursor: pointer;
  border-style: dashed;
  border-color: var(--row-color, var(--ink));
  border-width: 2px;
  color: var(--row-color, var(--ink));
  box-shadow: 0 0 0 3px var(--row-cell-bg, var(--paper)), 0 0 0 6px var(--row-color, var(--ink));
}

/* Sélectionnable par les DEUX méthodes à la fois : on superpose les deux
   indices (halo blanc proche + halo couleur plus large) pour bien montrer
   qu'il y a deux façons de jouer ce chiffre. */
.cell.is-selectable-both {
  cursor: pointer;
  border-color: var(--row-color, var(--ink));
  border-width: 2px;
  color: var(--row-color, var(--ink));
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 6px var(--row-color, var(--ink)), 0 0 0 9px #ffffff, 0 0 0 11px var(--row-color, var(--ink));
  animation: selectable-pulse 1.6s ease-in-out infinite;
}

@keyframes selectable-pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

.cell.is-selectable:hover,
.cell.is-selectable-color:hover,
.cell.is-selectable-both:hover {
  transform: translateY(-2px);
}

.cell.is-pending-white {
  background: var(--focus-ring) !important;
  color: white !important;
  border-color: var(--focus-ring) !important;
  animation: none;
  box-shadow: none;
}

.cell.is-pending-color {
  background: var(--ink) !important;
  color: white !important;
  border-color: var(--ink) !important;
  animation: none;
  box-shadow: none;
}

.sheet-row-points {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-align: right;
  white-space: nowrap;
  min-width: 2.6em;
}

.sheet-misses {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  align-items: center;
}

.sheet-misses .miss-box {
  width: 26px;
  height: 26px;
  border: 1.5px solid var(--line-strong);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: var(--paper);
}

.sheet-misses .miss-box.is-checked {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.sheet-misses .miss-box.is-suggested {
  animation: miss-blink 0.9s ease-in-out infinite;
  cursor: pointer;
}

@keyframes miss-blink {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(213, 94, 0, 0.6);
    border-color: var(--danger);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(213, 94, 0, 0);
    border-color: var(--danger);
  }
}

.sheet-misses-label {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ----------------------------------------------------------------------
   Bouton de validation flottant (apparaît quand une sélection est en
   attente sur une carte -- remplace le gros panneau de décision)
   ---------------------------------------------------------------------- */
.sheet-validate-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--line);
}

.sheet-validate-bar-hint {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.sheet-validate-actions {
  display: flex;
  gap: var(--space-2);
}

/* ----------------------------------------------------------------------
   Statut d'attente (en attendant les autres joueurs en phase blanche)
   ---------------------------------------------------------------------- */
.waiting-validation {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.waiting-validation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px var(--space-3);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--paper);
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
}

.waiting-validation-chip.is-validated {
  border-color: var(--success);
  color: var(--success);
  background: var(--row-c-bg);
}

/* ----------------------------------------------------------------------
   Écran de fin de partie
   ---------------------------------------------------------------------- */
.end-game-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 43, 43, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--space-4);
}

.end-game-card {
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 480px;
  width: 100%;
  text-align: center;
}

.end-game-rank-list {
  list-style: none;
  padding: 0;
  margin: var(--space-5) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.end-game-rank-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.end-game-rank-list li.is-winner {
  background: var(--row-c-bg);
  font-weight: 800;
}

.toast-root {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 60;
}

.toast {
  background: var(--ink);
  color: var(--paper-raised);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-raised);
  animation: toast-in 0.2s ease-out;
  max-width: 320px;
}

@keyframes toast-in {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .cell {
    width: 25px;
    height: 32px;
    font-size: 0.85rem;
  }
  .cell.is-bonus-lock {
    width: 25px;
    height: 25px;
  }
}
