/* $TAP Mini App - Animations */

/* Coin Effect Animations for TAP game */
@keyframes coinFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
    }
    50% {
        transform: translateY(-40px) scale(1.2) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-80px) scale(0.8) rotate(360deg);
    }
}

@keyframes coinChain {
    0% {
        opacity: 0.8;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.1) rotate(180deg);
    }
    100% {
        opacity: 0;
        transform: scale(0.5) rotate(360deg);
    }
}

/* Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideLeft {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -30px, 0);
    }
    70% {
        transform: translate3d(0, -15px, 0);
    }
    90% {
        transform: translate3d(0, -4px, 0);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-60px);
    }
}

@keyframes glow {
    0% {
        box-shadow: 0 0 5px rgba(233, 69, 96, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(233, 69, 96, 0.4), 0 0 30px rgba(233, 69, 96, 0.2);
    }
    100% {
        box-shadow: 0 0 5px rgba(233, 69, 96, 0.2);
    }
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

@keyframes wiggle {
    0%, 7% {
        transform: rotateZ(0);
    }
    15% {
        transform: rotateZ(-15deg);
    }
    20% {
        transform: rotateZ(10deg);
    }
    25% {
        transform: rotateZ(-10deg);
    }
    30% {
        transform: rotateZ(6deg);
    }
    35% {
        transform: rotateZ(-4deg);
    }
    40%, 100% {
        transform: rotateZ(0);
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateY(-5px) scale(1.1);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes progressFill {
    from {
        width: 0%;
    }
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.3);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.3);
    }
    70% {
        transform: scale(1);
    }
}

/* Animation Classes */
.animate-fadeIn {
    animation: fadeIn 0.3s ease-out;
}

.animate-fadeOut {
    animation: fadeOut 0.3s ease-out;
}

.animate-slideUp {
    animation: slideUp 0.3s ease-out;
}

.animate-slideDown {
    animation: slideDown 0.3s ease-out;
}

.animate-slideLeft {
    animation: slideLeft 0.3s ease-out;
}

.animate-slideRight {
    animation: slideRight 0.3s ease-out;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-bounce {
    animation: bounce 1s ease-in-out infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

.animate-scaleIn {
    animation: scaleIn 0.3s ease-out;
}

.animate-scaleOut {
    animation: scaleOut 0.3s ease-out;
}

.animate-wiggle {
    animation: wiggle 0.6s ease-in-out;
}

.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

/* Tap-specific animations */
.tap-button-active {
    animation: pulse 0.2s ease-out;
}

.tap-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    pointer-events: none;
}

.tap-ripple.active {
    animation: ripple 0.6s ease-out;
}

.tap-counter-animate {
    animation: floatUp 1s ease-out forwards;
}

.points-increase {
    animation: countUp 0.8s ease-out;
}

.progress-animate {
    animation: progressFill 1s ease-out;
}

/* Screen transition animations */
.screen-enter {
    animation: slideLeft 0.3s ease-out;
}

.screen-exit {
    animation: slideRight 0.3s ease-out;
}

/* Button hover effects */
.btn-hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn-hover-lift:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Loading state animations */
.loading-dots::after {
    content: '.';
    animation: loadingDots 1.5s steps(3, end) infinite;
}

@keyframes loadingDots {
    0%, 20% {
        color: rgba(255, 255, 255, 0);
        text-shadow: .25em 0 0 rgba(255, 255, 255, 0), .5em 0 0 rgba(255, 255, 255, 0);
    }
    40% {
        color: white;
        text-shadow: .25em 0 0 rgba(255, 255, 255, 0), .5em 0 0 rgba(255, 255, 255, 0);
    }
    60% {
        text-shadow: .25em 0 0 white, .5em 0 0 rgba(255, 255, 255, 0);
    }
    80%, 100% {
        text-shadow: .25em 0 0 white, .5em 0 0 white;
    }
}

/* Navigation animations */
.nav-item {
    transition: all 0.2s ease;
}

.nav-item:hover {
    transform: translateY(-2px);
}

.nav-item.active {
    transform: translateY(-1px);
}

.nav-indicator {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 3px 3px 0 0;
    transition: all 0.3s ease;
}

/* Toast animations */
.toast-slide-in {
    animation: slideUp 0.3s ease-out;
}

.toast-slide-out {
    animation: slideDown 0.3s ease-out;
}

/* Balance update animation */
.balance-update {
    animation: countUp 0.5s ease-out;
}

.balance-highlight {
    animation: glow 0.8s ease-out;
}

/* Achievement unlock animation */
.achievement-unlock {
    animation: bounce 0.6s ease-out, glow 1s ease-out;
}

/* Error state animations */
.error-shake {
    animation: shake 0.5s ease-in-out;
}

/* Success state animations */
.success-bounce {
    animation: bounce 0.8s ease-out;
}

/* Card flip animation */
.card-flip {
    perspective: 1000px;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip.flipped .card-flip-inner {
    transform: rotateY(180deg);
}

.card-flip-front,
.card-flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
}

.card-flip-back {
    transform: rotateY(180deg);
}

/* Stagger animation for lists */
.stagger-item {
    animation: slideUp 0.4s ease-out;
}

.stagger-item:nth-child(1) { animation-delay: 0s; }
.stagger-item:nth-child(2) { animation-delay: 0.1s; }
.stagger-item:nth-child(3) { animation-delay: 0.2s; }
.stagger-item:nth-child(4) { animation-delay: 0.3s; }
.stagger-item:nth-child(5) { animation-delay: 0.4s; }

/* Performance optimizations */
.animate-gpu {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000;
}

/* Disable animations for reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tap-button {
        animation: none !important;
    }
    
    .loading-spinner {
        animation: none !important;
        border-top-color: var(--accent-red);
    }
}

/* Custom easing functions */
.ease-bounce {
    animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ease-back {
    animation-timing-function: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ease-elastic {
    animation-timing-function: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ========================================= */
/* ENHANCED CELEBRATION ANIMATIONS FOR TAP BONUS */
/* ========================================= */

/* Celebration Overlay */
.celebration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

/* Confetti Animation */
.celebration-confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.celebration-confetti::before,
.celebration-confetti::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24, #f0932b);
    animation: confettiFall 3s ease-out infinite;
}

.celebration-confetti::before {
    left: 20%;
    animation-delay: 0s;
}

.celebration-confetti::after {
    left: 80%;
    animation-delay: 0.5s;
}

@keyframes confettiFall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Fireworks Animation */
.celebration-fireworks {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: fireworkExplode 1.5s ease-out;
}

.firework:nth-child(1) {
    background: #ff6b6b;
    animation-delay: 0.2s;
    transform: translate(-30px, -30px);
}

.firework:nth-child(2) {
    background: #4ecdc4;
    animation-delay: 0.4s;
    transform: translate(30px, -20px);
}

.firework:nth-child(3) {
    background: #f9ca24;
    animation-delay: 0.6s;
    transform: translate(0px, -40px);
}

@keyframes fireworkExplode {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(8) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(15) rotate(360deg);
        opacity: 0;
    }
}

/* Sparkles Animation */
.celebration-sparkles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.sparkle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: linear-gradient(45deg, #fff, #ffd700);
    border-radius: 50%;
    animation: sparkleShine 2s ease-in-out infinite;
}

.sparkle:nth-child(1) {
    top: 20%;
    left: 15%;
    animation-delay: 0s;
}

.sparkle:nth-child(2) {
    top: 30%;
    right: 20%;
    animation-delay: 0.3s;
}

.sparkle:nth-child(3) {
    bottom: 40%;
    left: 25%;
    animation-delay: 0.6s;
}

.sparkle:nth-child(4) {
    bottom: 25%;
    right: 15%;
    animation-delay: 0.9s;
}

.sparkle:nth-child(5) {
    top: 50%;
    left: 50%;
    animation-delay: 1.2s;
}

@keyframes sparkleShine {
    0%, 100% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(3) rotate(180deg);
        opacity: 1;
        box-shadow: 0 0 20px #ffd700;
    }
}

/* BOOM Text Animation */
.celebration-text {
    text-align: center;
    margin-bottom: 20px;
}

.boom-text {
    font-size: 28px;
    font-weight: 800;
    color: #ff6b6b;
    text-shadow: 2px 2px 0px #fff, -2px -2px 0px #fff, 2px -2px 0px #fff, -2px 2px 0px #fff;
    animation: boomEffect 0.8s ease-out;
    margin-bottom: 15px;
}

@keyframes boomEffect {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Enhanced Points Display */
.points-celebration {
    text-align: center;
    margin: 30px 0;
}

.earned-points-big {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    animation: pointsAppear 1s ease-out;
    position: relative;
    overflow: hidden;
}

.earned-points-big::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

.points-value {
    display: block;
    font-size: 48px;
    font-weight: 900;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: numbersCountUp 1.5s ease-out;
}

.points-label {
    display: block;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    margin-top: 5px;
}

@keyframes pointsAppear {
    0% {
        transform: translateY(50px) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translateY(-10px) scale(1.05);
        opacity: 0.9;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes numbersCountUp {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Celebration Messages */
.celebration-message {
    animation: messageSlideIn 1.2s ease-out;
}

.main-message {
    font-size: 24px;
    font-weight: 700;
    color: #4ecdc4;
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.sub-message {
    font-size: 16px;
    color: #666;
    font-weight: 500;
    line-height: 1.4;
}

@keyframes messageSlideIn {
    0% {
        transform: translateX(-50px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Enhanced Balance Display */
.balance-display {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    text-align: center;
    animation: balanceSlideUp 1s ease-out 0.5s both;
}

.balance-row {
    margin-bottom: 10px;
}

.balance-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.balance-value {
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    margin: 0 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.balance-unit {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

.progress-text {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

@keyframes balanceSlideUp {
    0% {
        transform: translateY(30px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Tomorrow Message */
.tomorrow-message {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    border-radius: 15px;
    margin: 20px 0;
    animation: tomorrowBounce 1s ease-out 1s both;
}

.clock-icon {
    font-size: 32px;
    margin-bottom: 10px;
    animation: clockTick 2s ease-in-out infinite;
}

.message-text {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.next-tap-time {
    font-size: 14px;
    color: #34495e;
    font-weight: 500;
}

@keyframes tomorrowBounce {
    0% {
        transform: translateY(40px) scale(0.9);
        opacity: 0;
    }
    50% {
        transform: translateY(-5px) scale(1.02);
        opacity: 0.8;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes clockTick {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(15deg);
    }
    75% {
        transform: rotate(-15deg);
    }
}

/* Enhanced Action Buttons */
.next-actions-enhanced {
    margin-top: 30px;
    animation: actionsSlideIn 1s ease-out 1.5s both;
}

.next-actions-enhanced h4 {
    text-align: center;
    color: #2c3e50;
    font-weight: 700;
    margin-bottom: 20px;
    font-size: 18px;
}

.action-buttons-enhanced {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-buttons-enhanced .btn {
    padding: 16px 20px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.action-buttons-enhanced .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.action-buttons-enhanced .btn-secondary {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #2c3e50;
    box-shadow: 0 8px 25px rgba(252, 182, 159, 0.3);
}

.action-buttons-enhanced .btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

.action-buttons-enhanced .btn:active {
    transform: translateY(-1px);
}

@keyframes actionsSlideIn {
    0% {
        transform: translateY(50px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Results Content Animation */
.results-content {
    animation: resultsAppear 0.8s ease-out;
}

@keyframes resultsAppear {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Tap Results Enhanced */
.tap-results {
    position: relative;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 30px 20px;
    border-radius: 20px;
    margin: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    color: white;
    overflow: hidden;
}

.tap-results::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="stars" patternUnits="userSpaceOnUse" width="100" height="100"><circle cx="20" cy="20" r="1" fill="%23fff" opacity="0.3"/><circle cx="60" cy="40" r="0.5" fill="%23fff" opacity="0.4"/><circle cx="30" cy="70" r="0.8" fill="%23fff" opacity="0.2"/><circle cx="80" cy="80" r="1.2" fill="%23fff" opacity="0.3"/></pattern></defs><rect width="100" height="100" fill="url(%23stars)"/></svg>') repeat;
    opacity: 0.1;
    animation: starsFloat 20s linear infinite;
}

@keyframes starsFloat {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-100px);
    }
}