/* Estilos generales del cuerpo y el contenedor principal */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f4f8;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    min-height: 100vh;
    padding: 1rem;
    box-sizing: border-box;
    overflow: hidden;
    /* Oculta el confeti que sale de la pantalla */
    user-select: none;
    /* Evita selección de texto */
}

/* Estilos para el botón principal */
.open-modal-button {
    background-color: #4a90e2;
    color: white;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    transition: background-color 0.3s ease, transform 0.1s ease;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    font-size: 1.125rem;
}

.open-modal-button:hover {
    background-color: #357bd8;
    transform: translateY(-2px);
}

.open-modal-button:active {
    background-color: #2b6cb0;
    transform: translateY(0);
}

.container {
    background-color: #ffffff;
    border-radius: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    max-width: 95%;
    width: 400px;
    border: 1px solid #e2e8f0;
    position: relative;
    transition: none;
    box-sizing: border-box;
}

/* Estilos de botones generales */
.button-game-control {
    background-color: #4a90e2;
    /* Azul principal */
    color: white;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    /* Hace que sea circular o muy redondeado */
    transition: background-color 0.3s ease, transform 0.1s ease, box-shadow 0.3s ease;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    min-width: 120px;
    /* Asegura un tamaño mínimo para el botón circular */
    background-image: linear-gradient(to right, #4a90e2 0%, #63a4ff 100%);
    /* Degradado */
    border: 1px solid #3a7bc4;
    /* Borde sutil */
}

.button-game-control:hover {
    background-color: #357bd8;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px -2px rgba(0, 0, 0, 0.15), 0 3px 5px -1px rgba(0, 0, 0, 0.08);
    background-image: linear-gradient(to right, #357bd8 0%, #4a90e2 100%);
    /* Degradado al pasar el ratón */
}

.button-game-control:active {
    background-color: #2b6cb0;
    transform: translateY(0);
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    background-image: linear-gradient(to right, #2b6cb0 0%, #357bd8 100%);
    /* Degradado al hacer click */
}

/* Grupo de botones principal en la parte inferior */
.main-button-group {
    display: flex;
    justify-content: center;
    /* Centrar los botones */
    align-items: center;
    /* Alinear verticalmente los elementos */
    gap: 1rem;
    /* Espacio entre botones */
    width: 100%;
    padding: 0.5rem 0;
    flex-wrap: wrap;
    /* Permite que los elementos se envuelvan en pantallas pequeñas */
}

/* Estilos para iconos (no se usan en este HTML, pero se mantienen por si se añaden) */
.icon-base {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    vertical-align: middle;
    background-repeat: no-repeat;
    background-size: contain;
    filter: brightness(0) saturate(100%) invert(var(--tw-invert, 0)) sepia(var(--tw-sepia, 0)) saturate(var(--tw-saturate, 0)) hue-rotate(var(--tw-hue-rotate, 0)) brightness(var(--tw-brightness, 0)) contrast(var(--tw-contrast, 0));
}

.button-game-control .icon-base {
    filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%) contrast(100%);
}

.icon-reload {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.76 0 3.3.73 4.46 1.94L13 11h7V4l-2.35 2.35z'/%3E%3C/svg%3E");
}

.icon-card-selection {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm0 16H5V5h14v14zM8.5 13.5l2.5 3.01L14.5 11l4.5 6H5l3.5-4.5z'/%3E%3C/svg%3E");
}

/* Estilos para el selector de números (cartons-Winner) */
.main-button-group .select-wrapper {
    position: relative;
    display: inline-block;
    min-width: 80px;
    /* Ancho mínimo para el selector */
    flex-shrink: 0;
    /* Evita que se encoja */
}

.main-button-group select#cartons-Winner {
    appearance: none;
    /* Elimina los estilos nativos del sistema */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #f8f9fa;
    /* Color de fondo claro */
    border: 1px solid #cbd5e0;
    /* Borde sutil */
    border-radius: 9999px;
    /* Muy redondeado */
    padding: 0.75rem 2.5rem 0.75rem 1.5rem;
    /* Padding para el texto y espacio para el ícono */
    font-size: 1.125rem;
    color: #2d3748;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    width: 100%;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    /* Sombra interna sutil */
}

.main-button-group select#cartons-Winner:hover {
    border-color: #a8c7ed;
    background-color: #eef2f6;
}

.main-button-group select#cartons-Winner:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
    /* Sombra de enfoque azul */
    background-color: #ffffff;
}

/* Flecha personalizada para el selector */
.main-button-group .select-wrapper::after {
    content: '▼';
    /* Carácter de flecha */
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    pointer-events: none;
    /* Asegura que la flecha no intercepte clics */
    color: #4a5568;
    /* Color de la flecha */
    font-size: 0.8rem;
    transition: transform 0.2s ease;
}

.main-button-group select#cartons-Winner:focus+.select-wrapper::after {
    transform: translateY(-50%) rotate(180deg);
    /* Gira la flecha al enfocar */
}

/* Estilos de la cuadrícula de cartas */
.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /* 4 columnas */
    gap: 0.75rem;
    /* Espacio entre cartas */
    padding: 0.5rem;
    background-color: #edf2f7;
    border-radius: 0.75rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card-item {
    position: relative;
    width: 100%;
    padding-bottom: 150%;
    /* Relación de aspecto para tarjetas de lotería (altura = 1.5 * ancho) */
    border-radius: 0.5rem;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    background-color: #ffffff;
    /* Fondo blanco para las cartas */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    /* Tamaño de texto para el número */
    font-weight: bold;
    color: #2d3748;
}

.card-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}

.card-item span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    /* Asegura que el número esté encima de cualquier fondo de imagen si se añade */
}

.card-item.blue-bg {
    background-color: #66BB6A;
}

/* Estilos de modales */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: none;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    position: relative;
    box-sizing: border-box;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.modal-heading {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    color: #4b5563;
    margin-bottom: 1.5rem;
}

/* Estilos para el contenedor de la aplicación y la cabecera del modal */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: #fff;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.header-with-back {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e2e8f0;
}

.header-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2d3748;
    text-align: center;
    flex-grow: 1;
    margin: 0;
    padding: 0.25rem 0;
}

/* Estilos para las listas de elementos (barajas, cartones) */
.item-list-section {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: auto;
    scrollbar-color: #4a90e2 #f8f9fa;
    overscroll-behavior-y: contain;
}

.item-list-section::-webkit-scrollbar {
    width: 12px;
}

.item-list-section::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 10px;
}

.item-list-section::-webkit-scrollbar-thumb {
    background: #4a90e2;
    border-radius: 10px;
}

.item-list-section::-webkit-scrollbar-thumb:hover {
    background: #357bd8;
}

.item-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.item-label:hover {
    border-color: #a8c7ed;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.item-label.selected {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.3);
}

.item-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-grow: 1;
}

.item-image {
    width: 80px;
    height: 80px;
    border-radius: 0.5rem;
    object-fit: cover;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.item-description-text {
    display: flex;
    flex-direction: column;
}

.item-title {
    font-weight: bold;
    font-size: 1.1rem;
    color: #2d3748;
}

.item-subtitle {
    font-size: 0.9rem;
    color: #718096;
    margin-top: 0.2rem;
}

.hidden-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.custom-control {
    position: relative;
    display: inline-block;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.375rem;
    border: 2px solid #cbd5e0;
    background-color: #ffffff;
    transition: all 0.2s ease-in-out;
    margin-left: 1rem;
    flex-shrink: 0;
}

.custom-control::after {
    content: '';
    position: absolute;
    display: none;
    left: 0.75rem;
    top: 0.35rem;
    width: 0.6rem;
    height: 1.2rem;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
}

.hidden-input:checked+.custom-control {
    background-color: #2563eb;
    border-color: #2563eb;
}

.hidden-input:checked+.custom-control::after {
    display: block;
}

.hidden {
    display: none;
}

/* Estilos específicos para la visualización del cartón interactivo */
#interactive-carton-container {
    width: 100%;
    max-width: 380px;
    /* Limitar el ancho para que no sea demasiado grande en desktop */
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
    box-sizing: border-box;
    margin-bottom: 1rem;
}

#selected-carton-display {
    width: 100%;
    display: grid;
    background-color: #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.carton-card {
    position: relative;
    width: 100%;
    padding-bottom: 150%;
    /* Relación de aspecto para las cartas */
    overflow: hidden;
    border-radius: 0.3rem;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    color: #4a5568;
    cursor: pointer;
    /* Hace que las cartas sean clickeables */
    transition: transform 0.1s ease-in-out;
}

.carton-card:hover {
    transform: scale(1.02);
}

.carton-card img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Shading overlay for marked cards */
.carton-card.marked::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    /* Semi-transparent black shade */
    border-radius: 0.3rem;
    /* Match card border-radius */
    transition: opacity 0.3s ease-in-out;
    z-index: 15;
    /* Below the marking chip but above the image */
}

/* Estilos para la chapa de marcado */
.marking-chip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    /* Tamaño de la chapa en relación a la carta */
    height: auto;
    /* Allow height to adjust */
    aspect-ratio: 1 / 1;
    /* Force aspect ratio to 1:1 */
    background-image: url('https://loteria.softcom.hn/img/moneda.webp');
    /* Use the provided image */
    background-size: contain;
    /* Ensure the image fits within the circle */
    background-repeat: no-repeat;
    background-position: center;
    /* Center the image */
    border: none;
    /* No border needed if image has one or is borderless */
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3), inset 0 0 5px rgba(255, 255, 255, 0.5), inset 0 0 15px rgba(0, 0, 0, 0.3);
    /* Sombra externa e interna */
    border-radius: 50%;
    /* Forma circular */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    /* Oculto por defecto */
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    pointer-events: none;
    /* No debe interceptar eventos de clic */
    z-index: 20;
    /* Asegura que esté por encima de la imagen de la carta */
}

.marking-chip.active {
    opacity: 1;
    /* Visible cuando está activo */
    transform: translate(-50%, -50%) scale(1);
    /* Asegura la escala normal */
}

/* Animación para la chapa cuando aparece */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    60% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Hide the SVG within the marking chip (no checkmark) */
.marking-chip svg {
    display: none;
}



.carton-card.winning-line {
    border: 3px solid red;
    /* Borde rojo para líneas ganadoras */
    box-sizing: border-box;
}

/* Estilos para el título del cartón */
.carton-title {
    font-size: 1.25rem;
    font-weight: bold;
    color: #2d3748;
    margin-bottom: 0.75rem;
    text-align: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    width: 100%;
}

/* Estilos mejorados para las pestañas (tabs) */
.tab-header {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: #e2e8f0;
    /* Fondo del contenedor de pestañas */
    border-radius: 9999px;
    /* Forma de píldora */
    padding: 0.35rem;
    margin: 1rem 1.5rem 1rem 1.5rem;
    /* Margen para separarlo del contenido y bordes */
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
    /* Sutil sombra interna */
}

.tab-button {
    flex: 1;
    /* Distribuye el espacio equitativamente */
    text-align: center;
    padding: 0.75rem 0.5rem;
    border-radius: 9999px;
    /* Circular para cada botón de pestaña */
    color: #4a5568;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-button.active {
    background-color: #4a90e2;
    /* Color de fondo para la pestaña activa */
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    /* Sombra para resaltar la pestaña activa */
    transform: translateY(-1px);
    /* Ligero levantamiento */
}

.tab-button:hover:not(.active) {
    background-color: #cbd5e1;
    /* Color de fondo al pasar el ratón */
}

/* Estilos para el confeti */
.confeti {
    position: fixed;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    z-index: 1001;
    /* Asegura que esté por encima de todo */
}

@keyframes volar {
    from {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }

    to {
        transform: translate(var(--dx), var(--dy)) rotate(720deg);
        opacity: 0;
    }
}

/* Media queries para responsividad */
@media (max-width: 480px) {
    .container {
        width: 100%;
        max-width: none;
        padding: 0.75rem;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }

    #interactive-carton-container {
        max-width: none;
        /* Eliminar límite en pantallas muy pequeñas */
        padding: 0.5rem;
    }

    .carton-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .tab-header {
        margin: 0.75rem 1rem 0.75rem 1rem;
        padding: 0.25rem;
    }

    .tab-button {
        padding: 0.6rem 0.4rem;
        font-size: 0.9rem;
    }
}

@media (min-width: 640px) {
    .container {
        width: 500px;
        padding: 2.5rem;
    }

    #interactive-carton-container {
        max-width: 400px;
    }
}
