body {
    background-color: #000;
    color: #d1d1d1;
    font-family: 'Geist Mono', monospace;
    margin: 0;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    overflow: hidden;
    user-select: none;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(to bottom,
            transparent 0px,
            transparent 2px,
            rgba(0, 0, 0, 0.08) 2px,
            rgba(0, 0, 0, 0.08) 4px);
    pointer-events: none;
    z-index: 9999;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.55) 100%);
    pointer-events: none;
    z-index: 9998;
}

body.page-loaded #main-ui {
    opacity: 1;
    transform: translateY(0);
}

#main-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 40px;
    box-sizing: border-box;
    transition:
        filter 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.5s ease,
        transform 0.5s ease;
    opacity: 0;
    transform: translateY(8px);
    z-index: 10;
}

/* Player Frame Styles */
.player-container {
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 24px;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    width: 720px;
    max-width: 100%;
    box-sizing: border-box;
}

.player-legend {
    font-family: 'Geist Mono', monospace;
    font-size: 12px;
    color: #888;
    padding: 0 10px;
    letter-spacing: 0.05em;
}

.player-layout {
    display: flex;
    gap: 30px;
    align-items: center;
}

/* Left Column: Cover & Details */
.player-left {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding-right: 20px;
}

.player-header-row {
    display: flex;
    gap: 16px;
    align-items: center;
}

.album-art-wrapper {
    width: 78px;
    height: 78px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #111;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.album-art-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.track-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0; /* truncate text if too long */
}

.track-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.track-artist {
    margin: 0;
    font-size: 12px;
    color: #888888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: 'Geist Mono', monospace;
}

.progress-bar {
    color: #666;
    letter-spacing: -0.05em;
    font-size: 14px;
    user-select: none;
    white-space: nowrap;
}

.progress-meta {
    display: flex;
    align-items: center;
    color: #555555;
    font-size: 11px;
}

.meta-separator {
    margin: 0 8px;
    color: #333333;
}

#time-display {
    color: #888888;
}

/* Right Column: Lyrics Scroller */
.player-right {
    flex: 1 1 50%;
    height: 120px;
    display: flex;
    align-items: center;
    min-width: 0;
}

.lyrics-container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    text-align: right;
    
    /* Fading mask effect on top and bottom boundaries */
    mask-image: linear-gradient(to bottom, transparent 0%, #000 25%, #000 75%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #000 25%, #000 75%, transparent 100%);
}

.lyrics-scroller {
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    transform: translateY(48px); /* Initial vertical offset */
    padding: 48px 0; /* padding matches offset to scroll nicely */
}

.lyric-line {
    margin: 0;
    font-size: 11px;
    line-height: 18px;
    color: #383838;
    transition: color 0.3s ease, font-size 0.3s ease, text-shadow 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lyric-line.active {
    color: #ffffff;
    font-size: 12px;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.lyric-line.status {
    color: #666;
    text-align: right;
    font-style: italic;
}

/* Navigation Menu */
.bottom-nav {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(20, 20, 20, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 50px;
    padding: 8px;
    display: flex;
    gap: 5px;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
}

body.page-loaded .bottom-nav {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.nav-item {
    color: #888;
    text-decoration: none;
    padding: 8px 18px;
    border-radius: 50px;
    transition: all 0.3s;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
    color: #fff;
}

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

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

/* Glitch Exit Animation */
@keyframes glitch-out {
    0% {
        opacity: 1;
        transform: none;
        filter: none;
    }

    15% {
        opacity: 1;
        transform: skewX(-3deg);
        filter: brightness(1.5);
    }

    20% {
        opacity: 0.8;
        transform: translateX(-4px) skewX(2deg);
        filter: hue-rotate(90deg) brightness(2);
    }

    25% {
        opacity: 1;
        transform: translateX(4px);
        filter: none;
    }

    30% {
        opacity: 0.6;
        transform: skewX(-5deg);
        filter: hue-rotate(-90deg);
    }

    40% {
        opacity: 0;
        transform: translateY(3px);
        filter: blur(2px);
    }

    100% {
        opacity: 0;
    }
}

body.glitch-exit #main-ui {
    animation: glitch-out 0.4s forwards;
}

/* Discord Modal */
#discord-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    position: relative;
    width: 600px;
    max-width: calc(100% - 40px);
    border-radius: 18px;
    overflow: hidden;
    background: rgba(10, 10, 10, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.85);
}

.presence-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 28px;
    color: #e6e6e6;
}

.presence-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.presence-row {
    display: flex;
    gap: 18px;
    align-items: center;
}

.presence-avatar-wrapper {
    width: 74px;
    height: 74px;
    border-radius: 20px;
    background: #5865f2;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.presence-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.presence-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.presence-handle {
    font-size: 16px;
    color: #ffffff;
    font-weight: 700;
}

.presence-status-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #43b581;
    display: inline-block;
}

.presence-status {
    font-size: 12px;
    color: #888888;
}

.presence-close {
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: #f4f4f4;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.presence-close:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

.presence-card {
    display: flex;
    gap: 24px;
    align-items: stretch;
    background: transparent;
    border: none;
    padding: 0;
    margin-top: 4px;
}

.presence-card-art {
    flex: 1 1 50%;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    min-height: 120px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.presence-card-label {
    font-size: 10px;
    color: #888888;
    letter-spacing: 0.15em;
    font-weight: 700;
}

.presence-card-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.3;
}

.presence-card-subtitle {
    font-size: 12px;
    color: #888888;
}

.presence-card-meta {
    flex: 1 1 50%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    padding: 0 10px;
}

.presence-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    padding-bottom: 8px;
    color: #dddddd;
    font-size: 12px;
}

.presence-meta-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.presence-meta-label {
    font-size: 11px;
    color: #666666;
    letter-spacing: 0.05em;
    font-weight: 600;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#grid-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0.35;
}

@media (max-width: 768px) {
    .player-layout {
        flex-direction: column;
        align-items: stretch;
    }
    
    .player-left {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        padding-right: 0;
        padding-bottom: 20px;
    }
    
    .player-right {
        height: 100px;
    }
}


/* Mobile Nav Fix */
@media (max-width: 600px) {
    .bottom-nav {
        bottom: 20px !important;
        padding: 6px !important;
        gap: 2px !important;
        width: calc(100% - 24px) !important;
        max-width: 380px !important;
        justify-content: space-between !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(0) !important;
    }
    .nav-item {
        padding: 6px 10px !important;
        font-size: 11px !important;
    }
}
