:root {
  --bg: #10141c;
  --bg-alt: #171d2b;
  --text: #eef1f7;
  --text-dim: #9aa4b8;
  --accent: #4f8cff;
  --accent-hover: #6da0ff;
  --border: #2a3144;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden; /* pas de scroll, PC comme mobile */
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

.app {
  height: 100dvh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.view {
  width: 100%;
  max-width: 26rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.view--hidden {
  display: none;
}

.logo {
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 700;
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}

.view-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.menu-btn {
  padding: 0.9rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.menu-btn:hover {
  border-color: var(--accent);
  background: #1b2333;
}

.menu-btn:active {
  transform: scale(0.98);
}

.menu-btn--secondary {
  color: var(--text-dim);
  font-weight: 500;
}

.back-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.5rem;
}

.back-btn:hover {
  color: var(--text);
}

.account-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.account-form label {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.account-form input {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  color: var(--text);
}

.account-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.account-status {
  min-height: 1.2rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0;
}

.account-logged-in {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
  width: 100%;
  max-height: 9rem;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.avatar-btn {
  aspect-ratio: 1;
  font-size: 1.3rem;
  line-height: 1;
  background: none;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-btn:hover {
  border-color: var(--border);
}

.avatar-btn--selected {
  border-color: var(--accent);
  background: #1b2333;
}

.player-avatar {
  margin-right: 0.3rem;
}

/* ---------- Multijoueur : création / lobby ---------- */

.player-count-choice {
  display: flex;
  gap: 0.5rem;
}

.player-count-btn {
  flex: 1;
  padding: 0.6rem;
}

.player-count-btn--selected {
  border-color: var(--accent);
  background: #1b2333;
  color: var(--accent);
}

.lobby-code {
  font-size: 1.1rem;
  margin: 0;
}

.lobby-code strong {
  color: var(--accent);
  letter-spacing: 0.15em;
}

.lobby-players {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lobby-players li {
  padding: 0.6rem 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  text-align: center;
}

.lobby-players__empty {
  color: var(--text-dim);
  font-style: italic;
}

.code-display {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.code-digit {
  width: 3rem;
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 100%;
}

.keypad-btn {
  padding: 0.9rem;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  cursor: pointer;
}

.keypad-btn:hover {
  border-color: var(--accent);
}

.keypad-btn:active {
  transform: scale(0.96);
}

.keypad-btn--action {
  color: var(--text-dim);
}

/* ---------- Plateau animé (V2) ---------- */
/* Générique (Skyjo + Hilo) : chaque jeu crée son propre calque (id distinct) via
   window.BoardAnimation.ensureAnimationLayer(), tous deux avec cette classe. */

.board-animation-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  perspective: 600px;
}

.card-ghost {
  position: absolute;
  transform-style: preserve-3d;
}

.card-ghost .card {
  width: 100%;
  height: 100%;
}

.grid {
  perspective: 600px;
}

.grid .card {
  transform-style: preserve-3d;
}

.fullscreen-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.3rem;
  line-height: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  color: var(--text);
  cursor: pointer;
}

.fullscreen-btn:hover {
  border-color: var(--accent);
}

.profile-header {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  /* Aussi large que possible sans jamais chevaucher le ☰ (en jeu) ou le bouton plein écran, tous deux
     à 1rem des bords et larges de 2.5rem : on réserve 3.5rem de chaque côté, doublé puisque le header
     est centré (translateX(-50%)). Plancher à 9rem pour rester lisible sur les tout petits écrans,
     plafond à 22rem pour ne pas s'étirer inutilement sur desktop. */
  max-width: clamp(9rem, calc(100vw - 7rem), 22rem);
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  color: var(--text);
  cursor: pointer;
}

.profile-header:hover {
  border-color: var(--accent);
}

.profile-header-avatar {
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.profile-header-pseudo {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-menu {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10;
}

.game-menu-btn {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.3rem;
  line-height: 1;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  color: var(--text);
  cursor: pointer;
}

.game-menu-btn:hover {
  border-color: var(--accent);
}

.game-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 11rem;
  padding: 0.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.game-menu-dropdown--open {
  display: flex;
}

.game-menu-item {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.95rem;
  color: var(--text);
  background: none;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
}

.game-menu-item:hover {
  background: #232b3d;
}

/* PC : layout un peu plus large, menu non étiré sur toute la hauteur */
@media (min-width: 768px) {
  .view:not(.view--game) {
    max-width: 22rem;
  }
}

/* ---------- Plateau de jeu ---------- */

.view--game {
  max-width: none;
  width: 100%;
  height: 100%;
  gap: 0;
  /* Laisse la place au header profil (centré, fixe) au-dessus des panneaux adverses. */
  padding-top: 2.75rem;
}

/* Auto-adaptation du plateau : `.game-fit-viewport` occupe tout l'espace vertical restant sous le
   header ; `.game-fit-scale` contient le plateau + le statut à leur taille naturelle et reçoit une
   mise à l'échelle calculée en JS (fitGameBoard(), main.js) après chaque rendu et à chaque
   redimensionnement/rotation, pour que tout tienne toujours à l'écran sans rogner ni exiger le plein
   écran, quel que soit l'appareil ou le nombre de joueurs. `scrollWidth`/`scrollHeight` (utilisés côté
   JS) reflètent la taille réellement nécessaire même si elle dépasse la boîte — d'où le `overflow:
   hidden` ici, filet de sécurité pendant le calcul plutôt qu'un vrai scroll. */
.game-fit-viewport {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.game-fit-scale {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  transform: scale(var(--fit-scale, 1));
  transform-origin: center center;
}

.board {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.board-opponents { order: 1; }
.board-center { order: 2; }
.board-self { order: 3; }

.board-opponents,
.board-self {
  display: flex;
  justify-content: center;
  min-height: 0;
}

.board-opponents {
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Grilles adverses plus compactes dès qu'il y a plus d'un adversaire (3-4 joueurs), pour ne jamais
   provoquer de scroll même sur petit écran mobile. */
.board-opponents--multi .player-panel {
  padding: 0.3rem;
  gap: 0.2rem;
}

.board-opponents--multi .player-name {
  font-size: 0.7rem;
}

.board-opponents--multi .grid {
  grid-template-columns: repeat(4, minmax(1.3rem, 1.7rem));
  grid-template-rows: repeat(3, minmax(1.7rem, 2.2rem));
  gap: 0.15rem;
}

.board-opponents--multi .card {
  font-size: 0.75rem;
}

.player-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
}

.player-panel--active {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.08);
}

.player-name {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.player-score--round {
  color: var(--accent);
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(2.4rem, 3.4rem));
  grid-template-rows: repeat(3, minmax(3.2rem, 4.4rem));
  grid-auto-flow: column;
  gap: 0.3rem;
}

.card {
  border-radius: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #10141c;
  user-select: none;
}

.card--facedown {
  background: #2a3144;
  border: 1px solid var(--border);
}

.card--removed {
  background: transparent;
  border: 1px dashed var(--border);
}

.card--faceup {
  background: #cfd8e3;
}

.card--neg { background: #7fb3ff; }
.card--zero { background: #8fe3d8; }
.card--low { background: #9fe08a; }
.card--mid { background: #f5d76e; }
.card--high { background: #f28b82; }

.card--clickable {
  cursor: pointer;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.board-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 11rem;
  height: 4.5rem;
  flex-shrink: 0;
  align-self: center;
}

.pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.pile .card,
.pile .pile-label {
  width: 3rem;
  height: 4.2rem;
}

.pile-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 0.4rem;
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 0.7rem;
  text-align: center;
}

.pile--draw .pile-label {
  background: #2a3144;
  color: var(--text);
  border-style: solid;
}

.pile-count {
  font-size: 0.6rem;
  color: var(--text-dim);
}

.pile--clickable {
  cursor: pointer;
}

.pile--clickable .pile-label,
.pile--clickable .card {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.pending-card {
  width: 3rem;
  height: 4.2rem;
}

.pending-card .card {
  width: 3rem;
  height: 4.2rem;
}

/* V2 seulement : la carte piochée reste visuellement "tenue en main" (soulevée, ombre) tant que le
   joueur n'a pas décidé de la poser ou de la défausser. Valeurs synchronisées avec HOLD_LIFT_PX /
   HOLD_SCALE dans skyjo-board.js pour que le fantôme d'animation se fonde dans cet état sans à-coup. */
.board-animated .pending-card .card {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

.board-status {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.game-status-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.game-status-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

@media (min-width: 768px) {
  .board {
    flex-direction: row;
    align-items: stretch;
  }

  .board-self { order: 1; }
  .board-center { order: 2; }
  .board-opponents { order: 3; }

  .board-self,
  .board-opponents {
    flex: 1;
    align-items: center;
  }
}

/* ---------- Plateau Hilo (grille 3x3, cartes par couleur) ---------- */

.grid--hilo {
  grid-template-columns: repeat(3, minmax(2.6rem, 3.6rem));
  grid-template-rows: repeat(3, minmax(3.4rem, 4.6rem));
  grid-auto-flow: row;
}

.board-opponents--multi .grid--hilo {
  grid-template-columns: repeat(3, minmax(1.6rem, 2.1rem));
  grid-template-rows: repeat(3, minmax(2.1rem, 2.7rem));
}

/* Case en cours de reformation (diagonale éliminée, en attente du glissement choisi par le joueur) :
   distincte de `.card--removed` (définitif) — celle-ci va être comblée d'une carte dans l'instant. */
.card--empty {
  background: transparent;
  border: 1px dashed var(--accent);
  opacity: 0.5;
}

/* Case appartenant à l'un des Hilos proposés au choix (voir .card--hilo-{couleur} plus bas pour le fond). */
.card--hilo-candidate {
  outline: 2px solid var(--accent-hover);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.25);
}

.card--hilo-red { background: #f2555a; }
.card--hilo-orange { background: #f2994a; }
.card--hilo-yellow { background: #f5d76e; }
.card--hilo-green { background: #7ed957; }
.card--hilo-cyan { background: #56ccf2; }
.card--hilo-blue { background: #5a8dee; }
.card--hilo-purple { background: #b18cf2; }
.card--hilo-pink { background: #f28cc9; }

/* ---------- Popup de fin de manche/partie ---------- */

.round-popup {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(10, 14, 20, 0);
  backdrop-filter: blur(0px);
  transition: background 0.4s ease, backdrop-filter 0.4s ease;
}

.round-popup-card {
  min-width: 16rem;
  max-width: 90vw;
  padding: 1.5rem;
  border-radius: 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
  transform: translateY(-140%);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease;
}

.round-popup--visible {
  pointer-events: auto;
  background: rgba(10, 14, 20, 0.45);
  backdrop-filter: blur(6px);
}

.round-popup--visible .round-popup-card {
  transform: translateY(0);
  opacity: 1;
}

.round-popup-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
}

.round-popup-scores {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.round-popup-table {
  width: 100%;
  border-collapse: collapse;
}

.round-popup-table th {
  padding: 0.3rem 0.5rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.round-popup-table td {
  padding: 0.5rem;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
}

.round-popup-table tr:last-child td {
  border-bottom: none;
}

.round-popup-table th,
.round-popup-table td {
  text-align: center;
}

.round-popup-table th:nth-child(2),
.round-popup-table td:nth-child(2) {
  text-align: left;
}

.round-popup-avatar {
  width: 1.8rem;
  font-size: 1.1rem;
}

.round-popup-total {
  font-weight: 700;
}

.round-popup-total--low { color: #7ed957; }
.round-popup-total--high { color: #f2555a; }
.round-popup-total--mid { color: #f2994a; }

.round-popup-countdown {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.round-popup-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---------- Plateau Morpion ---------- */

.morpion-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.morpion-players {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
}

.morpion-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid transparent;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.morpion-player--active {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.08);
  color: var(--text);
}

.morpion-player-name {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
}

.morpion-player-symbol {
  font-weight: 700;
  color: var(--accent);
}

.morpion-grid-wrap {
  position: relative;
}

.morpion-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(4.2rem, 5.6rem));
  grid-template-rows: repeat(3, minmax(4.2rem, 5.6rem));
  gap: 0.5rem;
}

.morpion-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 700;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  color: var(--text);
  cursor: default;
  padding: 0;
}

.morpion-cell--clickable {
  cursor: pointer;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.morpion-cell--clickable:hover {
  border-color: var(--accent);
}

.morpion-cell--x { color: var(--accent); }
.morpion-cell--o { color: #f2994a; }

.morpion-winline {
  position: absolute;
  height: 0.35rem;
  background: var(--accent);
  border-radius: 999px;
  transform-origin: left center;
  pointer-events: none;
  z-index: 5;
}

.morpion-coin-toss {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgba(16, 20, 28, 0.85);
  border-radius: 0.75rem;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.morpion-coin-toss--fade {
  opacity: 0;
}

.morpion-coin {
  font-size: 3rem;
  line-height: 1;
}

.morpion-coin-result {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0;
  transform: translateY(0.4rem);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.morpion-coin-result--visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Plateau Puissance 4 ----------
   Panneaux joueurs, tirage au sort et ligne de victoire réutilisent les classes .morpion-* ci-dessus. Les
   cases ne masquent pas leur débordement (pas d'overflow: hidden) : un jeton qui tombe passe par-dessus
   les cases vides de sa colonne pendant l'animation de chute. */

.p4-grid-wrap {
  position: relative; /* seul ancêtre positionné des cases : référence des offsetTop/Left côté JS */
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.p4-preview,
.p4-grid {
  display: grid;
  grid-template-columns: repeat(var(--p4-cols, 7), 2.9rem);
  gap: 0.3rem;
  padding: 0 0.45rem;
}

.p4-preview {
  height: 2.9rem;
}

.p4-grid {
  grid-auto-rows: 2.9rem;
  padding: 0.45rem;
  background: #2457c5;
  border-radius: 0.9rem;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}

.p4-preview-slot,
.p4-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.p4-cell {
  border-radius: 50%;
  background: var(--bg);
  box-shadow: inset 0 3px 4px rgba(0, 0, 0, 0.45);
}

.p4-grid--playable .p4-cell--open {
  cursor: pointer;
}

.p4-cell--hover {
  background: #1b2333;
}

.p4-disc {
  display: block;
  width: 88%;
  height: 88%;
  border-radius: 50%;
  position: relative;
  z-index: 2;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.25);
}

.p4-disc--R { background: #e5484d; }
.p4-disc--Y { background: #f5c84c; }

.p4-preview-slot .p4-disc {
  width: 80%;
  height: 80%;
  opacity: 0.55;
}

.p4-cell--win .p4-disc {
  outline: 3px solid #fff;
  outline-offset: -3px;
}

.p4-player-line {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.p4-player-line .p4-disc {
  width: 0.9rem;
  height: 0.9rem;
}

/* ---------- Plateau Bâtonnets (Fort Boyard) ----------
   Panneaux joueurs et tirage au sort réutilisent les classes .morpion-* ci-dessus. */

.batonnets-players {
  flex-wrap: wrap;
}

.batonnets-player--loser {
  border-color: #e5484d;
  background: rgba(229, 72, 77, 0.08);
}

.batonnets-wrap {
  position: relative; /* référence du calque de tirage au sort */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  min-width: 16rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
}

.batonnets-counter {
  font-size: 1.1rem;
  font-weight: 700;
}

/* 10 bâtonnets par ligne au plus (40 max = 4 lignes), alignés à gauche pour que les retraits, toujours en
   fin de rangée, se lisent comme dans l'émission. */
.batonnets-row {
  display: grid;
  grid-template-columns: repeat(10, 0.9rem);
  column-gap: 0.75rem;
  row-gap: 0.9rem;
  padding-top: 1rem; /* place pour le soulèvement des bâtonnets retirés */
}

.batonnet {
  display: block;
  width: 0.9rem;
  height: 4.2rem;
  border-radius: 0.3rem;
  background: linear-gradient(90deg, #b9824a, #e0b07a 45%, #a46f3c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.batonnet--gone {
  visibility: hidden;
}

.batonnet--targeted {
  transform: translateY(-0.5rem);
  box-shadow: 0 0 0 2px #e5484d, inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}

.batonnets-last-move {
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.batonnets-take {
  display: flex;
  gap: 0.5rem;
}

.batonnets-take-btn {
  padding: 0.6rem 0.9rem;
}

.batonnets-take-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Sélecteur −/+ du nombre de bâtonnets (écrans solo et "Créer une partie"). */
.stick-stepper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.stick-stepper-btn {
  flex: 0 0 3rem;
  padding: 0.5rem;
  font-size: 1.2rem;
}

.stick-stepper-value {
  flex: 1;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
}

.lock-badge {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 500;
}

.hilo-choice-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

/* ---------- Plateau Bataille navale ----------
   Panneaux joueurs et tirage au sort réutilisent les classes .morpion-* ci-dessus. Une grille = 11×11
   cases (en-têtes A-J / 1-10 compris). Pendant la bataille : grande grille adverse + petite grille à soi,
   l'une sous l'autre sur mobile, côte à côte sur desktop. */

.bn-boards {
  position: relative; /* conteneur du tirage au sort (.morpion-coin-toss) */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.bn-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.bn-board-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
}

.bn-grid {
  display: grid;
  grid-template-columns: repeat(calc(var(--bn-n, 10) + 1), var(--bn-cell));
  grid-auto-rows: var(--bn-cell);
  gap: 2px;
}

.bn-grid--big { --bn-cell: 1.95rem; }
.bn-grid--small { --bn-cell: 1.05rem; gap: 1px; }

.bn-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.2rem;
  font-size: 0.7rem;
}

.bn-grid--small .bn-cell { font-size: 0.5rem; border-radius: 0.12rem; }

.bn-head {
  color: var(--text-dim);
  font-weight: 600;
}

.bn-sea {
  background: #16304f;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.bn-ship {
  background: #7d8aa3;
}

.bn-ship--placed {
  background: #8fa0bf;
}

.bn-ship--sunk {
  background: #5a2a2c;
}

.bn-ship--revealed {
  background: rgba(143, 160, 191, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.bn-ship--reveal-anim {
  animation: bn-reveal 0.6s ease-out both;
}

@keyframes bn-reveal {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

.bn-preview--ok { background: rgba(70, 200, 120, 0.75); }
.bn-preview--bad { background: rgba(229, 72, 77, 0.7); }

.bn-clickable {
  cursor: pointer;
}

.bn-target:hover {
  background: #23497a;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.bn-dot {
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: #9fc3ec;
}

.bn-hit {
  color: #ff6b6b;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
}

.bn-grid--small .bn-hit { font-size: 0.6rem; }

.bn-shot--hit.bn-ship--sunk .bn-hit { color: #ffb3b3; }

.bn-last {
  outline: 2px solid #f5c84c;
  outline-offset: -2px;
}

/* Effets d'animation (viseur, ronds dans l'eau, explosion), posés par-dessus la case visée. */
.bn-fx {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 3;
}

.bn-fx-aim {
  border: 2px solid #f5c84c;
  border-radius: 50%;
}

.bn-fx-ripple {
  border: 2px solid #9fc3ec;
  border-radius: 50%;
}

.bn-fx-boom {
  font-size: 1.3rem;
}

.bn-grid--small .bn-fx-boom { font-size: 0.8rem; }

/* Panneau de placement : liste des bateaux + actions. */
.bn-fleet {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: stretch;
  width: 100%;
  max-width: 22rem;
}

.bn-fleet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.bn-fleet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg-alt);
  color: var(--text);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.bn-fleet-item--selected {
  border-color: var(--accent);
  background: rgba(79, 140, 255, 0.15);
}

.bn-fleet-item--placed {
  color: var(--text-dim);
}

.bn-fleet-squares {
  display: flex;
  gap: 2px;
}

.bn-fleet-square {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  background: #8fa0bf;
}

.bn-fleet-item--placed .bn-fleet-square {
  background: #4a5670;
}

.bn-fleet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.bn-action {
  padding: 0.5rem 0.4rem;
  font-size: 0.85rem;
}

.bn-action--ready:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (min-width: 768px) {
  .bn-boards {
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
  }

  .bn-boards--placement {
    align-items: center;
  }

  .bn-fleet {
    width: 14rem;
  }
}

/* ---------- Plateau Démineur ----------
   Panneaux joueurs et calque de décompte réutilisent les classes .morpion-* ci-dessus. Taille des cases
   selon la difficulté (9×9 / 12×12 / 14×14), le tout réduit au besoin par fitGameBoard (main.js). */

.difficulty-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.difficulty-detail {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-weight: 400;
}

.demineur-setup-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.demineur-records {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 0.9rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  font-size: 0.9rem;
}

.demineur-records-title {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.demineur-record {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
}

.demineur-record--selected {
  color: var(--accent);
}

.demineur-players {
  flex-wrap: wrap;
  gap: 0.6rem;
}

.demineur-player {
  min-width: 6.5rem;
}

.demineur-player--me {
  border-color: var(--border);
}

.demineur-progress {
  width: 100%;
  height: 0.35rem;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.demineur-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.demineur-player-meta {
  font-size: 0.75rem;
}

.demineur-badge {
  font-size: 0.7rem;
  padding: 0 0.3rem;
  border-radius: 0.4rem;
}

.demineur-badge--done { background: rgba(126, 217, 87, 0.2); color: #7ed957; }
.demineur-badge--penalty { background: rgba(229, 72, 77, 0.2); color: #ff8a8d; }

.demineur-hud {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 1rem;
  font-weight: 600;
  min-height: 1.5rem;
}

.demineur-hud-time {
  font-variant-numeric: tabular-nums;
  min-width: 5.5rem;
}

.demineur-hud-penalty {
  color: #ff8a8d;
  font-size: 0.9rem;
}

.demineur-hud-dim {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 400;
}

.demineur-wrap {
  position: relative; /* référence du calque de décompte */
  padding: 0.5rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.demineur-grid {
  --dm-cell: 2.3rem;
  display: grid;
  grid-template-columns: repeat(var(--dm-cols, 9), var(--dm-cell));
  grid-auto-rows: var(--dm-cell);
  gap: 2px;
  touch-action: manipulation;
}

.demineur-grid[data-difficulty="moyen"] { --dm-cell: 1.95rem; }
.demineur-grid[data-difficulty="difficile"] { --dm-cell: 1.65rem; }

.dm-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  font: inherit;
  font-size: calc(var(--dm-cell) * 0.5);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
}

.dm-cell--hidden {
  background: linear-gradient(145deg, #3a4560, #2c3549);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3);
}

.dm-cell--hidden:hover {
  background: linear-gradient(145deg, #45527a, #333d55);
}

.dm-cell--flag,
.dm-cell--wrong {
  font-size: calc(var(--dm-cell) * 0.45);
}

.dm-cell--wrong {
  opacity: 0.55;
  outline: 2px solid #e5484d;
  outline-offset: -2px;
}

.dm-cell--open {
  background: #1d2433;
  cursor: default;
}

.dm-cell--boom {
  background: #6b2427;
  font-size: calc(var(--dm-cell) * 0.5);
}

.dm-cell--mine {
  background: #2a2f3d;
  font-size: calc(var(--dm-cell) * 0.45);
}

.dm-cell--n1 { color: #6da0ff; }
.dm-cell--n2 { color: #7ed957; }
.dm-cell--n3 { color: #f2555a; }
.dm-cell--n4 { color: #b78cff; }
.dm-cell--n5 { color: #f2994a; }
.dm-cell--n6 { color: #4fd1c5; }
.dm-cell--n7 { color: #eef1f7; }
.dm-cell--n8 { color: #9aa4b8; }

.dm-cell--fresh {
  animation: dm-open 0.25s ease-out both;
}

@keyframes dm-open {
  from { transform: scale(0.75); opacity: 0.3; }
  to { transform: scale(1); opacity: 1; }
}

/* Grille verrouillée (décompte, pénalité, grille finie, manche terminée) : visuellement atténuée. */
.demineur-grid--locked .dm-cell {
  cursor: default;
}

.demineur-grid--locked .dm-cell--hidden {
  filter: grayscale(0.6) brightness(0.8);
}

.demineur-countdown-value {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--text);
}

.demineur-tools {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 20rem;
}
