* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

header {
    display: grid;
    background-color: rgb(104, 102, 102);
    padding: 0;
}

.grid-container {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto;
    gap: 5px;
    background-color: rgb(0, 0, 102);
    padding: 5px;
}

.grid-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 2px solid black;
    padding: 10px;
    background-color: #ffffff;
    display: block;
}

#image-viewer {
    border: 0;
    background: transparent;
    padding: 0;

    width: 90vw;
    height: 90vh;
    height: 90dvh;

    max-width: 90vw;
    max-height: 90dvh;

    border-radius: 12px;
    outline: none;
    margin: auto;
    overflow: hidden;
    cursor: zoom-out;
}

#image-viewer[open] {
    display: flex;
    justify-content: center;
    align-items: center;
}

#image-viewer img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border: 0;
    padding: 0;
    border-radius: 8px;
}

#image-viewer::backdrop {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

/* Крестик внутри экрана, а не над границей окна. */
.close-gallery-btn {
    position: absolute;
    top: 8px;
    right: 8px;

    width: 48px;
    height: 48px;

    border: 0;
    border-radius: 50%;
    color: white;
    background: rgba(0, 0, 0, 0.65);

    font-size: 42px;
    line-height: 1;
    cursor: pointer;
    z-index: 1;
}

.close-gallery-btn:hover {
    color: #ffcc00;
}