body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
}

.custom-gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 10px;
}

.custom-gallery-item {
    margin: 5px;
    flex: 1 0 21%; /* 4 items per row */
    box-sizing: border-box;
    height: 250px; /* Set a fixed height for all items */
    overflow: hidden;
    position: relative;
}

.custom-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures the image covers the container without deformation or empty space */
    cursor: pointer;
    transition: transform 0.2s;
}

.custom-gallery-image:hover {
    transform: scale(1.05);
}

.custom-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    flex-direction: column; /* Stack elements vertically */
}

.custom-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80%; /* Leave space for the title below the image */
    object-fit: contain; /* Ensure the image maintains its aspect ratio */
}

.custom-title {
    margin: auto;
    display: block;
    width: 90%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    height: auto;
}

.custom-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
}

.custom-close:hover,
.custom-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

.custom-prev, .custom-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    padding: 16px;
    color: white;
    font-weight: bold;
    font-size: 20px;
    transition: 0.6s ease;
    user-select: none;
    z-index: 10000; /* Ensure arrows are above the image */
}

.custom-prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.custom-next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.custom-prev:hover, .custom-next:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

@media (max-width: 992px) and (min-width: 769px) {
    .custom-gallery-item {
        flex: 1 0 31%; /* 3 items per row */
    }
}

@media (max-width: 768px) {
    .custom-gallery-item {
        flex: 1 0 46%; /* 2 items per row */
    }
}

@media (max-width: 480px) {
    .custom-gallery-item {
        flex: 1 0 100%; /* 1 item per row */
        width: 100%;
    }
}
