:root {
    --bg-color: #121212;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-main: #FFFFFF;
    --text-sec: #B3B3B3;
    --primary: #1DB954;
    --primary-hover: #1ed760;
    --font-family: 'Inter', sans-serif;
    --spacing: 1rem;
    --radius: 12px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 500px;
    padding: var(--spacing);
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

h1,
h2,
h3 {
    margin-bottom: 1rem;
    font-weight: 700;
}

p {
    color: var(--text-sec);
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-sec);
    margin-bottom: 0.5rem;
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    border-radius: 4px;
    border: 1px solid #333;
    background: #2a2a2a;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--primary);
}

small {
    color: var(--text-sec);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: block;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.btn {
    width: 100%;
    padding: 0.875rem;
    border: none;
    border-radius: 500px;
    /* Pillow shape common in Spotify UI */
    font-weight: 700;
    cursor: pointer;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: transform 0.1s, background-color 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background-color: var(--primary);
    color: black;
}

.btn.primary:hover {
    background-color: var(--primary-hover);
}

.btn.secondary {
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    margin-bottom: var(--spacing);
}

.btn.secondary:hover {
    border-color: white;
}

.hidden {
    display: none !important;
}

/* Player Specifics */
.player-card {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.player-wrapper {
    position: relative;
    width: 100%;
}

#player-embed {
    width: 100%;
    height: 352px;
    /* Match previous iframe height */
    background: #000;
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#player-embed img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.controls {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Cover the player area (mostly) or sit below */
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    z-index: 10;
    animation: fadeIn 0.3s ease;
    padding: 1rem;
    text-align: center;
}

.info-card.hidden {
    display: none;
}

#track-art {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

#track-name {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

#track-artist {
    font-size: 1rem;
    color: var(--text-sec);
    font-weight: 400;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.blurred {
    filter: blur(20px) brightness(0.8);
    transition: filter 0.5s ease;
}

.blurred:hover {
    filter: blur(15px) brightness(0.9);
    /* Slightly clearer on hover to help find play button */
}

/* Playlist Selection UI */
.playlist-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    max-height: 200px;
    overflow-y: auto;
    justify-content: center;
}

.playlist-item {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    color: white;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 100%;
}

.playlist-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-sec);
    font-size: 0.75rem;
    margin-bottom: 1rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.divider span {
    padding: 0 10px;
}

/* Playback Controls */
.btn-control {
    background: transparent;
    border: none;
    color: #b3b3b3;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.1s;
}

.btn-control:hover {
    color: #ffffff;
}

.btn-control:active {
    transform: scale(0.95);
}

.btn-play {
    background-color: #ffffff;
    color: #000000;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    transition: transform 0.1s, background-color 0.2s;
}

.btn-play:hover {
    background-color: #f2f2f2;
    transform: scale(1.05);
    color: #000000;
    /* Ensure icon stays black */
}

.btn-play:active {
    transform: scale(0.95);
    background-color: #e6e6e6;
}

.btn-control svg {
    fill: currentColor;
}

/* Audio Visualizer */
#visualizer-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 64px;
    width: 100%;
    margin-top: -80px;
    /* Overlap placeholder area */
    margin-bottom: 2rem;
    gap: 4px;
    pointer-events: none;
    z-index: 5;
}

#visualizer-container.hidden {
    display: none;
}

.bar {
    width: 6px;
    background: #1DB954;
    /* Spotify Green */
    border-radius: 4px;
    animation: bounce 1s infinite ease-in-out;
}

/* Randomize animation delays for organic feel */
.bar:nth-child(1) {
    height: 20%;
    animation-duration: 0.8s;
    animation-delay: 0.1s;
}

.bar:nth-child(2) {
    height: 40%;
    animation-duration: 1.0s;
    animation-delay: 0.3s;
}

.bar:nth-child(3) {
    height: 60%;
    animation-duration: 0.7s;
    animation-delay: 0.0s;
}

.bar:nth-child(4) {
    height: 80%;
    animation-duration: 1.1s;
    animation-delay: 0.2s;
}

.bar:nth-child(5) {
    height: 50%;
    animation-duration: 0.9s;
    animation-delay: 0.4s;
}

.bar:nth-child(6) {
    height: 90%;
    animation-duration: 1.2s;
    animation-delay: 0.1s;
}

.bar:nth-child(7) {
    height: 30%;
    animation-duration: 0.8s;
    animation-delay: 0.5s;
}

.bar:nth-child(8) {
    height: 70%;
    animation-duration: 1.3s;
    animation-delay: 0.3s;
}

@keyframes bounce {

    0%,
    100% {
        height: 10%;
        opacity: 0.5;
    }

    50% {
        height: 100%;
        opacity: 1;
    }
}