/* =====================================================================================================
   PANNEAUX DE MENU EN PLEINE LARGEUR (Simon 2026-10-21 : « les popups paramètres, etc. doivent être en
   pleine largeur »).
   -----------------------------------------------------------------------------------------------------
   Paramètres, Boutique, Mes achats, Quêtes, Légal, Retours, Aide (tutoriel), Connexion et Matchs
   s'ouvrent désormais sur TOUTE la fenêtre (plus de petite carte flottante) ; le contenu reste centré
   dans une colonne de lecture de --pf-read (920 px) via une marge intérieure calculée : fenêtre étroite
   = marges minimes (--pf-min), fenêtre large = colonne centrée. La croix de fermeture suit le bord de
   la colonne. Les boîtes défilent en interne. Échap / focus piégé : js/panneaux-modal.js.
   Chargée TOUT EN DERNIER (après cite-engloutie.css) ; ne retire aucune règle d'habillage antique
   (marbre, frises, colonnes) — elle ne touche que la GÉOMÉTRIE. Hors périmètre : popups EN JEU, ateliers,
   sélecteur de mode, coffre-modal (petite célébration), écran de mort.
   ===================================================================================================== */

html body.ui-arcade {
  --pf-read: 920px;                                       /* largeur de lecture maximale du contenu */
  --pf-min: 16px;                                         /* marge minimale (mobile) */
  --pf-gut: max(var(--pf-min), calc((100% - var(--pf-read)) / 2));
}
@media (max-width: 600px) { html body.ui-arcade { --pf-min: 12px; } }

/* ---------- 1. FOND : l'overlay occupe tout l'écran, sans marge ni centrage ---------- */
html body.ui-arcade :is(#premium-panel, #stuff-panel, #quests-panel, #legal-panel, #feedback-panel,
                        #tutorial-panel, #login-panel, #foot-panel) {
  inset: 0 !important; width: 100% !important; height: 100dvh !important; max-width: none !important; max-height: none !important;
  padding: 0 !important; margin: 0 !important; gap: 0 !important;
  display: flex !important; flex-direction: column !important; align-items: stretch !important; justify-content: stretch !important;
  overflow: hidden !important; box-sizing: border-box !important; transform: none !important;
}
html body.ui-arcade :is(#premium-panel, #stuff-panel, #quests-panel, #legal-panel, #feedback-panel,
                        #tutorial-panel, #login-panel, #foot-panel).hidden { display: none !important; }

/* ---------- 2. BOÎTE : pleine largeur / pleine hauteur, colonne de lecture par marge intérieure ---------- */
html body.ui-arcade :is(#premium-panel #premium-box, #stuff-panel #stuff-box, #quests-panel #quests-box, #legal-panel #legal-box, #feedback-panel #feedback-box,
                        #tutorial-panel #tutorial-box, #login-panel #login-box, #foot-panel #foot-box) {
  position: relative !important; flex: 1 1 auto !important;
  width: 100% !important; min-width: 0 !important; max-width: none !important;
  height: 100% !important; min-height: 0 !important; max-height: none !important;
  margin: 0 !important; border-radius: 0 !important; border-left-width: 0 !important; border-right-width: 0 !important;
  box-sizing: border-box !important; overflow-x: hidden !important; overflow-y: auto !important; overscroll-behavior: contain;
  padding-left: var(--pf-gut) !important; padding-right: var(--pf-gut) !important;
  padding-top: max(34px, env(safe-area-inset-top)) !important; padding-bottom: max(26px, env(safe-area-inset-bottom)) !important;
  text-align: left; box-shadow: none !important;
}
/* La boutique gère son défilement dans #premium-scroll : la boîte, elle, reste fixe. */
html body.ui-arcade #premium-panel #premium-box { overflow-y: hidden !important; display: flex !important; flex-direction: column !important; }
html body.ui-arcade #premium-panel #premium-box #premium-scroll { flex: 1 1 auto !important; min-height: 0 !important; max-height: none !important; }

/* ---------- 3. OPTIONS : le panneau EST la fenêtre ---------- */
html body.ui-arcade #options-panel {
  inset: 0 !important; left: 0 !important; top: 0 !important; transform: none !important;
  width: 100% !important; height: 100dvh !important; max-width: none !important; max-height: none !important;
  border-radius: 0 !important; border-width: 0 !important; box-shadow: none !important;
  padding: max(26px, env(safe-area-inset-top)) var(--pf-gut) max(24px, env(safe-area-inset-bottom)) !important;
}

/* ---------- 4. CROIX DE FERMETURE : toujours visible, alignée sur le bord de la colonne ---------- */
html body.ui-arcade :is(#options-panel > .panel-x, #premium-panel #premium-box > .panel-x, #stuff-panel #stuff-box .panel-x, #quests-panel #quests-box .panel-x,
                        #legal-panel #legal-box .panel-x, #feedback-panel #feedback-box .panel-x, #tutorial-panel #tutorial-box .panel-x, #login-panel #login-box .panel-x, #foot-panel #foot-box .panel-x, #foot-panel #foot-box > .foot-x),
html body.ui-arcade :is(#stuff-panel, #quests-panel, #legal-panel, #feedback-panel, #tutorial-panel, #login-panel, #foot-panel) > .panel-x {
  position: fixed !important; top: max(12px, env(safe-area-inset-top)) !important;
  right: max(var(--pf-min), calc((100% - var(--pf-read)) / 2)) !important; left: auto !important;
  width: 46px !important; height: 46px !important; min-width: 46px !important; z-index: 5 !important;
}
html body.ui-arcade :is(.panel-x):focus-visible { outline: 3px solid #fff !important; outline-offset: 2px !important; box-shadow: 0 0 0 6px #154a42 !important; }

/* Titres : on laisse la place à la croix. */
html body.ui-arcade :is(#options-panel, #stuff-panel #stuff-box, #quests-panel #quests-box, #legal-panel #legal-box, #feedback-panel #feedback-box, #tutorial-panel #tutorial-box, #login-panel #login-box, #foot-panel #foot-box) > :is(h2, h3):first-of-type { padding-right: 58px !important; }

/* ---------- 5. MOBILE paysage (bas) : marges encore plus fines ---------- */
@media (max-height: 480px) {
  html body.ui-arcade :is(#premium-panel #premium-box, #stuff-panel #stuff-box, #quests-panel #quests-box, #legal-panel #legal-box, #feedback-panel #feedback-box, #tutorial-panel #tutorial-box, #login-panel #login-box, #foot-panel #foot-box) {
    padding-top: max(12px, env(safe-area-inset-top)) !important; padding-bottom: 12px !important;
  }
  html body.ui-arcade #options-panel { padding-top: max(10px, env(safe-area-inset-top)) !important; padding-bottom: 10px !important; }
  html body.ui-arcade :is(.panel-x) { width: 40px !important; height: 40px !important; min-width: 40px !important; top: 8px !important; }
}
