.bouncing-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(-100px); 
    animation: flyInBounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    animation-delay: calc(var(--letter-index) * 0.1s);
}

@keyframes flyInBounce {
    0% {
        opacity: 0;
        transform: translateY(-150px);
    }
    60% {
        opacity: 1;
        transform: translateY(10px);
    }
    80% {
        transform: translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0); 
    }
}

.bouncing-dollars {
    display: inline-block;
    position: relative;
    visibility: hidden; 
    /* The real letter reveals right as the dollar animation finishes */
    animation: revealLetter 1.2s calc(var(--letter-index) * 0.1s) forwards;
}

/* The Spinning Dollar Sign */
.bouncing-dollars::before {
    content: var(--fallback); 
    position: absolute;
    left: 0;
    top: 0;
    visibility: visible;
    opacity: 0;
    
    /* CRITICAL SMOOTHNESS TRICK: 
       We apply TWO animations. One handles the smooth linear spin, 
       the other handles the bouncy falling trajectory.
    */
    animation: 
        smoothSpin 1.2s linear calc(var(--letter-index) * 0.1s) forwards,
        bouncyDrop 1.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) calc(var(--letter-index) * 0.1s) forwards;
}

/* 1. Handles ONLY the rotation with a flawless, even distribution of degrees */
@keyframes smoothSpin {
    0% {
        transform: rotateY(0deg) rotateZ(0deg);
    }
    100% {
        transform: rotateY(1080deg) rotateZ(360deg); /* 3 full Y spins, 1 full Z roll */
    }
}

/* 2. Handles ONLY the vertical movement and visibility swapping */
@keyframes bouncyDrop {
    0% {
        opacity: 0;
        top: -150px;
    }
    30% {
        opacity: 1; /* Fade in quickly as it drops */
    }
    70% {
        top: 10px; /* Over-drop bounce floor */
    }
    85% {
        top: -5px; /* Rebound up */
    }
    99% {
        opacity: 1;
        visibility: visible;
    }
    100% {
        opacity: 0;
        visibility: hidden; /* Clean handoff to the real letter */
        top: 0px; /* Settle on baseline */
    }
}

/* 3. Reveals the static real letter (LOCKSMITH) seamlessly */
@keyframes revealLetter {
    0%, 99% {
        visibility: hidden;
    }
    100% {
        visibility: visible;
    }
}