:root {
    --bg-color: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* 动态背景 */
.bg-layer {
    position: fixed;
    top: -10%; left: -10%; right: -10%; bottom: -10%;
    background-image: linear-gradient(45deg, #0f172a, #1e1b4b);
    background-size: cover;
    background-position: center;
    filter: blur(60px) brightness(0.6);
    z-index: -2;
    transition: background-image 1s ease-in-out;
}
.bg-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at center, transparent 0%, rgba(15, 23, 42, 0.8) 100%);
    z-index: -1;
}

.app-container {
    width: 100%;
    max-width: 900px;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: calc(100% - 40px);
}

.panel.active {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}
.panel.hidden { display: none; }

/* Room Panel */
#room-panel { max-width: 400px; text-align: center; }
.logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 8px; color: var(--primary); }
.logo h1 { font-size: 24px; font-weight: 600; color: var(--text-main); }
.subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 14px; }
.input-group { display: flex; flex-direction: column; gap: 16px; }
input {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--glass-border);
    padding: 14px 20px;
    border-radius: 12px;
    color: white;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}
input:focus { border-color: var(--primary); }
button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex; align-items: center; justify-content: center;
}
button:hover { background: var(--primary-hover); }
button:active { transform: scale(0.98); }

/* Player Panel */
#player-panel { max-width: 860px; padding: 24px; display: flex; flex-direction: column; gap: 24px; }

.header-bar { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--glass-border); padding-bottom: 16px; }
.room-info { display: flex; gap: 12px; align-items: center; }
.room-badge, .users-badge {
    background: rgba(255,255,255,0.1);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    display: flex; align-items: center; gap: 6px;
}
.users-badge { color: #38bdf8; background: rgba(56, 189, 248, 0.1); }
.header-right { display: flex; align-items: center; gap: 16px; }
.sync-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.indicator.online { background: var(--success); box-shadow: 0 0 8px var(--success); }
.text-btn { background: transparent; color: var(--danger); padding: 6px 12px; font-size: 14px; }
.text-btn:hover { background: rgba(239, 68, 68, 0.1); }

/* Search Area */
.search-bar { display: flex; gap: 12px; position: relative; z-index: 10;}
.search-bar input { flex: 1; border-radius: 16px; padding: 16px 24px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); }
.search-bar button { border-radius: 16px; padding: 0 24px; }
.results-list {
    list-style: none;
    max-height: 200px; overflow-y: auto;
    border-radius: 12px;
    position: absolute; top: 155px; left: 24px; right: 24px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    z-index: 20;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: none;
}
.results-list.active { display: block; }
.results-list li {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    cursor: pointer;
    display: flex; justify-content: space-between;
    transition: background 0.2s;
}
.results-list li:hover { background: rgba(255,255,255,0.05); }
.results-list li strong { color: var(--text-main); }
.results-list li span { color: var(--text-muted); font-size: 13px; }

/* Main Content (Disc + Lyrics) */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
    margin: 20px 0;
}

@media (max-width: 768px) {
    .main-content { grid-template-columns: 1fr; gap: 20px; }
    .lyrics-section { height: 200px; }
    .vinyl-record { width: 160px !important; height: 160px !important; }
}

/* Disc Section */
.disc-section { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.vinyl-record {
    width: 240px; height: 240px;
    border-radius: 50%;
    background: #111;
    border: 8px solid rgba(255,255,255,0.1);
    box-shadow: 0 0 20px rgba(0,0,0,0.5), inset 0 0 10px #000;
    position: relative;
    overflow: hidden;
    display: flex; justify-content: center; align-items: center;
    animation: spin 20s linear infinite;
    animation-play-state: paused;
}
.vinyl-record.playing { animation-play-state: running; }
.vinyl-record img {
    width: 100%; height: 100%; object-fit: cover; opacity: 0.8;
}
.vinyl-hole {
    position: absolute; width: 40px; height: 40px;
    background: var(--bg-color); border-radius: 50%;
    border: 2px solid #333;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.song-info { text-align: center; }
.song-info h2 { font-size: 20px; margin-bottom: 6px; font-weight: 600; }
.song-info p { color: var(--text-muted); font-size: 14px; }

/* Lyrics Section */
.lyrics-section {
    height: 300px;
    position: relative;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 20%, black 80%, transparent 100%);
}
.lyrics-container {
    height: 100%;
    overflow-y: scroll;
    scrollbar-width: none; /* Firefox */
    scroll-behavior: smooth;
    padding: 130px 0; /* Padding to allow scrolling to middle */
}
.lyrics-container::-webkit-scrollbar { display: none; }
.lyric-line {
    font-size: 16px; color: rgba(255,255,255,0.4);
    margin: 16px 0; text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center left;
}
.lyric-line.active {
    color: var(--primary); font-size: 18px; font-weight: 600;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
    transform: scale(1.05);
}

/* Bottom Control */
.bottom-control audio {
    width: 100%; height: 44px; outline: none; border-radius: 22px;
}
/* Customizing the default audio player a bit for webkit */
audio::-webkit-media-controls-panel {
    background-color: rgba(255,255,255,0.1);
}
audio::-webkit-media-controls-current-time-display,
audio::-webkit-media-controls-time-remaining-display {
    color: white;
}
