:root {
    --fondo: #12101c;
    --superficie: #1d1a2b;
    --superficie-2: #272338;
    --borde: rgba(255, 255, 255, 0.08);
    --texto: #f2eff9;
    --texto-suave: #a89fc0;
    --acento: #7c4dff;
    --acento-2: #22d3ee;
    --ok: #34d399;
    --error: #f87171;
    --radio: 18px;
    --sombra: 0 18px 50px rgba(0, 0, 0, 0.45);
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--fondo);
    color: var(--texto);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ---------- Bloqueo de acceso ---------- */
.bloqueo {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: radial-gradient(1200px 600px at 50% 20%, #241d3a, var(--fondo));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.bloqueo.oculto { display: none; }
.bloqueo-tarjeta {
    background: linear-gradient(180deg, var(--superficie), var(--superficie-2));
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 34px 28px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}
.bloqueo-emoji { font-size: 2.6rem; display: block; margin-bottom: 8px; }
.bloqueo-tarjeta h2 { font-size: 1.35rem; margin-bottom: 6px; }
.bloqueo-tarjeta p { color: var(--texto-suave); font-size: 0.85rem; margin-bottom: 16px; line-height: 1.5; }
#clave {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--borde);
    background: var(--fondo);
    color: var(--texto);
    font-size: 1rem;
    outline: none;
    margin-bottom: 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#clave:focus { border-color: var(--acento); box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.25); }
.bloqueo-error { color: var(--error) !important; font-weight: 700; margin: 10px 0 0 !important; }
.bloqueo-tarjeta.sacudiendo { animation: sacudir 0.5s ease; }
@keyframes sacudir {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* ---------- Fondo animado ---------- */
.fondo { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.orbe {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.45;
}
.orbe-a { width: 420px; height: 420px; background: #6d28d9; top: -140px; left: -100px; }
.orbe-b { width: 380px; height: 380px; background: #0e7490; bottom: -120px; right: -80px; }
.orbe-c { width: 260px; height: 260px; background: #be185d; top: 40%; left: 60%; opacity: 0.25; }

/* ---------- Barra superior ---------- */
.barra {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--borde);
    background: rgba(18, 16, 28, 0.7);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 20;
}
.marca { display: flex; align-items: center; gap: 12px; }
.logo {
    font-size: 2rem;
    filter: drop-shadow(0 0 12px rgba(124, 77, 255, 0.6));
}
.marca h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    background: linear-gradient(90deg, var(--acento-2), var(--acento));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.marca-sub { font-size: 0.72rem; color: var(--texto-suave); margin-top: 2px; }
.barra-botones { display: flex; gap: 8px; }

.btn-ghost {
    background: var(--superficie-2);
    border: 1px solid var(--borde);
    color: var(--texto);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 1.15rem;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.12s ease;
}
.btn-ghost:hover { background: var(--superficie); transform: translateY(-2px); }

/* ---------- Disposición principal ---------- */
.envoltorio {
    flex: 1;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 26px 16px 40px;
}

/* ---------- Pestañas ---------- */
.pestanas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: var(--superficie);
    padding: 6px;
    border-radius: 14px;
    border: 1px solid var(--borde);
    margin-bottom: 18px;
}
.pestana {
    border: none;
    background: transparent;
    color: var(--texto-suave);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.15s ease;
}
.pestana.activa {
    background: linear-gradient(135deg, var(--acento), #b34dff);
    color: #fff;
    box-shadow: 0 6px 18px rgba(124, 77, 255, 0.35);
}

/* ---------- Tarjeta de juego ---------- */
.tarjeta {
    background: linear-gradient(180deg, var(--superficie), var(--superficie-2));
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 22px 20px 20px;
}

.estado-superior {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.hud-intentos { display: flex; gap: 6px; }
.punto-intento {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--superficie-2);
    border: 1px solid var(--borde);
    transition: 0.2s ease;
}
.punto-intento.usado { background: var(--error); border-color: var(--error); }
.punto-intento.acierto { background: var(--ok); border-color: var(--ok); }
.hud-texto { font-size: 0.8rem; color: var(--texto-suave); font-weight: 600; }

/* ---------- Zona de audio ---------- */
.zona-audio {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 8px 0 4px;
}
.espectro {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 46px;
    opacity: 0.35;
}
.espectro span {
    width: 7px;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(180deg, var(--acento-2), var(--acento));
}
.espectro.reproduciendo span {
    animation: ecualizar 0.9s ease-in-out infinite alternate;
}
.espectro.reproduciendo span:nth-child(3n+1) { animation-delay: 0.15s; }
.espectro.reproduciendo span:nth-child(3n+2) { animation-delay: 0.35s; }
.espectro.reproduciendo span:nth-child(3n) { animation-delay: 0.55s; }
@keyframes ecualizar {
    from { height: 10px; }
    to { height: 44px; }
}

.boton-play {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--acento), #b34dff);
    color: #fff;
    font-size: 2.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 0 6px rgba(124, 77, 255, 0.18), 0 12px 30px rgba(124, 77, 255, 0.45);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    outline: none;
}
.boton-play:hover { transform: scale(1.06); }
.boton-play:active { transform: scale(0.97); }
.boton-play.pausado { background: linear-gradient(135deg, var(--superficie-2), var(--superficie)); box-shadow: 0 0 0 6px rgba(255,255,255,0.06); }

/* ---------- Cronómetro y progreso ---------- */
.cronometro {
    text-align: center;
    font-size: 0.9rem;
    color: var(--texto-suave);
    margin-top: 14px;
    font-variant-numeric: tabular-nums;
}
.cronometro span { color: var(--texto); font-weight: 700; }

.barra-progreso {
    height: 8px;
    background: var(--superficie-2);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 8px;
    border: 1px solid var(--borde);
}
.relleno-progreso {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--acento-2), var(--acento));
    border-radius: 99px;
    transition: width 0.15s linear;
}

/* ---------- Mensajes ---------- */
.mensaje {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--borde);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 18px 0;
    font-size: 0.9rem;
    line-height: 1.5;
    min-height: 46px;
    color: var(--texto-suave);
}
.mensaje.bien { color: var(--ok); border-color: rgba(52, 211, 153, 0.4); background: rgba(52, 211, 153, 0.08); }
.mensaje.mal { color: var(--error); border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.08); }

/* ---------- Buscador ---------- */
.campo-busqueda { position: relative; }
#entrada {
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--borde);
    background: var(--fondo);
    color: var(--texto);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#entrada:focus {
    border-color: var(--acento);
    box-shadow: 0 0 0 3px rgba(124, 77, 255, 0.25);
}
#entrada::placeholder { color: var(--texto-suave); }

.sugerencias {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--superficie);
    border: 1px solid var(--borde);
    border-radius: 12px;
    box-shadow: var(--sombra);
    max-height: 260px;
    overflow-y: auto;
    z-index: 30;
    display: none;
}
.sugerencias.visible { display: block; }
.sugerencia {
    padding: 11px 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1px;
    border-bottom: 1px solid var(--borde);
}
.sugerencia:last-child { border-bottom: none; }
.sugerencia:hover, .sugerencia.destacada { background: var(--superficie-2); }
.sugerencia .s-titulo { font-weight: 700; font-size: 0.9rem; }
.sugerencia .s-artista { font-size: 0.78rem; color: var(--texto-suave); }
.sugerencia.sin-resultados { color: var(--texto-suave); font-size: 0.85rem; cursor: default; }

.fila-botones {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 10px;
    margin-top: 12px;
}
.btn {
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease, background 0.12s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn.principal {
    background: linear-gradient(135deg, var(--acento), #b34dff);
    color: #fff;
    box-shadow: 0 8px 22px rgba(124, 77, 255, 0.35);
}
.btn.secundario { background: var(--superficie-2); color: var(--texto); border: 1px solid var(--borde); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.filtro-infinito {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--texto-suave);
}
#filtro-genero {
    flex: 1;
    background: var(--fondo);
    color: var(--texto);
    border: 1px solid var(--borde);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.pie-modo { text-align: center; font-size: 0.8rem; color: var(--texto-suave); margin-top: 16px; min-height: 1.2em; }

/* ---------- Modales ---------- */
.modal {
    border: none;
    background: transparent;
    max-width: 520px;
    width: calc(100% - 32px);
    margin: auto;
    padding: 0;
}
.modal::backdrop { background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(4px); }
.modal-cofre {
    position: relative;
    background: linear-gradient(180deg, var(--superficie), var(--superficie-2));
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 26px 24px;
    box-shadow: var(--sombra);
}
.modal-cofre h2 { font-size: 1.3rem; margin-bottom: 16px; }
.modal-cierre {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--superficie-2);
    border: 1px solid var(--borde);
    color: var(--texto-suave);
    width: 34px;
    height: 34px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
}
.reglas { padding-left: 20px; display: flex; flex-direction: column; gap: 12px; font-size: 0.95rem; line-height: 1.55; color: var(--texto); }
.reglas strong { color: var(--acento-2); }
.reglas-fin { margin-top: 18px; font-weight: 700; color: var(--acento-2); }

.estadisticas {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    text-align: center;
}
.stat {
    background: var(--superficie-2);
    border: 1px solid var(--borde);
    border-radius: 12px;
    padding: 14px 6px;
}
.stat-num { display: block; font-size: 1.6rem; font-weight: 800; color: var(--acento-2); }
.stat-lbl { font-size: 0.7rem; color: var(--texto-suave); }
.titulo-distribucion { font-size: 0.95rem; margin: 20px 0 10px; color: var(--texto-suave); }
.distribucion { display: flex; flex-direction: column; gap: 7px; }

:root { --barra-distribucion: 0px; }
.fila-dista { display: grid; grid-template-columns: 30px 1fr; align-items: center; gap: 8px; font-size: 0.8rem; }
.fila-dista-num { color: var(--texto-suave); font-weight: 700; text-align: right; }
.fila-dista-barra { height: 12px; background: var(--superficie-2); border-radius: 6px; overflow: hidden; }
.fila-dista-barra > i {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--acento-2), var(--acento));
    border-radius: 6px;
    transition: width 0.5s ease;
}
.fila-dista p { font-size: 0.7rem; color: var(--texto-suave); }

/* ---------- Overlay de resultado ---------- */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 16px;
}
.overlay-tarjeta {
    background: linear-gradient(180deg, var(--superficie), var(--superficie-2));
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 30px 26px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    animation: aparecer 0.3s ease;
}
@keyframes aparecer {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to { opacity: 1; transform: none; }
}
.overlay-emoji { font-size: 3rem; display: block; margin-bottom: 6px; }
.overlay-tarjeta h2 { font-size: 1.6rem; margin-bottom: 6px; }
.overlay-sub { color: var(--texto-suave); font-size: 0.9rem; margin-bottom: 14px; }
.overlay-cancion {
    background: var(--superficie-2);
    border: 1px solid var(--borde);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 16px;
}
.overlay-cancion .c-titulo { font-size: 1.05rem; font-weight: 800; }
.overlay-cancion .c-artista { font-size: 0.85rem; color: var(--texto-suave); }
.overlay-rejilla {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 20px;
    min-height: 26px;
    font-size: 0.9rem;
    font-weight: 700;
}
.overlay-botones { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Pie ---------- */
.pie-pagina {
    text-align: center;
    font-size: 0.75rem;
    color: var(--texto-suave);
    padding: 18px 12px 26px;
}
.pie-pagina a { color: var(--acento-2); text-decoration: none; }
.pie-pagina a:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .marca-sub { display: none; }
    .marca h1 { font-size: 1.15rem; }
    .tarjeta { padding: 18px 14px; }
    .boton-play { width: 84px; height: 84px; font-size: 1.8rem; }
}