@import url('https://fonts.googleapis.com/css2?family=Mountains+of+Christmas:wght@400;700&display=swap');

/* Fondo y contenedor general */
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Evita scroll horizontal */
    overflow-y: auto;   /* Permite scroll vertical si la pantalla es muy baja */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh; /* Asegura altura mínima pero permite crecer */
    font-family: 'Arial Black', sans-serif;
    color: white;
    flex-direction: column; /* Alinea el título arriba y el reloj abajo */
    gap: 50px;
    position: relative;
}

/* Fondo animado usando pseudo-elemento */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), var(--bg-image, url('fondo10.jpg')) no-repeat center center;
    background-size: cover;
    animation: backgroundMove 30s ease-in-out infinite alternate;
}

.main-title {
    text-align: center;
    font-family: 'Mountains of Christmas', cursive;
    font-size: 4.5rem;
    text-transform: uppercase;
    margin-bottom: 20px;
    z-index: 10;
    position: relative; /* Ajustado para que fluya con el contenido */
    width: 80%; /* Mismo ancho que el contador */
    max-width: 1000px;
    
    /* Animación de luces */
    animation: falloElectrico 5s infinite;
}

@keyframes falloElectrico {
    0%, 19.9%, 22%, 62.9%, 64%, 64.9%, 70%, 100% {
        opacity: 1;
        text-shadow: 0 0 10px #fff, 0 0 20px #ff0000, 0 0 40px #ff0000;
    }
    20%, 21.9%, 63%, 63.9%, 65%, 69.9% {
        opacity: 0.3;
        text-shadow: none;
    }
}

@keyframes backgroundMove {
    0% { transform: scale(1.1); }
    100% { transform: scale(1.2) translate(-20px, -10px); }
}

/* Ajuste para móviles */
@media (max-width: 768px) {
    .main-title {
        font-size: 2rem;
        top: 5%;
    }
}



@keyframes twinkle {
    from { opacity: 0.5; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1.1); }
}

/* --- RELOJ (80% DE ANCHO) --- */
/* Contenedor principal adaptable */
.countdown-container {
    width: 80%; /* Tu requerimiento del 80% */
    max-width: 1000px;
    display: flex;
    flex-wrap: wrap; /* Permite que los elementos salten de línea en móviles */
    justify-content: center;
    gap: 20px; /* Espacio entre los bloques del reloj */
    z-index: 10;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 30px 10px;
    border-radius: 20px;
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: relative; /* Necesario para posicionar la nieve encima */
}

/* Cada bloque (Días, Horas, etc.) */
.countdown-item {
    flex: 1 1 150px; /* Crece y se encoge, pero intenta mantener 150px de base */
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Los números grandes */
.countdown-item span:first-child {
    display: block;
    font-size: clamp(3rem, 8vw, 6rem); /* Tamaño dinámico: min 3rem, max 6rem */
    font-weight: 900;
    line-height: 1;
}

/* Colores individuales para los números */
.countdown-item:nth-child(1) span:first-child { color: #ff4d4d; } /* Días: Rojo */
.countdown-item:nth-child(2) span:first-child { color: #00ff00; } /* Horas: Verde */
.countdown-item:nth-child(3) span:first-child { color: #ffd700; } /* Minutos: Dorado */
.countdown-item:nth-child(4) span:first-child { color: #f07807; } /* Segundos: Rojo */

/* Las etiquetas (Días, Horas...) */
.countdown-item .label {
    display: block;
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    text-transform: uppercase;
    margin-top: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    color: #eee;
}

/* --- AJUSTES ESPECÍFICOS PARA MÓVILES --- */
@media (max-width: 600px) {
    .countdown-container {
        width: 90%; /* Un poco más ancho en pantallas muy pequeñas */
        padding: 20px 5px;
    }
    
    .countdown-item {
        flex: 1 1 40%; /* Dos elementos por fila en móviles */
    }

    .main-title {
        font-size: 1.8rem; /* Título más pequeño para que no se corte */
        padding: 0 10px;
        width: 90%; /* Ajuste para coincidir con el contador en móviles */
    }
}
/* --- COPOS DE NIEVE --- */
.snowflake {
    position: fixed;
    top: -10px;
    color: white;
    user-select: none;
    z-index: 20;
    pointer-events: none;
    animation: fall linear forwards;
}

@keyframes fall {
    to { transform: translateY(105vh) rotate(360deg); }
}

#music-control {
    position: fixed;
    top: 100px;
    right: 20px; /* Aumentado para dar espacio y evitar que se monten */
    z-index: 100;
    cursor: pointer;
    border: none;
    color: white;
    font-size: 1.5rem;
    backdrop-filter: blur(5px);
    background: rgba(255, 255, 255, 0.2);
    padding: 10px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s;
}

#music-control:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.4);
}

/* Animación de onda expansiva */
@keyframes ripple {
    0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
    100% { box-shadow: 0 0 0 20px rgba(255, 255, 255, 0); }
}

.tick-pulse {
    animation: ripple 0.5s linear;
}

/* Partículas musicales */
.music-particle {
    position: fixed;
    color: #ffd700; /* Dorado */
    font-weight: bold;
    pointer-events: none;
    z-index: 99;
    animation: floatMusic 1.5s ease-out forwards;
}

@keyframes floatMusic {
    0% { transform: translate(-50%, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--tx)), -60px) rotate(var(--rot)); opacity: 0; }
}

/* Brillo cuando suena la música */
.music-playing {
    box-shadow: 0 0 15px #ffd700;
    animation: musicGlow 1.5s infinite alternate;
}

@keyframes musicGlow {
    from { box-shadow: 0 0 5px #ffd700; }
    to { box-shadow: 0 0 20px #ffd700, inset 0 0 10px rgba(255, 215, 0, 0.3); }
}



.snow-ground {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: white;
    box-shadow: 0 -10px 20px white; /* Resplandor de nieve */
    border-radius: 50% 50% 0 0 / 10px 10px 0 0; /* Curvatura suave */
    z-index: 6; /* Delante del muñeco de nieve */
}

/* --- MUÑECO DE NIEVE --- */
.snowman {
    position: fixed;
    bottom: 25px; /* Justo encima del suelo */
    right: 10%;   /* Posicionado a la derecha */
    width: 120px;
    height: 160px;
    z-index: 5;
    animation: sway 3s infinite ease-in-out alternate;
    cursor: pointer;
}

.body-bottom, .body-middle, .head {
    background: white;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: inset -5px -5px 10px rgba(0,0,0,0.1); /* Sombra interna para volumen */
}

.body-bottom {
    width: 80px;
    height: 80px;
    bottom: 0;
}

.body-middle {
    width: 60px;
    height: 60px;
    bottom: 55px;
    z-index: 1;
}

.head {
    width: 45px;
    height: 45px;
    bottom: 100px;
    z-index: 2;
}

.eye {
    width: 5px;
    height: 5px;
    background: black;
    border-radius: 50%;
    position: absolute;
    top: 15px;
    animation: blink 4s infinite;
}

.eye.left { left: 12px; }
.eye.right { right: 12px; }

.nose {
    width: 0;
    height: 0;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 12px solid orange; /* Zanahoria apuntando a la derecha */
    position: absolute;
    top: 22px;
    left: 50%;
}

.hat {
    width: 35px;
    height: 25px;
    background: #333;
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
}

.hat::after {
    content: '';
    width: 50px;
    height: 5px;
    background: #333;
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 2px;
}

.scarf {
    width: 50px;
    height: 12px;
    background: #d32f2f; /* Rojo navideño */
    position: absolute;
    bottom: 92px; /* Altura del cuello */
    left: 50%;
    transform: translateX(-50%);
    border-radius: 10px;
    z-index: 3; /* Encima del cuerpo */
}

.scarf::after {
    content: '';
    width: 15px;
    height: 35px;
    background: #d32f2f;
    position: absolute;
    top: 5px;
    right: 5px;
    border-radius: 5px;
    transform: rotate(-5deg);
    transform-origin: top center; /* Pivote arriba para que oscile desde el cuello */
    animation: wind 2s infinite ease-in-out alternate; /* Animación de viento */
}

/* Botones del muñeco */
.button {
    width: 8px;
    height: 8px;
    background: #222;
    border-radius: 50%;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2; /* Encima del cuerpo */
}

.button.top { bottom: 85px; }
.button.middle { bottom: 65px; }
.button.bottom { bottom: 45px; }

.arm {
    width: 40px;
    height: 3px;
    background: #5c4033; /* Color rama */
    position: absolute;
    top: 80px;
}

.arm.left { left: -20px; transform: rotate(20deg); }
.arm.right { 
    right: -20px; 
    transform: rotate(-20deg); 
    transform-origin: left center; /* Pivote en el hombro */
}

/* Animación de saludo */
.snowman.waving .arm.right {
    animation: wave 0.5s ease-in-out 3; /* Saluda 3 veces */
}

/* --- BOCADILLO DE TEXTO --- */
.speech-bubble {
    position: absolute;
    top: -50px; /* Encima del sombrero */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 8px 12px;
    border-radius: 12px;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    color: #333;
    font-weight: bold;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid white;
}

.speech-bubble.visible {
    opacity: 1;
}

@keyframes sway {
    0% { transform: rotate(-3deg); }
    100% { transform: rotate(3deg); }
}

@keyframes wave {
    0%, 100% { transform: rotate(-20deg); }
    50% { transform: rotate(-80deg); } /* Levanta el brazo */
}

@keyframes wind {
    0% { transform: rotate(-5deg); }
    100% { transform: rotate(15deg); }
}

@keyframes blink {
    0%, 96%, 100% { height: 5px; top: 15px; }
    98% { height: 1px; top: 17px; }
}

@media (max-width: 600px) {
    .snowman {
        transform: scale(0.7); /* Más pequeño en móviles */
        right: 5%;
        bottom: 15px;
    }
}

/* Animación de rebote para los números */
@keyframes bounceNum {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.bounce {
    animation: bounceNum 0.3s ease-out;
}

/* Botón de control del Tic-Tac */
#tick-control {
    position: fixed;
    top: 25px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: white;
    z-index: 100;
    backdrop-filter: blur(5px);
}

#tick-control:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.4);
}