/* multijoueur.php — règles propres à cette page.
   L'habillage commun vient de fichiers-partages-des-jeux/css/jeu.css. */

/* Habillage commun (body, #app, top-bar, boutons, info-bar, overlay,
   classement) : fichiers-partages-des-jeux/css/jeu.css.
   Ici, uniquement ce qui est propre a ce jeu. */
#app {
  position: relative;
  z-index: 1;
  padding: 32px 24px 24px;
  max-width: 960px;
}

h1 {
  text-align: center;
  margin-bottom: 8px;
}

.champ-pseudo {
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  padding: 10px 16px;
  border: 1px solid var(--line-forte);
  border-radius: 6px;
  background: var(--surface-0);
  color: var(--texte);
  outline: none;
  width: 200px;
}

.champ-pseudo:focus {
  border-color: var(--color-light);
}

.champ-pseudo::placeholder {
  color: var(--texte-faible);
}

.code-display {
  text-align: center;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--texte-doux);
}

.code-display .code {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-light);
  letter-spacing: 4px;
  background: var(--surface-2);
  padding: 4px 16px;
  border-radius: 8px;
  display: inline-block;
  cursor: pointer;
}

.status-bar {
  text-align: center;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--texte);
  font-weight: 600;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.status-bar.mon-tour {
  font-size: 1.15rem;
  color: #64ab7c;
  text-shadow: 0 0 12px rgba(74, 222, 128, 0.4);
}

.status-bar.tour-adverse {
  font-size: 1rem;
  color: #d2973a;
}

.info-bar {
  font-size: 0.82rem;
}

.info-item span {
  color: var(--color-light);
  font-weight: 700;
}

/* Zone centrale : tour + stats. Desktop = bandeau pleine largeur au-dessus des
   grilles (les 2 grilles pleine taille ne laissent pas la place au milieu).
   Mobile = vraiment entre les 2 grilles, avec flèches verticales. */
.zone-centrale {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  order: -1;
  flex-basis: 100%;
}

.zone-centrale .info-bar {
  margin-bottom: 0;
}

.tour-flag {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 8px 14px;
  border-radius: 6px;
  line-height: 1.2;
  text-align: center;
}

.tour-flag-adverse {
  color: #64ab7c;
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  text-shadow: 0 0 12px rgba(74, 222, 128, 0.35);
}

.tour-flag-flotte {
  color: #d2973a;
  background: var(--surface-2);
  border: 1px solid rgba(251, 191, 36, 0.25);
  font-weight: 600;
}

.tour-arrow {
  font-size: 1.05rem;
  line-height: 1;
  display: none;
}

.tour-flag-adverse .tour-arrow {
  color: #64ab7c;
  animation: tour-fleche 1.2s ease-in-out infinite;
}

.tour-flag-flotte .tour-arrow {
  color: #d2973a;
}

@keyframes tour-fleche {

  0%, 100% {
    opacity: 1;
  }

  50% {
    opacity: 0.45;
  }
}

.grilles-container {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.grille-wrapper {
  text-align: center;
}

.grille-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--texte);
  margin-bottom: 8px;
}

.grille {
  display: inline-grid;
  gap: 1px;
  background: var(--surface-2);
  border: 2px solid var(--line-forte);
  border-radius: 8px;
  overflow: hidden;
}

.grille-header {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--texte-faible);
  background: var(--surface-2);
}

.cell {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  background: var(--surface-1);
  user-select: none;
  -webkit-user-select: none;
}

.cell:hover {
  background: var(--surface-2);
}

.cell.eau {
  background: #1e3550;
  color: #7fb0dd;
}

.cell.touche {
  background: #9c333c;
  color: #ffdcdc;
}

.cell.coule {
  background: #47141a;
  color: #ff9a9a;
  box-shadow: inset 0 0 0 2px #c4545e;
}

.cell.navire {
  background: rgba(99, 102, 241, 0.35);
  border: 1px solid var(--line-forte);
}

.cell.navire-touche {
  background: #9c333c;
  border: 1px solid #b8434d;
}

.cell.navire-coule {
  background: #47141a;
  border: 2px solid #c4545e;
}

.cell.preview {
  background: var(--surface-2);
  border: 2px dashed rgba(99, 102, 241, 0.6);
}

.cell.preview-invalid {
  background: var(--surface-2);
  border: 2px dashed rgba(239, 68, 68, 0.6);
}

.cell.disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.placement-info {
  text-align: center;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--texte-doux);
}

.placement-info .key {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  color: var(--texte);
}

.navires-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}

.navire-tag {
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  color: var(--texte-doux);
}

.navire-tag.actif {
  background: rgba(99,102,241,0.3);
  border-color: var(--line-forte);
  color: var(--texte);
}

.navire-tag.place {
  background: rgba(16,185,129,0.2);
  border-color: rgba(16,185,129,0.4);
  color: #6ee7b7;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Attente */
.attente-card {
  text-align: center;
  padding: 40px;
}

.attente-card .spinner {
  font-size: 2rem;
  animation: pulse 1.5s infinite;
  margin-bottom: 16px;
}

@keyframes pulse {

  0%, 100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.attente-card .code-big {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-light);
  letter-spacing: 8px;
  margin: 16px 0;
}

.overlay-card {
  background: var(--surface-1);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
  padding: 40px;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.overlay-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.overlay-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  font-family: var(--font-display);
  color: #f0f3f6;
}

.overlay-stats {
  font-size: 0.9rem;
  color: var(--texte-doux);
  margin-bottom: 20px;
  line-height: 1.6;
}

.overlay-stats span {
  color: var(--color-light);
  font-weight: 700;
}

.btn-copier {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 8px;
  cursor: pointer;
  background: var(--surface-2);
  color: #d2973a;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  margin-left: 8px;
  vertical-align: middle;
}

.btn-copier:hover {
  background: rgba(251, 191, 36, 0.3);
  border-color: rgba(251, 191, 36, 0.5);
}

.btn-copier.copie {
  background: var(--surface-2);
  border-color: rgba(34, 197, 94, 0.4);
  color: #64ab7c;
}

@media (max-width: 780px) {

  .grilles-container {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  /* La zone centrale revient entre les 2 grilles (ordre du DOM) */
  .zone-centrale {
    order: 0;
    flex-basis: auto;
    width: 100%;
    gap: 6px;
  }

  .tour-flag {
    padding: 3px 12px;
    font-size: 0.9rem;
    border-radius: 6px;
  }

  .arrow-up, .arrow-down {
    display: inline;
  }

  .cell {
    width: 28px;
    height: 28px;
    font-size: 0.65rem;
  }

  #app {
    padding: 24px 12px 16px;
  }
}

@media (max-width: 400px) {

  .cell {
    width: 24px;
    height: 24px;
  }
}

/* === Lobby (Créer / Rejoindre une partie) === */
#lobby {
  max-width: 760px;
  margin: 0 auto;
}

.lobby-intro {
  text-align: center;
  color: var(--texte-doux);
  font-size: 0.92rem;
  margin-bottom: 22px;
  line-height: 1.6;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.lobby-panel {
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
  padding: 20px;
}

.lobby-panel h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--texte);
  margin-bottom: 14px;
  text-align: left;
}

.lobby-label {
  display: block;
  font-size: 0.8rem;
  color: var(--texte-doux);
  margin-bottom: 8px;
  font-weight: 600;
}

.visibilite-grille {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.visibilite-btn {
  flex: 1;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  color: var(--texte-doux);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.visibilite-btn:hover {
  background: var(--surface-2);
}

.visibilite-btn.active {
  background: var(--surface-2);
  border-color: var(--line-forte);
  color: var(--texte);
}

.lobby-input {
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--line-forte);
  background: var(--surface-2);
  color: #f1f5f9;
  outline: none;
  margin-bottom: 12px;
}

.lobby-input:focus {
  border-color: var(--line-forte);
}

.lobby-input::placeholder {
  color: var(--texte-faible);
}

.lobby-input-code {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 3px;
  max-width: 100px;
}

.lobby-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lobby-row .lobby-input {
  flex: 1;
  min-width: 110px;
}

.lobby-row .btn {
  flex-shrink: 0;
}

.lobby-btn-full {
  width: 100%;
}

.lobby-erreur {
  color: #d07070;
  font-size: 0.82rem;
  min-height: 1.2rem;
  margin-top: 4px;
}

.parties-publiques {
  margin-top: 16px;
}

.parties-publiques h3 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--texte);
  margin-bottom: 10px;
  font-weight: 700;
}

.liste-publiques {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.carte-publique {
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.carte-publique-info {
  flex: 1;
  min-width: 0;
}

.carte-publique-info .createur {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--texte);
}

.carte-publique-info .details {
  font-size: 0.72rem;
  color: var(--texte-doux);
  margin-top: 2px;
}

.carte-publique .btn {
  font-size: 0.76rem;
  padding: 6px 12px;
  flex-shrink: 0;
}

.aucune-partie {
  font-size: 0.8rem;
  color: var(--texte-faible);
  text-align: center;
  padding: 12px 0;
}

.lobby-seo {
  margin: 30px auto 4px;
  color: var(--texte-doux);
  font-size: 0.9rem;
  line-height: 1.7;
}

.lobby-seo h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--texte);
  margin-bottom: 12px;
  font-weight: 700;
}

.lobby-seo p {
  margin-bottom: 12px;
}

.lobby-seo a {
  color: var(--color-light);
  font-weight: 600;
  text-decoration: none;
}

.lobby-seo a:hover {
  text-decoration: underline;
}

@media (max-width: 680px) {

  .lobby-grid {
    grid-template-columns: 1fr;
  }
}

/* Ligne pseudo + bouton pour rejoindre directement une partie */
.ligne-rejoindre {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
