:root {
    --gap: 10px;
    --radius: 14px;
    --bg: #0e0f12;
    --fg: #f4f2ee;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    overflow: hidden;
}

/* ------------------------------------------------------------------ Board */

.board {
    display: grid;
    grid-template-columns: repeat(var(--cols), 1fr);
    grid-template-rows: repeat(var(--rows), 1fr);
    gap: var(--gap);
    width: 100%;
    height: 100dvh;
    padding: var(--gap);
}

.tile {
    grid-area: var(--area);
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius);
    background: #1a1c21;
    container-type: inline-size;
    opacity: 0;
    animation: tile-in 700ms cubic-bezier(0.22, 1, 0.36, 1) var(--delay, 0ms) forwards;
}

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 600ms cubic-bezier(0.22, 1, 0.36, 1), filter 400ms ease;
}

.tile:hover img,
.tile:focus-within img {
    transform: scale(1.05);
    filter: brightness(1.08);
}

.tile figcaption {
    position: absolute;
    inset: auto 0 0 0;
    padding: 2.4em 0.9em 0.8em;
    font-size: clamp(0.78rem, 5.5cqw, 1.3rem);
    line-height: 1.35;
    font-weight: 500;
    text-wrap: balance;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.45) 45%, transparent 100%);
}

@keyframes tile-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tile {
        animation: none;
        opacity: 1;
    }

    .tile img {
        transition: none;
    }

    .tile:hover img,
    .tile:focus-within img {
        transform: none;
    }
}

/* --------------------------------------------------------- Kleine Displays */

/* Auf schmalen Geräten ist das gepackte Raster zu kleinteilig – dort wird
   daraus eine scrollbare Spalte mit gleich großen Kacheln. */
@media (max-width: 700px) {
    html,
    body {
        overflow: auto;
    }

    .board {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: none;
        grid-auto-rows: 30vh;
        height: auto;
        min-height: 100dvh;
    }

    .tile {
        grid-area: auto;
    }
}

/* Auf dem Handy (xs) eine einzelne Spalte: zwei liegende Kacheln füllen den
   Bildschirm, alles weitere kommt beim Scrollen. Die Zeilenhöhe ist die halbe
   Viewporthöhe abzüglich der drei Abstände (oben, Mitte, unten). */
@media (max-width: 575px) {
    .board {
        grid-template-columns: 1fr;
        grid-auto-rows: calc((100dvh - 3 * var(--gap)) / 2);
    }
}

/* ------------------------------------------------------------------ Login */

.login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;
    padding: 1.5rem;
}

.login form {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 20rem;
}

.login h1 {
    margin: 0 0 1.5rem;
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: center;
}

.login label {
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: #a7a29a;
}

.login input {
    margin-bottom: 1rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid #34373f;
    border-radius: 9px;
    background: #1a1c21;
    color: var(--fg);
    font: inherit;
    font-size: 1rem; /* verhindert das Hineinzoomen auf iOS */
}

.login input:focus {
    outline: 2px solid #6b7280;
    outline-offset: 1px;
}

.login button {
    margin-top: 0.25rem;
    padding: 0.75rem 1rem;
    border: 0;
    border-radius: 9px;
    background: var(--fg);
    color: #16181d;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.login button:hover {
    background: #ffffff;
}

.login-error {
    margin: 0 0 1rem;
    padding: 0.6rem 0.75rem;
    border-radius: 9px;
    background: #3b1f22;
    color: #f6c9c4;
    font-size: 0.9rem;
}

.login-hint {
    margin: 1rem 0 0;
    color: #6f6b65;
    font-size: 0.8rem;
    text-align: center;
}

/* ------------------------------------------------------------ Leerer Stand */

.empty {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    height: 100dvh;
    padding: 2rem;
    text-align: center;
}

.empty h1 {
    margin: 0;
    font-size: clamp(1.6rem, 5vw, 2.6rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.empty p {
    margin: 0;
    max-width: 34rem;
    color: #a7a29a;
    line-height: 1.6;
}

.empty code {
    padding: 0.15em 0.4em;
    border-radius: 5px;
    background: #22242a;
    color: var(--fg);
    font-size: 0.95em;
}
