/* Othello — pages de jeu (solo, à deux sur un écran, multijoueur).
   Sorti des <style> en ligne de solo.php et multijoueur.php le 02/10/2026. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
}
#app {
  position: relative; z-index: 1;
  background: rgba(20, 20, 35, 0.55);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 30px 24px 24px;
  max-width: 560px;
  width: 100%;
  margin-top: 60px;
  text-align: center;
}
h1 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(90deg, var(--color-light), var(--color-mid), var(--color-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

/* --- Disposition : plateau + informations --------------------------------- */
/* En portrait, les informations passent au-dessus du plateau et les boutons
   dessous : la colonne d'informations s'efface (display: contents) et ses enfants
   sont rangés par `order`. En paysage, elle redevient une colonne à droite. */
.zone-jeu { display: flex; flex-direction: column; }
.colonne-infos { display: contents; }
.colonne-infos > * { order: 1; }
.colonne-plateau { order: 2; }
.colonne-infos > .actions { order: 3; }

.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: #94a3b8;
}
.option-aide {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: #94a3b8; cursor: pointer;
}
.option-aide input { width: 16px; height: 16px; accent-color: var(--color-mid); }
.score-display, .players-list {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.score-box, .player-tag {
  padding: 6px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  display: inline-flex; align-items: center; gap: 8px;
}
.player-tag { font-size: 0.9rem; font-weight: 600; padding: 8px 18px; }
.score-noir, .player-noir { background: rgba(30,30,30,0.8); color: #fff; border: 2px solid #555; }
.score-blanc, .player-blanc { background: rgba(255,255,255,0.85); color: #1a1a1a; border: 2px solid #ccc; }
.score-box.actif, .player-tag.actif { border-color: var(--color-mid); box-shadow: 0 0 12px color-mix(in srgb, var(--color-mid) 50%, transparent); }
/* Disques identiques aux pions (les emojis ⚫⚪ s'affichaient en violet selon les systèmes) */
.disque { width: 16px; height: 16px; border-radius: 50%; display: inline-block; flex: none; }
.disque-noir { background: radial-gradient(circle at 35% 35%, #555, #1a1a1a); box-shadow: 0 0 0 1px rgba(255,255,255,0.25); }
.disque-blanc { background: radial-gradient(circle at 35% 35%, #fff, #ccc); box-shadow: 0 0 0 1px rgba(0,0,0,0.25); }

.turn-indicator {
  font-size: 0.85rem;
  color: var(--color-accent);
  margin-bottom: 10px;
  min-height: 1.2em;
}
/* Message ponctuel : passe de tour, coup refusé, adversaire absent */
.message-jeu {
  min-height: 1.4em;
  margin: -4px 0 10px;
  font-size: 0.85rem;
  color: #fcd34d;
}
.message-jeu.alerte { color: #fca5a5; }
.message-jeu .btn { margin-left: 8px; padding: 6px 12px; font-size: 0.8rem; }

/* --- Plateau --------------------------------------------------------------- */
.board-container { display: flex; justify-content: center; margin-bottom: 16px; }
.board {
  display: grid;
  grid-template-columns: repeat(var(--taille, 8), 1fr);
  gap: 2px;
  background: #1a6b3c;
  border: 3px solid #0d4f2b;
  border-radius: 8px;
  padding: 4px;
  width: 100%;
  /* Le plus grand possible sans dépasser la hauteur de l'écran (PC, tablette) */
  max-width: min(600px, calc(100dvh - 410px));
  min-width: min(100%, 300px);
  aspect-ratio: 1;
}
#app { max-width: 680px; }
.cell {
  background: #2d8a4e;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  aspect-ratio: 1;
  transition: background 0.15s;
}
.cell:hover { background: #38a05d; }
.cell.valid-move { background: #3cb371; }
.cell.valid-move::after {
  content: '';
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.cell.last-move { box-shadow: inset 0 0 0 2px var(--color-mid); }
.cell.refuse { animation: case-refusee 0.35s ease; }
@keyframes case-refusee {
  0%, 100% { transform: translateX(0); background: #2d8a4e; }
  25% { transform: translateX(-3px); background: #7f1d1d; }
  75% { transform: translateX(3px); background: #7f1d1d; }
}
.pion {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  transition: transform 0.3s ease;
  position: absolute;
}
.pion.noir { background: radial-gradient(circle at 35% 35%, #555, #1a1a1a); box-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.pion.blanc { background: radial-gradient(circle at 35% 35%, #fff, #ccc); box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.pion.flip { animation: flipPion 0.4s ease; }

/* Aperçu : pion fantôme sur la case visée, pions qui seraient retournés cerclés */
.cell.apercu-pose::before {
  content: ''; position: absolute; width: 80%; height: 80%; border-radius: 50%; opacity: 0.55; z-index: 1;
}
.cell.apercu-pose[data-couleur="noir"]::before { background: radial-gradient(circle at 35% 35%, #555, #1a1a1a); }
.cell.apercu-pose[data-couleur="blanc"]::before { background: radial-gradient(circle at 35% 35%, #fff, #ccc); }
.cell.apercu-pose.valid-move::after { display: none; }
.cell.apercu-choisi { box-shadow: inset 0 0 0 3px #fcd34d; }
.pion.apercu-retourne { box-shadow: 0 0 0 3px #fcd34d, 0 0 10px rgba(252, 211, 77, 0.8); }
/* Coordonnées (a-h en haut, 1-8 à gauche), discrètes, dans le coin des cases de bord */
.coord { position: absolute; font-size: 0.6rem; font-weight: 700; line-height: 1; color: rgba(255, 255, 255, 0.55); pointer-events: none; z-index: 2; }
.coord-col { top: 2px; right: 3px; }
.coord-ligne { bottom: 2px; left: 3px; }
/* Indice (entraînement) et repères de la relecture */
.cell.indice { box-shadow: inset 0 0 0 4px #fcd34d; background: #4fae70; animation: indice-clignote 1s ease-in-out 3; }
@keyframes indice-clignote { 50% { background: #5fbf7f; } }
.cell.relecture-joue { box-shadow: inset 0 0 0 3px #93c5fd; }
.cell.relecture-meilleur { box-shadow: inset 0 0 0 3px #fcd34d; background: #3f9d63; }

/* --- Écran de réglages ------------------------------------------------------- */
.reglages { text-align: left; max-width: 520px; margin: 4px auto 8px; }
.reglage { margin-bottom: 18px; }
.reglage-titre { display: block; font-weight: 700; color: #e2e8f0; margin-bottom: 8px; font-size: 0.95rem; }
.reglage-aide { color: #94a3b8; font-size: 0.82rem; margin-top: 4px; }
.niveau-ligne { display: flex; align-items: center; gap: 12px; }
.niveau-ligne input { flex: 1; accent-color: var(--color-mid); }
.niveau-valeur { min-width: 32px; text-align: center; font-weight: 800; font-size: 1.3rem; color: var(--color-light); }
.choix { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choix-btn {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start; text-align: left;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 0.95rem; font-weight: 700;
  background: rgba(255,255,255,0.05); color: #e2e8f0; border: 1px solid rgba(255,255,255,0.15);
}
.choix-btn small { font-weight: 400; font-size: 0.75rem; color: #94a3b8; }
.choix-btn.actif { border-color: var(--color-mid); background: color-mix(in srgb, var(--color-mid) 15%, transparent); }
.reglage-cases { display: flex; flex-direction: column; gap: 10px; }
.reglage-cases .option-aide { font-size: 0.9rem; color: #cbd5e1; }
.badge-classement-etat { font-size: 0.82rem; color: #94a3b8; margin-bottom: 14px; }
.badge-classement-etat.classee { color: #fcd34d; }
.btn-commencer { width: 100%; padding: 14px; font-size: 1rem; }
/* Lien entre les deux pages (partie classée / entraînement), sous le bouton de départ */
.reglage-lien { margin-top: 14px; text-align: center; font-size: 0.86rem; color: #94a3b8; }
.reglage-lien a { color: var(--color-light); font-weight: 600; }
.progression { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.progression-titre { font-size: 0.78rem; color: #94a3b8; margin-right: 4px; }
.progression-niveau {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.2);
  background: transparent; color: #94a3b8; font-size: 0.78rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.progression-niveau.fait { background: color-mix(in srgb, var(--color-mid) 25%, transparent); color: var(--color-light); border-color: var(--color-mid); }
.progression-niveau.choisi { outline: 2px solid #fcd34d; outline-offset: 1px; }
.progression-fin { color: var(--color-light); font-weight: 700; margin-bottom: 8px; }
.progression-fin:empty { display: none; }

/* --- Relecture -------------------------------------------------------------- */
.relecture { margin: -4px auto 12px; max-width: 600px; }
.relecture-nav { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 8px; }
.relecture-nav .btn { padding: 8px 12px; }
.relecture-pos { min-width: 110px; font-weight: 700; color: #e2e8f0; }
.relecture-texte { font-size: 0.88rem; color: #cbd5e1; min-height: 2.4em; margin-bottom: 6px; }
.relecture-bilan { font-size: 0.88rem; color: #fcd34d; margin-bottom: 8px; }
.relecture .btn { margin: 4px; }

/* --- Horloges (multijoueur) -------------------------------------------------- */
.horloge { font-variant-numeric: tabular-nums; font-weight: 700; margin-left: 6px; opacity: 0.85; }
.horloge.bas { color: #f87171; opacity: 1; }
@keyframes flipPion {
  0% { transform: scale(1); }
  50% { transform: scale(0, 1); }
  100% { transform: scale(1); }
}

/* --- Boutons ----------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; line-height: 1; padding: 10px 24px; border: none; border-radius: 10px; font-family: 'Inter', sans-serif; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s; text-decoration: none; }
.btn-primary { background: var(--color-btn1); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary { background: rgba(255,255,255,0.1); color: #e0e0e0; border: 1px solid rgba(255,255,255,0.2); }
.btn-secondary:hover { background: rgba(255,255,255,0.15); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
/* Rejouer est écarté du plateau : on ne le touche plus par mégarde après un coup */
.colonne-infos .actions { margin-top: 4px; }
.btn-resultat { display: none; }
.partie-finie .btn-resultat { display: inline-flex; }

/* --- Écran de fin -------------------------------------------------------------- */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1001;             /* au-dessus de la barre du réseau (1000), qui masquait le titre */
  background: rgba(0,0,0,0.88);
  justify-content: center;
  align-items: center;
  padding: 12px;
  overflow-y: auto;
}
.overlay.visible { display: flex; }
.overlay-card {
  position: relative;
  background: rgba(30,30,50,0.95);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 36px 28px 28px;
  max-width: 400px;
  width: 100%;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  margin: auto;
  text-align: center;
}
.overlay-fermer {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08); color: #e0e0e0;
  font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.overlay-fermer:hover { background: rgba(255,255,255,0.18); }
.overlay-card h2 { font-size: 1.8rem; font-weight: 800; margin-bottom: 12px; }
.overlay-card .result-score { font-size: 1.2rem; color: #94a3b8; margin-bottom: 14px; }
.overlay-card .actions { margin-top: 16px; }
.overlay-detail { color: #94a3b8; font-size: 0.85rem; margin-bottom: 10px; }
.statut-enregistrement { font-size: 0.85rem; margin-bottom: 10px; min-height: 1.2em; color: #94a3b8; }
.statut-enregistrement.ok { color: #6ee7b7; }
.statut-enregistrement.erreur { color: #fca5a5; }
.rang-classement { font-weight: 700; color: #fcd34d; margin-bottom: 6px; }
.rang-classement:empty { display: none; }
.lien-classement { display: inline-block; color: var(--color-light); font-size: 0.9rem; font-weight: 600; margin-bottom: 12px; text-decoration: none; }
.lien-classement:hover { text-decoration: underline; }
.lien-classement[hidden] { display: none; }
.win-text { background: linear-gradient(90deg, var(--color-light), var(--color-mid)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.lose-text { background: linear-gradient(90deg, #f87171, #ef4444); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.draw-text { background: linear-gradient(90deg, #fbbf24, #f59e0b); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* CTA inscription */
.cta-inscription {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 14px;
  padding: 18px 20px;
  margin-top: 16px;
}
.cta-inscription[hidden] { display: none; }
.cta-rang { font-size: 1.1rem; font-weight: 800; color: #a78bfa; margin-bottom: 6px; }
.cta-rang:empty { display: none; }
.cta-rang .rang-nombre { color: #fbbf24; font-size: 1.3rem; }
.cta-score-msg { color: #c4b5fd; font-size: 0.85rem; margin-bottom: 12px; }
.cta-auth-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cta-auth-btns .btn { font-size: 0.85rem; padding: 8px 18px; }

/* --- Multijoueur : attente ------------------------------------------------------- */
.code-display { font-size: 2rem; font-weight: 800; letter-spacing: 0.3em; color: var(--color-accent); margin: 12px 0; }
.code-legende { text-align: center; margin-bottom: 12px; }
.code-legende span { font-size: 0.82rem; color: #64748b; }
.waiting-msg { color: #94a3b8; margin-bottom: 16px; font-size: 0.95rem; }
.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: rgba(251, 191, 36, 0.15); color: #fcd34d; transition: all 0.2s; 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: rgba(34, 197, 94, 0.2); border-color: rgba(34, 197, 94, 0.4); color: #4ade80; }
.formulaire-rejoindre { text-align: center; padding: 20px; }
.formulaire-rejoindre p { color: #cbd5e1; margin-bottom: 16px; }
.formulaire-rejoindre .ligne { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.formulaire-rejoindre input {
  font-family: 'Inter', sans-serif; font-size: 0.95rem; padding: 10px 16px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.08); color: #f1f5f9; outline: none; width: 200px;
}
.formulaire-rejoindre input:disabled { opacity: 0.7; }
.erreur-rejoindre { color: #f87171; font-size: 0.85rem; min-height: 1.2rem; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

footer { text-align: center; font-size: 0.78rem; color: #64748b; margin-top: 16px; }
footer a { color: #818cf8; text-decoration: none; }
footer a:hover { color: #a78bfa; }

.info-bar { gap: 8px; }
@media (max-width: 480px) {
  #app { padding: 20px 12px 16px; }
  .board { gap: 1px; padding: 3px; }
  h1 { font-size: 1.3rem; }
  .info-bar { font-size: 0.8rem; }
  /* « IA faible » : seulement si la place le permet */
  .niveau-desc-long { display: none; }
}

/* Petits écrans en hauteur (320×568…) : la bannière laisse sa place au plateau
   (le bouton Accueil reste sous le plateau), qui ne dépasse plus du bas. */
@media (max-height: 640px) and (orientation: portrait) {
  #app { margin-top: 52px; padding-top: 12px; }
  #app .jeu-banner { display: none; }
  h1 { font-size: 1.15rem; margin-bottom: 6px; }
  .score-display { margin-bottom: 6px; }
  .board { max-width: min(440px, calc(100dvh - 250px)); margin: 0 auto; }
}

/* Téléphone en paysage : plateau à gauche, à la hauteur de l'écran ; scores et
   boutons à droite. Avant, le plateau commençait sous le bas de l'écran. */
@media (orientation: landscape) and (max-height: 560px) {
  body { padding: 8px; }
  #app { max-width: 900px; margin-top: 44px; padding: 10px 14px; }
  #app .jeu-banner, #app > h1 { display: none; }
  .zone-jeu { flex-direction: row; align-items: center; gap: 18px; justify-content: center; }
  .colonne-plateau { order: 0; flex: none; }
  .board-container { margin-bottom: 0; }
  .board { width: calc(100dvh - 76px); max-width: calc(100dvh - 76px); }
  .colonne-infos { display: flex; flex-direction: column; flex: 1; min-width: 200px; max-width: 320px; }
  .info-bar { flex-wrap: wrap; gap: 6px; justify-content: center; }
  footer { display: none; }
  .overlay-card { padding: 28px 20px 18px; }
  .overlay-card h2 { font-size: 1.4rem; margin-bottom: 6px; }
}
