.chess-fx {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 8;
  contain: layout paint;
  --fx-bright: #a5f9e2;
  --fx-flare: #ffe4a3;
}
:root[data-realm='sugar'] .chess-fx {
  --fx-bright: #fc8fe8;
  --fx-flare: #d3ff91;
}
:root[data-realm='ashen'] .chess-fx {
  --fx-bright: #ffa654;
  --fx-flare: #fbd3a0;
}
:root[data-realm='jackpot'] .chess-fx {
  --fx-bright: #63eeff;
  --fx-flare: #ff61c1;
}
.chess-fx-spark {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--fx-bright);
  box-shadow: 0 0 8px 2px var(--fx-bright);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  animation: chess-fx-burst 560ms var(--fx-delay, 0ms) ease-out forwards;
}
.chess-fx-mine,
.chess-fx-blade,
.chess-fx-damage,
.chess-fx-defeat {
  background: var(--fx-flare);
  box-shadow: 0 0 10px 3px var(--fx-flare);
}
.chess-fx-victory,
.chess-fx-rush,
.chess-fx-jackpot {
  width: 12px;
  height: 12px;
  animation-duration: 760ms;
}
@keyframes chess-fx-burst {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--fx-dx)), calc(-50% + var(--fx-dy)))
      scale(0.3);
    opacity: 0;
  }
}
html.meta-motion-off .chess-fx {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  .chess-fx {
    display: none;
  }
}

.chess-fx-traveler {
  position: absolute;
  display: grid;
  place-items: center;
  width: 12.5%;
  height: 12.5%;
  pointer-events: none;
  z-index: 2;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
  animation: chess-fx-travel 420ms cubic-bezier(0.2, 0.82, 0.25, 1) forwards;
}

.chess-fx-traveler .piece {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: clamp(24px, 4vw, 56px);
  filter: drop-shadow(0 2px 5px var(--fx-flare));
}

.chess-fx-traveler-capture {
  animation-duration: 330ms;
}

:root[data-realm='sugar'] .chess-fx-traveler .piece {
  filter: drop-shadow(0 0 9px #ff8bea);
}

:root[data-realm='ashen'] .chess-fx-traveler .piece {
  filter: drop-shadow(0 4px 7px #db6c3b);
}

:root[data-realm='jackpot'] .chess-fx-traveler .piece {
  filter: drop-shadow(0 0 10px #63eeff);
}

.chess-fx-impact {
  position: absolute;
  width: 15%;
  aspect-ratio: 1;
  border: 3px solid var(--fx-flare);
  border-radius: 50%;
  background: radial-gradient(circle, var(--fx-bright), transparent 65%);
  pointer-events: none;
  transform: translate(-50%, -50%);
  opacity: 0;
  animation: chess-fx-impact 720ms ease-out forwards;
}

.chess-fx-impact-rush,
.chess-fx-impact-laststand,
.chess-fx-impact-jackpot,
.chess-fx-impact-victory,
.chess-fx-impact-defeat {
  width: 48%;
  border-width: 7px;
  animation-duration: 1000ms;
}

.chess-fx-impact-rush {
  border-style: dotted;
  background: conic-gradient(
    from 45deg,
    #fc8fe8,
    transparent,
    #a6ff90,
    transparent,
    #93edff,
    transparent,
    #fc8fe8
  );
}

.chess-fx-impact-laststand {
  border-style: double;
  background: radial-gradient(circle, #fff1ad, #ba5827 25%, transparent 68%);
  box-shadow: 0 0 22px #a14727;
}

.chess-fx-impact-jackpot,
.chess-fx-impact-wager {
  border-radius: 12%;
  border-style: double;
  transform: translate(-50%, -50%) rotate(45deg);
  background: repeating-conic-gradient(
    from 0deg,
    #51f9fe 0deg 10deg,
    transparent 10deg 40deg,
    #fb6ad2 40deg 50deg,
    transparent 50deg 80deg
  );
}

@keyframes chess-fx-travel {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.95;
  }
  55% {
    transform: translate(
        calc(-50% + var(--fx-mid-x)),
        calc(-50% + var(--fx-mid-y))
      )
      scale(1.14);
    opacity: 1;
  }
  100% {
    transform: translate(
        calc(-50% + var(--fx-travel-x)),
        calc(-50% + var(--fx-travel-y))
      )
      scale(0.94);
    opacity: 0;
  }
}

@keyframes chess-fx-impact {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 0.95;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.6);
    opacity: 0;
  }
}

.chess-fx-cinematic {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
  background: radial-gradient(circle, #ffffff33, #080a18bb 70%);
  animation: chess-fx-scene 1800ms ease-in-out both;
}

.chess-fx-cinematic strong {
  display: block;
  max-width: 92%;
  padding: 0.45em 0.7em;
  border: 3px solid currentColor;
  border-radius: 0.35em;
  font-size: clamp(1.15rem, 5vw, 3.4rem);
  font-weight: 950;
  line-height: 1.15;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 3px 12px #000c;
  transform: rotate(-4deg);
}

.chess-fx-cinematic-sugar {
  color: #fff0a4;
  background: repeating-conic-gradient(
    #f76ec777 0deg 24deg,
    #71e6f077 24deg 48deg
  );
}

.chess-fx-cinematic-ashen {
  color: #ffce86;
  background: radial-gradient(circle at bottom, #e35a3677, #160d19ee 75%);
}

.chess-fx-cinematic-jackpot {
  color: #9dffed;
  background: repeating-linear-gradient(
    110deg,
    #321c64dd 0 24px,
    #b5277fbb 24px 28px
  );
}

@keyframes chess-fx-scene {
  0%,
  100% {
    opacity: 0;
  }
  16%,
  78% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chess-fx-cinematic {
    display: none;
  }
}

/* Painted special-action plates: a short framed flash over the board. */
.chess-fx-plate {
  position: absolute;
  inset: 6%;
  margin: 0;
  display: grid;
  place-items: end center;
  overflow: hidden;
  border-radius: 18px;
  border: 3px solid #ffffffcc;
  box-shadow: 0 18px 60px #000c;
  pointer-events: none;
  animation: chess-fx-plate 1600ms ease-in-out both;
  z-index: 6;
}
.chess-fx-plate img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: chess-fx-plate-pan 1600ms ease-out both;
}
.chess-fx-plate figcaption {
  position: relative;
  margin: 0 0 6%;
  padding: 0.35em 0.8em;
  border-radius: 0.4em;
  background: #080a18cc;
  color: #fff6c8;
  font-size: clamp(1rem, 4.6vw, 2.6rem);
  font-weight: 950;
  letter-spacing: 0.08em;
  text-shadow: 0 3px 10px #000;
}
.chess-fx-plate-rush figcaption {
  color: #ffe6fb;
  background: #b0337fcc;
}
.chess-fx-plate-laststand figcaption {
  color: #ffce86;
  background: #2a0f0ccc;
}
.chess-fx-plate-wager figcaption {
  color: #9dffed;
  background: #2b1660cc;
}
@keyframes chess-fx-plate {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.94);
  }
  14%,
  82% {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes chess-fx-plate-pan {
  from {
    transform: scale(1.14) translateY(2%);
  }
  to {
    transform: scale(1.02) translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .chess-fx-plate {
    display: none;
  }
}
