.artist-item.rendered {
    opacity: 1 !important;
    transform: translateX(0) !important;
}

/* Enhanced Flashy Spotify App CSS - CORRECTED FOR VISIBILITY (Black & White H1) */

:root {
    --primary-color: #1DB954; /* Spotify Green */
    --primary-dark: #1ed760;
    --secondary-color: #191414; /* Dark background elements */
    --accent-color: #FF6B35; /* Vibrant Orange/Coral for accent */
    --accent-light: #FFB366;
    --background-dark: #121212; /* Very dark overall background */
    --surface-color: #1a1a1a; /* Slightly lighter dark for cards/surfaces */
    --text-primary: #ffffff; /* Main white text */
    --text-secondary: #b3b3b3; /* Secondary grey text */
    --text-muted: #6a6a6a; /* Muted grey text */

    /* ***** NEW / ADJUSTED COLORS FOR BETTER CONTRAST & VISIBILITY ***** */
    /* H1 Black & White Scheme */
    --h1-text-color: #FFFFFF; /* Pure white for H1 text */
    --h1-shadow-color: rgba(0, 0, 0, 0.9); /* Strong black shadow for H1 */

    /* Artist Item Visibility Enhancements */
    --artist-item-bg-initial: rgba(26, 26, 26, 0.95); /* Even less transparent for better base contrast */
    --artist-item-text: #E8E8E8; /* Very light grey for non-hovered artist names */
    --artist-item-info-text: #B0B0B0; /* Slightly darker grey for non-hovered info text */
    --artist-item-hover-bg: linear-gradient(135deg, rgba(29, 185, 84, 0.5) 0%, rgba(30, 30, 30, 0.98) 100%); /* Stronger green presence on hover */
    --artist-item-hover-text: #FFFFFF; /* Ensures text is pure white on hover */

    --searched-artist-bg: linear-gradient(135deg, rgba(60, 60, 60, 0.98) 0%, rgba(40, 40, 40, 0.98) 100%); /* Clearly distinct search result background */
    --search-input-focus-shadow-color: rgba(29, 185, 84, 0.8); /* Stronger shadow on search input focus */


    --gradient-primary: linear-gradient(135deg, #1DB954 0%, #1ed760 100%);
    --gradient-accent: linear-gradient(135deg, #FF6B35 0%, #FFB366 100%);
    --gradient-dark: linear-gradient(135deg, #191414 0%, #000000 100%);
    --shadow-glow: 0 0 30px rgba(29, 185, 84, 0.3);
    --shadow-accent: 0 0 20px rgba(255, 107, 53, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: var(--background-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(29, 185, 84, 0.25) 0%, transparent 60%),
        radial-gradient(circle at 80% 20%, rgba(255, 107, 53, 0.25) 0%, transparent 60%),
        radial-gradient(circle at 40% 40%, rgba(29, 185, 84, 0.15) 0%, transparent 70%);
    z-index: -2;
    animation: backgroundShift 20s ease-in-out infinite alternate;
}

@keyframes backgroundShift {
    0% { transform: translateX(-20px) translateY(-10px); }
    100% { transform: translateX(20px) translateY(10px); }
}

/* Floating Particles */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(29, 185, 84, 0.6), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 107, 53, 0.6), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(29, 185, 84, 0.7), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255, 107, 53, 0.7), transparent);
    background-repeat: repeat;
    background-size: 150px 100px;
    z-index: -1;
    animation: floatingParticles 30s linear infinite;
}

@keyframes floatingParticles {
    0% { transform: translateY(0px) rotate(0deg); }
    100% { transform: translateY(-100px) rotate(360deg); }
}

.container {
    background: rgba(26, 26, 26, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(29, 185, 84, 0.2);
    margin: 20px auto;
    padding: 40px;
    border-radius: 24px;
    max-width: 900px;
    box-shadow: 
        var(--shadow-glow),
        0 20px 40px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    animation: containerFloat 6s ease-in-out infinite alternate;
}

@keyframes containerFloat {
    0% { transform: translateY(0px) rotateX(0deg); }
    100% { transform: translateY(-10px) rotateX(1deg); }
}

/* Glowing border animation */
.container::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: var(--gradient-primary);
    border-radius: 26px;
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite alternate;
    opacity: 0.8;
}

@keyframes borderGlow {
    0% { opacity: 0.7; filter: blur(1px); }
    100% { opacity: 1; filter: blur(0px); }
}

h1 {
    /* ***** H1: PURE BLACK TEXT WITH WHITE SHADOW FOR MAX CONTRAST ***** */
    color: var(--h1-text-color); /* Set text to pure white initially */
    /* Remove background-clip text for H1 to show solid color */
    background: none; /* Ensure no text-fill-color from previous gradient */
    -webkit-text-fill-color: initial; /* Reset to default text fill */
    
    font-size: 3.5em;
    font-weight: 900;
    text-align: center;
    margin-bottom: 30px;
    /* Strong white shadow, black background for the H1 text */
    text-shadow: 
        -2px -2px 0 var(--h1-shadow-color),  /* Top-left black border */
        2px -2px 0 var(--h1-shadow-color),   /* Top-right black border */
        -2px 2px 0 var(--h1-shadow-color),    /* Bottom-left black border */
        2px 2px 0 var(--h1-shadow-color),     /* Bottom-right black border */
        0 0 10px rgba(255, 255, 255, 0.7); /* Subtle white glow */
    animation: titlePulse 4s ease-in-out infinite alternate;
    position: relative;
}

/* Adjust titlePulse animation for new H1 style */
@keyframes titlePulse {
    0% { 
        transform: scale(1) rotateY(0deg); 
        text-shadow: 
            -2px -2px 0 var(--h1-shadow-color), 2px -2px 0 var(--h1-shadow-color), 
            -2px 2px 0 var(--h1-shadow-color), 2px 2px 0 var(--h1-shadow-color), 
            0 0 10px rgba(255, 255, 255, 0.7); 
    }
    100% { 
        transform: scale(1.05) rotateY(2deg); 
        text-shadow: 
            -3px -3px 0 var(--h1-shadow-color), 3px -3px 0 var(--h1-shadow-color), 
            -3px 3px 0 var(--h1-shadow-color), 3px 3px 0 var(--h1-shadow-color), 
            0 0 15px rgba(255, 255, 255, 1); /* Brighter glow on pulse */
    }
}

/* Enhanced Search Section */
.search-section {
    background: var(--gradient-dark);
    border: 2px solid rgba(29, 185, 84, 0.3);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    animation: searchSectionFloat 8s ease-in-out infinite alternate;
}

@keyframes searchSectionFloat {
    0% { transform: translateX(-5px) rotateZ(-0.5deg); }
    100% { transform: translateX(5px) rotateZ(0.5deg); }
}

.search-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(29, 185, 84, 0.25), transparent);
    animation: searchSweep 3s infinite;
}

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

.search-section input[type="text"] {
    flex-grow: 1;
    padding: 15px 25px;
    border: 2px solid rgba(29, 185, 84, 0.3);
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 1.1em;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
}

.search-section input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 
        0 0 30px var(--search-input-focus-shadow-color), 
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.15);
}

.search-section button {
    padding: 15px 30px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 20px rgba(29, 185, 84, 0.3);
    position: relative;
    overflow: hidden;
}

.search-section button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.search-section button:hover::before {
    left: 100%;
}

.search-section button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 30px rgba(29, 185, 84, 0.5);
}

.search-section button:active {
    transform: translateY(-1px) scale(1.02);
}

/* Enhanced Artist Items */
.artist-item {
    display: flex;
    align-items: center;
    /* ***** ADJUSTED INITIAL BACKGROUND & TEXT COLOR FOR BETTER VISIBILITY ***** */
    background: var(--artist-item-bg-initial); /* Base background is very dark, less transparent */
    border: 1px solid rgba(29, 185, 84, 0.2);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    backdrop-filter: blur(10px);
    
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                box-shadow 0.4s ease-in-out, 
                border-color 0.4s ease-in-out,
                background 0.4s ease-in-out; 
    
    position: relative;
    overflow: hidden;
    opacity: 0; 
    transform: translateX(-50px);
}

@keyframes artistSlideIn {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.artist-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.artist-item:hover {
    transform: translateY(-8px) scale(1.02) rotateY(2deg); 
    box-shadow: 
        0 20px 40px rgba(29, 185, 84, 0.3),
        0 0 30px rgba(255, 107, 53, 0.2);
    border-color: var(--primary-color);
    /* ***** MORE PRONOUNCED HOVER BACKGROUND ***** */
    background: var(--artist-item-hover-bg); 
}

.artist-item:hover::before {
    opacity: 0.1;
}

.rank-number {
    font-size: 1.8em;
    font-weight: 900;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 60px;
    text-align: center;
    margin-right: 20px;
    animation: rankPulse 2s ease-in-out infinite alternate;
}

@keyframes rankPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.1); }
}

.artist-image {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 20px;
    border: 3px solid rgba(29, 185, 84, 0.5);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                border-color 0.4s ease,
                box-shadow 0.4s ease;
    box-shadow: 0 0 20px rgba(29, 185, 84, 0.3);
}

.artist-item:hover .artist-image {
    transform: scale(1.1) rotate(5deg);
    border-color: var(--accent-color);
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
}

.artist-info {
    flex-grow: 1;
    text-align: left;
}

.artist-name {
    font-size: 1.4em;
    font-weight: 700;
    /* ***** ENSURING INITIAL TEXT IS VERY LIGHT FOR VISIBILITY ***** */
    color: var(--artist-item-text); 
    margin-bottom: 8px;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.artist-item:hover .artist-name {
    /* ***** ENSURING HOVER TEXT IS PURE WHITE FOR MAXIMUM CONTRAST ***** */
    color: var(--artist-item-hover-text); 
    text-shadow: 0 0 10px rgba(29, 185, 84, 0.5);
}

.artist-info p {
    /* ***** INFO TEXT IS SLIGHTLY DARKER GREY FOR SUBTLE HIERARCHY ***** */
    color: var(--artist-item-info-text); 
    margin: 5px 0;
    font-size: 0.95em;
    transition: color 0.3s ease, transform 0.3s ease;
}

.artist-item:hover .artist-info p {
    /* ***** Making paragraph text clearly white on hover ***** */
    color: var(--text-primary); 
    transform: translateX(5px);
}

/* Loading Animation */
.loading-message {
    text-align: center;
    font-size: 1.3em;
    color: var(--text-secondary);
    animation: loadingPulse 1.5s ease-in-out infinite alternate;
}

@keyframes loadingPulse {
    0% { opacity: 0.6; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.05); }
}

.spinner {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    border: 3px solid rgba(29, 185, 84, 0.3);
    border-radius: 50%;
    border-top-color: var(--text-primary);
    animation: spin 1s linear infinite;
    margin-left: 10px;
    box-shadow: 0 0 15px rgba(29, 185, 84, 0.3);
}

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

/* Enhanced Search Results */
.search-results-display {
    width: 100%;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid rgba(29, 185, 84, 0.3);
    position: relative;
}

.searched-artist {
    /* Use the new searched artist background variable */
    background: var(--searched-artist-bg);
    border: 2px solid rgba(255, 107, 53, 0.4);
    border-radius: 20px;
    padding: 25px;
    box-shadow: var(--shadow-accent);
    animation: searchResultSlide 0.5s ease-out;
    backdrop-filter: blur(15px);
}

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

.searched-artist .artist-image {
    width: 100px;
    height: 100px;
    border-color: var(--accent-color);
    box-shadow: 0 0 25px rgba(255, 107, 53, 0.4);
}

.searched-artist .artist-info h3 {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.6em;
}

.rank-badge {
    background: var(--gradient-primary) !important;
    color: white !important;
    padding: 8px 16px !important;
    border-radius: 25px !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 15px rgba(29, 185, 84, 0.4) !important;
    animation: badgePulse 2s ease-in-out infinite alternate !important;
}

@keyframes badgePulse {
    0% { transform: scale(1); box-shadow: 0 4px 15px rgba(29, 185, 84, 0.4); }
    100% { transform: scale(1.05); box-shadow: 6px 20px rgba(29, 185, 84, 0.6); }
}

.not-ranked {
    background: linear-gradient(135deg, #666 0%, #999 100%) !important;
    color: white !important;
    padding: 8px 16px !important;
    border-radius: 25px !important;
    font-weight: 700 !important;
}

/* Highlight Effect */
.highlight-searched {
    border: 3px solid var(--accent-color) !important;
    box-shadow: 
        0 0 30px rgba(255, 107, 53, 0.6),
        0 20px 40px rgba(255, 107, 53, 0.3) !important;
    transform: scale(1.03) !important;
    animation: highlightPulse 2s ease-in-out infinite alternate !important;
}

@keyframes highlightPulse {
    0% { 
        box-shadow: 
            0 0 30px rgba(255, 107, 53, 0.6),
            0 20px 40px rgba(255, 107, 53, 0.3);
    }
    100% { 
        box-shadow: 
            0 0 40px rgba(255, 107, 53, 0.8),
            0 25px 50px rgba(255, 107, 53, 0.4);
    }
}

/* Error Messages */
.error-message {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.3) 0%, rgba(220, 53, 69, 0.2) 100%);
    border: 2px solid rgba(220, 53, 69, 0.7);
    color: #ff8888;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    font-weight: 600;
    animation: errorShake 0.5s ease-in-out;
    backdrop-filter: blur(10px);
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 20px;
        border-radius: 16px;
    }
    
    h1 {
        font-size: 2.5em;
    }
    
    .search-section {
        flex-direction: column;
        gap: 15px;
    }
    
    .artist-item {
        padding: 15px;
    }
    
    .artist-image {
        width: 60px;
        height: 60px;
    }
    
    .rank-number {
        font-size: 1.4em;
        min-width: 40px;
        margin-right: 15px;
    }
}

/* Scroll animations */
@media (prefers-reduced-motion: no-preference) {
    .artist-item {
        /* This applies the staggered animation delay for the initial fade-in/slide-in */
        /* The '--animation-order' CSS variable is set by JavaScript */
        animation-delay: calc(var(--animation-order, 0) * 0.1s);
        animation-fill-mode: forwards; /* Ensures the animation stays at its 'to' state */
    }
}