:root {
  --screen-bg: #000;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: var(--screen-bg);
  overflow: hidden;
}

.screen-page {
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.stage-shell {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.stage {
  position: relative;
  width: min(100%, calc((100dvh - 24px) * 24 / 5));
  max-width: 100%;
  aspect-ratio: 24 / 5;
  overflow: hidden;
  background: #000;
}

@media (min-aspect-ratio: 24/5) {
  .stage {
    width: auto;
    height: min(calc(100dvh - 24px), 100%);
  }
}

.porthole-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.porthole {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: calc(var(--size) * 1%);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  overflow: hidden;
}

.porthole video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.porthole img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.porthole .loop-video {
  position: absolute;
  inset: 0;
  transition: opacity 80ms linear;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.ship-bg {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

@media (max-width: 900px) {
  .screen-page {
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .stage {
    width: 100%;
  }
}
