.castle .experience-art {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-height: 0;
  width: 100%;
  margin: 0;
  overflow: visible;
}

.castle .experience-frame {
  position: relative;
  isolation: isolate;
  width: min(100%, 378px);
  aspect-ratio: .87;
  overflow: hidden;
  border-radius: 44% 44% 8px 8px;
}

.castle .experience-art .exp-arch {
  position: absolute;
  inset: 4% 7% 4%;
  width: auto;
  height: auto;
  border-radius: 44% 44% 8px 8px;
}

.castle .experience-character {
  bottom: 7%;
  left: 50%;
  width: 82%;
  transform: translateX(-50%);
  transform-origin: 50% 83%;
}

.castle .exp-art-caption {
  position: static;
  width: min(100%, 320px);
  padding: 8px 12px;
  border: 1px solid #b5905a72;
  background: #1e1724a3;
  color: #fae1bf;
  font-size: clamp(10px, 2.6vw, 12px);
  line-height: 1.4;
  letter-spacing: .12em;
  text-align: center;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

/* This fixed decoration is above the scene and below the header and native dialog. */
.castle-corruption {
  position: fixed;
  z-index: 25;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* The decoration continues over the footer background, below its text and links. */
.site-footer { z-index: auto; }

.site-footer > .container {
  position: relative;
  z-index: 26;
  text-shadow: 0 1px 4px #100b1c, 0 0 8px #100b1c;
}

/* Keep the middle of the viewport clear while the edges close in. */
.castle-corruption::before {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 0% 59%, #ad32fb82, transparent 46%),
    radial-gradient(ellipse at 100% 31%, #982aee88, transparent 43%),
    linear-gradient(0deg, #711d9f45, transparent 16%);
  opacity: var(--decay-mist, 0);
  content: "";
}

.corruption-edge {
  position: absolute;
  width: clamp(150px, 41vw, 690px);
  height: min(91vh, 840px);
}

.corruption-edge--left {
  --reveal: var(--decay-tendrils, 0);
  bottom: -4%;
  left: -5%;
  transform: translate3d(calc((1 - var(--reveal)) * -132%), 0, 0);
}

.corruption-edge--right {
  --reveal: var(--decay-echo, 0);
  top: -5%;
  right: -6%;
  transform: translate3d(calc((1 - var(--reveal)) * 132%), 0, 0) scale(-1, -1);
}

.corruption-tendril {
  position: absolute;
  top: var(--level);
  left: var(--anchor, 0%);
  width: var(--length);
  aspect-ratio: var(--sprite-ratio);
  translate: 0 -50%;
  rotate: var(--rest-angle);
  scale: 1 var(--thickness, 1);
}

.corruption-tendril::before {
  position: absolute;
  inset: 0;
  content: "";
  background: var(--tendril-image) no-repeat center / contain;
}

.corruption-tendril--left-top {
  --tendril-image: url("tendril-1.webp");
  --sprite-ratio: 670 / 249;
  --level: 22%;
  --length: 94%;
  --rest-angle: -9deg;
}

.corruption-tendril--left-middle {
  --tendril-image: url("tendril-3.webp");
  --sprite-ratio: 712 / 180;
  --level: 51%;
  --length: 114%;
  --anchor: -4%;
  --thickness: 1.22;
  --rest-angle: 3deg;
}

.corruption-tendril--left-bottom {
  --tendril-image: url("tendril-5.webp");
  --sprite-ratio: 689 / 232;
  --level: 80%;
  --length: 96%;
  --rest-angle: 7deg;
}

.corruption-tendril--right-top {
  --tendril-image: url("tendril-7.webp");
  --sprite-ratio: 719 / 201;
  --level: 83%;
  --length: 95%;
  --rest-angle: -8deg;
}

.corruption-tendril--right-upper {
  --tendril-image: url("tendril-2.webp");
  --sprite-ratio: 726 / 175;
  --level: 61%;
  --length: 90%;
  --rest-angle: 4deg;
}

.corruption-tendril--right-lower {
  --tendril-image: url("tendril-4.webp");
  --sprite-ratio: 750 / 178;
  --level: 36%;
  --length: 112%;
  --anchor: -4%;
  --thickness: 1.16;
  --rest-angle: -2deg;
}

.corruption-tendril--right-bottom {
  --tendril-image: url("tendril-6.webp");
  --sprite-ratio: 752 / 153;
  --level: 13%;
  --length: 94%;
  --rest-angle: 8deg;
}

.corruption-tendril--left-high-branch {
  --tendril-image: url("tendril-6.webp");
  --sprite-ratio: 752 / 153;
  --level: 12%;
  --length: 82%;
  --thickness: 0.52;
  --rest-angle: -25deg;
}

.corruption-tendril--left-fore-branch {
  --tendril-image: url("tendril-2.webp");
  --sprite-ratio: 726 / 175;
  --level: 37%;
  --length: 65%;
  --thickness: 0.63;
  --rest-angle: 18deg;
}

.corruption-tendril--left-low-branch {
  --tendril-image: url("tendril-1.webp");
  --sprite-ratio: 670 / 249;
  --level: 69%;
  --length: 72%;
  --thickness: 0.59;
  --rest-angle: -14deg;
}

.corruption-tendril--right-high-branch {
  --tendril-image: url("tendril-5.webp");
  --sprite-ratio: 689 / 232;
  --level: 91%;
  --length: 67%;
  --thickness: 0.5;
  --rest-angle: 17deg;
}

.corruption-tendril--right-fore-branch {
  --tendril-image: url("tendril-3.webp");
  --sprite-ratio: 712 / 180;
  --level: 49%;
  --length: 76%;
  --thickness: 0.59;
  --rest-angle: -21deg;
}

.corruption-tendril--right-low-branch {
  --tendril-image: url("tendril-7.webp");
  --sprite-ratio: 719 / 201;
  --level: 23%;
  --length: 66%;
  --thickness: 0.65;
  --rest-angle: 14deg;
}

.corruption-tendril--reverse::before { scale: -1 1; }

.corruption-tendril.is-deforming::before { visibility: hidden; }

.corruption-tendril canvas {
  visibility: hidden;
  position: absolute;
  top: -60%;
  left: 0;
  width: 100%;
  height: 220%;
}

.corruption-tendril.is-deforming canvas { visibility: visible; }

.castle [data-character] {
  transform-origin: 50% 80%;
  animation: castle-character-float var(--float-duration, 5.6s) ease-in-out infinite;
  animation-delay: var(--float-delay, 0s);
}

.castle [data-character="miyamoto"] {
  --rest-angle: 3deg;
  --float-lift: -9px;
  --float-turn: -1.3deg;
}

.castle [data-character="pafnutiy"] {
  --float-duration: 5.4s;
  --float-delay: -1.1s;
  --rest-angle: 5deg;
  --float-lift: -10px;
  --float-turn: -2deg;
}

.castle [data-character="borshchemir"] {
  --float-duration: 6.6s;
  --float-delay: -.8s;
  --baseline-x: -50%;
  --float-lift: -8px;
  --float-turn: 1deg;
}

.castle [data-character="montgomery"] {
  --float-duration: 5.2s;
  --baseline-x: 1%;
  --rest-angle: 4deg;
  --float-lift: -10px;
  --float-turn: -2deg;
}

.castle [data-character="gromykhalo"] {
  --float-duration: 6.3s;
  --float-delay: -1.5s;
  --rest-angle: 6deg;
  --float-lift: -8px;
  --float-turn: -1.5deg;
}

@keyframes castle-character-float {
  0%, 100% {
    transform: translate3d(var(--baseline-x, 0%), 0, 0) rotate(var(--rest-angle, 0deg));
  }

  50% {
    transform: translate3d(var(--baseline-x, 0%), var(--float-lift), 0)
      rotate(calc(var(--rest-angle, 0deg) + var(--float-turn)));
  }
}

@media (max-width: 850px) {
  .corruption-edge { width: clamp(125px, 42vw, 365px); height: clamp(275px, 72vh, 550px); }
  .corruption-edge--left { left: -12%; }
  .corruption-edge--right { right: -12%; }
}

@media (max-width: 580px) {
  .castle .experience-frame { width: min(100%, 300px); }
  .castle .exp-art-caption { width: min(100%, 265px); }
}

@media (prefers-reduced-motion: reduce) {
  /* Keep the requested ambient animation and limit its travel. */
  .castle [data-character] {
    --float-lift: -3px;
    --float-turn: 0deg;
    animation: castle-character-float 8s ease-in-out infinite !important;
  }
}
