body {
    margin: 0;
    font-family: sans-serif;
  }
  .gallery-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 10px;
    max-width: 100%;
    margin: auto;
  }
  .gallery-item {
    width: 100%;
    height: 0;
    padding-bottom: 66.66%;/*  Aspect ratio 3:2 */
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
  }
  .gallery-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
  }
  .gallery-item:hover img {
    transform: scale(1.05);
  }
  .image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.4) 40%, transparent 70%);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 15px;
    box-sizing: border-box;
  }
  .gallery-item:hover .image-overlay {
    opacity: 1;
  }
  .alt-text {
    color: white;
    font-size: 1.2em;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
    margin: 0;
  }

  /* Modal Styles */
  .modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.85); /* Black w/ opacity */
    padding-top: 20px; /* Location of the box */
    box-sizing: border-box;
  }
  .modal-content {
    position: relative;
    margin: auto;
    padding: 0;
    width: 90%;
    max-width: 800px; /* Max width of the image/content */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
  }
  .modal-image {
    max-width: 100%;
    max-height: 80vh; /* Max height of the image */
    display: block;
    margin: 0 auto 10px auto; /* Spacing below image */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  }
  .modal-caption {
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    font-size: 0.9em;
    width: 100%;
    max-width: 700px;
  }
  .close-button {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
  }
  .close-button:hover,
  .close-button:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
  }
  .prev-button, .next-button {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -30px; /* Adjust based on button size */
    color: white;
    font-weight: bold;
    font-size: 24px;
    transition: 0.3s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background-color: rgba(0,0,0,0.3);
  }
  .prev-button {
    left: 10px;
    border-radius: 3px 0 0 3px;
  }
  .next-button {
    right: 10px;
    border-radius: 3px 0 0 3px;
  }
  .prev-button:hover, .next-button:hover {
    background-color: rgba(0,0,0,0.6);
  }

  /* Responsive adjustments */
  @media (max-width: 900px) {
    .gallery-container {
      grid-template-columns: repeat(2, 1fr);
    }
  }
  @media (max-width: 600px) {
    .gallery-container {
      grid-template-columns: 1fr;
    }
    .alt-text {
        font-size: 0.8em;
    }
    .modal-image {
        max-height: 70vh;
    }
    .prev-button, .next-button {
        font-size: 18px;
        padding: 12px;
    }
    .close-button {
        font-size: 30px;
        top: 10px;
        right: 20px;
    }
  }
  