body {
    font-family: 'Inter', sans-serif;
    touch-action: manipulation;
}
.font-fredoka {
    font-family: 'Fredoka One', cursive;
}

/* ▼▼▼ ESTILOS PARA EL NUEVO COLOR PICKER (PICKR) ▼▼▼ */
.pcr-button {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    border: 2px solid #ddd;
}
html.dark .pcr-button {
     border-color: #4a5568;
}

/* ▲▲▲ FIN DE ESTILOS PARA PICKR ▲▲▲ */
.game-grid {
    display: grid;
    gap: 5px; /* <- ESTE ES EL GAP HORIZONTAL (COLUMNAS) */
    padding: 10px;
    border-radius: 16px; 
    box-shadow: 0 10px 20px rgba(0,0,0,0.1), inset 0 0 10px rgba(0,0,0,0.2);
    overflow: hidden; 
    position: relative;

    /* ▼▼▼ ESTILOS RESTAURADOS Y PREPARACIÓN PARA EL BORDE DINÁMICO ▼▼▼ */
    --progress-color: var(--grid-border-color, #FFD700); /* Define el color */

    --sprite-atlas: none;
    z-index: 2;
    background: transparent !important; 
}



/* ▼▼▼ ¡REGLA DE PSEUDO-ELEMENTO MODIFICADA! ▼▼▼ */
.game-grid::after {
    content: '';
    position: absolute;
    /* Se ajusta perfectamente al interior del borde transparente del .game-grid.
       Si .game-grid tiene padding, este se quedará por dentro. */
    top: 0; 
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    
    /* 1. Hereda el radio del borde para ser redondeado */
    border-radius: 16px; /* Importante: el mismo valor que en .game-grid */
    
    /* 2. El borde del pseudo-elemento ES EL VISIBLE */
    border: 8px solid transparent; /* El mismo grosor del borde de .game-grid */
    
    /* 3. Usa 'border-image' para crear el gradiente de progreso */
    border-image-source: linear-gradient(
        45deg, /* Tu ángulo de 45 grados */
        var(--progress-color) var(--jelly-progress), /* La parte "llena" */
        transparent var(--jelly-progress)             /* La parte "vacía" */
    );
    
    /* 4. Configuración para que el gradiente funcione en las 4 caras */
    border-image-slice: 1; 
    border-image-width: 8px; /* Debe coincidir con el 'border' de .game-grid */
    border-image-repeat: stretch;
    
    z-index: 3; /* Se asegura que esté por encima del fondo del tablero */
}

.game-grid::before {
    content: ''; /* Requerido para que el pseudo-elemento se muestre */
    position: absolute;
    z-index: -1; /* Lo coloca detrás del tablero */

    /* Se expande 12px más allá del tablero en todas las direcciones */
    top: -12px;
    left: -12px;
    right: -12px;
    bottom: -12px;

    /* ▼▼▼ LÍNEA MODIFICADA ▼▼▼ */
    /* Ahora usa una variable. Si la variable no está definida, usa grid_1.png como respaldo. */
    background: var(--grid-texture-url, none);
    
    /* Este es el radio exterior y final del borde */
    border-radius: 24px; 
}

.candy {
    border-radius: 8px;
    user-select: none;
    /* width: 100%; */ /* <-- ELIMINA O COMENTA ESTA LÍNEA */
    flex-shrink: 0; 
    box-shadow: inset 0 -4px rgba(0,0,0,0.15);
    transition: transform 0.3s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 1;
    
    aspect-ratio: 1 / 1;
    max-width: 100%;
     
    /* --- CAMBIOS PARA USAR SPRITES --- */
    background-image: var(--sprite-atlas);
    background-repeat: no-repeat;
    background-size: 300% 300%; 
    font-size: 0;
    will-change: transform;
}

/* --- NUEVAS CLASES PARA CADA SPRITE --- */
/* Estas posiciones corresponden a una grilla 3x3. 
   (columna, fila) -> (0% 0%), (50% 0%), (100% 0%), etc. */

/* Fila 1 */
.sprite-strawberry { background-position: 0% 0%; }
.sprite-grape      { background-position: 50% 0%; }
.sprite-orange     { background-position: 100% 0%; }

/* Fila 2 */
.sprite-lemon      { background-position: 0% 50%; }
.sprite-cherry     { background-position: 50% 50%; }
.sprite-kiwi       { background-position: 100% 50%; }

/* Fila 3 (Boosters) */
.sprite-striped    { background-position: 0% 100%; }
.sprite-wrapped    { background-position: 50% 100%; }


.candy.inactive {
    opacity: 0;
    pointer-events: none;
}
/* Estilos para Boosters (conservamos los bordes) */
.striped-h, .striped-v {
    border: 3px dashed white;
}
.wrapped {
    border: 3px solid white;
    animation: wrapped-pulse 1.5s infinite;
}
@keyframes wrapped-pulse {
    0% { box-shadow: 0 0 10px 0px rgba(255,255,255,0.5); }
    50% { box-shadow: 0 0 15px 5px rgba(255,255,255,0.8); }
    100% { box-shadow: 0 0 10px 0px rgba(255,255,255,0.5); }
}
.mode-selector button.active {
    background-color: #ec4899; /* pink-500 */
    color: white;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
.stopping, .swapping {
    animation: stop-bounce 0.3s ease-out;
}
@keyframes stop-bounce {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
.highlight {
    animation: highlight-pulse 0.4s ease-out;
}
@keyframes highlight-pulse {
    50% { 
        transform: scale(1.2);
        filter: brightness(1.5) drop-shadow(0 0 5px white); 
    }
}
.explode {
    animation: explode-effect 0.4s ease-in forwards;
}
@keyframes explode-effect {
    0% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}
.shockwave {
    animation: shockwave-effect 0.4s ease-out;
}
@keyframes shockwave-effect {
    50% { transform: translate(var(--shock-x, 0), var(--shock-y, 0)); }
    100% { transform: translate(0, 0); }
}
.fall {
    animation: fall 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes fall {
    from { transform: translateY(-200%); }
    to { transform: translateY(0); }
}
.selection-box {
    position: absolute;
    
    border: 3px solid #f472b6; /* pink-400 */
    border-radius: 12px;
    z-index: 10;
    pointer-events: none;

    /* ▼▼▼ LÍNEAS AÑADIDAS ▼▼▼ */
    margin-top: -5px;  /* Ajusta este valor */
    margin-left: -5px; /* Ajusta este valor */
    /* ▲▲▲ FIN DE LÍNEAS AÑADIDAS ▲▲▲ */
    
    box-shadow: 0 0 15px 5px rgba(244, 114, 182, 0.7); /* Sombra del mismo color */
    transition: opacity 0.3s ease;
    animation: highlight-pulse 0.7s ease-in-out;
}
.combo-box {
    position: absolute;
    border: 3px solid #fde047; /* yellow-300 */
    
    border-radius: 12px;
    z-index: 10;
    pointer-events: none;

    /* ▼▼▼ AÑADE ESTAS LÍNEAS AQUÍ TAMBIÉN ▼▼▼ */
    margin-top: -5px;
    margin-left: -5px;
    
    box-shadow: 0 0 15px 5px rgba(253, 224, 71, 0.7);
    transition: opacity 0.3s ease;
    /* Reutilizamos la misma animación de pulso */
    animation: highlight-pulse 0.7s ease-in-out;
}

.booster-box {
    position: absolute;
    /* Un color naranja/ámbar brillante para boosters */
    border: 3px solid #f59e0b; /* amber-500 */
    border-radius: 12px;
    z-index: 10;
    pointer-events: none;

    /* ▼▼▼ Y AQUÍ TAMBIÉN ▼▼▼ */
    margin-top: -5px;
    margin-left: -5px;

    box-shadow: 0 0 15px 5px rgba(245, 158, 11, 0.7); /* Sombra del mismo color */
    transition: opacity 0.3s ease;
    animation: highlight-pulse 0.7s ease-in-out;
}
.win-modal {
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}
.jelly-grid {
    position: absolute;
    top: 10px; right: 10px; bottom: 10px; left: 10px;
    display: grid;
    gap: 5px; /* <- ESTE ES EL GAP HORIZONTAL (COLUMNAS) */
    pointer-events: none;
    z-index: 1;
    background-size: cover;
    background-position: center;
}
.jelly-cell {
    background-color: transparent; 
    background-image: url('assets/jelly.png');
    background-size: 100% 100%; /* ►►► CAMBIA 'cover' POR ESTO */
    background-position: center;
    background-repeat: no-repeat; /* ►►► AÑADE ESTA LÍNEA */
    border-radius: 8px;
    transition: opacity 0.5s ease;
    opacity: 1;
}

.jelly-cell.double-locked {
    background-image: none;
}
.jelly-cell.inactive {
    background-image: none;
    /* Mantenemos el fondo de hielo/piedra normal si lo deseas, */
    /* pero la imagen de "bloqueo" principal debe irse. */
    /* Por ejemplo, si 'inactive' es el hielo: */
    background-image: url('assets/piedra_bloqueo.png');
    background-color: transparent;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 1;
}
.jelly-cell.inactive {
     background-image: none;
}
/* Nuevo estado para cuando la gelatina ha sido eliminada */
.jelly-cell.cleared {
    opacity: 0; /* Hacemos la gelatina invisible */
    pointer-events: none; /* Evita interacciones con la celda invisible */
}
.jelly-cell.combo-highlight {
    /* Esta animación resalta la celda DEBAJO del dulce */
    animation: jelly-combo-flash 0.6s ease-out;
}

@keyframes jelly-combo-flash {
    50% {
        /* Un flash amarillo brillante y fuerte */
        background-color: rgba(253, 224, 71, 0.9); /* yellow-300 con opacidad */
        box-shadow: 0 0 20px 10px rgba(253, 224, 71, 0.7);
    }
    /* Al terminar, vuelve automáticamente a su estado transparente por defecto */
}

@keyframes jelly-pulse {
    0%, 100% {
        /* Sombra interior sutil, color amarillo-blanco */
        box-shadow: inset 0 0 8px 2px rgba(255, 255, 200, 0.7);
    }
    50% {
        /* Sombra interior brillante e intensa */
        box-shadow: inset 0 0 20px 10px rgba(255, 255, 220, 1);
    }
}

/* Clase para aplicar la animación a las últimas gelatinas */
.jelly-cell.jelly-highlight-pulse {
    /* Ejecuta la animación 'jelly-pulse' durante 1.2 segundos,
       con calma (ease-in-out) y en bucle infinito */
    animation: jelly-pulse 1.2s ease-in-out infinite;
    
    /* Asegura que el brillo se vea por encima de la imagen de gelatina */
    z-index: 2; 
}
/* ▼▼▼ ESTILOS PARA LA RULETA (MODIFICADOS) ▼▼▼ */
.roulette-container {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}
.roulette-container.visible {
    opacity: 1;
    pointer-events: all;
}
.roulette-wheel {
    width: 80%;
    height: 80%;
    background-color: #fff;
    border-radius: 50%;
    border: 10px solid #fef08a; /* yellow-200 */
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transition: transform 4s cubic-bezier(0.25, 1, 0.5, 1);
}
.roulette-section {
    position: absolute;
    width: 50%;
    height: 50%;
    background-color: var(--bg);
    transform-origin: 100% 100%;
    transform: rotate(calc(72deg * var(--i)));
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 0);
    display: flex;
    align-items: center;
    justify-content: center;
    /* Borde sutil para separar secciones */
    border-right: 1px solid rgba(0,0,0,0.1);
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.combo-indicator-img {
  width: 48px;  /* <-- Puedes seguir ajustando el tamaño aquí */
  height: 48px; /* <-- Y aquí también */
  object-fit: contain;
}
/* AJUSTES PARA QUE EL TEXTO DE LA RULETA SE VEA BIEN */
.roulette-section span {
    display: block;
    /* ▼▼▼ AJUSTE PARA CENTRAR MEJOR EL TEXTO Y EVITAR QUE SE CORTE ▼▼▼ */
    transform: rotate(45deg) translate(-15%, -65%);
    color: white;
    font-weight: bold;
    font-size: 1.8rem; /* Texto más grande y legible */
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7); /* Sombra más fuerte */
    user-select: none;
}
.roulette-pointer {
    position: absolute;
    top: calc(50% - 30px);
    left: calc(50% - 20px);
    width: 40px;
    height: 40px;
    background-color: #ef4444; /* red-500 */
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    transform: translateY(-100%);
    z-index: 60;
    border-bottom: 5px solid #b91c1c; /* red-700 */
}
/* ▲▲▲ FIN DE ESTILOS DE RULETA ▲▲▲ */

/* ▼▼▼ ESTILOS PARA LA BARRA DE MODO ▼▼▼ */
.mode-indicator {
    height: 64px; /* 🎨 Aumentamos la altura fija para imágenes más grandes */
    padding: 0; /* Eliminamos padding para un control total */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease-in-out, background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden; /* ¡Esencial! Oculta el resto del carrete */
    position: relative; 
}
.mode-indicator img {
    height: 48px; /* 🎨 Tamaño de la imagen, un poco más pequeña que el contenedor */
    width: 48px;
    object-fit: contain; /* Asegura que la imagen no se deforme */
}
.mode-indicator.active {
    background-color: var(--active-mode-bg, #ec4899);
    color: white;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    font-weight: bold;
}
/* ▼▼▼ NUEVOS ESTILOS PARA TRAGAPERRAS Y CARRUSEL ▼▼▼ */
.mode-indicator .slot-reel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transition: transform 0.2s cubic-bezier(0.33, 1, 0.68, 1);
}
/* <-- INICIO: CORRECCIÓN PARA EL ESPACIADO DEL TEXTO --> */
.mode-indicator .slot-reel div {
    height: 64px; /* ⚙️ ¡Clave! Debe coincidir exactamente con la altura de .mode-indicator */
    display: flex;
    align-items: center;
    justify-content: center;
}
/* <-- FIN: CORRECCIÓN --> */
.mode-indicator.is-spinning .slot-reel {
    animation: slot-spin 0.2s linear infinite;
}
@keyframes slot-spin {
    from { transform: translateY(0); }
    to { transform: translateY(-100%); } /* El 100% se refiere a la altura del propio reel */
}

/* --- ESTILOS PARA CARRUSEL --- */
.carousel-flash {
    animation: carousel-flash-effect 0.1s ease-out;
}
@keyframes carousel-flash-effect {
    50% { 
        transform: scale(1.1);
        background-color: #fbcfe8; /* pink-100 */
    }
}
/* ▲▲▲ FIN DE NUEVOS ESTILOS ▲▲▲ */

.combo-status-button {
    background-color: #f5f3ff; /* Un color violeta muy claro, similar al fondo */
    border: 2px solid #a78bfa; /* Borde violeta */
    color: #6d28d9; /* Ícono violeta */
    border-radius: 0.75rem; /* 12px */
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem; /* 24px */
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    transition: all 0.2s ease-in-out;
}

/* Estado "presionado" del botón */
.combo-status-button.active {
    background-color: #8b5cf6; /* Color violeta más oscuro */
    color: #ffffff; /* Ícono blanco */
    transform: scale(0.95); /* Ligeramente más pequeño */
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.2); /* Sombra interior para efecto presionado */
}

#renderCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100; /* MODIFICADO: Asegura que las partículas estén encima de todo */
    pointer-events: none; /* Permite hacer clic a través del canvas */
    background-color: transparent; /* Fondo transparente */
}

/* --- NEW RESPONSIVE LAYOUT FOR CONTROLS --- */

#controls-container {
    display: flex;
    flex-wrap: wrap; /* Allows items to wrap to the next line */
    justify-content: center; /* Center items horizontally */
    align-items: center;
    gap: 16px; /* Adds space between items */
    width: 100%;
}

#booster-alarm-img {
    width: 70px; /* Tamaño pequeño por defecto */
    object-fit: contain;
}

#combo-status-img {
    width: 70px; /* Tamaño pequeño por defecto */
    object-fit: contain;
}

/* Wrapper for the central info panel */
#info-wrapper {
    width: 100%; /* Takes full width on small screens by default */
    max-width: 24rem; /* 384px, equivalent to w-96 */
    order: 1; /* Appears first on small screens */
}

/* Wrapper for the alarm image */
#alarm-wrapper {
    order: 2; /* Appears after info on small screens */
}

/* Wrapper for the combo button */
#button-wrapper {
    order: 3; /* Appears last on small screens */
}

@media (min-width: 534px) {
    #controls-container {
        flex-wrap: nowrap; /* Evita que se bajen de línea */
        
    }

    #info-wrapper {
        width: auto; /* Permite que se encoja */
        order: 2; /* Se mueve al medio */
        
    }

    #alarm-wrapper {
        order: 1; /* Se mueve a la izquierda */
    }

    #button-wrapper {
        order: 3; /* Se mantiene a la derecha */
    }
}

@media (min-width: 768px) {
    #controls-container {
        flex-wrap: nowrap; /* Prevents wrapping on wide screens */
        justify-content: space-between; /* Creates space around the center element */
    }

    /* ▼▼▼ MODIFICADO ▼▼▼ */
    /* Full size for alarm and button on wide screens */
    #booster-alarm-img {
        width: 140px; /* Tamaño base */
    }

    #combo-status-img {
        width: 140px; /* Mismo tamaño que la alarma */
    }
    /* ▲▲▲ FIN DE LA MODIFICACIÓN ▲▲▲ */

    #info-wrapper {
        width: auto; /* Allows it to shrink to its content's size */
        order: 2; /* Moves to the middle on wide screens */
        flex-grow: 1; /* Takes up the available space in the middle */
    }

    #alarm-wrapper {
        order: 1; /* Moves to the left on wide screens */
    }

    #button-wrapper {
        order: 3; /* Stays on the right on wide screens */
    }
}

:root {
    /* ... */
    /* Este es el valor base para pantallas normales */
    --base-board-size: min(90vmin, 600px); 
}

/* --- SHORT SCREEN LAYOUT (for smaller heights) --- */
/* This makes the info panel shorter when the screen height is limited */
@media (max-height: 700px) {
    #info-wrapper .py-2 {
        padding-top: 0.25rem; /* Reduces vertical padding */
        padding-bottom: 0.25rem;
    }
    #info-wrapper .mb-2 {
        margin-bottom: 0.25rem; /* Reduces vertical margin */
    }
    #info-wrapper #mode-indicator-bar {
        padding: 0.5rem; /* Reduces padding on the mode selector */
    }
}

/* ▼▼▼ ¡NUEVA SECCIÓN AÑADIDA! ▼▼▼ */
/* --- LAYOUT PARA PANTALLAS GRANDES (ESCRITORIO) --- */
@media (min-width: 2000px) {
    :root {
        /* Esto le dice a CSS que use 800px como base en pantallas grandes */
        /* ¡AHORA SÍ PUEDES CAMBIAR ESTE VALOR! */
        --base-board-size: min(90vmin, 950px); 
    }
}
/* ▲▲▲ ¡FIN DE LA SECCIÓN AÑADIDA! ▲▲▲ */


/* --- CHARACTER AND TITLE ANIMATIONS --- */

#character-container {
    --character-offset-y: -30px; /* Offset base del contenedor */
    
    /* ►►► NUEVO: Variable para el atlas del personaje (se establecerá en game.js) */
    --character-atlas: none; 

    top: var(--character-offset-y); 
    left: 50%;
    transform: translateX(-50%); /* Solo centra, ya no escala */
    z-index: 5;
    transition: top 0.3s ease;
    will-change: transform, opacity;
}

/* ►►► NUEVO: Estilos base para el personaje y el marco con sus propias variables */
#character-image, #character-frame {
    /* Aplicamos el atlas */
    background-image: var(--character-atlas);
    background-size: 200% 200%; /* Parrilla 2x2 */
    background-repeat: no-repeat;

    /* Variables para la escala y el offset individual */
    --base-scale: 1;
    --vertical-offset: 0px;
    
    /* Aplicamos la transformación individual */
    transform: translateY(var(--vertical-offset)) scale(var(--base-scale));
    
    /* Transición para la escala, pero NO para el background-position */
    transition: transform 0.3s ease, background-position 0s; 
}
.char-idle  { background-position: 0% 0%; }
/* (1,2) lose */
.char-lose  { background-position: 100% 0%; }
/* (2,1) win */
.char-win   { background-position: 0% 100%; }
/* (2,2) frame */
.char-frame { background-position: 100% 100%; }

#title-wrapper.move-up {
    transform: translateY(-80%) scale(0.5); 
    opacity: 0; 
}

#character-container.appear {
    animation: character-appear-anim 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ►►► MODIFICADO: La animación de aparición ahora solo afecta la opacidad y escala del contenedor */
@keyframes character-appear-anim {
    from {
        transform: translateX(-50%) scale(0.1);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) scale(1);
        opacity: 1;
    }
}

#character-image.win-anim {
    animation: character-win-anim 0.6s ease-in-out;
}

/* La animación de victoria sigue funcionando sobre la transformación base del personaje */
@keyframes character-win-anim {
    0%, 100% { 
        transform: translateY(var(--vertical-offset)) scale(var(--base-scale)) rotate(0); 
    }
    50% { 
        /* Se combina el offset base con el de la animación y se multiplica la escala */
        transform: translateY(calc(var(--vertical-offset) - 15px)) scale(calc(var(--base-scale) * 1.1)) rotate(5deg); 
    }
}

#character-image.lose-anim {
    animation: character-lose-anim 0.5s ease-in-out;
}

/* Esta animación no necesita cambios ya que es relativa */
@keyframes character-lose-anim {
    0%, 100% { transform: translateX(0) translateY(var(--vertical-offset)) scale(var(--base-scale)); }
    20% { transform: translateX(-5px) translateY(var(--vertical-offset)) scale(var(--base-scale)) rotate(-3deg); }
    40% { transform: translateX(5px) translateY(var(--vertical-offset)) scale(var(--base-scale)) rotate(3deg); }
    60% { transform: translateX(-5px) translateY(var(--vertical-offset)) scale(var(--base-scale)) rotate(-3deg); }
    80% { transform: translateX(5px) translateY(var(--vertical-offset)) scale(var(--base-scale)) rotate(3deg); }
}

/* --- LOADING OVERLAY STYLES --- */

#loading-overlay {
    transition: opacity 0.5s ease-out;

    /* ▼▼▼ LÍNEAS AÑADIDAS ▼▼▼ */
    background-image: url('assets/backgrounds/fondo_1.png'); /* ¡Cambia esta ruta! */
    background-size: cover;      /* Para que la imagen cubra toda la pantalla */
    background-position: center; /* Para centrar la imagen */
    background-repeat: no-repeat;/* Para que no se repita */
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none; /* Allows clicks to pass through while fading */
}

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Añade esta regla si no la tienes, o añade la propiedad si ya existe */
#mode-activation-area {
    cursor: pointer;
    /* ▼▼▼ AÑADE ESTA LÍNEA ▼▼▼ */
    user-select: none; /* Esto evita el highlight azul */
}

/* --- Animación para las tarjetas de modo --- */
@keyframes pulse-cards {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

/* Clase que aplicaremos con JS para activar la animación */
.pulse-animation .mode-indicator {
  animation: pulse-cards 0.4s ease-in-out;
}

/* --- Estilos para el botón de configuración colapsable --- */
#settings-button.collapsed {
    /* El botón mide 48px (p-2 + w-8 + p-2) */
    /* Lo movemos 32px a la derecha, dejando 16px visibles */
    transform: translateX(32px);
    
    /* Ajustamos el padding y el borde para que parezca un "handle" */
    padding-left: 0.25rem; /* p-1 */
    padding-right: 0.25rem; /* p-1 */
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Ocultar/mostrar el icono correcto */
#settings-button #settings-gear-icon {
    display: block;
    width: 2rem; /* h-8 w-8 */
    height: 2rem;
}
#settings-button #settings-arrow-icon {
    display: none;
    width: 1.5rem; /* h-6 w-6 */
    height: 1.5rem;
}

#settings-button.collapsed #settings-gear-icon {
    display: none;
}
#settings-button.collapsed #settings-arrow-icon {
    display: block;
}
/* --- CORRECCIÓN ATLAS DE ICONOS (según tu layout 3x3) --- */

/* 1. Clase base: Define la imagen y la parrilla 3x3 */
.icon-atlas {
    background-image: url('assets/atlas/icons.png');
    background-repeat: no-repeat;
    /* Esta es la cuadrícula 3x3. Esto es lo MÁS importante. */
    background-size: 300% 300%; 
}

/* 2. Definiciones de posición (BASADO EN TU LISTA) */

/* ▼▼▼ SECCIÓN MODIFICADA ▼▼▼ */
/* Fila 1: alarm_off (1,1), alarm_on (1,2), auto (1,3) */
.icon-alarm-off { background-position: 0% 0%; }
.icon-alarm-on  { background-position: 50% 0%; }
.icon-auto      { background-position: 100% 0%; } /* <-- VALOR INTERCAMBIADO */

/* Fila 2: button_off (2,1), button_on (2,2), chaos (2,3) */
.icon-button-off { background-position: 0% 50%; }
.icon-button-on  { background-position: 50% 50%; }
.icon-chaos      { background-position: 100% 50%; }

/* Fila 3: random (3,1), smart (3,2), vertical (3,3) */
.icon-random   { background-position: 0% 100%; }
.icon-smart    { background-position: 50% 100%; } /* <-- VALOR INTERCAMBIADO */
.icon-vertical { background-position: 100% 100%; }
/* ▲▲▲ FIN DE LA SECCIÓN MODIFICADA ▲▲▲ */


/* --- CORRECCIÓN DE ERRORES VISUALES --- */

#booster-alarm-img, #combo-status-img {
    width: 70px;  /* <-- TAMAÑO BASE (MÓVIL < 534px) */
    height: 70px; /* <-- TAMAÑO BASE (MÓVIL < 534px) */
    
    /* Corrección de Atlas */
    background-size: 300% 300%; 
    object-fit: unset; 
}

/* 4. Ajuste de tamaño para RANGO MEDIO (534px a 767px) */
@media (min-width: 534px) {
    #booster-alarm-img, #combo-status-img {
        width: 60px;  /* <-- TAMAÑO MÁS PEQUEÑO PARA QUE QUEPA */
        height: 60px; 
    }
}

/* 5. Ajuste de tamaño para ESCRITORIO (768px+) */
@media (min-width: 768px) {
    #booster-alarm-img, #combo-status-img {
         width: 140px;  /* <-- TAMAÑO GRANDE */
         height: 140px; 
    }
}
@keyframes spin-candy-types {
    0%, 100% { 
        background-position: 0% 0%; /* Fresa */
        filter: blur(2px); /* <-- AÑADIDO */
        opacity: 0.8;      /* <-- AÑADIDO */
    }
    16.6% { 
        background-position: 50% 0%;    /* Uva */
        filter: blur(4px); /* <-- AÑADIDO */
        opacity: 0.6;      /* <-- AÑADIDO */
    }
    33.3% { 
        background-position: 100% 0%;   /* Naranja */
        filter: blur(2px); /* <-- AÑADIDO */
        opacity: 0.8;      /* <-- AÑADIDO */
    }
    50% { 
        background-position: 0% 50%;      /* Limón */
        filter: blur(4px); /* <-- AÑADIDO */
        opacity: 0.6;      /* <-- AÑADIDO */
    }
    66.6% { 
        background-position: 50% 50%;    /* Cereza */
        filter: blur(2px); /* <-- AÑADIDO */
        opacity: 0.8;      /* <-- AÑADIDO */
    }
    83.3% { 
        background-position: 100% 50%;   /* Kiwi */
        filter: blur(4px); /* <-- AÑADIDO */
        opacity: 0.6;      /* <-- AÑADIDO */
    }
}

/* Aplicaremos esta clase con JS.
  Ejecuta la animación en un bucle infinito y usa 'steps(1)' 
  para que salte entre frames, creando el mismo efecto 
  de "parpadeo" que tenías con setInterval.
*/
.candy.is-spinning {
    /* Duración total de 0.3s para 6 pasos = 50ms por frame.
      ¡Esto es exactamente la misma velocidad que tenías!
    */
    animation: spin-candy-types 0.3s steps(1) infinite;
}
/* 6. Arreglar los Indicadores de Modo (MISMA CORRECCIÓN) */
.mode-indicator {
    /* DEBE COINCIDIR CON .icon-atlas */
    background-size: 300% 300%;
}

/* 7. Ocultar la etiqueta <img> que borramos del HTML, por si acaso */
.mode-indicator img {
    display: none; 
}
@keyframes trophy-grow {
            0% { transform: scale(0) rotate(-45deg); opacity: 0; }
            80% { transform: scale(1.1) rotate(10deg); opacity: 1; }
            100% { transform: scale(1) rotate(0deg); opacity: 1; }
        }
        
        /* ▼▼▼ AÑADIR ESTO ▼▼▼ */
        .pulse-score-animation {
            animation: pulse-score 0.4s cubic-bezier(0.4, 0, 0.6, 1);
        }

        @keyframes pulse-score {
            0%, 100% {
                transform: scale(1);
            }
            50% {
                /* Esto agranda la tarjeta y sus iconos internos */
                transform: scale(1.03); 
            }
        }
/* --- AÑADE ESTO A TU styles.css --- */

/* * Animación de giro vertical "tragaperras".
 * Es un blur y un movimiento vertical muy rápido que se repite.
 * El JS la mantendrá activa por 1 segundo.
 */
@keyframes vertical-spin-flicker {
    0% {
        transform: translateY(-15px);
        filter: blur(2px);
        opacity: 0.8;
    }
    20% {
        transform: translateY(15px);
        filter: blur(4px);
        opacity: 0.5;
    }
    40% {
        transform: translateY(-10px);
        filter: blur(2px);
        opacity: 0.8;
    }
    60% {
        transform: translateY(10px);
        filter: blur(4px);
        opacity: 0.5;
    }
    80% {
        transform: translateY(-5px);
        filter: blur(2px);
        opacity: 0.8;
    }
    100% {
        transform: translateY(0);
        filter: blur(3px);
        opacity: 0.6;
    }
}

/* Clase que aplica la animación de giro */
.candy.is-spinning-vertical {
    animation: vertical-spin-flicker 0.1s infinite;
    /* El JS limpiará esta clase después de ~1s */
}

/* * Animación de "parada" (entrada).
 * El dulce nuevo aparece desde arriba y cae en su sitio.
 */
@keyframes vertical-stop {
    from {
        transform: translateY(-30px); /* Empieza 30px arriba */
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Clase que aplica la animación de parada */
.candy.stopping-vertical {
    animation: vertical-stop 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

#blocker-grid {
    position: absolute;
    top: 10px; 
    right: 10px; 
    bottom: 10px; 
    left: 10px;
    display: grid;
    gap: 5px; /* <- ESTE ES EL GAP HORIZONTAL (COLUMNAS) */
    z-index: 3; /* Encima de los dulces (z-index: 2) */
    pointer-events: none; /* El grid no bloquea... */
}

.blocker-cell.double-locked {
    background-image: url('assets/piedra_bloqueo_2.png'); 
}

.blocker-cell.inactive {
    background-image: url('assets/piedra_bloqueo.png');
}

.blocker-cell {
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    pointer-events: auto; /* ...pero las celdas SÍ bloquean */
}

.column-wrapper {
    position: relative;
    overflow: hidden;
    height: 100%;
    z-index: 2; /* <- CAPA 2 (Encima de la gelatina) */
}

/* * El carrete que contiene los dulces y se anima 
 */
.reel {
    display: grid;
    gap: 5px; /* <- ESTE ES EL GAP VERTICAL (FILAS) */
    position: relative; 
    width: 100%;
    /* ▼▼▼ LÍNEA AÑADIDA ▼▼▼ */
    grid-template-rows: repeat(var(--num-rows, 1), 1fr);
}

/* * Estos estilos son para el carrete de la gelatina (jelly-grid).
 * Aunque no causan tu error, también faltaban y son necesarios
 * para que la variable --num-rows de tu game.js funcione.
 */
.jelly-reel {
    display: grid;
    gap: 5px; /* <- ESTE ES EL GAP VERTICAL (FILAS) */
    grid-template-rows: repeat(var(--num-rows, 1), 1fr); 
    height: 100%;
}

.blocker-reel {
    display: grid;
    gap: 5px; /* <- ESTE ES EL GAP VERTICAL (FILAS) */
    grid-template-rows: repeat(var(--num-rows, 1), 1fr); 
    height: 100%;
}

/* --- AÑADE ESTO A TU styles.css --- */

/* * Animación de "motion blur" (flicker).
 * Esta es una versión del 'vertical-spin-flicker'
 * SIN la propiedad 'transform' para que no entre
 * en conflicto con la animación del carrete (reel).
 */
@keyframes vertical-blur-flicker {
    0% {
        filter: blur(2px);
        opacity: 0.9;
    }
    20% {
        filter: blur(4px);
        opacity: 0.6;
    }
    40% {
        filter: blur(2px);
        opacity: 0.9;
    }
    60% {
        filter: blur(4px);
        opacity: 0.6;
    }
    80% {
        filter: blur(2px);
        opacity: 0.9;
    }
    100% {
        filter: blur(3px);
        opacity: 0.7;
    }
}
.candy.is-spinning-blur {
    animation: vertical-blur-flicker 0.1s infinite;
}