:root{
    /* Helligkeit (1 = normal, >1 heller) */
    --thumbnail-brightness: 1.9;
    --thumbnail-contrast: 1.05;
    --gap: 1.5vmin;
    --board-size: 95vmin; /* quadratische Grundgröße, passt in jeden Viewport */
    --overlay-bg: rgba(0,0,0,0.82);
    --font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    --accent: rgba(255,255,255,0.92);
}

/* Reset / Basis */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
    background: #1FB7F2;
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden; /* Raster passt ohne Scroll */
}

#board {
    height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2vmin;
}

/* Raster: quadratisch, gleich große Zellen */
.grid {
    width: var(--board-size);
    height: var(--board-size);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: var(--gap);
    align-items: stretch;
    justify-items: stretch;
}

/* Thumbnails */
.grid img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    filter: brightness(var(--thumbnail-brightness)) contrast(var(--thumbnail-contrast));
    transition: transform 180ms ease, filter 180ms ease;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6) inset;
    user-select: none;
    -webkit-user-drag: none;
}

.grid img:focus,
.grid img:hover {
    transform: scale(1.02);
    outline: 3px solid rgba(255,255,255,0.06);
}

/* Overlay / Lightbox */
#overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    z-index: 1000;
}

/* overlayContent hat die gleiche quadratische Größe wie das Raster, sodass es dieses vollständig überdeckt */
.overlay-content {
    width: var(--board-size);
    height: var(--board-size);
    max-width: 96vw;
    max-height: 96vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    gap: 1vmin;
}

/* view-box ist die tatsächliche Anzeigefläche (Bild oder Text) */
.view-box {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Overlay Bild: füllt die Box vollständig, alle Bilder gleich groß (object-fit: cover sorgt für ein konsistentes Aussehen) */
#overlayImage {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    cursor: pointer;
}

/* Beschreibung genau in derselben Fläche, größere, fette Schrift */
#description {
    width: 90%;
    height: 100%;
    padding: 3vmin;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #1FB7F2;
    color: var(--accent);
    font-weight: 700; /* fett */
    font-size: clamp(18px, 3vmin, 34px); /* größer */
    line-height: 1.4;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

/* Navigation Buttons (Pfeile) */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 12vmin;
    height: 28vmin;
    min-width: 48px;
    min-height: 96px;
    background: linear-gradient(90deg, rgba(0,0,0,0.16), rgba(0,0,0,0.35));
    border: none;
    color: var(--accent);
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.95;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

/* Pfeilform mit CSS */
.nav-btn::before {
    content: "";
    display: inline-block;
    width: 2.2vmin;
    height: 2.2vmin;
    border-top: 4px solid var(--accent);
    border-right: 4px solid var(--accent);
    transform: rotate(135deg);
}

.nav-btn.next::before {
    transform: rotate(-45deg);
}

/* Positionen */
.nav-btn.prev { left: -6vmin; }
.nav-btn.next { right: -6vmin; }

/* Position Indicator (z.B. "3 / 9") */
.position-indicator {
    position: absolute;
    bottom: 1.5vmin;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.28);
    padding: 0.6vmin 1.1vmin;
    border-radius: 999px;
    font-size: clamp(12px, 1.6vmin, 16px);
}

/* Utilities */
.hidden { display: none !important; }

/* Kleine Bildschirme: kleinere Nav-Buttons & geringerer Abstand */
@media (max-width: 520px) {
    .nav-btn { width: 10vmin; height: 22vmin; }
    .nav-btn.prev { left: -4vmin; }
    .nav-btn.next { right: -4vmin; }
    :root { --gap: 1vmin; }
}