.pipboy-section {
  width: min(980px, calc(100% - var(--page-gutter)));
  margin: clamp(34px, 6vw, 70px) auto;
}

.pipboy-carousel {
  position: relative;
  width: min(100%, 900px);
  margin-inline: auto;
}

/* Frame sits on top */
.pipboy-frame {
  position: relative;
  z-index: 2;
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

/* Gallery screen sits behind the frame */
.pipboy-screen {
  position: absolute;
  z-index: 4;

  left: 15%;
  top: 21%;
  width: 47%;
  height: 51%;

  overflow: hidden;
  border: 2px solid rgba(115, 255, 112, 0.55);
  border-radius: 30px;
  background: #061108;
}

.pipboy-screen img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;

  filter:
    sepia(0.35)
    hue-rotate(65deg)
    saturate(1.25)
    contrast(1.15)
    brightness(0.9);

  transition: opacity 0.35s ease;
}

.pipboy-screen img.is-fading {
  opacity: 0;
}

.pipboy-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(95, 255, 112, 0.08) 0px,
      rgba(95, 255, 112, 0.08) 1px,
      transparent 2px,
      transparent 5px
    ),
    radial-gradient(circle at center, transparent 45%, rgba(0, 0, 0, 0.48));
}

/* Buttons */
.pipboy-button {
  position: absolute;
  z-index: 6;
  top: 50%;
  transform: translateY(-50%);

  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid rgba(115, 255, 112, 0.55);

  color: #9cff7d;
  background: rgba(0, 0, 0, 0.65);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.pipboy-prev {
  left: 12%;
}

.pipboy-next {
  left: 60.3%;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
}

.gallery-lightbox.is-open {
  pointer-events: auto;
  opacity: 1;
}

.gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(67, 255, 86, 0.14), transparent 34%),
    rgba(0, 0, 0, 0.82);
  opacity: 0;
  transition: opacity 0.28s ease;
}

.gallery-lightbox.is-open .gallery-lightbox-backdrop {
  opacity: 1;
}

.gallery-lightbox-window {
  position: relative;
  z-index: 2;

  width: min(92vw, 980px);
  max-height: 86vh;
  padding: clamp(10px, 2vw, 18px);

  border: 3px solid rgba(141, 255, 113, 0.72);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(6, 18, 8, 0.96), rgba(20, 44, 18, 0.92)),
    repeating-linear-gradient(
      to bottom,
      rgba(104, 255, 105, 0.08) 0px,
      rgba(104, 255, 105, 0.08) 1px,
      transparent 2px,
      transparent 6px
    );

  box-shadow:
    inset 0 0 24px rgba(116, 255, 102, 0.22),
    0 0 28px rgba(116, 255, 102, 0.22),
    0 24px 70px rgba(0, 0, 0, 0.75);

  transform: scale(0.12) rotate(-4deg);
  opacity: 0;
  filter: brightness(1.8) blur(6px);
}

.gallery-lightbox.is-open .gallery-lightbox-window {
  animation: crtOpen 0.42s cubic-bezier(.2, 1.2, .25, 1) forwards;
}

.gallery-lightbox.is-closing .gallery-lightbox-window {
  animation: crtClose 0.32s ease forwards;
}

.gallery-lightbox-window img {
  width: 100%;
  max-height: calc(86vh - 36px);
  display: block;
  object-fit: contain;
  border-radius: 14px;
  cursor: pointer;
}

.gallery-lightbox-window::after {
  content: "";
  position: absolute;
  inset: clamp(10px, 2vw, 18px);
  pointer-events: none;
  border-radius: 14px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(122, 255, 109, 0.09) 0px,
      rgba(122, 255, 109, 0.09) 1px,
      transparent 2px,
      transparent 5px
    );
  mix-blend-mode: screen;
}

@keyframes crtOpen {
  0% {
    transform: scale(0.08, 0.02) rotate(-5deg);
    opacity: 0;
    filter: brightness(2.4) blur(9px);
  }

  45% {
    transform: scale(1.05, 0.08) rotate(1deg);
    opacity: 1;
    filter: brightness(2) blur(4px);
  }

  72% {
    transform: scale(0.98, 1.04) rotate(0deg);
    filter: brightness(1.25) blur(1px);
  }

  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
    filter: brightness(1) blur(0);
  }
}

@keyframes crtClose {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
    filter: brightness(1) blur(0);
  }

  55% {
    transform: scale(1.04, 0.1) rotate(2deg);
    opacity: 1;
    filter: brightness(2) blur(4px);
  }

  100% {
    transform: scale(0.06, 0.02) rotate(-4deg);
    opacity: 0;
    filter: brightness(2.5) blur(10px);
  }
}

.pipboy-screen {
  cursor: zoom-in;
}

@media (max-width: 720px) {
  .pipboy-section {
    width: 100%;
  }

  .pipboy-carousel {
    width: 125%;
    transform: translateX(-10%);
  }

  .pipboy-button {
    width: 34px;
    height: 34px;
    font-size: 1.5rem;
  }
}