@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.6); /* Start more scaled down from center */
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1); /* End at normal scale in center */
    }
}

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

#topper {
    display: none; /* Hidden by default */
    position: fixed;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important; /* Center horizontally and vertically */
    background-color: #1e1e1e;
    color: #ffffff;
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 100px rgba(59, 130, 246, 0.3);
    z-index: 1000;
    animation: slideIn 0.6s ease-out forwards; /* Apply animation on show */
    text-align: center;
    max-width: 90%;
    width: 90%;
    max-width: 500px;
    max-height: none;
    overflow: visible;
    transition: all 0.6s ease-out; /* Smooth fade transition */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(59, 130, 246, 0.2);
    /* Ensure perfect centering on all devices */
    margin: 0;
    box-sizing: border-box;
}

/* Large screen devices (laptops and desktops) */
@media (min-width: 1024px) {
    #topper {
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90%;
        max-width: 500px;
        padding: 40px;
    }
    
    #closeTopper {
        top: 15px !important;
        right: 20px !important;
    }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    #topper {
        width: 85%;
        max-width: 400px;
        padding: 30px 20px;
        border-radius: 20px;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
    
    #topperContent h2 {
        font-size: 2rem;
    }
    
    #topperContent p {
        font-size: 1.2rem;
    }
    
    #topperContent .highlight {
        font-size: 1.4rem;
    }
    
    #topperContent .leaderboard-topper {
        font-size: 1.3rem;
    }
    
    #topperContent .badge {
        font-size: 1.1rem;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    #topper {
        width: 92%;
        max-width: 350px;
        padding: 25px 15px;
        border-radius: 16px;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }
    
    #topperContent h2 {
        font-size: 1.8rem;
    }
    
    #topperContent p {
        font-size: 1.1rem;
    }
    
    #topperContent .highlight {
        font-size: 1.3rem;
    }
    
    #topperContent .leaderboard-topper {
        font-size: 1.2rem;
    }
    
    #topperContent .badge {
        font-size: 1rem;
    }
    
    #closeTopper {
        font-size: 28px;
        width: 40px;
        height: 40px;
        top: 15px;
        right: 15px;
    }
}

#topperContent {
    margin-bottom: 15px;
    position: relative;
}

#topperContent h2 {
    font-size: 2.3rem; /* Increased size for better visibility */
    margin-bottom: 20px;
    color: #f4c542; /* Gold color */
    animation: pulse 2s infinite;
    font-weight: 600;
    text-shadow: 0 0 20px rgba(244, 197, 66, 0.5);
}

#topperContent p {
    font-size: 1.4rem;
    margin: 20px 0;
    line-height: 1.6;
    color: #e5e7eb;
}

#topperContent .highlight {
    font-weight: bold;
    color: #4285f4; /* Blue for name */
    font-size: 1.6rem;
    text-shadow: 0 0 15px rgba(66, 133, 244, 0.5);
}

#topperContent .leaderboard-topper {
    font-weight: bold;
    color: #34a853; /* Green for "Leaderboard Topper" */
    font-size: 1.5rem;
    text-shadow: 0 0 15px rgba(52, 168, 83, 0.5);
}

#topperContent .badge {
    font-weight: bold;
    color: #ff9800; /* Orange for badges, games, trivia, and courses */
    font-size: 1.3rem;
    text-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

#closeTopper {
    background: rgba(0, 0, 0, 0.8);
    border: none;
    cursor: pointer;
    font-size: 36px;
    color: #ffffff; /* White color for better visibility */
    position: absolute;
    top: 20px;
    right: 20px;
    transition: all 0.2s ease; /* Faster transition */
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

#closeTopper:hover {
    color: #ff6b6b; /* Slightly red on hover */
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05); /* Smaller scale effect */
}