@charset "UTF-8";

/*
 * perf-patch.css — Runtime performance tweaks
 *
 * Bu dosya tüm diğer CSS'lerden SONRA yüklenir, override eder.
 * Amaç: oyun sırasında "donma/jank" hissini azaltmak.
 *
 * Yaklaşım:
 * 1. Mobile'da backdrop-filter (blur) tamamen kapat → en büyük kazanç.
 *    Sebep: backdrop-filter GPU-pahalı, mobil chip'ler zorlanır.
 *    Etki: 20+ yerde kullanılan blur, mobile'da solid bg ile değişir.
 *
 * 2. prefers-reduced-motion → animasyonları yumuşat
 *    (kullanıcı OS'unda "Reduce Motion" açtıysa)
 *
 * 3. Animasyonlu element'lere will-change: transform → GPU layer'a taşı
 *    (kart, zar, trick area — sürekli animate ediliyor)
 *
 * 4. .card, .tg-die, .pinfo gibi sürekli render olan element'ler
 *    için contain: layout style → reflow yayılımını kıs
 */

/* ── 1. Mobile + tablet: backdrop-filter'ları tamamen öldür ── */
@media (max-width: 900px) {
  *,
  *::before,
  *::after {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  /* Backdrop-filter blur'a güvenen şeffaf bg'leri biraz koyulaştır */
  #tg-topbar { background: rgba(18, 8, 2, 0.94) !important; }
  #mm-topbar { background: rgba(10, 10, 16, 0.92) !important; }
  #legal-gate-modal { background: rgba(0, 0, 0, 0.92) !important; }
  #bug-report-modal { background: rgba(0, 0, 0, 0.88) !important; }
  #tg-pes-modal { background: rgba(0, 0, 0, 0.86) !important; }
}

/* ── 2. Reduced motion respect ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── 3. GPU layer hints for hot animation paths ── */
/* Toto: cards, trick area, bid pills */
.card,
.card-back,
#trick-cards,
.pbid-label,
.pinfo {
  will-change: transform;
  transform: translateZ(0); /* force composite layer */
}

/* Tavla: dice, pieces, drawer */
.tg-die,
.tg-piece,
.draw-card-wrap {
  will-change: transform;
  transform: translateZ(0);
}

/* Confetti / celebration overlays */
.tv-confetti,
.confetti,
.tg-win-overlay,
#round-overlay {
  will-change: transform, opacity;
}

/* ── 4. Containment for high-render-frequency containers ── */
#table,
#tg-board,
#hand-bottom,
#hand-top,
#hand-left,
#hand-right {
  contain: layout style;
}

/* ── 5. Throttle expensive filters/shadows during animation ── */
/* Disable drop-shadow on cards during transform animations to prevent re-paint */
.card.is-playing,
.tg-die.rolling {
  filter: none !important;
}

/* ── 6. Smaller text-shadow blur on mobile (cheaper) ── */
@media (max-width: 600px) {
  #mm-logo, .tg-win-title, #tg-variant-label {
    text-shadow: 0 2px 6px rgba(0,0,0,0.45) !important;
  }
}

/* ── 7. KILL infinite animations (ALL devices) ──────────────────
   27+ yer'de `animation: ... infinite` var. Çoğu box-shadow /
   text-shadow / filter pulse → PAINT-only → CPU paint per frame.
   Desktop'ta bile (özellikle Electron/preview tarayıcıda) jank.
   Mobile'da garanti.
   Çözüm: tek satır — tüm animasyonları "1 kez çalış, dur" yap.
   - Bir kez oynayan animasyonlar (kart enter, modal fade, dice roll)
     etkilenmez (zaten default iteration-count: 1)
   - Sadece `infinite` veya N>1 olanlar 1'e iner → constant paint biter
   ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  animation-iteration-count: 1 !important;
}

/* Statik "sıra bu oyuncuda" göstergesi (pulse iptal olduğu için) */
.pinfo.is-turn {
  box-shadow: 0 0 0 2px rgba(var(--neon-1-rgb, 255,45,139), 0.8),
              0 8px 24px rgba(var(--neon-1-rgb, 255,45,139), 0.35) !important;
}

/* Background floating cards: decorative, tamamen kapat */
.mm-bg-card {
  animation: none !important;
  opacity: 0.04 !important;
}

/* ── 8. KILL card deal animations ──────────────────────────────
   52 kart × dealInLuxe 0.6s = 52 paralel translateY+scale+rotate
   compositing → kart dağıtımında jank kaynağı. Anında göster.
   ──────────────────────────────────────────────────────────── */
.card,
.card-back,
.hand .card,
.hand .card-back {
  animation: none !important;
}

/* ── 9. NUCLEAR: kill all transitions ──────────────────────────
   "Hâlâ donuyor" şikayetinin son çözümü. Tüm CSS transition'ları
   anında bitir. Hover/aktif state değişiklikleri snap-on/snap-off
   olur (görsel polish gider ama jank kesin gider).
   ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  transition-duration: 0s !important;
  transition-delay: 0s !important;
  animation-duration: 0s !important;
}
