/* ════════════════════════════════════════════════
   FALL GUYS — stage 3D
   Tout le jeu vit DANS #fg-stage (absolute, pas fixed) :
   - bureau : le stage est déplacé par le JS dans le cadre Golden Hour
   - mobile : la gp-zone passe en fixed plein écran, le stage suit
   ════════════════════════════════════════════════ */

.jeu-v-wrap { max-width: 720px; margin: 0 auto; }
#game-content { overflow: hidden; }

#fg-gp-zone {
  position: relative;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  min-height: 300px;
}

#fg-stage {
  position: absolute; inset: 0; overflow: hidden;
  background: #FFE3C4;
  font-family: "Fredoka", "Arial Rounded MT Bold", Arial, sans-serif;
  touch-action: none; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
}
#fg-stage #c { position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  filter: saturate(1.09) contrast(1.03); }
/* Mobile : un filter CSS sur le canvas = passe compositor plein écran recalculée à
   chaque frame par-dessus le rendu WebGL (même famille de coût que le backdrop-filter
   retiré des overlays) → on garde l'étalonnage bureau, on le coupe au tactile. */
@media (pointer: coarse){ #fg-stage #c { filter: none; } }
#fg-stage #touch { position: absolute; inset: 0; z-index: 5; }

/* ---------- HUD ---------- */
#fg-stage #hud { position: absolute; top: 0; left: 0; right: 0; z-index: 20; display: flex;
  align-items: flex-start; justify-content: space-between; padding: 14px 16px; pointer-events: none;
  padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
#fg-stage .pill { background: #FFF6EC; border: 3px solid #3A2E39; border-radius: 999px; color: #3A2E39;
  box-shadow: 0 4px 0 #3A2E39; padding: 7px 16px; font-weight: 600; font-size: 15px; letter-spacing: .04em; }
#fg-stage #timerPill { font-size: 26px; font-weight: 700; min-width: 118px; text-align: center;
  font-variant-numeric: tabular-nums; position: absolute; left: 50%; transform: translateX(-50%); }
#fg-stage .hudRight { display: flex; gap: 10px; pointer-events: auto; }
#fg-stage .iconBtn { font-family: inherit; cursor: pointer; width: 46px; height: 46px; border-radius: 50%;
  background: #FFF6EC; border: 3px solid #3A2E39; box-shadow: 0 4px 0 #3A2E39; color: #3A2E39;
  font-size: 21px; font-weight: 700; line-height: 1; display: grid; place-items: center; padding: 0; }
#fg-stage .iconBtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #3A2E39; }
#fg-stage .iconBtn.off { color: #C9B6A8; }
#fg-stage .hudLeft { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
#fg-stage #posPill { display: none; background: #FFC145; font-size: 17px; min-width: 66px; text-align: center; }
#fg-stage #posPill.show { display: block; }
#fg-stage .rankLine { font-size: 23px; font-weight: 700; margin: 0 0 2px; letter-spacing: .04em; }

/* ---------- touch controls ---------- */
#fg-stage #stick { position: absolute; width: 120px; height: 120px; border-radius: 50%; z-index: 10;
  display: none; border: 3px solid rgba(58,46,57,.35); background: rgba(255,246,236,.28);
  pointer-events: none; transform: translate(-50%,-50%); }
#fg-stage #stickKnob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px;
  border-radius: 50%; background: #FF6B57; border: 3px solid #3A2E39; transform: translate(-50%,-50%); }
#fg-stage #jumpBtn { position: absolute; right: 22px; bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  z-index: 10; width: 96px; height: 96px; border-radius: 50%; display: none; font-family: inherit;
  background: #FFC145; border: 4px solid #3A2E39; box-shadow: 0 6px 0 #3A2E39;
  color: #3A2E39; font-size: 19px; font-weight: 700; letter-spacing: .05em; }
#fg-stage #jumpBtn:active { transform: translateY(5px); box-shadow: 0 1px 0 #3A2E39; }
#fg-stage #shoveBtn { position: absolute; right: 34px; bottom: calc(138px + env(safe-area-inset-bottom, 0px));
  z-index: 10; width: 78px; height: 78px; border-radius: 50%; display: none; font-family: inherit;
  background: #FF6B57; border: 4px solid #3A2E39; box-shadow: 0 6px 0 #3A2E39;
  color: #FFF6EC; font-size: 15px; font-weight: 700; letter-spacing: .04em; }
#fg-stage #shoveBtn:active { transform: translateY(5px); box-shadow: 0 1px 0 #3A2E39; }

/* ---------- toasts / countdown ---------- */
#fg-stage #toast { position: absolute; top: 88px; left: 50%; transform: translateX(-50%) scale(.8);
  z-index: 22; background: #2EC4B6; color: #FFF6EC; border: 3px solid #3A2E39; box-shadow: 0 4px 0 #3A2E39;
  border-radius: 999px; padding: 8px 22px; font-weight: 700; font-size: 18px; letter-spacing: .06em;
  opacity: 0; transition: opacity .18s, transform .18s; pointer-events: none; }
#fg-stage #toast.show { opacity: 1; transform: translateX(-50%) scale(1); }
#fg-stage #count { position: absolute; inset: 0; z-index: 24; display: grid; place-items: center;
  pointer-events: none; font-weight: 700; font-size: min(26vw, 150px); color: #FFF6EC;
  -webkit-text-stroke: 6px #3A2E39; text-shadow: 0 10px 0 rgba(58,46,57,.28); }
#fg-stage #fade { position: absolute; inset: 0; z-index: 15; background: #3A2E39; opacity: 0;
  pointer-events: none; transition: opacity .12s; }
#fg-stage #vig { position: absolute; inset: 0; z-index: 8; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 55%, rgba(58,46,57,.13) 100%); }
#fg-stage #slines { position: absolute; inset: -14%; z-index: 8; pointer-events: none; opacity: 0;
  background: repeating-conic-gradient(from 0deg at 50% 46%,
    rgba(255,255,255,0) 0deg 9deg, rgba(255,255,255,.7) 10.5deg 12.5deg, rgba(255,255,255,0) 14deg 23deg);
  -webkit-mask: radial-gradient(ellipse at 50% 46%, transparent 44%, #000 80%);
  mask: radial-gradient(ellipse at 50% 46%, transparent 44%, #000 80%); }

/* ---------- overlays ---------- */
#fg-stage .overlay { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center;
  /* Pas de backdrop-filter : la scène 3D continue d'animer derrière (menu volontairement
     vivant) → un flou recalculé à chaque frame plein écran est le pire cas pour le mobile.
     Fond plus opaque à la place (recette anti-lag commune du projet). */
  background: rgba(255,214,178,.78); }
#fg-stage .overlay.hidden { display: none; }
#fg-stage .card { background: #FFF6EC; border: 4px solid #3A2E39; border-radius: 30px;
  box-shadow: 0 10px 0 #3A2E39; padding: 30px 38px 34px; text-align: center; color: #3A2E39;
  max-width: min(88%, 470px); }
#fg-stage .kicker { font-size: 14px; font-weight: 700; letter-spacing: .28em; color: #FF6B57; margin-bottom: 10px; }
#fg-stage .fg-title { margin: 0 0 6px; font-size: clamp(36px, 13vw, 52px); line-height: .95;
  font-weight: 700; letter-spacing: .01em; }
#fg-stage .fg-title .accent { color: #FF6B57; }
#fg-stage .bigBtn { font-family: inherit; cursor: pointer; margin-top: 18px; background: #FF6B57;
  color: #FFF6EC; border: 4px solid #3A2E39; border-radius: 999px; box-shadow: 0 6px 0 #3A2E39;
  font-size: 22px; font-weight: 700; letter-spacing: .08em; padding: 13px 42px; }
#fg-stage .bigBtn:active { transform: translateY(5px); box-shadow: 0 1px 0 #3A2E39; }
#fg-stage .bigBtn.alt { background: #2EC4B6; }
#fg-stage #fg-online-btn { margin-top: 10px; font-size: 16px; padding: 9px 30px; }
#fg-stage .btnRow { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
#fg-stage .ghostBtn { font-family: inherit; cursor: pointer; margin-top: 14px; background: none;
  border: none; color: #8A7466; font-weight: 600; font-size: 14px; letter-spacing: .06em;
  text-decoration: underline; }
#fg-stage .hint { margin: 18px 0 0; font-size: 13px; color: #8A7466; font-weight: 500; line-height: 1.6; }
#fg-stage .big { font-size: 64px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0; }
#fg-stage .badge { display: inline-block; background: #FFC145; border: 3px solid #3A2E39;
  box-shadow: 0 4px 0 #3A2E39; border-radius: 999px; padding: 6px 18px; font-weight: 700;
  font-size: 16px; letter-spacing: .06em; margin: 6px 0 2px; animation: fg-pop .4s cubic-bezier(.2,2,.4,1); }
#fg-stage .badge.hidden { display: none; }
@keyframes fg-pop { from { transform: scale(0); } to { transform: scale(1); } }
#fg-stage .mBest { margin: 8px 0 0; font-weight: 600; color: #8A7466; font-size: 15px; }

/* ---------- map selector ---------- */
#fg-stage .mapRow { display: flex; align-items: stretch; gap: 10px; margin: 16px 0 0; justify-content: center; }
#fg-stage .mapBox { width: 230px; background: #FFFDF8; border: 3px solid #3A2E39; border-radius: 20px;
  box-shadow: 0 4px 0 #3A2E39; padding: 10px 12px 12px; position: relative; overflow: hidden; }
#fg-stage .mapStrip { position: absolute; top: 0; left: 0; right: 0; height: 7px; display: flex; }
#fg-stage .mapStrip span { flex: 1; }
#fg-stage .mapName { font-weight: 700; font-size: 21px; margin-top: 6px; }
#fg-stage .mapSub { font-size: 12.5px; color: #8A7466; font-weight: 600; margin-top: 1px; }
#fg-stage .mapBest { font-size: 13px; color: #FF6B57; font-weight: 700; margin-top: 6px; letter-spacing: .04em; }
#fg-stage .dots { display: flex; gap: 7px; justify-content: center; margin-top: 12px; }
#fg-stage .dots span { width: 9px; height: 9px; border-radius: 50%; background: #E3D2C2; border: 2px solid #3A2E39; }
#fg-stage .dots span.on { background: #FF6B57; }

/* ════════════════════════════════════════════════
   BOUTON QUITTER ✕ (créé par le JS mobile)
   Visible en portrait ET en paysage (bloc mobile combiné).
   ════════════════════════════════════════════════ */
.jvfg-exit-mob {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(14px, env(safe-area-inset-right, 0px));
  z-index: 300;
  width: 46px; height: 46px; border-radius: 50%;
  background: #FFF6EC; border: 3px solid #3A2E39; box-shadow: 0 4px 0 #3A2E39;
  color: #3A2E39; font-size: 19px; font-weight: 700; line-height: 1;
  font-family: "Fredoka", Arial, sans-serif;
  align-items: center; justify-content: center; padding: 0;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.jvfg-exit-mob:active { transform: translateY(3px); box-shadow: 0 1px 0 #3A2E39; }

/* ════════════════════════════════════════════════
   DESKTOP GOLDEN HOUR (≥ 641px, body.jvfg-gh posé par le JS)
   ════════════════════════════════════════════════ */
@media (min-width: 641px) {
  body.jvfg-gh #topbar { display: none !important; }
  body.jvfg-gh .jeu-v-wrap { display: none !important; }

  #jvfg-gh {
    position: fixed; inset: 0; z-index: 200;
    font-family: 'Space Grotesk', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: #16141f;
  }
  .jvfg-bg {
    position: absolute; inset: 0;
    /* Le dégradé reste en couche de secours le temps que l'image charge */
    background:
      url('../../assets/images/couverturejeuxpc/fond-fall-guys-2560x1620.webp') center/cover no-repeat,
      radial-gradient(ellipse at 72% 16%, rgba(255,248,222,.85) 0%, rgba(255,248,222,0) 46%),
      linear-gradient(180deg, #9AD4EE 0%, #CFE0D2 30%, #FFE3C4 58%, #FFC98F 82%, #FFB379 100%);
  }

  #jvfg-header {
    position: absolute; top: 22px; left: 30px; right: 30px; z-index: 8;
    display: flex; align-items: center; justify-content: space-between;
    background: #fff; border: 1px solid rgba(20,20,40,.07); border-radius: 16px;
    padding: 12px 20px; box-shadow: 0 10px 30px rgba(20,20,40,.18);
  }
  .jvfg-logo-box {
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, #FF8A70, #FF6B57);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font: 800 12px 'Space Grotesk', sans-serif;
    box-shadow: 0 3px 8px rgba(255,107,87,.35); flex-shrink: 0;
  }
  .jvfg-btn-coral {
    background: linear-gradient(135deg, #FF8A70, #FF6B57); color: #fff;
    border: none; border-radius: 10px; padding: 9px 16px;
    font: 700 13.5px 'Space Grotesk', sans-serif; cursor: pointer;
    box-shadow: 0 4px 12px rgba(255,107,87,.32); transition: filter .15s;
  }
  .jvfg-btn-coral:hover { filter: brightness(1.06); }
  .jvfg-btn-ghost {
    background: #fff; color: #16141f; border: 1px solid rgba(20,20,40,.14);
    border-radius: 12px; padding: 13px 18px; font: 700 13.5px 'Space Grotesk', sans-serif;
    cursor: pointer; transition: background .15s;
  }
  .jvfg-btn-ghost:hover { background: #f8f7fd; }
  .jvfg-float-btn {
    display: flex; align-items: center; gap: 7px;
    background: rgba(255,246,236,.72);
    color: #3A2E39; border: 1px solid rgba(58,46,57,.22); border-radius: 11px;
    padding: 10px 16px; font: 700 13px 'Space Grotesk', sans-serif; cursor: pointer;
    box-shadow: 0 8px 20px rgba(90,40,60,.16); transition: filter .15s;
  }
  .jvfg-float-btn:hover { filter: brightness(.95); }

  .jvfg-screen {
    position: absolute; inset: 0;
    opacity: 0; visibility: hidden; pointer-events: none;
    transform: scale(1.02);
    transition: opacity .45s ease, transform .45s ease;
  }
  .jvfg-screen.jvfg-active { opacity: 1; visibility: visible; pointer-events: auto; transform: none; }

  /* Cadre de jeu : large (jeu 3D paysage), 16/9 borné par la hauteur */
  .jvfg-game-frame {
    position: relative;
    height: min(calc(100vh - 136px), calc((100vw - 64px) * 9 / 16));
    aspect-ratio: 16 / 9; flex: none;
    border-radius: 22px; overflow: hidden;
    box-shadow: 0 34px 70px rgba(80,30,50,.42), 0 0 44px rgba(255,180,120,.4), 0 0 0 6px rgba(255,244,235,.65);
  }
}

/* ════════════════════════════════════════════════
   MOBILE — plein écran (portrait ≤640px OU téléphone en paysage)
   ════════════════════════════════════════════════ */
@media (max-width: 640px), (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  html, body { overscroll-behavior: none; }
  body { overflow: hidden !important; }
  /* Masquer le chrome de page : en paysage (>640px) les règles mobiles de
     common.css ne s'appliquent plus, le bloc SEO repasserait au-dessus du jeu. */
  #topbar,
  .similar-games,
  .game-content,
  footer,
  .bgw,
  #stt-btn { display: none !important; }
  .jeu-v-wrap { max-width: none; padding: 0 !important; }
  #game-content { overflow: visible; padding: 0 !important; }
  .ct.pw { padding: 0 !important; }
  .app { background: none !important; }

  /* Zone de jeu fixée plein écran (transform:none : l'anim .au retient un
     transform qui casserait le fixed) */
  #fg-gp-zone {
    position: fixed !important;
    inset: 0 !important;
    z-index: 50 !important;
    width: 100vw !important;
    height: 100svh !important;
    aspect-ratio: unset !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    animation: none !important;
  }

  /* Bouton quitter : visible aussi en portrait (pas seulement en paysage) */
  .jvfg-exit-mob { display: flex !important; }

  /* Dégager le ✕ : les boutons ♪ ↺ du HUD glissent à sa gauche */
  #fg-stage #hud {
    padding-right: calc(max(14px, env(safe-area-inset-right, 0px)) + 56px);
    padding-left: max(16px, env(safe-area-inset-left, 0px));
  }
}

/* ════════════════════════════════════════════════
   MOBILE PAYSAGE — HUD safe-area + overlays compacts 2 colonnes
   ════════════════════════════════════════════════ */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {

  /* Boutons tactiles : dégagés de l'encoche / gesture bar */
  #fg-stage #jumpBtn {
    right: max(20px, calc(env(safe-area-inset-right, 0px) + 8px));
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 86px; height: 86px;
  }
  #fg-stage #shoveBtn {
    right: max(30px, calc(env(safe-area-inset-right, 0px) + 18px));
    bottom: calc(112px + env(safe-area-inset-bottom, 0px));
    width: 70px; height: 70px; font-size: 13px;
  }

  #fg-stage #count { font-size: min(34svh, 150px); }
  #fg-stage #toast { top: 66px; }
  #fg-stage #timerPill { font-size: 22px; min-width: 104px; }

  /* ── Accueil : carte 2 colonnes (titre à gauche, sélecteur de carte à droite) ── */
  #fg-stage #menu .card {
    display: grid;
    grid-template-columns: minmax(0, auto) auto;
    grid-template-areas:
      "kicker map"
      "title  map"
      "btn    dots"
      "online dots";
    column-gap: 30px; row-gap: 2px;
    align-items: center;
    padding: 14px 28px 16px;
    max-width: none;
    max-height: calc(100svh - 20px);
  }
  #fg-stage #menu .kicker { grid-area: kicker; margin: 0; text-align: left; font-size: 12px; }
  #fg-stage #menu .fg-title { grid-area: title; font-size: 36px; text-align: left; }
  #fg-stage #menu .mapRow { grid-area: map; margin: 0; }
  #fg-stage #menu .dots { grid-area: dots; margin: 8px 0 0; align-self: start; }
  #fg-stage #menu #playBtn { grid-area: btn; margin: 10px 0 0; padding: 9px 34px; font-size: 18px; justify-self: start; }
  #fg-stage #menu #fg-online-btn { grid-area: online; margin: 8px 0 0; padding: 7px 24px; font-size: 14px; justify-self: start; }
  #fg-stage #menu .hint { display: none; }

  /* ── Fin : résultat à gauche, actions empilées à droite ── */
  #fg-stage #end .card {
    display: grid;
    grid-template-columns: minmax(0, auto) auto;
    grid-template-areas:
      "kicker acts"
      "time   acts"
      "rank   acts"
      "badge  acts"
      "best   ghost";
    column-gap: 32px; row-gap: 2px;
    align-items: center;
    padding: 14px 28px 16px;
    max-width: none;
    max-height: calc(100svh - 20px);
  }
  #fg-stage #end .kicker { grid-area: kicker; margin: 0; font-size: 12px; }
  #fg-stage #end .big { grid-area: time; font-size: 44px; margin: 0; }
  #fg-stage #end .rankLine { grid-area: rank; font-size: 18px; }
  #fg-stage #end .badge { grid-area: badge; margin: 4px 0 0; font-size: 13px; padding: 4px 14px; justify-self: center; }
  #fg-stage #end .mBest { grid-area: best; margin: 4px 0 0; }
  #fg-stage #end .btnRow { grid-area: acts; flex-direction: column; align-items: stretch; gap: 10px; }
  #fg-stage #end .btnRow .bigBtn { margin: 0; padding: 11px 30px; font-size: 18px; }
  #fg-stage #end .ghostBtn { grid-area: ghost; margin: 6px 0 0; justify-self: center; }
}
