:root {
    --bg-dark: #050505;
    --text: #ffffff;
    --glass-bg: rgba(20, 20, 20, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent: #00f3ff;
    --font-head: 'Space Grotesk', sans-serif;
    --font-ui: 'Inter', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    background: var(--bg-dark);
    color: var(--text);
    font-family: var(--font-ui);
    height: 100vh;
    overflow: hidden;
    display: flex; justify-content: center; align-items: center;
}

/* FUEGOS ARTIFICIALES */
#fireworks {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 5; pointer-events: none;
}

/* FONDO */
.atmosphere { position: fixed; inset: -10%; z-index: 0; }
#bg-blur {
    width: 120%; height: 120%; object-fit: cover;
    filter: blur(80px) brightness(0.4); transition: 1s ease;
}
.vignette {
    position: absolute; inset: 0;
    background: radial-gradient(circle, transparent 0%, #000 100%);
}

.stage {
    position: relative; z-index: 10; width: 100%; height: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 20px;
}

/* HEADER */
.top-nav {
    position: absolute; top: 0; left: 0; right: 0; height: 90px; padding: 0 30px;
    display: flex; justify-content: space-between; align-items: center; z-index: 20;
}

.header-left { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.brand { font-family: var(--font-head); font-weight: 700; font-size: 1.4rem; letter-spacing: -1px; line-height: 1; }
.brand span { color: var(--accent); }

/* Menú Desplegable */
.dropdown-wrapper { position: relative; z-index: 2000; }

.social-header-btn {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.75rem; color: rgba(255,255,255,0.7);
    text-decoration: none; transition: all 0.2s ease;
    background: rgba(255,255,255,0.05); padding: 4px 10px; border-radius: 12px;
    border: 1px solid var(--glass-border); cursor: pointer;
}
.social-header-btn:hover, .social-header-btn.active { 
    color: #fff; background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.3);
}
.social-header-btn svg { width: 12px; height: 12px; }

.dropdown-menu {
    position: absolute; top: 125%; left: 0; min-width: 180px;
    background: #111; border: 1px solid #333; box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    border-radius: 8px; padding: 5px; opacity: 0; transform: translateY(-5px);
    pointer-events: none; transition: all 0.2s ease;
}
.dropdown-menu.active { opacity: 1; transform: translateY(0); pointer-events: all; }

.dropdown-item {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 6px;
    color: #ccc; text-decoration: none; font-size: 0.85rem; transition: background 0.1s ease;
}
.dropdown-item:hover { background: #222; color: #fff; }
.dropdown-item svg { width: 16px; height: 16px; fill: currentColor; opacity: 0.7; }
.dropdown-item:hover svg { opacity: 1; color: var(--accent); }

/* Estado Live */
.header-right { display: flex; align-items: center; gap: 15px; }
.live-status {
    display: flex; align-items: center; gap: 8px; font-size: 0.7rem; font-weight: 600; letter-spacing: 1px;
    background: rgba(0,0,0,0.4); padding: 5px 12px; border-radius: 20px; border: 1px solid var(--glass-border);
}
.dot {
    width: 6px; height: 6px; background: #ff3b3b; border-radius: 50%;
    box-shadow: 0 0 8px #ff3b3b; animation: blink 2s infinite;
}
@keyframes blink { 50% { opacity: 0.4; } }

.btn-icon {
    background: none; border: none; color: white; cursor: pointer; padding: 5px; transition: transform 0.2s;
}
.btn-icon:hover { transform: scale(1.1); color: var(--accent); }

/* PLAYER WRAPPER */
.player-wrapper {
    position: relative; width: 100%; max-width: 850px; display: flex; box-sizing: border-box;
    /* Esto recorta el visualizador por abajo */
    border-radius: 24px; overflow: hidden; 
}

/* Anillo y Visualizador */
.halo-ring {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; overflow: visible; z-index: 20;
}
.halo-track { fill: none; stroke: rgba(255,255,255,0.05); stroke-width: 2; }
.halo-fill {
    fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round;
    filter: drop-shadow(0 0 5px var(--accent));
    transition: stroke-dashoffset 0.1s linear, stroke 1s ease, filter 0.5s ease; 
}
.halo-fill.off { stroke: #333333; filter: none !important; }

/* AQUÍ ESTÁ EL EFECTO BORROSO ORIGINAL */
.viz-wrapper {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 0; /* Detrás del contenido */
    pointer-events: none;
    opacity: 0.5; /* Mantenemos la opacidad para el efecto borroso */
}
canvas { display: block; width: 100%; height: 100%; }

/* Contenido Cristal */
.glass-content {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(30px) saturate(160%);
    border-radius: 24px; width: 100%; display: flex; align-items: center;
    padding: 40px; gap: 50px; border: 1px solid rgba(255,255,255,0.05);
    box-shadow: 0 30px 60px rgba(0,0,0,0.5);
    position: relative; z-index: 10; /* Encima del visualizador */
}

.art-section { flex-shrink: 0; }
.cd-case {
    width: 260px; height: 260px; border-radius: 16px; overflow: hidden;
    position: relative; box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
#art-img { width: 100%; height: 100%; object-fit: cover; }
.shine {
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
}

.info-section { flex-grow: 1; display: flex; flex-direction: column; gap: 15px; min-width: 0; width: 100%; }
.meta-tags { display: flex; justify-content: space-between; font-size: 0.75rem; font-weight: 600; color: rgba(255,255,255,0.5); }
.badge { background: #fff; color: #000; padding: 2px 6px; border-radius: 3px; transition: opacity 0.5s ease; }
.time-display { transition: opacity 0.5s ease; font-feature-settings: "tnum"; }
.hidden { opacity: 0; }

/* TITULOS (Centrados y con corte) */
.titles {
    text-align: center; display: flex; flex-direction: column; align-items: center;
    width: 100%; margin-bottom: 10px; position: relative;
}

#track-title {
    font-family: var(--font-head); font-weight: 700; font-size: 2.2rem;
    line-height: 1.1; margin-bottom: 5px;
    /* El corte con 3 puntos */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
    cursor: pointer; /* Mano para indicar click */
}

#track-artist {
    font-size: 1.1rem; color: var(--accent); font-weight: 500; letter-spacing: 1px;
    /* El corte con 3 puntos */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 100%;
    cursor: pointer; /* Mano para indicar click */
}

/* TOOLTIP FLOTANTE */
#custom-tooltip {
    position: fixed;
    background: #111;
    border: 1px solid var(--accent);
    color: #fff;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: var(--font-ui);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    max-width: 90vw; /* Que no se salga en móvil */
    width: max-content;
    white-space: pre-wrap; /* Permite saltos de línea */
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}
#custom-tooltip.visible { opacity: 1; transform: translateY(0); }

/* CONTROLES */
.controls-row { display: flex; align-items: center; margin-top: 10px; position: relative; }
.play-container { flex-grow: 1; display: flex; justify-content: center; }
.btn-main {
    width: 70px; height: 70px; border-radius: 50%;
    background: var(--text); color: #000; border: none;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; box-shadow: 0 0 20px rgba(255,255,255,0.2); transition: 0.2s;
}
.btn-main:active { transform: scale(0.95); }
.btn-main svg { width: 30px; height: 30px; }
.volume-box {
    position: absolute; right: 0;
    background: rgba(0,0,0,0.3); padding: 8px 12px; border-radius: 20px;
    display: flex; align-items: center; gap: 10px;
}
input[type=range] {
    width: 80px; height: 4px; -webkit-appearance: none;
    background: rgba(255,255,255,0.2); border-radius: 2px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 12px; height: 12px;
    background: var(--text); border-radius: 50%;
}

/* SIDEBAR & OVERLAY */
.overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
    backdrop-filter: blur(2px);
}
.overlay.active { opacity: 1; pointer-events: all; }
.sidebar {
    position: fixed; top: 0; right: 0; height: 100%; width: 350px;
    background: #0a0a0a; border-left: 1px solid var(--glass-border);
    z-index: 50; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
    flex: 0 0 auto; padding: 20px; border-bottom: 1px solid var(--glass-border);
    display: flex; justify-content: space-between; align-items: center;
    background: #0a0a0a; z-index: 2;
}
.sidebar-header h3 { font-family: var(--font-head); color: var(--accent); font-size: 1.1rem; }
#close-history { background: none; border: none; color: #fff; font-size: 2rem; cursor: pointer; }

.history-list {
    flex: 1 1 auto; display: flex; flex-direction: column; overflow-y: auto; padding: 10px; min-height: 0;
}
.history-item {
    display: grid; grid-template-columns: 20px 50px 1fr auto; 
    gap: 15px; align-items: center; padding: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.9rem;
    background: #0a0a0a; flex: 0 0 auto; min-height: 80px; 
}
.h-number { color: rgba(255,255,255,0.3); font-size: 0.8rem; }
.h-art { width: 50px; height: 50px; border-radius: 4px; object-fit: cover; }
.h-info { overflow: hidden; }
.h-title { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-artist { font-size: 0.8rem; color: rgba(255,255,255,0.6); }
.h-time { font-size: 0.75rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.loader { padding: 20px; text-align: center; color: #666; margin: auto; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .stage { padding: 15px; }
    .player-wrapper { flex-direction: column; max-width: 400px; }
    .glass-content { flex-direction: column; padding: 30px 20px; gap: 20px; text-align: center; }
    .cd-case { width: 220px; height: 220px; }
    .info-section { align-items: center; }
    .meta-tags { width: 100%; justify-content: center; gap: 15px; }
    .titles h1 { font-size: 1.6rem; white-space: normal; } /* En movil quizás quieras que salte de linea, si no, quita esto */
    .controls-row { width: 100%; justify-content: center; margin-top: 15px; }
    .volume-box { display: none; }
    .sidebar { width: 85%; }
}