/* --- VARIABLES DE DISEÑO --- */
:root {
    --bg-color: #0f172a; /* Azul oscuro profundo */
    --text-color: #e2e8f0; /* Gris claro para texto */
    --primary-color: #3b82f6; /* Azul brillante */
    --secondary-color: #1e293b; /* Gris azulado oscuro */
    --accent-color: #ef4444; /* Rojo vibrante para selección */
    --shadow-light: 0 4px 10px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.5);
    --cell-size: 30px; 
}

/* Paleta de colores para palabras encontradas */
.color-found-0 { background-color: #22c55e !important; color: white !important; box-shadow: 0 0 15px #22c55e !important; } 
.color-found-1 { background-color: #f97316 !important; color: white !important; box-shadow: 0 0 15px #f97316 !important; } 
.color-found-2 { background-color: #a855f7 !important; color: white !important; box-shadow: 0 0 15px #a855f7 !important; } 
.color-found-3 { background-color: #14b8a6 !important; color: white !important; box-shadow: 0 0 15px #14b8a6 !important; } 
.color-found-4 { background-color: #facc15 !important; color: #0f172a !important; box-shadow: 0 0 15px #facc15 !important; } 
.color-found-5 { background-color: #e11d48 !important; color: white !important; box-shadow: 0 0 15px #e11d48 !important; } 
.color-found-6 { background-color: #06b6d4 !important; color: white !important; box-shadow: 0 0 15px #06b6d4 !important; } 
.color-found-7 { background-color: #84cc16 !important; color: white !important; box-shadow: 0 0 15px #84cc16 !important; } 
.color-found-8 { background-color: #4f46e5 !important; color: white !important; box-shadow: 0 0 15px #4f46e5 !important; } 
.color-found-9 { background-color: #ca8a04 !important; color: white !important; box-shadow: 0 0 15px #ca8a04 !important; } 

/* --- ANIMACIONES GLOBALES --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilo inicial para elementos que se revelan al hacer scroll */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    /* CAMBIO: Duración de la transición a 2 segundos */
    transition: opacity 2s ease-out, transform 2s ease-out;
}

/* Estilo cuando el elemento entra en el viewport */
.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}
/* ------------------------------------ */

/* --- ESTILOS BASE --- */
body {
    font-family: "Poppins", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    user-select: none;
    overflow-x: hidden; 
    position: relative;
}

/* EFECTO DE FONDO GRADIENTE */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.1) 0%, transparent 30%),
                radial-gradient(circle at bottom right, rgba(239, 68, 68, 0.1) 0%, transparent 30%);
    animation: bg-fade 15s infinite alternate ease-in-out;
    z-index: -1;
}

@keyframes bg-fade {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}


h1 {
    font-size: 3em;
    color: var(--primary-color);
    text-shadow: var(--shadow-hover);
    margin-bottom: 25px;
    letter-spacing: 2px;
    animation: bounceIn 1s ease-out;
    cursor: pointer; 
    transition: color 0.3s ease; 
}

/* EFECTO HOVER DEL TÍTULO */
h1:hover {
    color: #22c55e; 
}

@keyframes bounceIn {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

/* --- VISTAS GLOBALES --- */
#selection-view {
    width: 100%;
    max-width: 1200px;
    display: none; 
    flex-direction: column;
    align-items: center;
    padding: 10px;
    margin-bottom: 50px; 
}

#game-view {
    display: none; 
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-top: 20px;
    position: relative;
}

/* --- SECCIÓN DE TEMAS Y BÚSQUEDA --- */
.sub-header {
    /* Nueva animación de scroll reveal aplicada aquí (ver HTML) */
    text-align: center;
}

#search-bar-container {
    width: 100%;
    max-width: 450px;
    margin-bottom: 30px;
    /* Nueva animación de scroll reveal aplicada aquí (ver HTML) */
}

#search-input {
    width: 100%;
    padding: 12px 20px;
    border-radius: 30px;
    border: 2px solid var(--primary-color);
    background-color: var(--secondary-color);
    color: var(--text-color);
    font-size: 1.1em;
    outline: none;
    transition: border-color 0.3s ease;
    text-align: center;
}
#search-input:focus {
    border-color: #22c55e;
}

#topics-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    min-height: 50px; 
}

/* Botones con ruteo # */
.topic-btn {
    text-decoration: none; 
    background: var(--secondary-color);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 30px;
    padding: 10px 22px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
    text-transform: capitalize;
    
    /* ANIMACIÓN DE ENTRADA ESCALONADA */
    opacity: 0; /* Oculta por defecto para la animación */
    animation: fadeInUp 0.5s ease-out forwards;
}

.topic-btn.hidden { 
    display: none;
    /* Al estar oculto, la animación no se aplica o se pausa */
}

/* Aseguramos que la opacidad del .topic-btn es 1 si ya terminó la animación */
.topic-btn[style*="animation-delay"] {
    /* Este selector ayuda a que la animación se aplique correctamente con el JS */
    opacity: 0; 
}

.topic-btn:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-3px) scale(1.02);
    box-shadow: var(--shadow-hover);
}

/* --- CRONÓMETRO --- */
#timer-display {
    font-size: 1.5em;
    font-weight: bold;
    color: #22c55e; 
    margin-bottom: 10px;
    padding: 5px 15px;
    background-color: var(--secondary-color);
    border-radius: 8px;
    box-shadow: var(--shadow-light);
    min-width: 120px; 
    text-align: center;
}

/* --- GRIDO Y CELDAS --- */
#grid-wrapper {
    width: 100%; 
    display: flex;
    justify-content: center;
    overflow: hidden; 
}

#grid {
    display: grid;
    gap: 3px;
    justify-content: center;
    margin-top: 20px;
    border-radius: 12px;
    padding: 8px;
    background: rgba(30, 41, 59, 0.7);
    box-shadow: var(--shadow-hover);
    width: max-content; 
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background-color: var(--secondary-color);
    color: var(--text-color);
    text-transform: uppercase;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1em; 
    border-radius: 6px; 
    cursor: pointer;
    transition: all 0.2s ease, background-color 0.8s;
}

.cell:hover {
    background-color: rgba(59, 130, 246, 0.7);
    transform: scale(1.1) translateY(-2px);
    z-index: 2;
}

.cell.selected {
    background-color: var(--accent-color);
    transform: scale(1.1);
    box-shadow: 0 0 15px var(--accent-color);
}

/* --- LISTA DE PALABRAS --- */
#word-list {
    margin-top: 30px;
    text-align: center;
    max-width: 800px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 10px;
}

.word {
    display: inline-block;
    background: var(--secondary-color);
    padding: 8px 15px;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.3s ease;
    color: var(--text-color);
    box-shadow: var(--shadow-light);
    cursor: default;
}

.word.found {
    text-decoration: line-through;
    opacity: 0.8;
    transform: scale(1.05);
    box-shadow: var(--shadow-hover);
}

/* Contenedor del anuncio */
.ads-container {
    width: 100%;
    max-width: 728px; 
    margin: 30px auto;
    text-align: center;
}

/* --- PANTALLA DE VICTORIA --- */
#win-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9); 
    display: none; 
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 500;
    backdrop-filter: blur(8px); 
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

#win-content {
    background: var(--secondary-color);
    padding: 40px 60px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: scale(0.9);
    animation: zoomIn 0.5s forwards 0.3s ease-out;
}

@keyframes zoomIn {
    to { transform: scale(1); }
}

#win-screen h2 {
    font-size: 2.5em;
    color: var(--primary-color);
    margin-bottom: 5px;
}

/* ESTILOS DEL TIEMPO FINAL */
#final-time-display {
    margin: 20px 0 10px 0;
    padding: 15px 30px;
    background: #0f172a; 
    border: 3px solid #22c55e;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
}

#final-time {
    font-size: 3em; 
    font-weight: 700;
    color: #22c55e; 
    text-shadow: 0 0 5px rgba(34, 197, 94, 0.8);
}

/* --- ESTILOS DE MEJOR TIEMPO --- */
#best-time-display {
    margin: 10px 0 25px 0;
    padding: 10px 20px;
    background: var(--secondary-color); 
    border: 2px dashed var(--primary-color); 
    border-radius: 8px;
}

#best-time {
    font-size: 2em; 
    font-weight: 700;
    color: var(--primary-color); 
}

#record-status {
    font-size: 1.2em;
    font-weight: bold;
    margin-top: 5px;
}

.new-record-status {
    color: #facc15 !important; /* Amarillo para Récord */
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.7);
}

.old-record-status {
    color: #94a3b8; /* Gris suave para Récord no superado */
}
/* ------------------------------------------- */


/* ESTILOS DEL BOTÓN DE ACCIÓN */
.action-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 30px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-hover);
}

.action-btn:hover {
    background: #22c55e;
    transform: scale(1.05);
}


/* --- FOOTER Y SECCIÓN DE INFORMACIÓN (MODIFICADO) --- */
footer {
    width: 100%;
    max-width: 1000px;
    padding: 15px 0;
    margin-top: 50px; 
    border-top: 1px solid var(--secondary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    /* La clase .scroll-reveal se aplicará en el HTML */
}

.footer-button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px; 
    margin: 15px 0;
}

.footer-toggle-btn {
    background: var(--secondary-color);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s, color 0.3s;
    font-weight: 600;
}

.footer-toggle-btn:hover {
    background: var(--primary-color);
    color: white;
}

/* Estilos genéricos para las secciones colapsables (info, creador, donaciones) */
.collapsible-section {
    max-width: 800px;
    margin: 10px auto 20px auto; 
    padding: 0 20px; 
    background: var(--secondary-color);
    border-radius: 15px;
    box-shadow: var(--shadow-hover);
    text-align: left;
    overflow: hidden;
    max-height: 0; 
    /* Transición más suave para el colapso */
    transition: max-height 0.5s ease-in-out, padding 0.5s ease-in-out, opacity 0.5s; 
}

.collapsible-section.expanded {
    max-height: 500px; /* Suficiente para contener el contenido */
    padding: 20px; 
    border: 1px solid var(--primary-color);
}

.collapsible-section h3 {
    color: var(--primary-color);
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 5px;
    margin-top: 10px;
    margin-bottom: 15px;
    text-align: center;
}
.collapsible-section ul {
    list-style-type: '👉 ';
    padding-left: 20px;
    margin-bottom: 15px;
}

/* --- Estilos Específicos de Creador y Donaciones --- */
.creator-text {
    margin-bottom: 15px;
    text-align: center;
}

/* Enlaces sociales */
.social-links {
    margin: 20px 0 10px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
}

.social-btn {
    display: flex; /* Alinea el ícono y el texto */
    align-items: center; /* Alinea verticalmente */
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

/* Estilo para el ícono dentro del botón */
.social-btn i {
    margin-right: 8px; /* Espacio entre el ícono y el texto */
    font-size: 1.1em;
}

.instagram-btn {
    background-color: #E1306C; /* Instagram */
    color: white;
    border: 2px solid #E1306C;
}

.instagram-btn:hover {
    background-color: transparent;
    color: #E1306C;
    transform: translateY(-3px);
}

.linkedin-btn {
    background-color: #0A66C2; /* LinkedIn */
    color: white;
    border: 2px solid #0A66C2;
}

.linkedin-btn:hover {
    background-color: transparent;
    color: #0A66C2;
    transform: translateY(-3px);
}

/* Donaciones */
.donation-text {
    font-style: italic;
    margin: 10px 0 20px 0;
    color: #22c55e;
    font-size: 1.05em;
    text-align: center;
}

.donation-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-color);
    border: 1px dashed var(--text-color);
    border-radius: 10px;
}

.donation-alias, .donation-paypal {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.donation-label {
    font-weight: 400;
    color: var(--primary-color);
    font-size: 0.9em;
}

.donation-value {
    font-weight: 700;
    font-size: 1.2em;
    color: var(--text-color);
    padding: 5px 10px;
    background: var(--secondary-color);
    border-radius: 5px;
    margin-top: 5px;
    word-break: break-all;
}

/* Media Queries */
@media (max-width: 768px) {
    h1 { font-size: 2em; }
    .cell {
        width: 25px;
        height: 25px;
        font-size: 0.8em;
    }
    :root { --cell-size: 25px; }
}

@media (max-width: 480px) {
    h1 { font-size: 1.5em; margin-bottom: 15px; }
    .topic-btn { padding: 6px 12px; font-size: 0.8em; }
    .cell {
        width: 22px;
        height: 22px;
        font-size: 0.7em;
    }
    :root { --cell-size: 22px; }

    .footer-button-group {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }
    .footer-toggle-btn {
        width: 100%;
        box-sizing: border-box;
    }
    .social-links {
        flex-direction: column;
    }
    .social-btn {
        width: 100%;
        box-sizing: border-box;
        justify-content: center; /* Centrar el contenido en móvil */
    }
    .collapsible-section.expanded {
        padding: 15px;
    }
}