* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    margin: 0;
    font-family: Arial;
    background-color: white;
}

.header {
    text-align: center;
    padding: 20px;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.container {
    width: 100%;
    padding: 0 8px;
    margin: 0 auto;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: -4px; /* Negative margin to counteract padding */
}

.column {
    flex: 25%;
    max-width: 25%;
    padding: 4px;
}

.column img {
    width: 100%;
    display: block; /* Removes any inline spacing */
    margin-bottom: 8px;
    cursor: pointer;
    transition: 0.3s;
    vertical-align: middle;
}

.column img:hover {
    opacity: 0.7;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
}

.modal-content {
    margin: auto;
    display: block;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    object-fit: contain;
}

#imageCaption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    height: 150px;
}

.modal-content, #imageCaption {  
    animation-name: zoom;
    animation-duration: 0.6s;
}

@keyframes zoom {
    from {transform: scale(0)} 
    to {transform: scale(1)}
}

.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

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

/* Tablet view */
@media screen and (max-width: 800px) {
    .column {
        flex: 33.33%;
        max-width: 33.33%;
    }
    .container {
        padding: 0 4px;
    }
}

/* Mobile view */
@media screen and (max-width: 600px) {
    .row {
        margin: -2px;
    }
    
    .column {
        flex: 33.33%;
        max-width: 33.33%;
        padding: 2px;
    }
    
    .column img {
        margin-bottom: 4px;
    }
    
    .container {
        padding: 0 2px;
    }
    
    .header {
        padding: 15px;
    }
}

/* Modal responsive adjustments */
@media only screen and (max-width: 700px) {
    .modal-content {
        width: 95%;
        max-height: 80vh;
    }
    .modal {
        padding-top: 40px;
    }
    .close {
        right: 25px;
        top: 15px;
    }
}

/* New animation styles */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-img {
    opacity: 0; /* Start hidden */
}

.gallery-img.fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

/* Modify the existing styles */
.column img {
    width: 100%;
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
    transition: 0.3s;
    vertical-align: middle;
    will-change: opacity, transform; /* Optimize for animations */
}