* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

*:focus {
    outline: none;
}

:root {
    /* FIXED gap - absolutely never changes */
    --gap: 25px;
}

body {
    background: #000000;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

/* Subtle background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ========================================
   MAIN LAYOUT - Flexbox Column
   ======================================== */

.music-player {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1400px;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px clamp(15px, 5vw, 40px);
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    /* FIXED gap - never changes */
    gap: 25px;
}

/* ========================================
   HEADER SECTION - Title + Social Links
   ======================================== */

.header-section {
    flex: 0 0 auto;
    width: 100%;
    text-align: center;
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

.song-info {
    margin-bottom: 12px;
}

.song-title {
    /* Responsive size - bigger when space allows, titles are priority */
    font-size: clamp(1.8rem, 3.5vw, 2.6rem);
    font-weight: 300;
    margin-bottom: 8px;
    color: #ffffff;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.album-title {
    /* Responsive size - bigger when space allows */
    font-size: clamp(0.85rem, 1.2vw, 1.1rem);
    color: #888888;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.social-links {
    display: flex;
    gap: clamp(10px, 2vw, 16px);
    justify-content: center;
    align-items: center;
}

.social-btn {
    /* Responsive size */
    width: clamp(36px, 4vw, 48px);
    height: clamp(36px, 4vw, 48px);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.3s ease;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.social-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.social-btn.spotify:hover {
    background: #1DB954;
    border-color: #1DB954;
}

.social-btn.youtube:hover {
    background: #FF0000;
    border-color: #FF0000;
}

.social-btn svg {
    width: 50%;
    height: 50%;
}

/* ========================================
   RECORD SECTION - Fluid sizing
   ======================================== */

.record-container {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0;
    opacity: 0;
    animation: fadeInScale 1s ease 0.2s forwards;
}

.record {
    /*
     * PERFECT CIRCLE - Record is lower priority than titles
     * Fixed elements: header ~140px, controls ~160px, gaps 50px, padding 40px = 390px
     * Record fills remaining space, max 600px on large screens
     */
    --record-size: min(calc(100vh - 390px), calc(100vw - 60px), 600px);
    width: var(--record-size);
    height: var(--record-size);
    min-width: 120px;
    min-height: 120px;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    border-radius: 50%;
    background: 
        radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 70% 70%, rgba(255, 255, 255, 0.03) 0%, transparent 50%),
        #0a0a0a;
    border: 3px solid #1a1a1a;
    position: relative;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 0 60px rgba(0, 0, 0, 0.8),
        inset 0 0 60px rgba(0, 0, 0, 0.5);
    /* transition managed by JavaScript for pause return animation */
    overflow: hidden;
    cursor: pointer;
}

.record::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: repeating-conic-gradient(
        from 0deg at 50% 50%,
        transparent 0deg 0.5deg,
        rgba(255, 255, 255, 0.02) 0.5deg 1deg
    );
    opacity: 0.3;
}

/* Note: rotation is now handled via JavaScript for precise pause/return control */

.record:hover:not(.playing) {
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.08),
        0 0 80px rgba(0, 0, 0, 0.9),
        inset 0 0 60px rgba(0, 0, 0, 0.5);
}

.album-art {
    width: 65%;
    height: 65%;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    box-shadow: 
        inset 0 0 40px rgba(0, 0, 0, 0.8),
        0 0 20px rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(0, 0, 0, 0.3);
    /* transition managed by JavaScript for pause return animation */
}

/* Album art rotation is now handled via JavaScript */

.record-label {
    width: 8%;
    height: 8%;
    background: #000000;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 
        inset 0 0 10px rgba(0, 0, 0, 0.8),
        0 0 10px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.record-label::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30%;
    height: 30%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* ========================================
   CONTROLS SECTION - Fluid sizing
   ======================================== */

.controls-section {
    flex: 0 0 auto;
    width: 100%;
    max-width: min(500px, calc(100vw - 40px));
    opacity: 0;
    animation: fadeIn 0.8s ease 0.4s forwards;
}

.progress-container {
    width: 100%;
    margin-bottom: 15px;
}

.progress-bar {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 0;
    overflow: visible;
    cursor: pointer;
    transition: height 0.2s ease;
    touch-action: manipulation;
    position: relative;
}

.progress-bar::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    right: 0;
    bottom: -20px;
    pointer-events: auto;
}

.progress-bar:hover {
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    background: rgba(255, 255, 255, 0.6);
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 0;
}

.progress-bar:hover .progress-fill {
    background: rgba(255, 255, 255, 0.8);
}

.time-display {
    display: flex;
    justify-content: space-between;
    /* Fixed size */
    font-size: 0.7rem;
    color: #666666;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 15px;
}

.control-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0;
    /* Fixed size - controls are secondary priority */
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.control-btn svg {
    width: 100%;
    height: 100%;
    transition: all 0.2s ease;
}

.control-btn::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.02);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.control-btn:hover {
    color: rgba(255, 255, 255, 0.9);
}

.control-btn:hover::after {
    opacity: 1;
}

.control-btn:active {
    color: rgba(255, 255, 255, 1);
}

.play-btn {
    /* Fixed size - controls are secondary priority */
    width: 48px;
    height: 48px;
    font-size: 1.6rem;
    color: rgba(255, 255, 255, 0.85);
}

.play-btn:hover {
    color: rgba(255, 255, 255, 1);
}

.volume-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    padding: 5px 0;
    position: relative;
}

.volume-icon {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    width: 20px;
    text-align: center;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.volume-container:hover .volume-icon {
    color: rgba(255, 255, 255, 0.7);
}

.volume-slider {
    flex: 1;
    height: 44px;
    background: transparent;
    border-radius: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    padding: 0;
    box-sizing: border-box;
}

.volume-slider::-webkit-slider-runnable-track {
    -webkit-appearance: none;
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 0;
}

.volume-slider:hover::-webkit-slider-runnable-track {
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.volume-slider::-moz-range-track {
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 0;
}

.volume-slider:hover::-moz-range-track {
    height: 3px;
    background: rgba(255, 255, 255, 0.2);
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: -5px;
}

.volume-slider:hover::-webkit-slider-thumb {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.volume-slider:hover::-moz-range-thumb {
    background: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

/* ========================================
   ANIMATIONS
   ======================================== */

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

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* Volume controls always visible - record shrinks to accommodate */

/* ========================================
   LANDSCAPE ORIENTATION - Different layout
   ======================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .music-player {
        flex-direction: row;
        padding: max(10px, env(safe-area-inset-top)) 20px max(10px, env(safe-area-inset-bottom));
        gap: 25px;
    }

    .header-section {
        flex: 0 0 auto;
        width: auto;
        max-width: 30%;
        text-align: left;
    }

    .song-info {
        margin-bottom: 12px;
    }

    .song-title {
        font-size: clamp(1rem, 3vh, 1.4rem);
    }

    .album-title {
        font-size: clamp(0.6rem, 1.5vh, 0.8rem);
    }

    .social-links {
        justify-content: flex-start;
        gap: 8px;
    }

    .social-btn {
        width: 28px;
        height: 28px;
    }

    .record-container {
        flex: 0 0 auto;
    }
    
    .record {
        --record-size: min(calc(100vh - 40px), 30vw, 240px);
        width: var(--record-size);
        height: var(--record-size);
    }

    .controls-section {
        flex: 1 1 auto;
        max-width: 350px;
    }

    .progress-container {
        margin-bottom: 8px;
    }

    .controls {
        gap: 20px;
        margin-bottom: 8px;
    }

    .control-btn {
        width: 28px;
        height: 28px;
    }

    .play-btn {
        width: 40px;
        height: 40px;
    }

}

/* ========================================
   LOADING STATE
   ======================================== */

.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ========================================
   MODAL STYLES
   ======================================== */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(10px);
}

.modal-content {
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    animation: modalFadeIn 0.3s ease;
    position: relative;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 1);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    padding: 20px 24px 16px;
    margin: 0;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Playlist Tree - Hierarchical List */
.playlist-tree {
    padding: 0 16px 16px;
    overflow-y: auto;
    flex: 1;
}

.playlist-node {
    margin-bottom: 4px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
    transition: background 0.2s ease;
}

.playlist-node.active {
    background: rgba(255, 255, 255, 0.05);
}

.playlist-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.playlist-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.playlist-art {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.playlist-info {
    flex: 1;
    min-width: 0;
}

.playlist-name {
    font-size: 0.95rem;
    color: #ffffff;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playlist-node.active .playlist-name {
    color: #ffffff;
}

.playlist-count {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.expand-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.3);
    transition: transform 0.25s ease, color 0.2s ease;
    flex-shrink: 0;
}

.playlist-node.expanded .expand-icon {
    transform: rotate(180deg);
    color: rgba(255, 255, 255, 0.6);
}

.playlist-header:hover .expand-icon {
    color: rgba(255, 255, 255, 0.6);
}

/* Songs List - Nested */
.songs-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
}

.playlist-node.expanded .songs-list {
    max-height: 500px;
}

.song-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px 10px 76px;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

.song-item:first-child {
    padding-top: 12px;
}

.song-item:last-child {
    padding-bottom: 12px;
}

.song-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.song-item.active {
    background: rgba(255, 255, 255, 0.08);
}

.song-number {
    width: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.song-item.active .song-number {
    color: rgba(255, 255, 255, 0.6);
}

.song-details {
    flex: 1;
    min-width: 0;
}

.song-name {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-item.active .song-name {
    color: #ffffff;
    font-weight: 500;
}

/* Now Playing Indicator - Animated Bars */
.now-playing-indicator {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
    margin-left: auto;
    flex-shrink: 0;
}

.now-playing-indicator span {
    width: 3px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
    animation: soundBars 0.8s ease-in-out infinite;
}

.now-playing-indicator span:nth-child(1) {
    height: 60%;
    animation-delay: 0s;
}

.now-playing-indicator span:nth-child(2) {
    height: 100%;
    animation-delay: 0.2s;
}

.now-playing-indicator span:nth-child(3) {
    height: 40%;
    animation-delay: 0.4s;
}

@keyframes soundBars {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
    }

.empty-message {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    padding: 60px 20px;
    font-size: 0.9rem;
    }

/* Hide volume on touch devices (uses hardware volume buttons instead) */
@media (pointer: coarse) {
    .volume-container {
        display: none !important;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .modal-content {
        max-width: calc(100% - 32px);
        max-height: 80vh;
        border-radius: 16px;
        margin: auto;
    }

    .modal-title {
        font-size: 0.9rem;
        padding: 16px 20px 12px;
    }

    .modal-close {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }

    .playlist-tree {
        padding: 0 12px 12px;
    }

    .playlist-header {
        padding: 10px 12px;
        gap: 12px;
    }

    .playlist-art {
        width: 44px;
        height: 44px;
    }

    .playlist-name {
        font-size: 0.9rem;
    }

    .playlist-count {
        font-size: 0.7rem;
    }

    .song-item {
        padding: 8px 12px 8px 68px;
        gap: 10px;
    }

    .song-name {
        font-size: 0.85rem;
    }

    .song-number {
        font-size: 0.75rem;
    }
}
