#openModalBtn {
    padding: 15px 30px;
    font-size: 18px;
    cursor: pointer;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

#openModalBtn:hover {
    background-color: #0056b3;
}

/* Estilos del Modal */
.modal {
    display: flex; /* Keep using flex for centering */
    position: fixed; /* Posición fija relativa al viewport */
    z-index: 1000; /* Por encima de todo */
    left: 0;
    top: 0;
    width: 100%; /* Ancho completo */
    height: 100%; /* Alto completo */
    overflow: auto; /* Habilita scroll si es necesario */
    background-color: rgba(0,0,0,0.5); /* Fondo semitransparente */
    justify-content: center; /* Centra horizontalmente el contenido */
    align-items: center; /* Centra verticalmente el contenido */
    opacity: 0; /* Start hidden */
    visibility: hidden; /* Start hidden */
    transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s; /* Fade transition, hide visibility after fade */
}

.modal.show {
    opacity: 1; /* Become visible */
    visibility: visible; /* Become visible */
    transition-delay: 0s; /* Ensure visibility transition happens immediately */
}

.modal-content {
    background-color: #fff;
    margin: auto; /* Centrado automático */
    padding: 0; /* Adjusted: Remove padding to allow columns to fill */
    border: 1px solid #ddd;
    border-radius: 8px;
    width: 90%; /* Ancho responsivo - adjusted for columns */
    max-width: 900px; /* Ancho máximo - adjusted for columns */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    position: relative; /* Para posicionar el botón de cerrar */
    transform: scale(0.8) translateY(-50px); /* Initial state for animation */
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55), width 0.3s ease, max-width 0.3s ease, height 0.3s ease; /* Physics-based spring animation */
    display: flex; /* Use flexbox for layout */
    flex-direction: column; /* Stack elements vertically */
    height: 70vh; /* Define a height for the modal */
    max-height: 650px; /* Optional: Max height */
    overflow: hidden; /* Prevent content overflow from modal-content itself */
}

/* Apply final transform state when modal is shown */
.modal.show .modal-content {
    transform: scale(1) translateY(0);
}

.close-btn {
    color: #aaa;
    position: absolute;
    top: 5px; /* Adjusted position */
    right: 15px; /* Adjusted position */
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 10; /* Ensure it's above column content */
}

.close-btn:hover,
.close-btn:focus {
    color: #333;
    text-decoration: none;
}

/* Styles for the columns container */
.modal-columns {
    display: flex;
    flex-grow: 1; /* Allow columns container to fill available space */
    /* margin-top: 20px; Removed, handled by flex */
    gap: 0; /* Remove gap, borders will separate */
    overflow: hidden; /* Prevent columns from overflowing modal */
    padding-top: 35px; /* Space for close button */
}

.modal-column {
    flex: 1; /* Each column takes equal space */
    border-right: 1px solid #eee; /* Use borders for separation */
    padding: 15px;
    /* border-radius: 5px; Removed */
    /* background-color: #f9f9f9; Set individually */
    /* min-height: 200px; Removed, flexbox handles height */
    overflow-y: auto; /* Allow scrolling within columns if needed */
    display: flex; /* Use flexbox */
    flex-direction: column; /* Stack title and list */
}

/* Remove border from the last column */
.modal-column:last-child {
    border-right: none;
}

/* Specific Column Styles */
#col1 {
    background-color: #f9f9f9; /* Keep background for Col 1 */
}

#col2, #col3 {
    background-color: #fff; /* White background for Col 2 & 3 */
}

.modal-column h3 {
    margin-top: 0;
    font-size: 1em;
    color: #555;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px; /* Increased padding */
    margin-bottom: 15px; /* Increased margin */
    flex-shrink: 0; /* Prevent title from shrinking */
}

.modal-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
    flex-grow: 1; /* Allow list to take remaining space */
    overflow-y: auto; /* Scroll list if needed */
}

.modal-column li {
    padding: 8px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s ease;
    margin-bottom: 5px; /* Space between items */
    color: #333; /* Default text color */
}

.modal-column li:hover {
    color: navy; /* Set text color to navy blue on hover */
}

/* Media query para pantallas pequeñas */
@media (max-width: 600px) {
    .modal-content {
        width: 100%; /* Full width on mobile */
        height: 100%; /* Full height on mobile */
        max-width: none;
        max-height: none; /* Allow full height */
        border-radius: 0; /* Optional: remove border radius */
        border: none; /* Optional: remove border */
        top: 0; /* Align to top */
        left: 0; /* Align to left */
        margin: 0; /* Remove margin */
        transform: none !important; /* Disable open/close animation for full screen */
        transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s; /* Keep fade */
    }

    #openModalBtn {
        padding: 12px 25px;
        font-size: 16px;
    }

    .modal-columns {
        /* Remove stacking behavior */
        flex-direction: row; /* Back to default */
        overflow: visible; /* Allow absolute positioning overflow */
        padding-top: 0; /* Reset padding */
        position: relative; /* Position context for columns */
        height: 100%; /* Fill modal content */
    }

    .modal-column {
        /* Reset stacking styles */
        min-height: auto;
        border-bottom: none;
        flex-grow: 1;
        flex-basis: 100%;

        /* Absolute positioning for single view */
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: none; /* Hide all columns by default */
        background-color: #fff; /* Default white background */
        border-right: none; /* Remove desktop border */
        padding: 15px; /* Base padding */
        padding-top: 80px; /* Space for close and back buttons */
        overflow-y: auto; /* Ensure scrolling within column */
    }

    /* Initial state: Show only Col 1 */
    #col1 {
        display: flex; /* Show col1 initially */
        background-color: #f9f9f9; /* Keep original col1 bg */
    }
     #col2, #col3 {
         background-color: #fff; /* Ensure white bg for others when shown */
    }


    .modal-column h3 {
        padding-bottom: 8px;
        margin-bottom: 10px;
        padding-top: 0; /* Reset extra padding */
        position: sticky; /* Keep title visible while scrolling list */
        top: -15px; /* Adjust based on padding */
        background: inherit; /* Match column background */
        z-index: 5; /* Keep above list items */
        margin-left: -15px; /* Align with column edge */
        margin-right: -15px; /* Align with column edge */
        padding-left: 85px; /* Re-apply padding */
        padding-right: 15px; /* Re-apply padding */

    }

    .modal-column ul {
         /* Flex grow and overflow already handled */
    }

    .modal-column li {
        padding: 10px 8px; /* Slightly larger touch target */
    }

    /* Back button styling */
    .back-btn {
        position: absolute;
        top: 65px; /* Below the close button (top: 5px + height ~28px) */
        left: 15px;
        z-index: 15; /* Above content, below close btn */
        background: #f0f0f0;
        border: 1px solid #ccc;
        padding: 5px 12px;
        cursor: pointer;
        border-radius: 4px;
        font-size: 14px;
        color: #333;
        transition: background-color 0.2s ease;
        width: 50px;
    }

    .back-btn:hover {
        background-color: #e0e0e0;
    }

    /* Ensure close button is on top */
    .close-btn {
        z-index: 20;
        color: #666; /* Make slightly more prominent */
    }
}