/* Ajouts multijoueur au style de SUTOM (jeu.css, inchangé hormis les URL de polices).
   Mêmes variables, mêmes couleurs : rien de nouveau dans la palette. */

:root {
  --mini: 6px;
  --rayon: 5px;
  --hauteur-touche: 45px;
}

/* ------------------------------------------------------------ socle */

body {
  height: auto;
  max-height: none;
  min-height: 100vh;
  min-height: 100dvh;
}

#contenu {
  min-height: 100vh;
  min-height: 100dvh;
  justify-content: flex-start;
}

[hidden] {
  display: none !important;
}

h1 {
  font-size: min(2em, 11vw);
  white-space: nowrap;
}

.bouton-icone {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  color: inherit;
  cursor: pointer;
  border-radius: var(--rayon);
}

:focus-visible {
  outline: 3px solid var(--couleur-mal-place);
  outline-offset: 2px;
}

#notification-area {
  position: fixed;
  top: 3.6rem;
  left: 0;
  right: 0;
  z-index: 9;
  min-height: 0;
  pointer-events: none;
}

body.mode-jeu #notification-area {
  top: 40%;
}

#notification-label:empty {
  display: none;
}

#panel-area:not([hidden]) {
  display: block;
}

#panel-fenetre h3 {
  font-size: 20px;
  margin: 0.75em 0 0.25em;
  padding: 0 0.5em;
}

.bandeau-connexion {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  padding: 0.5rem;
  font-size: 16px;
  background: var(--couleur-bien-place);
  color: #ffffff;
}

/* ------------------------------------------------------------ éléments communs */

.ecran {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 0.5rem 2.5rem;
  font-size: 18px;
}

.bouton {
  font: inherit;
  font-size: 18px;
  line-height: 1.2;
  padding: 0.65rem 1rem;
  border-radius: var(--rayon);
  border: 1px solid var(--couleur-police);
  background: transparent;
  color: var(--couleur-police);
  cursor: pointer;
}

.bouton:hover,
.bouton:active {
  background-color: var(--couleur-lettre-survole);
}

.bouton-principal {
  background-color: var(--couleur-fond-grille);
  border-color: var(--couleur-fond-grille);
  color: #ffffff;
}

.bouton-principal:hover,
.bouton-principal:active {
  background-color: var(--couleur-fond-grille);
  filter: brightness(1.12);
}

.bouton:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input[type="text"],
select {
  font: inherit;
  color: var(--couleur-police);
  background-color: var(--couleur-fond);
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

input[type="text"] {
  font-size: 20px;
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
}

/* ------------------------------------------------------------ accueil */

.accueil-logo {
  min-height: 0;
  margin: 0.5rem auto 0;
  background: transparent;
}

.accueil-accroche {
  margin: 0;
  line-height: 1.5;
  max-width: 30em;
}

.accueil-formulaire {
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: start;
}

.champ label {
  display: block;
  font-size: 15px;
  margin-bottom: 0.3rem;
}

.champ-code {
  margin-top: 0.75rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--couleur-bordure);
}

.champ-ligne {
  display: flex;
  gap: 0.5rem;
}

#champ-code {
  text-transform: uppercase;
  font-family: "RobotoMono Regular", monospace;
  letter-spacing: 0.12em;
}

#champ-code::placeholder {
  letter-spacing: 0.12em;
  opacity: 0.35;
}

/* ------------------------------------------------------------ salon */

.salon-titre {
  margin: 0.25rem 0 0;
  font-size: 28px;
}

.salon-code-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.salon-legende {
  margin: 0;
  font-size: 15px;
}

.salon-code {
  min-height: 0;
  margin: 0;
}

.salon-code td {
  font-family: "RobotoMono Regular", monospace;
}

.salon-partage {
  display: flex;
  gap: 0.5rem;
}

.salon-statut {
  margin: 0;
  min-height: 1.4em;
}

.salon-membres {
  list-style: none;
  margin: 0;
  padding: 0;
  width: min(100%, 420px);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: start;
}

.salon-membre {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
}

.salon-membre.moi {
  border-color: var(--couleur-fond-grille);
  box-shadow: inset 4px 0 0 var(--couleur-fond-grille);
}

.salon-membre.deconnecte {
  opacity: 0.5;
}

.salon-membre-marque {
  font-size: 14px;
  opacity: 0.8;
}

.salon-membre .bouton {
  margin-left: auto;
  font-size: 14px;
  padding: 0.2rem 0.6rem;
}

.salon-options {
  width: min(100%, 420px);
  box-sizing: border-box;
  border: 1px solid var(--couleur-bordure);
  border-radius: var(--rayon);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: start;
}

.salon-options legend {
  font-size: 15px;
  padding: 0 0.3rem;
}

.salon-options select {
  font-size: 18px;
  min-width: 40%;
}

.salon-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

/* ------------------------------------------------------------ partie : disposition */

body.mode-jeu {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

body.mode-jeu #contenu {
  height: 100%;
  min-height: 0;
  margin-left: 4px;
  margin-right: 4px;
}

body.mode-jeu header {
  margin-bottom: 0;
}

body.mode-jeu #ecrans {
  flex: 1 1 auto;
  min-height: 0;
}

#ecran-jeu {
  height: 100%;
  padding: 0;
  gap: 0;
  font-size: 16px;
}

.jeu-disposition {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.jeu-centre {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  gap: 4px;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  --taille-cellule: clamp(24px, min(9.2vw, 5.2dvh), 48px);
}

.adversaires-droite {
  display: none;
}

.adversaires {
  flex: 0 0 auto;
  max-height: 24dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  align-content: start;
  gap: 4px;
  padding: 4px 2px;
  box-sizing: border-box;
  width: 100%;
  border-bottom: 1px solid var(--couleur-bordure);
}

.adversaires:empty {
  display: none;
}

@media (min-width: 1100px) {
  :root {
    --mini: 7px;
  }

  .jeu-disposition {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 540px) minmax(0, 1fr);
    gap: 12px;
  }

  .adversaires,
  .adversaires-droite {
    display: grid;
    max-height: none;
    height: 100%;
    border-bottom: 0;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    padding: 8px 4px;
  }

  .adversaires:empty {
    display: grid;
  }

  .jeu-centre {
    --taille-cellule: clamp(30px, 5.4dvh, 48px);
  }
}

/* ------------------------------------------------------------ partie : adversaires */

.adversaire {
  font: inherit;
  color: inherit;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--rayon);
  padding: 3px 2px;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  cursor: pointer;
  position: relative;
}

.adversaire:hover {
  border-color: var(--couleur-non-trouve);
}

.adversaire.cible {
  border-color: var(--couleur-bien-place);
}

.adversaire-pseudo {
  font-size: 11px;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adversaire-chrono {
  font-family: "RobotoMono Regular", monospace;
  font-size: 11px;
  line-height: 1.1;
}

.adversaire-chrono.critique {
  color: var(--couleur-bien-place);
}

.mini-grille {
  display: grid;
  grid-template-columns: repeat(var(--colonnes, 6), var(--mini));
  grid-auto-rows: var(--mini);
  gap: 1px;
  padding: 1px;
  background-color: var(--couleur-bordure-grille);
}

.mini-grille i {
  background-color: var(--couleur-fond-grille);
}

.mini-grille i.c2 {
  background-color: var(--couleur-bien-place);
}

.mini-grille i.c1 {
  background: radial-gradient(circle closest-side, var(--couleur-mal-place) 88%, var(--couleur-fond-grille) 100%);
}

.mini-grille i.courante {
  background-color: rgb(0, 95, 160);
}

.adversaire-effets {
  font-size: 10px;
  line-height: 12px;
  min-height: 12px;
}

.adversaire.elimine {
  opacity: 0.35;
  filter: grayscale(1);
  cursor: default;
}

.adversaire.deconnecte .adversaire-pseudo {
  opacity: 0.55;
  font-style: italic;
}

.adversaire-rang {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--couleur-police);
}

.adversaire.touche {
  animation: touche 0.7s ease-out;
}

@keyframes touche {
  0% {
    background-color: rgba(231, 0, 42, 0.55);
  }
  100% {
    background-color: transparent;
  }
}

/* Beaucoup d'adversaires sur petit écran : on n'affiche que les grilles. */
.adversaires.dense {
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  --mini: 4px;
}

.adversaires.dense .adversaire-pseudo {
  display: none;
}

/* ------------------------------------------------------------ partie : tableau de bord */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  max-width: 500px;
  padding: 0 4px;
  box-sizing: border-box;
}

.hud-chrono-zone {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.hud-chrono {
  font-family: "RobotoMono Regular", monospace;
  font-size: 34px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.hud-chrono.critique {
  color: var(--couleur-bien-place);
  animation: battement 1s steps(2, jump-none) infinite;
}

.hud-chrono.accelere::after {
  content: " ×2";
  font-size: 16px;
  color: var(--couleur-mal-place);
}

@keyframes battement {
  50% {
    opacity: 0.55;
  }
}

.hud-barre {
  width: 112px;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  background-color: rgba(127, 127, 127, 0.3);
}

.hud-barre-remplissage {
  height: 100%;
  width: 100%;
  background-color: var(--couleur-fond-grille);
  transform-origin: left center;
  transform: scaleX(1);
}

.hud-barre-remplissage.critique {
  background-color: var(--couleur-bien-place);
}

.hud-stats {
  display: flex;
  gap: 0.9rem;
  margin: 0;
}

.hud-stats div {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
}

.hud-stats dt {
  font-size: 11px;
  opacity: 0.75;
}

.hud-stats dd {
  margin: 0;
  font-size: 18px;
  font-family: "RobotoMono Regular", monospace;
}

.hud-ciblage {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.hud-ciblage button {
  font: inherit;
  font-size: 13px;
  padding: 3px 8px;
  border-radius: var(--rayon);
  border: 1px solid var(--couleur-non-trouve);
  background: none;
  color: inherit;
  cursor: pointer;
}

.hud-ciblage button[aria-checked="true"] {
  border-color: var(--couleur-fond-grille);
  background-color: var(--couleur-fond-grille);
  color: #ffffff;
}

.effets-actifs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 20px;
  font-size: 13px;
}

.effet-puce {
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--couleur-non-trouve);
  font-variant-numeric: tabular-nums;
}

.effet-puce.bonus {
  border-color: var(--couleur-fond-grille);
}

/* ------------------------------------------------------------ partie : grille */

.grille-zone {
  position: relative;
  margin: 0 auto;
}

.jeu-centre #grille {
  min-height: 0;
  margin: 0 auto;
  font-size: calc(var(--taille-cellule) * 0.62);
  transition: box-shadow 0.3s;
}

.grille tr.brouillee td::before {
  content: "🌫️";
  position: absolute;
  top: -2px;
  right: 0;
  font-size: 10px;
}

.grille tr.brouillee td:not(:last-child)::before {
  content: none;
}

.grille.secousse {
  animation: secousse 0.45s;
}

@keyframes secousse {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

.voile-encre {
  position: absolute;
  inset: -6px;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.tache {
  position: absolute;
  border-radius: 46% 54% 52% 48% / 55% 45% 55% 45%;
  background-color: rgb(16, 16, 26);
  box-shadow: 0 0 0 6px rgba(16, 16, 26, 0.75), 18px 12px 0 -4px rgb(16, 16, 26), -14px 16px 0 -6px rgb(16, 16, 26);
  opacity: 0.96;
  transition: opacity 1s;
}

.voile-encre.disparait .tache {
  opacity: 0;
}

.jeu-centre.gele #grille,
.jeu-centre.gele #input-area {
  box-shadow: 0 0 0 3px rgb(190, 225, 255);
  filter: saturate(0.4) brightness(1.15);
}

.jeu-centre.gele #input-area .input-lettre {
  cursor: not-allowed;
}

.jeu-voile {
  position: absolute;
  inset: -4px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  text-align: center;
  background-color: rgba(var(--couleur-fond-rgb), 0.86);
  border-radius: var(--rayon);
}

.jeu-voile-texte {
  font-size: 44px;
  line-height: 1.1;
}

.jeu-voile-detail {
  font-size: 16px;
}

.jeu-voile-detail:empty,
.jeu-voile-actions:empty {
  display: none;
}

.jeu-voile-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

/* ------------------------------------------------------------ partie : bonus, clavier, fil */

.inventaire {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.inventaire button {
  font: inherit;
  font-size: 13px;
  min-width: 76px;
  padding: 3px 6px;
  border-radius: var(--rayon);
  border: 1px dashed var(--couleur-non-trouve);
  background: none;
  color: inherit;
  cursor: pointer;
}

.inventaire button.plein {
  border-style: solid;
  border-color: var(--couleur-mal-place);
}

.inventaire button:disabled {
  cursor: default;
  opacity: 0.55;
}

.jeu-centre #input-area {
  margin: 0 auto;
  font-size: 18px;
}

.jeu-centre .input-lettre {
  height: var(--hauteur-touche);
}

#input-area.clavier-efface .input-lettre,
#input-area.clavier-efface .input-lettre.lettre-bien-place,
#input-area.clavier-efface .input-lettre.lettre-mal-place,
#input-area.clavier-efface .input-lettre.lettre-non-trouve {
  background-color: transparent;
  color: var(--couleur-police);
  border-color: var(--couleur-police);
}

#input-area.clavier-efface .input-lettre.input-lettre-vide {
  border: 0;
}

#input-area.clavier-efface .input-lettre.input-lettre-effacer,
#input-area.clavier-efface .input-lettre.input-lettre-entree {
  background-color: var(--couleur-lettre-speciale);
  border-color: var(--couleur-lettre-speciale);
}

.fil {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 500px;
  min-height: 2.6em;
  font-size: 13px;
  line-height: 1.3;
  text-align: start;
  opacity: 0.85;
}

.fil li {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.fil li:nth-child(n + 3) {
  display: none;
}

@media (min-width: 1100px) {
  .fil li:nth-child(n + 3) {
    display: list-item;
  }

  .fil {
    min-height: 6.5em;
  }
}

/* ------------------------------------------------------------ panneaux : classement, règles */

.classement {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  text-align: start;
}

.classement th,
.classement td {
  padding: 5px 6px;
  border-bottom: 1px solid rgba(127, 127, 127, 0.35);
}

.classement th {
  font-size: 13px;
  font-weight: normal;
  opacity: 0.75;
  text-align: start;
}

.classement td:first-child,
.classement td:nth-child(n + 3) {
  font-family: "RobotoMono Regular", monospace;
  text-align: end;
}

.classement th:first-child,
.classement th:nth-child(n + 3) {
  text-align: end;
}

.classement td.en-lice {
  font-family: inherit;
  font-size: 14px;
  opacity: 0.8;
}

.classement tr.moi td {
  background-color: rgba(0, 119, 199, 0.35);
}

.classement tr.elimine td {
  opacity: 0.6;
}

.fin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.fin-resume {
  font-size: 18px;
  margin: 0.25rem 0 0.75rem;
}

.regles-liste {
  text-align: start;
  font-size: 14px;
  margin: 0.25em 0;
  padding-left: 1.5em;
}

.regles-liste li {
  margin: 0.2em 0;
}

.regles-credits {
  font-size: 12px;
  opacity: 0.8;
}

/* ------------------------------------------------------------ petits écrans */

@media (max-width: 500px) {
  .jeu-centre {
    --hauteur-touche: clamp(36px, 6dvh, 46px);
  }

  .hud-chrono {
    font-size: 28px;
  }

  .hud-barre {
    width: 84px;
  }

  .hud-stats {
    gap: 0.6rem;
  }

  .hud-stats dd {
    font-size: 15px;
  }

  .inventaire button {
    min-width: 64px;
    font-size: 12px;
  }
}

@media (max-height: 700px) {
  body.mode-jeu header {
    --taille-icone-zone: 36px;
  }

  body.mode-jeu h1 {
    font-size: 26px;
  }

  .hud-ciblage button {
    padding: 2px 6px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
