/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1002;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fff;
    margin: 15vh auto; /* Changed from 5% to 15vh for better vertical centering */
    padding: 20px;
    border: 1px solid #888;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: flex; /* Added */
    flex-direction: column; /* Added */
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

.gif-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center; /* Added */
    gap: 20px;
    margin: 20px 0; /* Changed from margin-top to margin */
    min-height: 350px; /* Added to ensure consistent vertical space */
}

.gif-option {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 10px;
    transition: border-color 0.3s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden;
    background-color: #cec2e3;
    width: calc(33.333% - 40px);
    height: 135px;
    box-sizing: border-box;
    display: flex; /* Added */
    align-items: center; /* Added */
    justify-content: center; /* Added */
}

.gif-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gif-option img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
    padding: 8px;
}

.gif-option.selected {
    border-color: #007BFF;
}

@media (max-width: 768px) {
    .modal-content {
        margin: 10vh auto; /* Adjusted for mobile */
    }
    
    .gif-option {
        width: calc(50% - 30px);
        height: 110px;
    }
}

@media (max-width: 480px) {
    .gif-option {
        width: 100%;
        height: 135px;
    }
}