.game-stage .portrait-layer {
  --portrait-base-height: clamp(22rem, 55vh, 34rem);
  position: relative;
  display: block;
  width: 100%;
  height: clamp(25rem, 61vh, 38rem);
  min-height: 0;
  overflow: hidden;
  padding: 0;
  isolation: isolate;
  pointer-events: none;
}

.game-stage .portrait-layer[hidden] {
  display: block;
  visibility: hidden;
}

.portrait-slot {
  position: absolute;
  inset-block: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 34%;
  overflow: visible;
}

.portrait-slot-left {
  left: 5%;
}

.portrait-slot-center {
  left: 33%;
}

.portrait-slot-right {
  right: 5%;
}

.stage-portrait {
  --character-height-scale: 1;
  position: relative;
  z-index: 1;
  display: grid;
  flex: 0 0 auto;
  place-items: end center;
  width: auto;
  height: calc(var(--portrait-base-height) * var(--character-height-scale));
  max-height: calc(100% / 1.06);
  aspect-ratio: 3 / 4;
  margin: 0;
  overflow: visible;
  filter: brightness(0.72) saturate(0.88);
  transform: scale(1);
  transform-origin: center bottom;
  transition:
    filter 180ms ease,
    transform 180ms ease,
    opacity 180ms ease;
  opacity: 0.94;
}

.stage-portrait[data-character='ryan'] {
  --character-height-scale: 1;
}

.stage-portrait[data-character='cooper'],
.stage-portrait[data-character='sterling'] {
  --character-height-scale: 0.97;
}

.stage-portrait[data-character='cydney'] {
  --character-height-scale: 0.91;
}

.stage-portrait[data-character='gabi'],
.stage-portrait[data-character='ashley'] {
  --character-height-scale: 0.84;
}

.stage-portrait[data-character='kenly'] {
  --character-height-scale: 0.81;
}

.stage-portrait.is-speaking {
  z-index: 3;
  filter: brightness(1) saturate(1);
  transform: scale(1.06);
  opacity: 1;
}

.stage-portrait .portrait-image,
.stage-portrait .portrait-fallback {
  grid-area: 1 / 1;
  align-self: end;
  justify-self: center;
}

.stage-portrait .portrait-image {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 3 / 4;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 1.1rem 1.2rem rgba(0, 0, 0, 0.36));
}

.stage-portrait .portrait-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  aspect-ratio: 3 / 4;
  border: 1px solid rgba(224, 228, 240, 0.28);
  border-radius: 1rem 1rem 0.3rem 0.3rem;
  box-shadow: 0 1.2rem 2.5rem rgba(0, 0, 0, 0.28);
}

.stage-portrait.has-image .portrait-fallback {
  visibility: hidden;
}

.stage-portrait .portrait-caption {
  position: relative;
  z-index: 4;
  grid-area: 1 / 1;
  align-self: end;
  margin: 0 0 0.9rem;
  transition: opacity 180ms ease;
}

.stage-portrait.is-inactive .portrait-caption {
  opacity: 0.62;
}

@media (max-width: 680px) {
  .game-stage .portrait-layer {
    --portrait-base-height: clamp(15rem, 42vh, 22rem);
    height: clamp(18rem, 48vh, 25rem);
  }

  .portrait-slot {
    width: 40%;
  }

  .portrait-slot-left {
    left: 0;
  }

  .portrait-slot-center {
    left: 30%;
  }

  .portrait-slot-right {
    right: 0;
  }

  .stage-portrait {
    max-height: calc(100% / 1.05);
  }

  .stage-portrait.is-speaking {
    transform: scale(1.05);
  }

  .stage-portrait .portrait-caption {
    margin-bottom: 0.55rem;
    padding: 0.3rem 0.55rem;
    font-size: 0.62rem;
  }
}
