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

/* ============ FONDO: GIF DE BAILE (marca de agua) ============ */
#fondo-baile {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: 0;
    opacity: 0.30;
    pointer-events: none;
    object-fit: cover;
    filter: blur(1.5px) brightness(0.65);
}

html, body {
    background: transparent;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    font-family: 'Georgia', serif;
    color: white;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
    position: fixed;
}

#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 1;
    touch-action: none;
    mix-blend-mode: screen;
}

/* ============ HUD ============ */
#hud {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 12px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(15, 5, 20, 0.85);
    border: 1.5px solid #ffd700;
    border-radius: 18px;
    padding: 8px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.35), inset 0 0 20px rgba(255, 215, 0, 0.08);
    opacity: 0;
    transition: opacity 0.5s ease;
    max-width: 92vw;
    min-width: 220px;
}

#hud.visible { opacity: 1; }

#hud-nivel {
    color: #ffd700;
    font-size: 0.6rem;
    letter-spacing: 3px;
    font-family: Arial, sans-serif;
    opacity: 0.7;
    font-weight: 600;
}

#hud-icono {
    font-size: 1.5rem;
    line-height: 1;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
}

#hud-texto {
    color: #ffffff;
    font-size: 0.82rem;
    font-family: Arial, sans-serif;
    text-align: center;
    line-height: 1.3;
    letter-spacing: 0.3px;
}

#hud-info {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 215, 0, 0.25);
    width: 100%;
    justify-content: center;
}

#hud-contador {
    color: #ffd700;
    font-size: 1rem;
    font-weight: bold;
    text-shadow: 0 0 15px #ffd700;
    font-family: 'Courier New', monospace;
}

#hud-timer {
    color: #ff4d6d;
    font-size: 1rem;
    font-weight: bold;
    text-shadow: 0 0 15px #ff4d6d;
    font-family: 'Courier New', monospace;
}

#hud-timer.oculto { display: none; }

#hud-timer.alerta {
    animation: pulsarTimer 0.5s infinite;
}

@keyframes pulsarTimer {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ============ PROGRESO ============ */
#progreso {
    position: fixed;
    bottom: max(15px, env(safe-area-inset-bottom, 15px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 30px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 77, 109, 0.3);
    opacity: 0;
    transition: opacity 0.5s ease;
}

#progreso.visible { opacity: 1; }

.punto {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.5s ease;
}

.punto.activo {
    background: #ff4d6d;
    box-shadow: 0 0 15px #ff4d6d;
    transform: scale(1.4);
}

.punto.completado {
    background: #ffd700;
    box-shadow: 0 0 10px #ffd700;
}

/* ============ HISTORIA ============ */
#historia {
    position: fixed;
    bottom: 55px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    text-align: center;
    width: 90%;
    max-width: 550px;
    opacity: 0;
    transition: opacity 1s ease;
    pointer-events: none;
    padding: 0 15px;
}

#historia.visible { opacity: 1; }

#historia-titulo {
    font-size: 1.3rem;
    color: #ff4d6d;
    margin-bottom: 6px;
    text-shadow: 
        -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
        -2px 0 0 #000, 2px 0 0 #000, 0 -2px 0 #000, 0 2px 0 #000,
        0 0 20px rgba(255, 77, 109, 0.9), 0 0 40px rgba(255, 77, 109, 0.5);
    font-weight: 700;
    letter-spacing: 1.5px;
}

#historia-texto {
    font-size: 0.85rem;
    color: #ffffff;
    line-height: 1.5;
    font-style: italic;
    font-weight: 600;
    text-shadow: 
        -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000,
        -1.5px 0 0 #000, 1.5px 0 0 #000, 0 -1.5px 0 #000, 0 1.5px 0 #000,
        0 0 8px rgba(0,0,0,1);
}

/* ============ INTRO ============ */
#intro {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, rgba(25, 5, 30, 0.96) 0%, rgba(0, 0, 0, 0.99) 100%);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 1s ease, visibility 1s;
    padding: 20px;
}

#intro.oculto {
    opacity: 0;
    visibility: hidden;
}

.intro-panel {
    text-align: center;
    padding: 35px 25px;
    max-width: 420px;
    width: 100%;
    background: rgba(20, 5, 30, 0.85);
    border: 1.5px solid #ff4d6d;
    border-radius: 22px;
    box-shadow: 0 0 60px rgba(255, 77, 109, 0.4), inset 0 0 40px rgba(255, 77, 109, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.intro-panel h1 {
    font-size: 2.5rem;
    color: #ff4d6d;
    margin-bottom: 12px;
    text-shadow: 0 0 30px rgba(255, 77, 109, 0.8), 0 0 60px rgba(255, 77, 109, 0.4);
    font-weight: 300;
    letter-spacing: 2px;
}

.intro-panel p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 8px;
}

.intro-panel .intro-sub {
    font-size: 0.78rem;
    color: rgba(255, 215, 0, 0.7);
    font-style: italic;
    margin-bottom: 22px;
    letter-spacing: 0.5px;
}

#btn-empezar {
    margin-top: 15px;
    background: transparent;
    border: 2px solid #ffd700;
    color: #ffd700;
    padding: 14px 40px;
    font-size: 0.95rem;
    font-family: Arial, sans-serif;
    letter-spacing: 3px;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.4s ease;
    text-transform: uppercase;
    font-weight: bold;
    touch-action: manipulation;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.3);
}

#btn-empezar:active {
    background: #ffd700;
    color: #000;
    box-shadow: 0 0 50px #ffd700;
    transform: scale(0.97);
}

/* ============ CÓDIGO ============ */
#codigo {
    position: fixed;
    top: 150px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid #ffd700;
    border-radius: 15px;
    padding: 14px 22px;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    text-align: center;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
    transition: opacity 0.5s ease;
    max-width: 92vw;
}

#codigo.oculto { opacity: 0; pointer-events: none; }

#codigo p {
    color: #ffd700;
    font-size: 0.7rem;
    letter-spacing: 3px;
    margin-bottom: 10px;
    font-weight: bold;
    font-family: Arial, sans-serif;
}

#codigo-colores {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.color-codigo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    animation: pulsoColor 1s infinite alternate;
}

@keyframes pulsoColor {
    from { transform: scale(1); }
    to { transform: scale(1.12); }
}

/* ============ TOAST ============ */
#toast {
    position: fixed;
    bottom: 95px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    background: rgba(255, 77, 109, 0.95);
    color: white;
    padding: 11px 22px;
    border-radius: 30px;
    font-family: Arial, sans-serif;
    font-size: 0.85rem;
    letter-spacing: 1px;
    box-shadow: 0 0 30px rgba(255, 77, 109, 0.8);
    transition: all 0.3s ease;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}

#toast.oculto {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

/* ============ MENSAJE FINAL DEL CORAZÓN ============ */
#mensaje-final {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    z-index: 200;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: all 1.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    padding: 20px;
    max-width: 90%;
}

#mensaje-final.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#mensaje-final h1 {
    font-size: 5rem;
    font-family: 'Georgia', serif;
    color: #ffd700;
    font-weight: 700;
    letter-spacing: 10px;
    margin-bottom: 20px;
    text-shadow: 
        -4px -4px 0 #000, 4px -4px 0 #000, -4px 4px 0 #000, 4px 4px 0 #000,
        -4px 0 0 #000, 4px 0 0 #000, 0 -4px 0 #000, 0 4px 0 #000,
        -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000,
        0 0 20px #ffd700, 0 0 40px #ffd700, 0 0 60px #ff4d6d, 0 0 100px #ff4d6d;
    animation: pulsoTitulo 2s infinite alternate;
}

@keyframes pulsoTitulo {
    0% { 
        transform: scale(1); 
        text-shadow: 
            -4px -4px 0 #000, 4px -4px 0 #000, -4px 4px 0 #000, 4px 4px 0 #000,
            -4px 0 0 #000, 4px 0 0 #000, 0 -4px 0 #000, 0 4px 0 #000,
            -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000,
            0 0 20px #ffd700, 0 0 40px #ffd700, 0 0 60px #ff4d6d;
    }
    100% { 
        transform: scale(1.05); 
        text-shadow: 
            -4px -4px 0 #000, 4px -4px 0 #000, -4px 4px 0 #000, 4px 4px 0 #000,
            -4px 0 0 #000, 4px 0 0 #000, 0 -4px 0 #000, 0 4px 0 #000,
            -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000,
            0 0 30px #ffd700, 0 0 60px #ffd700, 0 0 90px #ff4d6d, 0 0 120px #ff4d6d; 
    }
}

#mensaje-final .flores-deco {
    font-size: 2.2rem;
    margin-bottom: 22px;
    filter: drop-shadow(0 0 15px #ffd700) drop-shadow(0 0 4px #000);
    animation: flotarFlores 3s infinite ease-in-out;
}

@keyframes flotarFlores {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

#mensaje-final .mensaje-texto {
    font-size: 1.5rem;
    color: #ffffff;
    line-height: 1.7;
    letter-spacing: 1px;
    font-style: italic;
    font-weight: 600;
    font-family: 'Georgia', serif;
    margin-bottom: 28px;
    text-shadow: 
        -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000,
        -3px 0 0 #000, 3px 0 0 #000, 0 -3px 0 #000, 0 3px 0 #000,
        -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
        0 0 15px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 77, 109, 0.5);
}

#mensaje-final .firma {
    font-size: 1.6rem;
    color: #ff4d6d;
    letter-spacing: 5px;
    font-family: 'Georgia', serif;
    font-weight: 700;
    text-shadow: 
        -3px -3px 0 #000, 3px -3px 0 #000, -3px 3px 0 #000, 3px 3px 0 #000,
        -3px 0 0 #000, 3px 0 0 #000, 0 -3px 0 #000, 0 3px 0 #000,
        -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000,
        0 0 20px #ff4d6d, 0 0 40px #ff4d6d;
    animation: firmaPulso 2.5s infinite alternate;
}

@keyframes firmaPulso {
    0% { opacity: 0.85; }
    100% { opacity: 1; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 500px) {
    #hud { min-width: auto; padding: 7px 14px; }
    #hud-texto { font-size: 0.75rem; }
    #hud-icono { font-size: 1.3rem; }
    #hud-nivel { font-size: 0.55rem; letter-spacing: 2px; }
    #historia-titulo { font-size: 1.15rem; }
    #historia-texto { font-size: 0.78rem; }
    .intro-panel h1 { font-size: 2rem; }
    #codigo { top: 130px; padding: 11px 16px; }
    .color-codigo { width: 30px; height: 30px; }
    #codigo-colores { gap: 8px; }
    .punto { width: 8px; height: 8px; }
    
    #mensaje-final h1 {
        font-size: 3rem;
        letter-spacing: 5px;
    }
    #mensaje-final .flores-deco {
        font-size: 1.6rem;
    }
    #mensaje-final .mensaje-texto {
        font-size: 1.05rem;
        line-height: 1.6;
    }
    #mensaje-final .firma {
        font-size: 1.15rem;
        letter-spacing: 2px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    #hud { flex-direction: row; padding: 6px 14px; gap: 10px; min-width: auto; }
    #hud-info { border-top: none; border-left: 1px solid rgba(255, 215, 0, 0.25); padding-top: 0; padding-left: 12px; width: auto; }
    #hud-texto { font-size: 0.7rem; }
    #historia { bottom: 35px; }
    #historia-titulo { font-size: 0.95rem; }
    #historia-texto { font-size: 0.7rem; }
    .intro-panel { padding: 20px; }
    .intro-panel h1 { font-size: 1.6rem; }
    #codigo { top: 80px; }
    #mensaje-final h1 { font-size: 2.3rem; letter-spacing: 4px; }
    #mensaje-final .mensaje-texto { font-size: 0.95rem; }
    #mensaje-final .firma { font-size: 1rem; }
}
