:root {
    --transition-speed: 0.2s;
    --button-height: 30px;
    --button-width: 120px;
    --mobile-font-size: 14px;
    --mobile-padding: 10px;
    --image-width: 350px;
    --image-height: 250px;
    --image-margin: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
    text-transform: capitalize;
    transition: all var(--transition-speed) cubic-bezier(.34, 1.12, .68, 1.31);
}

.gallery {
    min-height: 100vh;
    background: #eee;
    padding-bottom: 50px;
}

.gallery .controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    padding: var(--mobile-padding) 0;
    list-style: none;
}

.gallery .controls .buttons {
    height: var(--button-height);
    width: var(--button-width);
    background: #fff;
    color: #666;
    font-size: var(--mobile-font-size);
    line-height: var(--button-height);
    cursor: pointer;
    margin: 5px;
    box-shadow: 0 3px 5px rgba(0, 0, 0, .3);
    text-align: center;
}

.gallery .controls .buttons.active {
    background: crimson;
    color: #fff;
}

@media screen and (max-width: 768px) {
    .gallery .controls {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .gallery .controls .buttons {
        width: calc(33.33% - 10px); /* 10px is the margin between buttons */
        margin: 5px; /* Adjusted margin for better spacing */
    }

    .gallery .image-container .image {
        width: calc(100% - (2 * var(--image-margin)));
        margin: var(--image-margin) 0;
        height: 180px;
    }
}

.gallery .image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.gallery .image-container .image {
    height: var(--image-height);
    width: var(--image-width);
    overflow: hidden;
    border: 8px solid rgba(0, 0, 0, 0.3);
    box-shadow: 0 3px 5px rgba(0, 0, 0, .3);
    margin: var(--image-margin);
    transition: all var(--transition-speed) cubic-bezier(.34, 1.12, .68, 1.31);
    position: relative;
}

.gallery .image-container .image:before,
.gallery .image-container .image:after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    border: 8px solid transparent;
    transition: all var(--transition-speed) cubic-bezier(.34, 1.12, .68, 1.31);
}

.gallery .image-container .image:before {
    top: 0;
    left: 0;
    border-top-color: #fff;
    border-right-color: #fff;
}

.gallery .image-container .image:after {
    bottom: 0;
    right: 0;
    border-bottom-color: #fff;
    border-left-color: #fff;
}

.gallery .image-container .image:hover {
    border-color: transparent;
}

.gallery .image-container .image:hover:before,
.gallery .image-container .image:hover:after {
    border-color: crimson;
}

.gallery .image-container .image img {
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.gallery .image-container .image:hover img {
    transform: scale(1.4);
}
