/* perf-touch.css — mobile performance layer.
   Scoped to touch devices via @media (hover:none) and (pointer:coarse), so it is ALWAYS on inside
   Telegram on a phone and NEVER touches desktop review fidelity. The glass look (translucency,
   gradients, borders, soft shadows) is kept intact — only the GPU-expensive bits that actually jank
   on phones are removed: per-frame filters, large decorative blurs, and perpetual nav repaints.
   Loaded last in index.html so these win. To roll back: delete this file + its <link>. */

/* ============================================================================================
   GLASS NAV — kill the see-through. The opt-in "Стеклянная навигация" rail is deliberately made
   transparent (navigation.css: `.glass-nav .tabbar:has(.menu-material){background:transparent}`) so the
   glass material refracts the page behind it; on a busy screen the cases/items bleed through the rail.
   Give the rail a fully OPAQUE dark base (green tint + lime rim kept, so it still reads as glass) and
   neutralize the material's backdrop so nothing behind the rail shows. ALL platforms (this is a visual
   bug, not a perf tier). Written with an `html.` prefix so it out-specifies navigation.css — which the
   glass component injects at runtime, after this sheet — and the non-:has rule covers WebViews without
   :has() support too. ============================================================================ */
html.glass-nav .tabbar,
html.glass-nav .tabbar:has(.menu-material) {
  background:
    radial-gradient(ellipse at var(--reflection-x,50%) 0%, #d4ff7533, transparent 60%),
    linear-gradient(155deg, #11161d, #0b0e13 60%, #0f141b) !important;
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}
html.glass-nav .menu-material {
  background: linear-gradient(155deg, #11161d, #0b0e13 60%, #0f141b) !important;
}
html.glass-nav .menu-material .glass-surface,
html.glass-nav .menu-material .glass-surface--svg,
html.glass-nav .menu-material .glass-surface--webgl,
html.glass-nav .menu-material .glass-surface--fallback {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
}

@media (hover: none) and (pointer: coarse) {

  /* 1. BIGGEST WIN. "transition: all" sits on ~1200 elements. On every class toggle (tab switch,
     game state change, HUD tick) it also animates layout, filter and box-shadow, forcing a
     layout+paint storm each frame of the transition. Narrow it to cheap, GPU-composited properties.
     Elements that had no transition keep duration 0, so nothing new animates. A handful of
     deliberate layout transitions (if any) will snap instead of ease — acceptable, not laggy. */
  *, *::before, *::after {
    transition-property: transform, opacity, color, background-color, border-color !important;
  }

  /* 2. Perpetual decorative keyframes on the fixed bottom nav (luxLine / navShimmer / navBreathe)
     repaint the always-visible bar forever, on EVERY screen — a constant GPU + battery drain that
     reads as general sluggishness. Stop the idle shimmer; the nav still works. Tab feedback uses
     transitions (kept in rule 1), not these keyframes. */
  .tabbar, .tabbar *,
  .tabbar::before, .tabbar::after,
  .tabbar *::before, .tabbar *::after { animation: none !important; }

  /* 3. The live crash canvas carries a CSS filter (saturate .89 / contrast 1.028) — the browser
     re-runs it over the entire bitmap on every animated frame. The grade is imperceptible; the
     per-frame cost is not. Drop it. */
  #cr-canvas { filter: none !important; }

  /* 4. Decorative glow blobs use filter: blur(18px) — each is its own compositing layer that the GPU
     must fully re-blur whenever it repaints (e.g. on scroll). Blur cost rises steeply with radius, so
     halving it is far cheaper while the glow still reads. */
  .card-lava > i { filter: blur(9px) !important; }
}

/* ============================================================================================
   ANDROID-ONLY HARD TIER — gated on html[data-tg-platform="android"] (set early by platform.js).
   iOS (WKWebView) renders the glass kit smoothly and is intentionally NOT touched by anything here;
   only Telegram's Android Chromium WebView — weak at backdrop-filter, blur(), large shadow blur and
   WebGL — gets these. The glass identity (tints, gradients, borders, rims, selection glows) is kept;
   only the GPU-heavy bits are removed or tamed. Rules are written FLAT (each fully prefixed), never as
   a native-nested block, because older Android system WebViews may fail to parse CSS nesting and would
   then drop the whole block. Derived from a full cross-screen audit (2026-11-25). Paired JS gates in
   app.js (glass WebGL mount, crash canvas quality, fair-surface import) and fair-surface.js.
   ============================================================================================ */

/* --- Bottom nav: drop the always-on backdrop blur (re-sampled on every scroll frame, on every
       screen); keep the luxury opaque tint + gold rim, trim the 40px outer shadow to 20px. --- */
html[data-tg-platform="android"] .tabbar {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  background: linear-gradient(180deg, #131314, #060607) !important;
  box-shadow: 0 -12px 20px rgba(0,0,0,.6), inset 0 1px 0 rgba(232,209,154,.16) !important;
}
/* opt-in "glass navigation" rail (default OFF): the broad .tabbar rule above would flatten it to dark,
   so restore the green glass tint + lime bevel (more specific, wins). WebGL glass is disabled on Android. */
html[data-tg-platform="android"] .glass-nav .tabbar {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  background: radial-gradient(ellipse at var(--reflection-x,50%) 0%, #d4ff7540, transparent 60%),
              linear-gradient(155deg, #11161d, #0b0e13 60%, #0f141b) !important; /* fully opaque — no case bleed-through */
  box-shadow: inset 0 1px #f1ffdda3, inset 0 -1px #adf55c3b, 0 3px 10px #050a045c !important;
}
/* safety net: if a glass-surface ever renders on Android (the JS gate should prevent it), neutralize its
   SVG-displacement / blur backdrop — the single most expensive effect in the kit — with a dark-green tint. */
html[data-tg-platform="android"] .glass-surface--svg,
html[data-tg-platform="android"] .glass-surface--fallback {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  background: linear-gradient(150deg, #1a2116, #0b0e13 62%) !important;
}

/* --- Modal + sheet scrims: drop the full-viewport backdrop blur (re-blurs every frame while a dialog
       sits over the animating scene); darken the scrim so it still dims. The opaque full-screen
       drop/reveal takeover (.drop-modal) is excluded so it stays solid. --- */
html[data-tg-platform="android"] .modal:not(.drop-modal),
html[data-tg-platform="android"] .sheet-wrap .sheet-backdrop {
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  background: rgba(3,3,4,.9) !important;
}

/* --- Crash scene: the rocket plane + growing trail carry a drop-shadow halo re-blurred EVERY rAF
       frame (the heaviest continuous filter). Drop the halo; the neon fill + big readout stay. --- */
html[data-tg-platform="android"] #tab-crash .cr-plane,
html[data-tg-platform="android"] #tab-crash .crash.is-crashed .cr-plane,
html[data-tg-platform="android"] #tab-crash .cr-trail-line,
html[data-tg-platform="android"] #tab-crash .crash.is-crashed .cr-trail-line { filter: none !important; }

/* --- Home mode tiles: the lava glow blobs are blurred, infinitely-animating composited layers that
       re-raster every frame. Hide them (exactly what the shipped lite-motion setting already does); the
       tiles keep their tint, icon and glow. Freeze + de-blur the aura ::before into a static tone halo. --- */
html[data-tg-platform="android"] .card-lava { display: none !important; }
html[data-tg-platform="android"] .mode-tile::before {
  animation: none !important; filter: none !important;
  background: radial-gradient(circle, color-mix(in srgb, var(--mode-tone) 26%, transparent), transparent 70%) !important;
  opacity: .5 !important;
}
/* stop the perpetual linear icon spin on the upgrade tile (never idles — keeps a layer awake forever). */
html[data-tg-platform="android"] .mode-tile[data-mode="upgrade"] .tile .glyph { animation: none !important; }

/* --- Provably-fair: hide the decorative WebGL refraction plate (the card keeps its own gradient). The
       GL work itself is also stopped in fair-surface.js / app.js on Android — CSS alone can't. --- */
html[data-tg-platform="android"] .fair-surface { display: none !important; }

/* --- Large / colored shadow blurs on elements that repaint on scroll, drag, spin or animation: radius
       roughly halved, shape + rims kept so nothing looks flat. (Purely static shadows are left alone.) --- */
html[data-tg-platform="android"] .sheet-wrap .sheet { box-shadow: 0 -16px 28px rgba(0,0,0,.85), inset 0 1px 0 rgba(232,209,154,.14) !important; }
html[data-tg-platform="android"] .mode-tile { box-shadow: inset 0 1px 0 rgba(255,255,255,.09), inset 0 0 0 1px rgba(232,209,154,.07), 0 8px 12px rgba(0,0,0,.4) !important; }
html[data-tg-platform="android"] .mode-tile:active { box-shadow: 0 10px 14px rgba(0,0,0,.5), inset 0 0 0 1px color-mix(in srgb, var(--mode-tone) 30%, transparent) !important; }
html[data-tg-platform="android"] #tab-crash .crash { box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 10px 15px rgba(0,0,0,.35); }
html[data-tg-platform="android"] #tab-crash #cr-cta { box-shadow: 0 10px 14px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.6), inset 0 -3px 0 rgba(0,0,0,.18) !important; }
html[data-tg-platform="android"] .face-me { box-shadow: 0 0 16px rgba(34,229,132,.4), inset 0 0 0 3px rgba(255,255,255,.25); }
html[data-tg-platform="android"] .face-op { box-shadow: 0 0 16px rgba(75,139,255,.4), inset 0 0 0 3px rgba(255,255,255,.25); }
html[data-tg-platform="android"] .tabbar__item.is-passing:not(.active)::after { box-shadow: inset 0 0 0 1.5px rgba(204,255,74,.75), 0 0 10px rgba(204,255,74,.22) !important; }
html[data-tg-platform="android"] .tabbar__item.is-passing .tabbar__ava { box-shadow: 0 0 0 3px var(--accent), 0 0 10px rgba(204,255,74,.5) !important; }
html[data-tg-platform="android"] .cf-pick button.on.gem { box-shadow: 0 0 0 1px rgba(204,255,74,.55), 0 0 12px rgba(204,255,74,.18), inset 0 1px 0 rgba(255,255,255,.12) !important; }
html[data-tg-platform="android"] .cf-pick button.on.cube { box-shadow: 0 0 0 1px rgba(91,152,255,.55), 0 0 12px rgba(62,139,255,.2), inset 0 1px 0 rgba(255,255,255,.12) !important; }
html[data-tg-platform="android"] .up-grid .item-card.is-selected { box-shadow: 0 0 0 1px rgba(204,255,74,.6), 0 0 12px rgba(204,255,74,.16) !important; }
html[data-tg-platform="android"] .wheel-ico { box-shadow: 0 0 14px color-mix(in srgb, var(--arc) 30%, transparent); }

/* --- drop-shadow (silhouette) filters on transparent art in scrolling grids / the spinning wheel:
       halve the blur radius (Android blur cost scales steeply with radius). --- */
html[data-tg-platform="android"] .item-card__media img { filter: drop-shadow(0 3px 3px rgba(0,0,0,.5)); }
html[data-tg-platform="android"] .case-card--art .case-card__cover img { filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); }
html[data-tg-platform="android"] .wheel-arc { filter: drop-shadow(0 0 3px color-mix(in srgb, var(--arc) 55%, transparent)); }
html[data-tg-platform="android"] .wheel.win .wheel-arc { filter: drop-shadow(0 0 6px var(--arc)); }
html[data-tg-platform="android"] .wheel-ico.img img { filter: drop-shadow(0 0 4px color-mix(in srgb, var(--arc) 40%, transparent)); }
