/* Pages de jeu du Snake : réglages, bloc de jeu (scores, plateau, croix tactile),
   fenêtre de fin. L'habillage commun (fond, carte, boutons, overlay) vient de css/jeu.css. */

.top-bar-outils { display: flex; gap: 6px; min-width: 60px; justify-content: flex-end; }
.sn-outil {
  width: 38px; height: 38px;
  border: 1px solid var(--line-forte); border-radius: 6px;
  background: transparent; color: var(--texte);
  font-size: 1.05rem; line-height: 1; cursor: pointer;
}
.sn-outil:hover { background: var(--surface-2); border-color: var(--color-light); }

/* --- Réglages ------------------------------------------------------------ */
.sn-reglages { margin-bottom: 14px; transition: opacity 0.15s; }
body.sn-en-jeu .sn-reglages { opacity: 0.45; }
.sn-reglage { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; margin-bottom: 8px; }
.sn-reglage-titre { font-size: 0.82rem; font-weight: 700; color: var(--texte-doux); text-transform: uppercase; letter-spacing: 0.04em; }
.sn-reglage-aide { flex-basis: 100%; font-size: 0.8rem; color: var(--texte-doux); }
.sn-niveaux { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.sn-niveau {
  width: 36px; height: 36px;
  border: 1px solid var(--line-forte); border-bottom-width: 3px; border-radius: 6px;
  background: var(--surface-2); color: var(--texte);
  font: 700 0.9rem 'Inter', sans-serif; cursor: pointer;
}
.sn-niveau:hover:not(:disabled) { border-color: var(--color-light); }
.sn-niveau:disabled { cursor: not-allowed; }
.sn-cat-tranquille { border-bottom-color: #4ade80; }
.sn-cat-normal { border-bottom-color: #22d3ee; }
.sn-cat-rapide { border-bottom-color: #f59e0b; }
.sn-cat-extreme { border-bottom-color: #ef4444; }
.sn-niveau.actif { background: var(--color-btn1); border-color: var(--color-btn1); color: #fff; }
.sn-options { font-size: 0.85rem; color: var(--texte); }
.sn-option { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.sn-option select {
  font: inherit; color: var(--texte); background: var(--surface-2);
  border: 1px solid var(--line-forte); border-radius: 6px; padding: 5px 8px;
}

.sn-legende { font-size: 0.8rem; color: var(--texte-doux); margin-bottom: 10px; }
.sn-pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 10px; vertical-align: baseline; }
.sn-pastille-anti { background: #22d3ee; }
.sn-pastille-croix { background: #ef4444; }

/* --- Bloc de jeu --------------------------------------------------------- */
.sn-bloc {
  display: flex; flex-direction: column; align-items: center;
  scroll-margin-top: 56px;
}
.sn-infos { width: 100%; max-width: 720px; margin-bottom: 12px; justify-content: space-around; }
.sn-plateau {
  position: relative; max-width: 100%;
  border: 2px solid var(--line-forte); border-radius: 8px; overflow: hidden;
  background: #0a0a1a; box-sizing: content-box;
  touch-action: none;
}
.sn-plateau canvas { display: block; }
@keyframes sn-choc {
  0% { border-color: #ef4444; box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.45); }
  100% { border-color: var(--line-forte); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.sn-plateau.sn-choc { animation: sn-choc 0.7s ease-out; }

/* Message posé sur le plateau. Une simple consigne se range en bas, sans rien cacher du
   serpent ; une pause, un décompte ou un résultat (texte fort) prend le centre. */
.sn-voile {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px; pointer-events: none;
}
.sn-voile[hidden] { display: none; }
.sn-voile p {
  display: flex; flex-direction: column; gap: 6px; color: #f0f3f6; font-size: 0.9rem; font-weight: 600;
  background: rgba(6, 8, 11, 0.8); border-radius: 8px; padding: 8px 14px;
}
.sn-voile p:empty { display: none; }
.sn-voile-centre { align-items: center; background: rgba(6, 8, 11, 0.55); pointer-events: auto; }
.sn-voile-centre p { background: none; font-size: 0.95rem; }
.sn-voile strong { font-size: 1.5rem; }
.sn-voile .sn-chiffre { font-size: 4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.sn-voile-cliquable { cursor: pointer; }

/* Croix directionnelle : seulement sur les appareils tactiles */
.sn-croix {
  display: none;
  grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(2, 58px); gap: 6px;
  margin-top: 14px; touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.sn-fleche {
  border: 1px solid var(--line-forte); border-radius: 10px;
  background: var(--surface-2); color: var(--texte);
  font-size: 1.25rem; cursor: pointer; touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.sn-fleche:active { background: var(--color-btn1); color: #fff; }
.sn-haut { grid-column: 2; grid-row: 1; }
.sn-gauche { grid-column: 1; grid-row: 2; }
.sn-bas { grid-column: 2; grid-row: 2; }
.sn-droite { grid-column: 3; grid-row: 2; }
@media (pointer: coarse) {
  .sn-croix { display: grid; }
}

/* Écran couché, téléphone ou tablette : plateau à gauche, scores et croix à droite */
@media (orientation: landscape) and (max-height: 560px) {
  body.page-jeu, body.page-defi, body.page-salle { padding-top: 8px; }
  .page-jeu .jeu-banner, .page-defi .jeu-banner, .page-salle .jeu-banner { display: none; }
}
@media (orientation: landscape) and (max-height: 560px), (orientation: landscape) and (pointer: coarse) {
  .sn-bloc {
    display: grid; grid-template-columns: auto 200px; grid-template-rows: auto auto;
    column-gap: 12px; justify-content: center; align-items: center;
  }
  .sn-plateau { grid-column: 1; grid-row: 1 / span 2; }
  .sn-infos { grid-column: 2; grid-row: 1; flex-direction: column; align-items: flex-start; margin-bottom: 0; align-self: start; }
  .sn-croix { grid-column: 2; grid-row: 2; margin-top: 0; justify-content: center; align-self: end; }
}

/* --- Sous le plateau ----------------------------------------------------- */
.sn-note { min-height: 1.2em; margin-top: 10px; font-size: 0.85rem; color: #fbbf24; }
.sn-objectif { margin-top: 4px; font-size: 0.88rem; color: var(--texte-doux); }
.sn-lien-classement { display: inline-block; margin-top: 10px; }
.sn-texte { text-align: left; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.sn-texte h2 { font-family: var(--font-display); font-size: 1.15rem; color: #f0f3f6; margin-bottom: 8px; }
.sn-texte h3 { font-size: 1rem; color: #f0f3f6; margin: 14px 0 6px; }
.sn-texte p, .sn-texte li { font-size: 0.92rem; line-height: 1.6; color: var(--texte); margin-bottom: 8px; }
.sn-texte ul { padding-left: 20px; }
.sn-texte a { color: var(--color-light); }

/* --- Fenêtre de fin ------------------------------------------------------ */
.overlay-box { position: relative; max-width: 420px; width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; }
.overlay-fermer {
  position: absolute; top: 8px; right: 8px; width: 34px; height: 34px;
  border: none; border-radius: 6px; background: transparent; color: var(--texte-doux);
  font-size: 1.5rem; line-height: 1; cursor: pointer;
}
.overlay-fermer:hover { background: var(--surface-2); color: var(--texte); }
.fin-gagne { color: #4ade80; }
.fin-perdu { color: #f87171; }
#fin-message { color: var(--texte); font-size: 0.95rem; margin: 6px 0 12px; }
.fin-verdict { font-size: 0.92rem; font-weight: 600; color: #fbbf24; margin-bottom: 10px; }
.fin-palier { font-size: 0.9rem; color: #4ade80; margin-bottom: 10px; }
.fin-raccourci { font-size: 0.75rem; color: var(--texte-faible); margin-top: 10px; }
@media (pointer: coarse) { .fin-raccourci { display: none; } }
.overlay-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
#cta-inscription { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
#cta-inscription[hidden] { display: none; }
.cta-score-msg { font-size: 0.88rem; color: var(--texte); margin-bottom: 10px; }
.cta-auth-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.overlay-box .lien-classement { display: inline-block; margin-top: 12px; }

.sn-confetti {
  position: fixed; top: -10px; z-index: 1100; pointer-events: none; font-size: 1.2rem;
  animation: sn-confetti 3s ease-in forwards;
}
@keyframes sn-confetti { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sn-confetti { display: none; }
  .sn-plateau.sn-choc { animation: none; }
}

@media (max-width: 480px) {
  body.page-jeu, body.page-defi, body.page-salle { padding-left: 8px; padding-right: 8px; }
  .page-jeu #app, .page-defi #app, .page-salle #app { padding: 18px 10px 16px; }
  /* Le bandeau sort de la carte par des marges négatives calées sur son padding :
     elles doivent suivre le padding réduit, sinon la page défile de côté. */
  .page-jeu .jeu-banner, .page-defi .jeu-banner, .page-salle .jeu-banner { margin: -18px -10px 16px; }
  .sn-niveau { width: 30px; height: 34px; font-size: 0.85rem; }
  .sn-infos { padding: 8px 10px; }
}
