:root {
    --primary-bg: #1a1a2e;
    --accent-color: #0f3460;
    --highlight-color: #e94560;
    --text-color: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.02);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background: linear-gradient(rgba(26, 26, 46, 0.5), rgba(26, 26, 46, 0.5)), url('background.jpg') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-color);
    min-height: 100vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 10px;
}

body.pwa-mode {
    min-height: 100dvh;
    padding: calc(12px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px));
}

body.pwa-mode .main-header {
    margin-bottom: 10px;
}

body.pwa-mode .main-header h1 {
    font-size: clamp(1.6rem, 6vw, 2.35rem);
}

body.pwa-mode .app-container.radio-only {
    width: min(100%, 520px);
}

body.pwa-mode .player-cardglass {
    border-radius: 16px;
}

.main-header {
    width: 100%;
    text-align: center;
    padding: 10px 0;
    z-index: 10;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.main-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #e94560, #a3f7bf);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
    letter-spacing: 2px;
}

/* Background Animation */
.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.3;
    mix-blend-mode: screen;
}

.blob-1 {
    top: 10%;
    left: 10%;
    width: 300px;
    height: 300px;
    background: #ff007f;
    animation: drift-1 15s infinite alternate ease-in-out, neon-1 10s infinite alternate;
}

.blob-2 {
    bottom: 20%;
    right: 10%;
    width: 400px;
    height: 400px;
    background: #00f0ff;
    animation: drift-2 18s infinite alternate-reverse ease-in-out, neon-2 12s infinite alternate;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 250px;
    height: 250px;
    background: #7000ff;
    animation: drift-3 20s infinite alternate ease-in-out, neon-3 15s infinite alternate;
}

@keyframes drift-1 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30vw, 20vh) scale(1.2);
    }
}

@keyframes drift-2 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(-40vw, -10vh) scale(1.1);
    }
}

@keyframes drift-3 {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(20vw, -30vh) scale(1.3);
    }
}

@keyframes neon-1 {
    0% {
        background: #ff007f;
    }

    50% {
        background: #00f0ff;
    }

    100% {
        background: #7000ff;
    }
}

@keyframes neon-2 {
    0% {
        background: #00f0ff;
    }

    50% {
        background: #7000ff;
    }

    100% {
        background: #ffea00;
    }
}

@keyframes neon-3 {
    0% {
        background: #7000ff;
    }

    50% {
        background: #ffea00;
    }

    100% {
        background: #ff007f;
    }
}

/* App Container */
.app-container {
    display: flex;
    gap: 30px;
    width: 100%;
    max-width: 1000px;
    flex: 0 0 auto;
    z-index: 1;
    padding-bottom: 10px;
}

.app-container.radio-only {
    max-width: 560px;
}

.app-container.radio-only .player-cardglass {
    min-height: 0;
    padding: 28px;
}

.app-container.radio-only .album-art-container {
    width: min(320px, 78vw);
    height: min(320px, 78vw);
    margin-bottom: 24px;
}

.app-container.radio-only #track-details {
    font-size: 1.55rem;
}

.app-container.radio-only .external-players {
    margin-top: 4px;
}

[hidden] {
    display: none !important;
}

/* Glassmorphism Cards */
.player-cardglass,
.playlist-cardglass {
    flex: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.playlist-cardglass {
    justify-content: flex-start;
}

.player-cardglass:hover {
    transform: translateY(-5px);
}

/* Player Specifics */
.now-playing {
    width: 100%;
    text-align: center;
}

.album-art-container {
    width: 280px;
    height: 280px;
    margin: 0 auto 20px;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

#album-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.about-project-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    margin: 0 auto 16px;
    padding: 0 18px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
}

.about-project-btn:hover {
    transform: translateY(-1px);
    background: rgba(233, 69, 96, 0.22);
    border-color: rgba(233, 69, 96, 0.55);
}

#sonic_art_full {
    display: none;
    width: 100%;
    height: 100%;
    background: #1a1a1a url('https://via.placeholder.com/300/1a1a1a/555555?text=Radio') center / cover no-repeat;
}

#sonic_art_full img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-art-container.radio-art #album-art {
    display: none;
}

.album-art-container.radio-art #sonic_art_full {
    display: block;
}

/* .vinyl-overlay { } Removed empty rule */

#track-details {
    font-size: 1.4rem;
    margin-bottom: 5px;
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    font-weight: 600;
}

.track-title-wrap {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 calc(100% - 2px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 calc(100% - 2px), transparent 100%);
}

.track-title {
    display: inline-flex;
    flex-wrap: nowrap;
    min-width: max-content;
    white-space: nowrap;
    will-change: transform;
}

#track-year {
    color: var(--highlight-color);
    font-size: 0.9rem;
    margin-bottom: 20px;
    font-weight: 300;
    letter-spacing: 1px;
}

.radio-description {
    width: 100%;
    max-width: 420px;
    margin: 10px auto 20px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 300;
    white-space: pre-line;
}

/* Progress Bar */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
    font-size: 0.8rem;
    color: #ddd;
}

.progress-bar {
    flex-grow: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: var(--highlight-color);
    width: 0%;
    border-radius: 3px;
    transition: width 0.1s linear;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.control-btn {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
}

.control-btn:hover {
    color: var(--highlight-color);
    transform: scale(1.1);
}

.control-btn.lg {
    font-size: 3rem;
    filter: drop-shadow(0 0 5px rgba(233, 69, 96, 0.5));
}

.control-btn.sm {
    font-size: 1.5rem;
    opacity: 0.8;
}

.control-btn:disabled {
    cursor: default;
    opacity: 0.35;
}

.control-btn:disabled:hover {
    color: #fff;
    transform: none;
}

.radio-btn {
    width: 100%;
    min-height: 44px;
    margin: 0 0 18px;
    border: 1px solid rgba(233, 69, 96, 0.5);
    border-radius: 8px;
    background: rgba(233, 69, 96, 0.14);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.radio-btn:hover,
.radio-btn.active {
    background: rgba(233, 69, 96, 0.28);
    border-color: var(--highlight-color);
    transform: translateY(-1px);
}

.external-players {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
}

.external-players a {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.2s, background 0.2s, border-color 0.2s;
}

.external-players a:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(233, 69, 96, 0.45);
}

.external-players img {
    display: block;
    max-width: 24px;
    max-height: 24px;
}

.progress-container.live-stream .progress-bar {
    cursor: default;
    overflow: hidden;
}

.progress-container.live-stream .progress-fill {
    width: 100%;
    animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse {
    0%,
    100% {
        opacity: 0.35;
    }

    50% {
        opacity: 1;
    }
}

/* Playlist */
.playlist-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 10px;
    flex-shrink: 0;
}

.add-btn {
    background: var(--highlight-color);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.add-btn:hover {
    background: #ff6b81;
}

#playlist {
    list-style: none;
    width: 100%;
    flex: 0 0 auto;
    overflow: visible;
    min-height: auto;
    padding-right: 5px;
}

/* Scrollbar Style */
#playlist::-webkit-scrollbar {
    width: 5px;
}

#playlist::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

.playlist-item {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    transition: background 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.playlist-item:hover,
.playlist-item.active {
    background: rgba(233, 69, 96, 0.2);
    border-left: 4px solid var(--highlight-color);
}

.playlist-title-wrap {
    display: block;
    flex: 1 1 auto;
    width: 0;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 calc(100% - 2px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 18px, #000 calc(100% - 2px), transparent 100%);
}

.playlist-title {
    display: inline-flex;
    flex-wrap: nowrap;
    font-size: 0.9rem;
    white-space: nowrap;
    will-change: transform;
}

.playlist-title.is-overflowing {
    animation: playlist-marquee var(--marquee-duration, 10s) linear infinite;
}

.track-title.is-overflowing {
    animation: playlist-marquee var(--marquee-duration, 10s) linear infinite;
}

.marquee-segment {
    flex: 0 0 auto;
    white-space: nowrap;
}

.is-overflowing .marquee-segment {
    padding-right: var(--marquee-gap, 32px);
}

@keyframes playlist-marquee {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(calc(var(--marquee-distance, 0px) * -1));
    }
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content.glass-modal {
    background: rgba(26, 26, 46, 0.95);
    padding: 40px;
    border-radius: 20px;
    width: 400px;
    text-align: center;
    border: 1px solid var(--glass-border);
    position: relative;
    box-shadow: 0 0 50px rgba(233, 69, 96, 0.2);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: #fff;
}

.glass-input {
    width: 100%;
    padding: 12px;
    margin: 15px 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
}

.file-upload-wrapper {
    margin: 20px 0;
    border: 2px dashed var(--glass-border);
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: border-color 0.3s;
}

.file-upload-wrapper:hover {
    border-color: var(--highlight-color);
}

.glass-btn {
    background: var(--highlight-color);
    border: none;
    padding: 12px 30px;
    color: white;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.glass-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 10px;
        -webkit-overflow-scrolling: touch;
    }

    .main-header {
        padding: 5px 0;
        margin-bottom: 5px;
    }

    .main-header h1 {
        font-size: 1.5rem;
    }

    .app-container {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 0;
        flex: 0 0 auto;
        min-height: 0;
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }

    .app-container.radio-only {
        max-width: 100%;
    }

    .player-cardglass {
        flex: 0 0 auto;
        padding: 15px;
        width: 100%;
    }

    .playlist-cardglass {
        flex: 1;
        padding: 15px;
        width: 100%;
        min-height: 0;
    }

    .now-playing {
        display: grid;
        grid-template-columns: 100px 1fr;
        grid-template-areas:
            "about about"
            "album info"
            "album progress"
            "album controls";
        gap: 5px 15px;
        align-items: center;
    }

    .album-art-container {
        grid-area: album;
        width: 100px;
        height: 100px;
        margin: 0;
    }

    .about-project-btn {
        grid-area: about;
        margin-bottom: 4px;
        justify-self: center;
    }

    .app-container.radio-only .album-art-container {
        width: 120px;
        height: 120px;
        margin: 0;
    }

    .track-info {
        grid-area: info;
        text-align: left;
        min-width: 0;
    }

    .radio-description {
        max-width: none;
        margin: 6px 0 0;
        font-size: 0.85rem;
        line-height: 1.35;
    }

    #track-details {
        font-size: 1.1rem;
        margin-bottom: 2px;
    }

    #track-year {
        font-size: 0.8rem;
        margin-bottom: 0;
    }

    .progress-container {
        grid-area: progress;
        margin-bottom: 0;
        width: 100%;
    }

    .controls {
        grid-area: controls;
        justify-content: flex-start;
        margin-bottom: 0;
        gap: 15px;
    }

    .radio-btn {
        grid-column: 1 / -1;
        margin: 5px 0 0;
        min-height: 40px;
    }

    .external-players {
        grid-column: 1 / -1;
    }

    .external-players {
        margin: 5px 0 0;
    }

    .app-container.radio-only .player-cardglass {
        padding: 18px 16px;
    }

    .app-container.radio-only .now-playing {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
        text-align: center;
    }

    .app-container.radio-only .about-project-btn {
        margin: 0 auto 14px;
    }

    .app-container.radio-only .album-art-container {
        width: min(260px, 76vw);
        height: min(260px, 76vw);
        margin: 0 auto 18px;
    }

    .app-container.radio-only .track-info {
        width: 100%;
        text-align: center;
    }

    .app-container.radio-only #track-details {
        font-size: 1.25rem;
        margin-bottom: 4px;
    }

    .app-container.radio-only .progress-container {
        width: 100%;
        margin: 8px 0 18px;
    }

    .app-container.radio-only .controls {
        justify-content: center;
        margin-bottom: 16px;
        gap: 22px;
    }

    .app-container.radio-only .external-players {
        width: 100%;
        margin: 4px 0 0;
        gap: 10px;
    }

    .app-container.radio-only .radio-description {
        text-align: center;
        margin: 14px auto 0;
        padding-bottom: 4px;
    }

    body.pwa-mode {
        background-attachment: scroll;
    }

    body.pwa-mode .player-cardglass {
        background: rgba(255, 255, 255, 0.07);
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow: 0 18px 45px rgba(0, 0, 0, 0.38);
    }

    body.pwa-mode .external-players a {
        background: rgba(255, 255, 255, 0.12);
    }

    .control-btn.lg {
        font-size: 2rem;
    }

    .control-btn.sm {
        font-size: 1.2rem;
    }

    .volume-container {
        display: none;
    }

    .playlist-header {
        margin-bottom: 10px;
        padding-bottom: 5px;
    }

    .playlist-header h3 {
        font-size: 1.1rem;
    }

    .add-btn {
        width: 30px;
        height: 30px;
    }

    .playlist-item {
        padding: 8px 10px;
        margin-bottom: 5px;
    }

    #playlist {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 480px) {
    .now-playing {
        grid-template-columns: 80px 1fr;
        gap: 5px 10px;
    }

    .album-art-container {
        width: 80px;
        height: 80px;
    }

    .app-container.radio-only .album-art-container {
        width: min(230px, 74vw);
        height: min(230px, 74vw);
    }

    .control-btn.lg {
        font-size: 1.8rem;
    }

    .control-btn.sm {
        font-size: 1rem;
    }

    #track-details {
        font-size: 1rem;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .app-container {
        gap: 15px;
    }

    .album-art-container {
        width: 100px;
        height: 100px;
        margin-bottom: 10px;
    }

    .player-cardglass,
    .playlist-cardglass {
        padding: 10px 15px;
    }

    .main-header {
        margin-bottom: 5px;
        padding: 0;
    }

    .main-header h1 {
        font-size: 1.5rem;
    }

    .volume-container {
        display: none;
    }

    #track-year {
        margin-bottom: 5px;
    }

    .progress-container {
        margin-bottom: 10px;
    }

    .controls {
        margin-bottom: 5px;
    }
}
