.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Creates a responsive number of columns */
    justify-content: center;
    gap: 10px;
    padding: 20px;
}

/* Ensure there are never more than 4 columns */
@media (min-width: 800px) {
    .image-gallery {
        grid-template-columns: repeat(4, 1fr); /* Exactly four columns if there's enough space */
    }
}

@media (max-width: 799px) and (min-width: 600px) {
    .image-gallery {
        grid-template-columns: repeat(3, 1fr); /* Three columns for mid-size screens */
    }
}

@media (max-width: 599px) {
    .image-gallery {
        grid-template-columns: repeat(2, 1fr); /* Two columns for smaller screens */
    }
}

@media (max-width: 399px) {
    .image-gallery {
        grid-template-columns: 1fr; /* One column for very small screens */
    }
}

.image-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    padding-top: 100%; /* 56.25% for 16:9 Aspect Ratio, adjust this value based on your actual aspect ratio */
    height: 0; /* Helps maintain aspect ratio */
}

.image-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures the image covers the area without distortion */
    transition: filter 0.3s ease;
}

.image-item:hover img {
    filter: brightness(50%);
}

.caption {
    position: absolute;
    bottom: 0;
    width: 100%;
    text-align: center;
    color: white;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 5px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Adjusts the width of the modal content */
    max-width: 600px; /* Ensures the modal does not become too large */
}

#img01 {
    width: 100%; /* Makes the image responsive within the modal */
    height: auto; /* Maintains the aspect ratio */
    max-height: 400px; /* Ensures the image does not get too tall */
}

/*
.caption {
    margin-top: 10px;
    text-align: center;
    color: black; 
}
*/