/* Cette page vise à tenir sur un seul écran sans défiler : moins de marge
   basse que le gabarit partagé, cartes resserrées, plateau et indices côte à
   côte plutôt qu'empilés. */
.container {
  padding-bottom: 24px;
}

#screen-game {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#screen-game .card {
  padding: 16px 18px;
}

/* Lobby : bouton "Gérer les mots" et son décompte, juste au-dessus de Démarrer. */
.roles-setup {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.roles-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 600;
}

.roles-list {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.role-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.role-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-row select {
  flex-shrink: 0;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.roles-setup p {
  margin: 0;
}

.word-filter-row-lobby {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
}

.word-filter-dialog {
  width: min(560px, calc(100% - 2rem));
  max-height: min(640px, calc(100% - 4rem));
}

/* Le display ne vaut QUE boîte ouverte. Posé sur .word-filter-dialog tout
   court, il battait le `dialog:not([open]) { display: none }` du navigateur
   (feuille de la page contre feuille du navigateur) : la boîte restait
   plantée dans le flux de la page, y compris en pleine partie. */
.word-filter-dialog[open] {
  display: flex;
  flex-direction: column;
}

.word-filter-dialog input[type="text"] {
  margin: 4px 0 10px;
}

.word-filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.word-filter-toolbar-actions {
  display: flex;
  gap: 6px;
}

/* Liste défilante à l'intérieur de la boîte de dialogue seulement : ça ne
   contredit pas l'objectif "pas de défilement" de l'écran de jeu lui-même,
   un catalogue de 380+ mots ne peut pas tenir autrement. */
.word-filter-list {
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  background: var(--surface-2);
}

.word-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Sans ça le filtre ne cache rien : la règle du navigateur pour [hidden]
   (display: none) perd contre le display: flex ci-dessus, qui vient de la
   feuille de la page. Le compteur baissait, la liste ne bougeait pas. */
.word-filter-row[hidden] {
  display: none;
}

.word-filter-empty {
  margin: 0;
  padding: 12px 8px;
  text-align: center;
}

.word-filter-row:hover {
  background: #262a35;
}

.word-filter-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.word-filter-row .word-filter-word {
  flex: 1;
}

.word-filter-row .word-filter-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.word-filter-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.status-line {
  font-size: 1.05rem;
  font-weight: 700;
}

/* Qui joue avec qui : une ligne de puces sous le statut, toujours visible
   (y compris à la fin de la manche) pour qu'on n'ait jamais à le deviner. */
.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.roster-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.roster-chip.you {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.2);
}

.roster-chip.seat-A,
.roster-chip.team-A {
  background: rgba(62, 207, 142, 0.14);
  border-color: rgba(62, 207, 142, 0.4);
  color: var(--success);
}

.roster-chip.seat-B,
.roster-chip.team-B {
  background: rgba(79, 163, 255, 0.14);
  border-color: rgba(79, 163, 255, 0.4);
  color: #4fa3ff;
}

.roster-chip.you.seat-A,
.roster-chip.you.team-A,
.roster-chip.you.seat-B,
.roster-chip.you.team-B {
  color: var(--text);
}

/* Ton propre coéquipier (même équipe, mode teams ; l'autre siège, mode duet) :
   même famille de couleur que toi, distingué du camp adverse par un contour
   plein plutôt qu'à demi-teinte. */
.roster-chip.mate {
  border-style: solid;
  font-weight: 700;
}

.roster-chip .roster-crown {
  margin-left: 2px;
}

.counters-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.counters-line .chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

/* Plateau et panneau d'indice côte à côte sur un écran large : c'est ce qui
   évite le défilement vertical une fois les cartes empilées. */
.game-live {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 12px;
  align-items: start;
}

@media (max-width: 820px) {
  .game-live {
    grid-template-columns: 1fr;
  }
}

.clue-display {
  margin-bottom: 12px;
}

.clue-text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  margin-top: 2px;
}

#clue-form .inline-form {
  flex-wrap: wrap;
}

#clue-number {
  width: 70px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

#pass-btn {
  margin-top: 4px;
}

#turn-hint {
  margin-top: 8px;
}

.key-toggle-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

/* Récap de fin de manche : la grille complète (ou les deux clés, en duet) ne
   sert plus qu'à relire la partie, pas à jouer — en tuiles compactes, elle
   tient sur l'écran au lieu de forcer un long défilement. */
.board-grid.small-grid {
  gap: 4px;
  margin-bottom: 10px;
}

.board-grid.small-grid .tile {
  aspect-ratio: 5 / 2.2;
  font-size: 0.6rem;
  padding: 3px;
  border-radius: 6px;
}

.end-recap-duet {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .end-recap-duet {
    grid-template-columns: 1fr;
  }
}

.tile {
  aspect-ratio: 5 / 4;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  line-height: 1.15;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.tile-word {
  line-height: 1.1;
}

/* Série d'origine du mot, en petit sous le mot : aide qui doit donner un
   indice sur un mot qu'il ne reconnaît pas. Toujours publique (pas une info
   cachée comme la couleur), donc affichée à tout le monde sans distinction. */
.tile-hint {
  font-size: 0.58rem;
  font-weight: 500;
  line-height: 1;
  opacity: 0.65;
}

.tile.revealed .tile-hint {
  opacity: 0.85;
}

.tile:not(:disabled) {
  cursor: pointer;
}

.tile:not(:disabled):hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.tile:disabled {
  cursor: default;
}

/* Case pas encore révélée mais dont tu connais la couleur (ta propre clé, ou
   toute la grille pour un chiffreur) : un liseré teinté plutôt qu'un fond
   plein, pour ne jamais se confondre avec une case déjà retournée aux yeux de
   toute la table. */
.tile.key-hint {
  border-width: 2px;
}

.tile.revealed {
  color: white;
  font-weight: 800;
}

.tile.c-agent.key-hint,
.tile.c-agentA.key-hint {
  border-color: var(--success);
  background: rgba(62, 207, 142, 0.12);
}

.tile.c-agent.revealed,
.tile.c-agentA.revealed {
  background: var(--success);
  border-color: var(--success);
}

.tile.c-agentB.key-hint {
  border-color: #4fa3ff;
  background: rgba(79, 163, 255, 0.12);
}

.tile.c-agentB.revealed {
  background: #4fa3ff;
  border-color: #4fa3ff;
}

.tile.c-bystander.key-hint,
.tile.c-neutral.key-hint {
  border-color: var(--warning);
  background: rgba(230, 184, 60, 0.12);
}

.tile.c-bystander.revealed,
.tile.c-neutral.revealed {
  background: var(--warning);
  border-color: var(--warning);
  color: #1a1500;
}

.tile.c-assassin.key-hint {
  border-color: var(--danger);
  background: rgba(239, 91, 91, 0.12);
}

.tile.c-assassin.revealed {
  background: #0c0d10;
  border-color: var(--danger);
  color: var(--danger);
}

.tile.recap {
  cursor: default;
}

/* Écran de fin : qui a gagné doit sauter aux yeux avant tout le reste. */
.end-banner {
  text-align: center;
  padding: 12px 16px 14px;
  margin: -16px -18px 12px;
  border-radius: 14px 14px 0 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.end-banner.win {
  background: rgba(62, 207, 142, 0.14);
  border-bottom-color: rgba(62, 207, 142, 0.4);
}

.end-banner.lose {
  background: rgba(239, 91, 91, 0.14);
  border-bottom-color: rgba(239, 91, 91, 0.4);
}

.end-icon {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 2px;
}

#end-title {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

#end-summary {
  margin: 0;
}

@media (max-width: 520px) {
  .tile {
    font-size: 0.68rem;
  }

  .tile-hint {
    font-size: 0.52rem;
  }
}
