/* ---- Keyframes ------------------------------------------------------- */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes screen-in { from { opacity: 0; transform: translateY(14px) scale(0.99); } to { opacity: 1; transform: none; } }
@keyframes pop-in { 0% { transform: scale(0); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
@keyframes merge-pop { 0% { transform: scale(1); } 45% { transform: scale(1.22); } 100% { transform: scale(1); } }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-9px) rotate(-1deg); } 40% { transform: translateX(8px) rotate(1deg); } 60% { transform: translateX(-6px); } 80% { transform: translateX(5px); } }
@keyframes score-float { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-34px); } }
@keyframes float-up { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 12% { opacity: 1; transform: translateY(-20px) scale(1.15); } 100% { transform: translateY(-340px) translateX(24px) scale(1); opacity: 0; } }
@keyframes count-pop { 0% { transform: scale(2.4); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.85); opacity: 0.2; } }
@keyframes blob-a { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(8vw, 6vh) scale(1.2); } }
@keyframes blob-b { 0%, 100% { transform: translate(0, 0) scale(1.1); } 50% { transform: translate(-9vw, -5vh) scale(0.9); } }
@keyframes blob-c { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(6vw, -8vh) scale(1.25); } }
@keyframes shimmer { from { background-position: -200% 0; } to { background-position: 200% 0; } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5); } 50% { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0); } }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes unlock { 0% { transform: scale(0.3) rotate(-25deg); opacity: 0; } 60% { transform: scale(1.2) rotate(6deg); opacity: 1; } 100% { transform: none; } }
@keyframes ring { 0% { transform: scale(0.6); opacity: 0.9; } 100% { transform: scale(2.2); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes defeat { 0% { filter: none; } 100% { filter: grayscale(0.8) brightness(0.8); } }

/* ---- Usage ----------------------------------------------------------- */
.screen-enter { animation: screen-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
.tile-inner.pop, .tile.spawned .tile-inner { animation: pop-in 0.2s ease-out; }
.tile-inner.bump, .tile.merged .tile-inner { animation: merge-pop 0.2s ease-out; }
.shake { animation: shake 0.45s; }
.defeated { animation: defeat 0.8s forwards; }
.glow { animation: glow 2s infinite; }
.skeleton { background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius-sm); min-height: 18px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin 0.8s linear infinite; display: inline-block; }
.unlock-anim { animation: unlock 0.7s cubic-bezier(0.2, 1.4, 0.4, 1); }

.bg-anim { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(circle at 20% 0%, var(--bg-2), var(--bg) 60%); }
.bg-anim i { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(70px); will-change: transform; }
.bg-anim i:nth-child(1) { background: var(--blob-1); top: -15vmax; left: -10vmax; animation: blob-a 22s ease-in-out infinite; }
.bg-anim i:nth-child(2) { background: var(--blob-2); bottom: -18vmax; right: -12vmax; animation: blob-b 26s ease-in-out infinite; }
.bg-anim i:nth-child(3) { background: var(--blob-3); top: 35%; left: 45%; width: 30vmax; height: 30vmax; animation: blob-c 30s ease-in-out infinite; }

.podium-bar { transform-origin: bottom; animation: rise 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
.rank-move { transition: transform 0.5s cubic-bezier(0.2, 0.9, 0.3, 1); }
.lb-row.flash { animation: glow 1s 2; }

.btn { transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s ease, filter 0.2s; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.97); }
.pulse-ring { position: relative; }
.pulse-ring::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 2px solid var(--primary); animation: ring 1.6s infinite; pointer-events: none; }

/* Reduced motion: respects both the OS setting and the in-app switch. */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}
:root[data-motion="reduce"] .bg-anim i { animation: none; }
