.uffizio-masonry-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 20px;
    width: 100%;
    max-width: 900px;
    /* Increased to medium size */
    margin: 0 auto;
    aspect-ratio: 1.4 / 1;
}

.masonry-item {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
    border-radius: 15px;
}

.mobile-gallery .masonry-item {
    border-radius: 5px;
}

/* Precise Grid Mapping based on Design Image */
.item-1 {
    grid-area: 1 / 1 / 3 / 2;
}

/* Tall Left */
.item-2 {
    grid-area: 1 / 2 / 2 / 4;
}

/* Wide Top Right */
.item-3 {
    grid-area: 2 / 2 / 3 / 3;
}

/* Middle Center */
.item-4 {
    grid-area: 2 / 3 / 4 / 4;
}

/* Tall Right */
.item-5 {
    grid-area: 3 / 1 / 4 / 2;
}

/* Bottom Left */
.item-6 {
    grid-area: 3 / 2 / 4 / 3;
}

/* Bottom Center */

.fade-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

.fade-image.active {
    opacity: 1;
    z-index: 1;
}

.fade-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill the box perfectly */
    display: block;
}

/* Responsive: Stack on mobile */
@media (max-width: 767px) {
    .uffizio-masonry-gallery {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
        aspect-ratio: auto;
    }

    .item-1,
    .item-2,
    .item-3,
    .item-4,
    .item-5,
    .item-6 {
        grid-area: auto;
        aspect-ratio: 1 / 1;
    }

    .item-2 {
        grid-column: span 2;
        aspect-ratio: 2 / 1;
    }
}