 body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    margin: 20px 0;
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    max-width: 920px;
    width: 100%;
}

.gallery-item {
    width: calc(33.333% - 20px); /* Drei Spalten mit Abständen */
    margin: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.gallery-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1; /* Quadratische Thumbnails */
    object-fit: cover; /* Bild wird skaliert und zentriert, um den Container zu füllen */
}

.gallery-item .title {
    padding: 10px;
    background-color: #f8f8f8;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    position: relative; /* Ändert Positionierung, um unterhalb des Bildes zu sein */
    bottom: 0;
    margin-top: 5px; /* Abstand zum Bild */
}

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

.lightbox-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    width: auto;
    height: auto;
}

.lightbox-content, .close {
    -webkit-animation-name: zoom;
    -webkit-animation-duration: 0.6s;
    animation-name: zoom;
    animation-duration: 0.6s;
}

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

@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;
}

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

.prev, .next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px;
    color: white;
    font-weight: bold;
    font-size: 20px;
    transition: 0.6s ease;
    user-select: none;
}

.next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.prev:hover, .next:hover {
    background-color: rgba(0,0,0,0.8);
}

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

/* Media Queries für Mobilgeräte */
@media (max-width: 600px) {
    .gallery-item {
        width: calc(100% - 20px); /* Eine Spalte */
        margin: 10px 0;
    }

    .prev, .next {
        display: none; /* Schaltflächen ausblenden */
    }

    .gallery-item img {
        height: auto; /* Beibehalten der natürlichen Höhe */
        aspect-ratio: auto; /* Aufheben des quadratischen Verhältnisses */
    }
}
