body {
  visibility: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #fafafa;
  margin: 0;
  padding: 20px;
}
h1 {
  text-align: center;
  margin-bottom: 30px;
}
.gallery {
  max-width: 960px;
  margin: 0 auto;
  padding-left:32px;
}
.gallery-item {
  width: 30%;
  margin-bottom: 20px;
  box-sizing: border-box;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease;
}
.gallery-item:hover {
  transform: scale(1.03);
}
.gallery-item img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  border-bottom: 1px solid #eee;
}
.caption {
  padding: 10px;
  font-size: 0.9rem;
  color: #555;
  text-align: center;
}

/* モーダル初期状態 */
#modal-viewer {
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 9999;
  cursor: zoom-out;

  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}
#modal-viewer.active {
  opacity: 1;
  visibility: visible;
}
#modal-viewer img {
  max-width: 90vw;
  max-height: 90vh;
  display: block;
  margin: 0 auto;
  box-shadow: 0 0 30px #000;
  border-radius: 10px;
}
#modal-caption {
  margin-top: 10px;
  color: #ddd;
  font-size: 1rem;
  text-align: center;
}
#modal-viewer > div {
  text-align: center;
}

@media (max-width: 768px) {
  .gallery-item {
    width: 48%;
  }
}
@media (max-width: 480px) {
  .gallery-item {
    width: 98%;
  }
}
.modal-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0,0,0,0.5);
  border: none;
  color: white;
  font-size: 2rem;
  padding: 0.3em 0.7em;
  cursor: pointer;
  z-index: 1001;
  user-select: none;
  border-radius: 4px;
  transition: background-color 0.3s;
}

.modal-nav-btn:hover {
  background-color: rgba(0,0,0,0.8);
}

#modal-prev-btn {
  left: 10px;
}

#modal-next-btn {
  right: 10px;
}
