/* =====================================================================
   LincolnX GamePicker v158 — Mobile performance + touch layer
   Loaded LAST. Every selector is prefixed with a double :not(#id) so it
   outranks the older !important layers (v76-v157) without editing them.
   Scope: phones & tablets  =  (max-width:900px) or a coarse touch pointer.
   Desktop mouse layouts are not changed.
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. ONE scroller, not three.
   html + body both had overflow-x:hidden, which silently turns each into
   an auto-overflow scroll container. That (a) breaks position:sticky on the
   header, (b) creates nested scrolling that feels heavy on iOS Safari.
   overflow-x:clip trims sideways overflow WITHOUT creating a scroller.
   --------------------------------------------------------------------- */
@media (max-width:900px), (hover:none) and (pointer:coarse){
  @supports (overflow:clip){
    html:not(#lx58a):not(#lx58b), html:not(#lx58a):not(#lx58b) body{overflow-x:clip!important;overflow-y:visible!important}
  }
  html:not(#lx58a):not(#lx58b){
    scroll-behavior:auto!important;           /* smooth-scroll animation fights touch momentum */
    -webkit-text-size-adjust:100%;text-size-adjust:100%;
    touch-action:manipulation;                /* no 300ms tap delay / double-tap zoom, pinch still works */
    -webkit-tap-highlight-color:transparent;
  }
}

/* ---------------------------------------------------------------------
   2. Remove per-frame GPU work.
   Measured on a 633-game catalog: 2,547 live backdrop-filters, 4,535
   box-shadows and ~600 filter layers. iOS reclaims those GPU tiles under
   pressure and paints them BLACK; Android drops frames. Every surface that
   used a blur already has a 95-100% opaque background, so nothing visible
   changes.
   --------------------------------------------------------------------- */
@media (max-width:900px), (hover:none) and (pointer:coarse){
  /* 2a. No backdrop blur anywhere (header, sticky bar, bottom nav, overlays, cards, buttons). */
  html:not(#lx58a):not(#lx58b), html:not(#lx58a):not(#lx58b) body, html:not(#lx58a):not(#lx58b) body *, html:not(#lx58a):not(#lx58b) body *::before, html:not(#lx58a):not(#lx58b) body *::after{
    -webkit-backdrop-filter:none!important;backdrop-filter:none!important;
  }

  /* 2b. Game cards: no filters, animations, transitions or heavy inner shadows. */
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium,
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium *,
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium::before,
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium::after,
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium *::before,
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium *::after,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium *,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium::before,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium::after,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium *::before,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium *::after{
    filter:none!important;
    animation:none!important;
    transition:none!important;
    text-shadow:none!important;
    will-change:auto!important;
  }
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium *,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium *{box-shadow:none!important}

  /* 2c. Perpetual decorative loops that repaint during every scroll. */
  html:not(#lx58a):not(#lx58b) body header.nextgen-header,
  html:not(#lx58a):not(#lx58b) body header.nextgen-header::before,
  html:not(#lx58a):not(#lx58b) body header.nextgen-header::after,
  html:not(#lx58a):not(#lx58b) body #storagePickerSection::after,
  html:not(#lx58a):not(#lx58b) body .category-nav::after,
  html:not(#lx58a):not(#lx58b) body .lx-primary-search::after,
  html:not(#lx58a):not(#lx58b) body #viewPanel::after,
  html:not(#lx58a):not(#lx58b) body #lxOrderOverlay::before,
  html:not(#lx58a):not(#lx58b) body .new-badge{animation:none!important}

  /* 2d. Never blur / filter the whole page behind a dialog (huge GPU spike with 600 cards). */
  html:not(#lx58a):not(#lx58b) body.modal-blur > *,
  html:not(#lx58a):not(#lx58b) body.game-details-open > *{filter:none!important;-webkit-filter:none!important}
}

/* Respect the OS "reduce motion" setting everywhere. */
@media (prefers-reduced-motion:reduce){
  html:not(#lx58a):not(#lx58b) body *, html:not(#lx58a):not(#lx58b) body *::before, html:not(#lx58a):not(#lx58b) body *::after{
    animation-duration:.01ms!important;animation-iteration-count:1!important;
    transition-duration:.01ms!important;scroll-behavior:auto!important;
  }
}

/* ---------------------------------------------------------------------
   3. Poster canvas: a recycled / evicted bitmap must never show black.
   --------------------------------------------------------------------- */
@media (max-width:900px), (hover:none) and (pointer:coarse){
  html:not(#lx58a):not(#lx58b) body #games .premium-art-wrap,
  html:not(#lx58a):not(#lx58b) body #favoritesList .premium-art-wrap{background-color:#211725!important}

  /* Sleeping cards (windowing): same height as when awake, poster-shaped placeholder. */
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium.lx-card-sleeping{
    box-sizing:border-box!important;overflow:hidden!important;
    background:#0b0e1c!important;
  }
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium.lx-card-sleeping::before{
    content:""!important;display:block!important;position:static!important;
    width:100%!important;aspect-ratio:4/3!important;height:auto!important;
    background:#211725!important;border-radius:0!important;opacity:1!important;
    transform:none!important;
  }
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium.lx-card-sleeping::after{content:none!important;display:none!important}
}

/* ---------------------------------------------------------------------
   4. Touch targets >= 44x44 CSS px (Apple HIG / Material), without
   changing how the buttons look. Invisible hit-area extensions.
   --------------------------------------------------------------------- */
@media (max-width:900px), (hover:none) and (pointer:coarse){
  html:not(#lx58a):not(#lx58b) body #games .game-fav-button,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-fav-button{position:absolute!important;overflow:visible!important}
  html:not(#lx58a):not(#lx58b) body #games .game-fav-button::after,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-fav-button::after{
    content:""!important;display:block!important;position:absolute!important;
    top:-12px!important;right:-12px!important;bottom:-12px!important;left:-12px!important;
    background:transparent!important;border:0!important;border-radius:0!important;
    width:auto!important;height:auto!important;opacity:1!important;transform:none!important;
  }
  html:not(#lx58a):not(#lx58b) body #games .game-details-button,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-details-button{position:relative!important;overflow:visible!important}
  html:not(#lx58a):not(#lx58b) body #games .game-details-button::after,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-details-button::after{
    content:""!important;display:block!important;position:absolute!important;
    top:-13px!important;bottom:-13px!important;left:-10px!important;right:-10px!important;
    background:transparent!important;border:0!important;border-radius:0!important;
    width:auto!important;height:auto!important;opacity:1!important;transform:none!important;
  }
  /* Header / nav / floating controls */
  html:not(#lx58a):not(#lx58b) body .category-nav button,
  html:not(#lx58a):not(#lx58b) body .lx-mobile-bottom-nav a,
  html:not(#lx58a):not(#lx58b) body .lx-mobile-bottom-nav button,
  html:not(#lx58a):not(#lx58b) body .header-favorites,
  html:not(#lx58a):not(#lx58b) body .tutorial-btn,
  html:not(#lx58a):not(#lx58b) body .back-to-top,
  html:not(#lx58a):not(#lx58b) body .game-load-more,
  html:not(#lx58a):not(#lx58b) body .lx-empty-primary,
  html:not(#lx58a):not(#lx58b) body .lx-empty-secondary{min-height:44px!important}
  html:not(#lx58a):not(#lx58b) body .social-icon{min-width:44px!important;min-height:44px!important}
}

/* ---------------------------------------------------------------------
   5. iOS Safari zooms the page when a focused field is under 16px and
   never zooms back out. Keep text >= 16px in every form control.
   --------------------------------------------------------------------- */
@media (max-width:900px), (hover:none) and (pointer:coarse){
  html:not(#lx58a):not(#lx58b) body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  html:not(#lx58a):not(#lx58b) body select,
  html:not(#lx58a):not(#lx58b) body textarea{font-size:16px!important}
}

/* ---------------------------------------------------------------------
   6. Instant press feedback + no accidental text/image selection on cards.
   (Colour/outline/opacity only: no transform, so no layer is promoted.)
   --------------------------------------------------------------------- */
@media (hover:none), (max-width:900px){
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium{
    -webkit-touch-callout:none;-webkit-user-select:none;user-select:none;
    touch-action:manipulation;
  }
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium img,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium img{
    -webkit-touch-callout:none;-webkit-user-drag:none;user-drag:none;pointer-events:none;
  }
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium:active,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium:active{
    outline:2px solid rgba(255,176,102,.85)!important;outline-offset:-2px!important;
  }
  html:not(#lx58a):not(#lx58b) body #games .game-card-premium:active .game-art-button,
  html:not(#lx58a):not(#lx58b) body #favoritesList .game-card-premium:active .game-art-button{opacity:.82!important}
  html:not(#lx58a):not(#lx58b) body button:active,
  html:not(#lx58a):not(#lx58b) body [role="button"]:active,
  html:not(#lx58a):not(#lx58b) body .lx-mobile-bottom-nav a:active,
  html:not(#lx58a):not(#lx58b) body .category-nav button:active,
  html:not(#lx58a):not(#lx58b) body summary:active{opacity:.78!important}
  html:not(#lx58a):not(#lx58b) body button,html:not(#lx58a):not(#lx58b) body a,html:not(#lx58a):not(#lx58b) body [role="button"],html:not(#lx58a):not(#lx58b) body label,html:not(#lx58a):not(#lx58b) body select,html:not(#lx58a):not(#lx58b) body summary{touch-action:manipulation}
}
