/* ===== ANIMATIONS ===== */

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% center;
    }

    100% {
        background-position: 200% center;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 10px currentColor;
    }

    50% {
        box-shadow: 0 0 20px currentColor;
    }
}

@keyframes numberPop {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    50% {
        transform: translateY(-30px) scale(1.5);
        opacity: 1;
    }

    100% {
        transform: translateY(-60px) scale(1);
        opacity: 0;
    }
}

@keyframes coinCollect {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: scale(1.3) rotate(180deg);
    }

    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

@keyframes attackFlash {

    0%,
    100% {
        background-color: transparent;
    }

    50% {
        background-color: rgba(255, 56, 56, 0.3);
    }
}

@keyframes upgradeSuccess {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(0, 255, 136, 0.4);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(0, 255, 136, 0.6);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(0, 255, 136, 0);
    }
}

@keyframes progressFill {
    from {
        width: 0%;
    }

    to {
        width: var(--progress-width);
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ===== ANIMATION CLASSES ===== */

.animate-slideUp {
    animation: slideUp 0.3s ease-out;
}

.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

.animate-popIn {
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.animate-shake {
    animation: shake 0.3s ease-in-out;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-upgradeSuccess {
    animation: upgradeSuccess 0.6s ease-out;
}

.animate-attackFlash {
    animation: attackFlash 0.3s ease-in-out;
}

/* ===== PREMIUM SHIMMER EFFECT ===== */

.shimmer {
    background: linear-gradient(90deg,
            rgba(255, 215, 0, 0.1) 0%,
            rgba(255, 215, 0, 0.3) 50%,
            rgba(255, 215, 0, 0.1) 100%);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

/* ===== NUMBER POP EFFECT ===== */

.number-pop {
    position: fixed;
    font-size: 24px;
    font-weight: 900;
    color: var(--accent-gold);
    pointer-events: none;
    z-index: 9999;
    animation: numberPop 1s ease-out forwards;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

/* ===== PROGRESS BARS ===== */

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-gold));
    border-radius: 4px;
    transition: width 0.3s ease-out;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.3),
            transparent);
    animation: shimmer 2s linear infinite;
}

/* ===== LOADING SPINNER ===== */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 215, 0, 0.2);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: rotate 1s linear infinite;
}

/* ===== COIN PARTICLE EFFECT ===== */

.coin-particle {
    position: fixed;
    font-size: 20px;
    pointer-events: none;
    z-index: 9999;
    animation: coinCollect 0.8s ease-out forwards;
}

/* ===== TRANSITION EFFECTS ===== */

.fade-enter {
    opacity: 0;
}

.fade-enter-active {
    opacity: 1;
    transition: opacity 0.3s ease-in;
}

.fade-exit {
    opacity: 1;
}

.fade-exit-active {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

/* ===== HOVER EFFECTS (DESKTOP) ===== */

@media (hover: hover) {
    .btn-collect:hover {
        transform: scale(1.02);
        box-shadow: var(--shadow-lg), var(--shadow-glow) rgba(255, 215, 0, 0.7);
    }

    .building-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

    .accelerator-card:hover {
        transform: translateY(-3px);
        border-color: var(--accent-gold);
    }

    .nav-btn:hover {
        color: var(--accent-gold);
    }

    .tab-btn:hover:not(.active) {
        background: var(--bg-secondary);
    }
}

/* ===== SCREEN TRANSITIONS ===== */

.screen {
    animation: fadeIn 0.3s ease-out;
}

/* ===== NOTIFICATION PULSE ===== */

.notification-pulse {
    position: relative;
}

.notification-pulse::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: var(--accent-red);
    border-radius: 50%;
    opacity: 0;
    animation: notificationWave 2s ease-out infinite;
}

@keyframes notificationWave {
    0% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(2);
    }
}

/* ===== RARITY GLOW EFFECTS ===== */

.rarity-common {
    border-color: var(--rarity-common);
}

.rarity-rare {
    border-color: var(--rarity-rare);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

.rarity-epic {
    border-color: var(--rarity-epic);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.4);
}

.rarity-legendary {
    border-color: var(--rarity-legendary);
    box-shadow: 0 0 30px rgba(251, 191, 36, 0.5);
    animation: glow 2s ease-in-out infinite;
}

/* ===== ATTACK/VICTORY ANIMATIONS ===== */

.victory-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 255, 136, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.defeat-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 56, 56, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

/* ===== COUNTDOWN TIMER PULSE ===== */

.timer-urgent {
    color: var(--accent-red);
    animation: pulse 1s infinite;
}

/* ===== REWARD BURST ===== */

@keyframes rewardBurst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }

    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }

    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.reward-burst {
    animation: rewardBurst 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===== MICRO-INTERACTIONS ===== */

.btn-primary:active,
.btn-secondary:active,
.btn-upgrade:active,
.btn-shield:active {
    transform: scale(0.97);
}

/* ===== SMOOTH TRANSITIONS ===== */

* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

button,
.building-card,
.boss-card,
.accelerator-card {
    transition: transform 0.1s ease, box-shadow 0.2s ease;
}

/* ===== FLOATING TEXT & GAME JUICE ===== */

.floating-text {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    font-size: 1.25rem;
    animation: floatUpFade 1.1s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 12px currentColor;
    white-space: nowrap;
    transform: translate(-50%, -50%);
}

.floating-money {
    color: #00ff88;
}

.floating-gems {
    color: #00e5ff;
}

.floating-crit {
    color: #ff0055;
    font-size: 1.6rem;
    animation: floatUpCrit 1.2s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

.floating-power {
    color: #ffd700;
}

.floating-damage {
    color: #ff3333;
    font-size: 1.4rem;
}

@keyframes floatUpFade {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.6);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -15px) scale(1.15);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -70px) scale(0.95);
    }
}

@keyframes floatUpCrit {
    0% {
        opacity: 0;
        transform: translate(-50%, 0) scale(0.4) rotate(-5deg);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -20px) scale(1.4) rotate(4deg);
    }
    40% {
        transform: translate(-50%, -30px) scale(1.2) rotate(-2deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -90px) scale(0.9) rotate(0);
    }
}

/* ===== SCREEN SHAKE ===== */

.shake-light {
    animation: shakeLight 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

.shake-medium {
    animation: shakeMed 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.shake-heavy {
    animation: shakeHeavy 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shakeLight {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-2px, 0, 0); }
    40%, 60% { transform: translate3d(2px, 0, 0); }
}

@keyframes shakeMed {
    10%, 90% { transform: translate3d(-3px, -1px, 0); }
    20%, 80% { transform: translate3d(4px, 2px, 0); }
    30%, 50%, 70% { transform: translate3d(-5px, -2px, 0); }
    40%, 60% { transform: translate3d(5px, 2px, 0); }
}

@keyframes shakeHeavy {
    10%, 90% { transform: translate3d(-6px, -3px, 0) scale(1.01); }
    20%, 80% { transform: translate3d(8px, 4px, 0) scale(0.99); }
    30%, 50%, 70% { transform: translate3d(-10px, -4px, 0) scale(1.02); }
    40%, 60% { transform: translate3d(10px, 4px, 0) scale(0.98); }
}

/* ===== BURST COINS ===== */

.burst-coin {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    font-size: 1.4rem;
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.8));
    will-change: transform, opacity, left, top;
}

/* ===== CONFETTI ===== */

.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 10000;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    top: -20px;
    width: 10px;
    height: 14px;
    opacity: 0.9;
    border-radius: 2px;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        top: -20px;
        transform: rotate(0deg) rotateY(0deg);
        opacity: 1;
    }
    100% {
        top: 105vh;
        transform: rotate(720deg) rotateY(1080deg);
        opacity: 0.2;
    }
}

/* ===== GACHA SUMMON 3D MODAL ===== */

.gacha-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    perspective: 1200px;
}

.gacha-modal.active {
    display: flex;
}

.gacha-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 7, 15, 0.92);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.4s ease forwards;
}

.gacha-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90%;
    max-width: 380px;
}

.gacha-rays {
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(30px);
    opacity: 0.6;
    animation: pulse 2s infinite alternate;
    pointer-events: none;
}

.gacha-rays.rarity-common { background: radial-gradient(circle, rgba(156, 163, 175, 0.5) 0%, transparent 70%); }
.gacha-rays.rarity-rare { background: radial-gradient(circle, rgba(56, 189, 248, 0.7) 0%, transparent 70%); }
.gacha-rays.rarity-epic { background: radial-gradient(circle, rgba(192, 132, 252, 0.8) 0%, transparent 70%); }
.gacha-rays.rarity-legendary { background: radial-gradient(circle, rgba(255, 215, 0, 0.9) 0%, rgba(255, 110, 0, 0.5) 40%, transparent 70%); }

.gacha-card-wrapper {
    width: 240px;
    height: 340px;
    perspective: 1000px;
    cursor: pointer;
    margin-bottom: 24px;
}

.gacha-card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.gacha-card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-sizing: border-box;
    padding: 16px;
    text-align: center;
}

.card-back-face {
    background: linear-gradient(135deg, #181926, #2d3142);
    border: 2px solid #ffd700;
    color: #ffd700;
}

.card-back-logo {
    font-size: 3.5rem;
    animation: float 2s infinite ease-in-out;
}

.card-back-title {
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: 3px;
    margin-top: 10px;
}

.card-back-tap {
    font-size: 0.75rem;
    color: #aaa;
    margin-top: 30px;
    animation: pulse 1.2s infinite;
}

.card-front {
    transform: rotateY(180deg);
    color: #ffffff;
    box-shadow: inset 0 0 20px rgba(255,255,255,0.2);
}

.card-front.rarity-legendary {
    border: 3px solid #ffd700;
    box-shadow: 0 0 35px rgba(255, 215, 0, 0.8), inset 0 0 15px rgba(255, 215, 0, 0.4);
}

.card-rarity-badge {
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 2px;
    padding: 3px 12px;
    border-radius: 20px;
    background: rgba(0,0,0,0.5);
    margin-bottom: 10px;
}

.card-avatar {
    font-size: 4.5rem;
    margin: 10px 0;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
}

.card-name {
    font-size: 1.3rem;
    font-weight: 900;
    margin-bottom: 6px;
}

.card-desc {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.85);
    margin-bottom: 12px;
}

.card-stars {
    color: #ffd700;
    font-size: 1.1rem;
    letter-spacing: 2px;
}

.gacha-claim-btn {
    min-width: 220px;
    padding: 14px 28px;
    font-size: 1.05rem;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
}