.header > img {
  width: 100%;
  height: auto;
  display: block;
}
h1 {
  text-align: center;
}
body {
  min-height: 100vh;
  display: -webkit-flex;
  display: flex;
  flex-direction: column;
}
/* -------------------------------------------------------- */
/* GALLERY GRID */
/* -------------------------------------------------------- */
.ingallery {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
.ingallery .inimage {
  object-fit: cover;
  border-radius: 10px;
  width: 20rem;
  height: 20rem;
  margin: 1rem;
  transition-duration: 0.8s;
  cursor: pointer;
}
.ingallery .inimage:hover {
  -webkit-transform: scale(1.1);
  -ms-transform: scale(1.1);
  transform: scale(1.1);
  filter: none;
}
/* -------------------------------------------------------- */
/* GALLERY POP UP */
/* -------------------------------------------------------- */
#myImg {
  border-radius: 5px;
  cursor: pointer;
  transition: 0.3s;
}
#myImg:hover { opacity: 0.7; }
/* The Modal (background) */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  /* FIX: hide horizontal overflow so wide images never trigger a side scrollbar */
  overflow-x: hidden;
  overflow-y: auto;
  padding: 60px 20px 60px;
  box-sizing: border-box;
  gap: 12px;
}
/* Inner wrapper: centers image vertically when it fits the screen,
   lets modal scroll naturally when image is zoomed larger */
.modal-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  gap: 12px;
  width: 100%;
}
/* Modal Content (Image): fits screen on open, no distortion */
.modal-content {
  display: block;
  /* FIX: 92vw instead of 90vw so image + padding never exceeds viewport width */
  max-width: 92vw;
  max-height: 78vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  transition: max-width 0.3s ease, max-height 0.3s ease, width 0.3s ease;
}
/* Open animation */
@keyframes modal-open-pop {
  from { opacity: 0; transform: scale(0.93); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-content {
  animation: modal-open-pop 0.2s ease-out;
}
/* Caption */
#caption {
  display: block;
  width: 80%;
  max-width: 700px;
  text-align: center;
  font-family: Georgia, 'Times New Roman', Times, serif;
  color: #ccc;
  padding: 0;
  height: auto;
  font-size: 0.95rem;
  line-height: 1.5;
  padding-bottom: 40px;
}
/* The Close Button */
.close {
  position: fixed;
  top: 15px;
  right: 35px;
  color: #f1f1f1;
  font-size: 40px;
  font-weight: bold;
  transition: 0.3s;
  line-height: 1;
  cursor: pointer;
  z-index: 1001;
}
.close:hover,
.close:focus {
  color: #bbb;
  text-decoration: none;
  cursor: pointer;
}
/* Lock page scroll when modal is open */
body.modal-open {
  overflow: hidden;
  height: 100vh;
}
/* -------------------------------------------------------- */
/* MOBILE */
/* -------------------------------------------------------- */
@media only screen and (max-width: 700px) {
  /* FIX: switch to a proper 2-column grid so items always sit 2-per-row */
  .ingallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.25rem;
    justify-items: center;
  }

  .ingallery .inimage {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    margin: 0;
  }

  /* FIX: tighter side padding so image has full width, less chance of overflow */
  .modal {
    padding: 55px 8px 40px;
    /* FIX: hide scrollbar visually on mobile (scroll still works) */
    -ms-overflow-style: none;  /* IE / Edge */
    scrollbar-width: none;     /* Firefox */
  }

  /* FIX: hide scrollbar for WebKit (Chrome, Safari) */
  .modal::-webkit-scrollbar {
    display: none;
  }

  .modal-content {
    /* FIX: near-full width on mobile so there's no room for a side scrollbar */
    max-width: 96vw;
    max-height: 70vh;
  }

  /* FIX: move close button inward so it's not clipped on narrow screens */
  .close {
    right: 16px;
    font-size: 32px;
  }
}