.encounter {
  --round: 7.6s;
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 1.4;
  pointer-events: none;
}
.battle-board {
  position: absolute; left: 1%; top: 37%; width: 98%; height: 51%;
  border-radius: 50%; border: 1px solid #ecce92;
  background: linear-gradient(180deg, #33284544, #331f3915 50%, #261b3c3d), url("media/astrolabe.webp") center / 100% 100%;
  box-shadow: inset 0 0 0 2px #70534e, inset 0 0 0 4px #cda86e, 0 3px #493242, 0 5px #c9a269, 0 8px #654a48, 0 1.4rem 2rem #27152f6b;
}
.piece {
  position: absolute; transform: translateX(-50%);
  --stone: #58605d; --rim: #e4c892;
}
.piece::before {
  content: ""; position: absolute; inset: auto 4% -3%; height: 14%; border-radius: 50%;
  border: 1px solid var(--rim); background: radial-gradient(ellipse, var(--stone) 44%, #44343f 72%);
  box-shadow: 0 2px #46313b, 0 4px var(--rim), 0 6px #614b48, 0 8px 7px #1f172c70;
}
.portrait { position: relative; width: 100%; border-radius: 0 0 48% 48% / 0 0 9% 9%; transform-origin: 50% 98%; }
.guardian { left: 56%; bottom: 50%; width: 25%; --stone: #8b694c; }
.array-master { left: 24%; bottom: 24%; width: 34%; --stone: #41796c; }
.talisman { left: 76%; bottom: 16%; width: 36%; --stone: #9b514e; }
.technique, .link-earned span {
  display: block; width: max-content; max-width: 150%; padding: .2em .9em;
  color: #fff0d4; background: linear-gradient(90deg, transparent, #302437ea 16% 84%, transparent);
  font: 600 clamp(.9rem, 1.4vw, 1.15rem)/1.35 var(--serif); text-align: center;
}
.technique { position: absolute; left: 50%; top: 106%; transform: translateX(-50%); }
.formation {
  position: absolute; left: 39%; top: 44%; width: 34%; height: 13%; border-radius: 50%;
  border: 2px solid #a6f6c9;
  background: radial-gradient(ellipse, transparent 47%, #61dcaa6b 51%, transparent 55%, #59ce954d 65%, transparent 70%);
  box-shadow: 0 0 .7rem #8dffc1, inset 0 0 .65rem #7ce5a6;
}
.formation::after {
  content: ""; position: absolute; inset: -22% -6%; border: 1px dashed #d7ffcf; border-radius: 50%;
}
/* Each spell crosses from its caster's hand to the same point on the guardian. */
.spell { position: absolute; top: 36%; z-index: 1; }
.spell img { position: absolute; top: 0; width: 38%; }
.wood-cast { left: 30%; width: 26%; height: 19%; opacity: 0; }
.wood-cast img { right: 0; transform: translate(50%, -50%); filter: drop-shadow(0 0 .35rem #9ef5ba); }
.fire-cast { left: 56%; width: 24%; height: 27%; transform: translate(45%, 18%); }
.fire-cast img { left: 0; transform: translate(-50%, -50%) rotate(-20deg); filter: drop-shadow(0 0 .35rem #ffb45d); }
.link-earned {
  position: absolute; z-index: 1; top: 64%; left: 44%; width: 11%;
  display: grid; justify-items: center;
}
.link-earned img { width: 88%; filter: drop-shadow(0 0 .45rem #ffe5a0); }
.link-earned span { font-size: .88rem; }

@media (prefers-reduced-motion: no-preference) {
  .array-master .portrait, .talisman .portrait, .guardian .portrait,
  .wood-cast, .fire-cast, .formation, .link-earned {
    animation-duration: var(--round); animation-iteration-count: infinite; animation-timing-function: ease-in-out;
  }
  .array-master .portrait { animation-name: place-array; }
  .talisman .portrait { animation-name: cast-seal; }
  .guardian .portrait { animation-name: take-hit; }
  .wood-cast { animation-name: send-array; }
  .fire-cast { animation-name: send-seal; }
  .formation { animation-name: mark-and-ignite; }
  .link-earned { animation-name: gain-link; }
}
@keyframes place-array {
  0%, 29%, 100% { transform: none; }
  8% { transform: translate(-2%, -3%) rotate(-3deg); }
  16% { transform: translate(5%, -5%) rotate(4deg); }
}
@keyframes cast-seal {
  0%, 38%, 72%, 100% { transform: none; }
  48% { transform: translate(3%, -3%) rotate(3deg); }
  57% { transform: translate(-6%, -5%) rotate(-5deg); }
}
@keyframes send-array {
  0%, 8%, 100% { opacity: 0; transform: translate(-100%, 100%); }
  12% { opacity: 1; transform: translate(-96%, 72%); }
  23% { opacity: 1; transform: translate(0, 0); }
  28%, 99% { opacity: 0; transform: translate(0, 0); }
}
@keyframes send-seal {
  0%, 46%, 100% { opacity: 0; transform: translate(100%, 100%); }
  51% { opacity: 1; transform: translate(99%, 77%); }
  56% { opacity: 1; transform: translate(65%, 8%); }
  63% { opacity: 1; transform: translate(0, 0); }
  68%, 99% { opacity: 0; transform: translate(0, 0); }
}
@keyframes mark-and-ignite {
  0%, 19%, 100% { opacity: 0; transform: scale(.55); }
  25%, 57% { opacity: 1; transform: scale(1); filter: none; }
  64% { opacity: 1; transform: scale(1.24); filter: sepia(1) saturate(4) hue-rotate(339deg); }
  82%, 99% { opacity: 0; transform: scale(1.38); filter: sepia(1) saturate(4) hue-rotate(339deg); }
}
@keyframes take-hit {
  0%, 20%, 30%, 59%, 74%, 100% { transform: none; }
  24% { transform: rotate(4deg) translateY(-3%); }
  64% { transform: rotate(-7deg) translateY(-7%); }
}
@keyframes gain-link {
  0%, 63%, 100% { opacity: 0; transform: translateY(22%) scale(.78); }
  72%, 88% { opacity: 1; transform: none; }
  97% { opacity: 0; transform: translateY(-12%); }
}
@media (max-width: 760px) {
  .encounter { width: min(100%, 26rem); justify-self: center; }
}
