/*
 * Saute-Lune — pages où l'on joue (solo, défi du jour) et zone de jeu.
 *
 * Contraintes du réseau :
 *   - #app reste à 800 px hors partie : au-delà, les blocs latéraux fixes
 *     (Infos, Jeux à la une) recouvrent le contenu dès 1280 px. Pendant la
 *     partie ils sont masqués, et la zone de jeu peut s'élargir.
 *   - padding horizontal de #app jamais sous 24 px : le banner partagé sort
 *     du conteneur avec des marges négatives calées sur cette valeur.
 */

* { box-sizing: border-box; }

body.page-saute-lune {
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, #26245e 0%, #14123a 55%, #090820 100%);
  color: #e5e9ff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.page-saute-lune #app {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.page-saute-lune h1 { font-size: 1.6rem; color: #fff3bf; margin: 8px 0 12px; text-align: center; }
.page-saute-lune h2 { font-size: 1.1rem; color: #c5cdfb; margin: 18px 0 8px; }
.page-saute-lune a { color: #ffe066; }

.setup-intro {
  color: #d0d5f5;
  line-height: 1.6;
  font-size: 0.95rem;
  text-align: center;
  margin: 0 auto 16px;
  max-width: 62ch;
}
.message-partie { min-height: 1.2em; text-align: center; color: #ffe066; font-size: 0.92rem; margin: 10px 0; }
.resume-record { text-align: center; color: #e5e9ff; font-size: 0.95rem; margin: 0 0 8px; }
.resume-record strong { color: #ffe066; }
.lien-defi { text-align: center; margin: 22px 0 6px; }
.entrainement-titre { text-align: center; margin-top: 30px; }

/* ---- Entraînement : choix de l'écran ------------------------------------- */
.choix-ecrans {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin: 10px 0;
}
.ecran-carte {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 86px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 2px solid #4c5fd9;
  background: #1c1a52;
  color: #e5e9ff;
  font: inherit;
  cursor: pointer;
  text-align: center;
}
.ecran-carte:hover, .ecran-carte:focus-visible { background: #2a2770; outline: none; border-color: #ffd43b; }
.ecran-num { font-size: 1.5rem; font-weight: 800; color: #ffe066; line-height: 1; }
.ecran-nom { font-weight: 700; font-size: 0.9rem; }
.ecran-record { font-size: 0.78rem; color: #b2f2bb; font-variant-numeric: tabular-nums; }
.option-numeros { text-align: center; font-size: 0.92rem; margin: 0 0 10px; }
.option-numeros input { width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px; }

/* ---- Zone de jeu dans la page --------------------------------------------- */
.zone-jeu { margin: 6px auto 18px; }
.zone-jeu[hidden] { display: none; }
body.sl-en-partie .bandeau-infos-wrap,
body.sl-en-partie .bloc-jeux-une-wrap { display: none !important; }
body.sl-en-partie #app { max-width: 1100px; }

/* ========================================================================== */
/* La zone de jeu : tableau de bord + scène (canvas 320 × 184 agrandi net).    */

.saute-lune {
  margin: 0 auto;
  --sl-fond: #0b0a24;
  --sl-carte: rgba(18, 15, 52, 0.95);
  --sl-texte: #f1f3ff;
  --sl-accent: #ffd43b;
  --sl-bouton: #ffd43b;
  --sl-bouton-texte: #1a1033;
  display: flex;
  flex-direction: column;
  background: var(--sl-fond);
  color: var(--sl-texte);
  border-radius: 12px;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

.sl-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  padding: 6px 12px;
  background: #1a1033;
  border-bottom: 2px solid #2f3a99;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  min-height: 36px;
}
.sl-hud-lib { opacity: 0.7; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
#hud-score { color: #ffe066; font-size: 1.05rem; }
#hud-vies { color: #ff6b8b; letter-spacing: 1px; }
.sl-multi { opacity: 0.45; font-weight: 700; }
.sl-multi.actif { opacity: 1; color: #ffa94d; }
.sl-jauge-bloc { display: inline-flex; align-items: center; gap: 5px; }
.sl-lune-ico { color: #ffd43b; }
.sl-jauge { display: inline-flex; gap: 2px; }
.sl-jauge i { display: block; width: 7px; height: 10px; border-radius: 2px; background: rgba(255, 255, 255, 0.14); }
.sl-jauge i.plein { background: #ffd43b; }
.sl-jauge.nuit i { background: #91a7ff; }
.sl-chrono { color: #ffe066; font-weight: 700; }
.sl-chrono[hidden] { display: none; }
.sl-ecran { margin-left: auto; opacity: 0.8; font-size: 0.85rem; }

.sl-scene {
  position: relative;
  width: 100%;
  min-height: 0;
  aspect-ratio: 320 / 184;
  max-height: calc(100vh - 90px);
  margin: 0 auto;
  background: #000;
}
/* En absolu : c'est la scène qui fixe la taille, jamais le canvas (sinon,
 * en plein écran mobile, son ratio propre la fait déborder de l'écran). */
.sl-scene canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

.sl-annonce {
  position: absolute;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  padding: 6px 16px;
  max-width: 90%;
  border-radius: 999px;
  background: rgba(10, 8, 34, 0.82);
  border: 1px solid rgba(255, 212, 59, 0.5);
  color: #fff3bf;
  font-weight: 700;
  font-size: clamp(0.8rem, 2.2vw, 1.05rem);
  text-align: center;
  pointer-events: none;
}
.sl-annonce[hidden] { display: none; }

/* ---- Barre d'outils ------------------------------------------------------ */
.sl-outils {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
  z-index: 5;
}
.sl-outils button {
  width: 40px;
  height: 40px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  background: rgba(20, 16, 50, 0.55);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.sl-outils button[hidden] { display: none; }
.sl-outils button.coupee { text-decoration: line-through; opacity: 0.6; }
.sl-outils button:focus-visible { outline: 3px solid var(--sl-accent); outline-offset: 2px; }
.saute-lune:not(.partie-lancee) #btn-pause { visibility: hidden; }

/* ---- Commandes tactiles -------------------------------------------------- */
.sl-tactile {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  touch-action: none;
  pointer-events: none;
}
.saute-lune.mode-tactile.partie-lancee .sl-tactile { display: block; pointer-events: auto; }
.sl-tactile button {
  position: absolute;
  bottom: max(12px, env(safe-area-inset-bottom));
  width: clamp(58px, 15vmin, 96px);
  height: clamp(58px, 15vmin, 96px);
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(22px, 5.5vmin, 34px);
  line-height: 1;
  padding: 0;
  pointer-events: none;
}
.sl-tactile button.appuye { background: rgba(255, 255, 255, 0.4); border-color: #fff; }
.sl-tactile [data-b="gauche"] { left: max(12px, env(safe-area-inset-left)); }
.sl-tactile [data-b="droite"] { left: calc(max(12px, env(safe-area-inset-left)) + clamp(58px, 15vmin, 96px) + 12px); }
.sl-tactile [data-b="saut"] {
  right: max(16px, env(safe-area-inset-right));
  width: clamp(72px, 20vmin, 118px);
  height: clamp(72px, 20vmin, 118px);
}
.sl-tactile [data-b="bas"] {
  right: calc(max(16px, env(safe-area-inset-right)) + clamp(72px, 20vmin, 118px) + 12px);
  width: clamp(48px, 12vmin, 76px);
  height: clamp(48px, 12vmin, 76px);
}

/* ---- Voiles (début, pause, fin, rotation) -------------------------------- */
.sl-voile {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: rgba(8, 6, 28, 0.55);
  touch-action: auto;
}
.sl-voile[hidden] { display: none; }
.sl-carte {
  max-width: 480px;
  width: 100%;
  max-height: 100%;
  overflow: auto;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--sl-carte);
  border: 2px solid rgba(255, 212, 59, 0.5);
  text-align: center;
}
.sl-carte h2 { margin: 0 0 8px; font-size: 1.35rem; color: var(--sl-accent); }
.sl-carte p { margin: 6px 0; line-height: 1.45; }
.sl-sous-titre { opacity: 0.85; }
.sl-commandes { font-size: 0.88rem; opacity: 0.9; }
.sl-commandes kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.1);
  font: inherit;
  font-size: 0.85em;
}
.saute-lune.mode-tactile .sl-clavier-seul { display: none; }
.saute-lune:not(.mode-tactile) .sl-tactile-seul { display: none; }

.sl-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.sl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border: 0;
  border-radius: 12px;
  background: var(--sl-bouton, #ffd43b);
  color: var(--sl-bouton-texte, #1a1033);
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
}
.page-saute-lune .sl-btn { background: #ffd43b; color: #1a1033; }
.page-saute-lune a.sl-btn { color: #1a1033; }
.sl-btn.grand { min-height: 52px; padding: 12px 28px; font-size: 1.1rem; }
.sl-btn.secondaire,
.page-saute-lune .sl-btn.secondaire { background: rgba(255, 255, 255, 0.14); color: #f1f3ff; }
.sl-btn:focus-visible { outline: 3px solid #ffd43b; outline-offset: 2px; }
.sl-btn[hidden] { display: none; }
.sl-btn:disabled { opacity: 0.6; cursor: wait; }

.bilan .score-final { font-size: 2rem; font-weight: 800; color: #ffe066; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.bilan .score-final small { font-size: 0.9rem; opacity: 0.8; color: #f1f3ff; }
.bilan table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.bilan th, .bilan td { padding: 4px; text-align: left; border-bottom: 1px solid rgba(255, 255, 255, 0.12); font-size: 0.95rem; }
.bilan td:last-child { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bilan small { opacity: 0.75; font-weight: 400; }
.sl-fin-statut { min-height: 1.3em; font-size: 0.92rem; }
.sl-fin-note { font-size: 0.85rem; opacity: 0.85; }
.sl-carte:focus { outline: none; }
.sl-debut-message { min-height: 1.2em; color: #ffe066; font-size: 0.9rem; }
.saute-lune:not(.classee) .sl-note-classee { display: none; }
#btn-jouer small { font-weight: 400; opacity: 0.7; font-size: 0.8em; margin-left: 4px; }
.saute-lune.mode-tactile #btn-jouer small { display: none; }
.sl-carte .partage-score { margin-top: 8px; }
.sl-fin-statut.attente { opacity: 0.8; }
.sl-fin-statut.ok { color: #b2f2bb; }
.sl-fin-statut.erreur { color: #ffa8a8; }
.sl-fin-statut a { color: #ffe066; }

.sl-tourner { background: var(--sl-fond); z-index: 7; flex-direction: column; text-align: center; }
.sl-tourner .icone { font-size: 56px; display: block; margin-bottom: 8px; }

/* ---- Plein écran (bouton ⛶) ---------------------------------------------- */
.saute-lune:fullscreen { border-radius: 0; height: 100%; }
.saute-lune:fullscreen .sl-scene { flex: 1; aspect-ratio: auto; max-height: none; }

/* Téléphone (ou petite fenêtre tactile) : le jeu prend tout l'écran. */
@media (pointer: coarse) and (max-height: 600px), (pointer: coarse) and (max-width: 700px) {
  body.sl-en-partie { overflow: hidden; }
  body.sl-en-partie .auth-nav { display: none !important; }
  body.sl-en-partie .zone-jeu .saute-lune {
    position: fixed;
    inset: 0;
    z-index: 1000;
    border-radius: 0;
  }
  body.sl-en-partie .zone-jeu .sl-scene { flex: 1; aspect-ratio: auto; max-height: none; }
  .sl-hud { font-size: 0.8rem; gap: 2px 10px; padding: 4px 10px; min-height: 28px; }
  /* Le nom de l'écran reste lisible, en version courte (« 3 · La cathédrale »). */
  .sl-ecran { font-size: 0; }
  .sl-ecran::after { content: attr(data-court); font-size: 0.78rem; }
}

/* Téléphone en paysage : quand des bandes noires bordent l'image, les commandes
 * et les outils s'y rangent au lieu de couvrir le jeu (largeur --sl-bande). */
.saute-lune.bandes .sl-tactile [data-b="gauche"],
.saute-lune.bandes .sl-tactile [data-b="droite"] {
  width: calc((var(--sl-bande) - 18px) / 2);
  height: calc((var(--sl-bande) - 18px) / 2);
  min-width: 44px;
  min-height: 44px;
  left: 6px;
}
.saute-lune.bandes .sl-tactile [data-b="droite"] { left: calc(12px + (var(--sl-bande) - 18px) / 2); }
.saute-lune.bandes .sl-tactile [data-b="saut"] {
  right: 8px;
  width: calc(var(--sl-bande) - 16px);
  height: calc(var(--sl-bande) - 16px);
}
.saute-lune.bandes .sl-tactile [data-b="bas"] {
  right: calc(var(--sl-bande) / 2 - 26px);
  bottom: calc(max(12px, env(safe-area-inset-bottom)) + var(--sl-bande));
  width: 52px;
  height: 52px;
}
.saute-lune.bandes .sl-outils {
  flex-direction: column;
  right: auto;
  left: calc(var(--sl-bande) / 2 - 20px);
}

/* Petits écrans en paysage : cartes plus compactes pour tenir en hauteur. */
@media (max-height: 420px) {
  .sl-carte { padding: 10px 14px; }
  .sl-carte h2 { font-size: 1.1rem; margin-bottom: 4px; }
  .bilan .score-final { font-size: 1.4rem; }
  .bilan th, .bilan td { padding: 2px 4px; font-size: 0.85rem; }
  .sl-btn { min-height: 38px; padding: 6px 14px; font-size: 0.92rem; }
  .sl-actions { margin-top: 8px; }
  .sl-commandes { font-size: 0.8rem; }
}
