#gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

#gallery img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 120ms ease, box-shadow 120ms ease;
  cursor: pointer;
}

#gallery img:focus-visible,
#gallery img:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.gallery-lightbox.is-visible {
  opacity: 1;
  pointer-events: all;
}

.gallery-lightbox__content {
  position: relative;
  max-width: min(100%, 1200px);
  max-height: 100%;
}

.gallery-lightbox__image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 6rem);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.gallery-lightbox__close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 0;
  border-radius: 999px;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  cursor: pointer;
}

.gallery-lightbox__close:focus-visible,
.gallery-lightbox__close:hover {
  background: rgba(0, 0, 0, 0.8);
}

@media (max-width: 600px) {
  #gallery {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
  }
}
