:root {
  --fx-core: #efb54a;
  --fx-accent: #f7dd91;
  --fx-rgb: 239, 181, 74;
}

body[data-fx-tier="1"] {
  --fx-core: #efb54a;
  --fx-accent: #f7dd91;
  --fx-rgb: 239, 181, 74;
}

body[data-fx-tier="2"] {
  --fx-core: #6bb7ff;
  --fx-accent: #d4ebff;
  --fx-rgb: 107, 183, 255;
}

body[data-fx-tier="3"] {
  --fx-core: #53ca8f;
  --fx-accent: #f6d877;
  --fx-rgb: 83, 202, 143;
}

body[data-fx-tier="4"] {
  --fx-core: #9a72ff;
  --fx-accent: #ffd76f;
  --fx-rgb: 154, 114, 255;
}

body[data-fx-tier="5"] {
  --fx-core: #ffd35c;
  --fx-accent: #fff3b7;
  --fx-rgb: 255, 211, 92;
}

.crossword-panel {
  isolation: isolate;
}

.crossword-cell {
  overflow: visible;
  isolation: isolate;
}

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.crossword-panel.fx-board-pulse::after,
.crossword-panel.fx-board-finale::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(var(--fx-rgb), 0.42), rgba(var(--fx-rgb), 0.18) 32%, transparent 68%);
}

.crossword-panel.fx-board-pulse::after {
  animation: fxBoardPulse 980ms ease-out forwards;
}

.crossword-panel.fx-board-finale::after {
  animation: fxBoardPulse 1.2s ease-out forwards;
}

.crossword-cell.fx-word-complete {
  z-index: 5;
  color: #1f2f48;
  animation: fxCellCelebrate 980ms cubic-bezier(0.2, 0.8, 0.2, 1);
  box-shadow:
    0 0 0 2px rgba(var(--fx-rgb), 0.72),
    0 0 16px rgba(var(--fx-rgb), 0.75),
    0 0 30px rgba(var(--fx-rgb), 0.42);
}

.crossword-cell.fx-word-complete::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: inherit;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.95), rgba(var(--fx-rgb), 0.68) 42%, transparent 72%);
  opacity: 0;
  animation: fxCellGlow 980ms ease-out;
}

.active-clue-panel.fx-clue-pop,
.completion-card.fx-final-card {
  animation: fxPanelCelebrate 760ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.clue-item.fx-clue-win {
  animation: fxClueWin 950ms ease-out;
}

.fx-burst {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  z-index: 11;
}

.fx-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(34px * var(--fx-scale, 1));
  height: calc(34px * var(--fx-scale, 1));
  margin-left: calc(-17px * var(--fx-scale, 1));
  margin-top: calc(-17px * var(--fx-scale, 1));
  border: 3px solid rgba(var(--fx-rgb), 0.92);
  border-radius: 999px;
  box-shadow: 0 0 24px rgba(var(--fx-rgb), 0.72), inset 0 0 18px rgba(255, 255, 255, 0.5);
  opacity: 0;
  animation: fxRingBurst 920ms ease-out forwards;
}

.fx-flash {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(28px * var(--fx-scale, 1));
  height: calc(28px * var(--fx-scale, 1));
  margin-left: calc(-14px * var(--fx-scale, 1));
  margin-top: calc(-14px * var(--fx-scale, 1));
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(var(--fx-rgb), 0.75) 42%, transparent 72%);
  filter: blur(1px);
  opacity: 0;
  animation: fxFlash 780ms ease-out forwards;
}

.fx-ray {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--ray-length, 42px);
  height: 3px;
  margin-top: -1.5px;
  transform-origin: 0 50%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(var(--fx-rgb), 0.86), transparent);
  box-shadow: 0 0 12px rgba(var(--fx-rgb), 0.65);
  opacity: 0;
  animation: fxRay 760ms ease-out forwards;
  animation-delay: var(--delay, 0s);
}

.fx-particle {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(10px * var(--size, 1));
  height: calc(10px * var(--size, 1));
  margin-left: calc(-5px * var(--size, 1));
  margin-top: calc(-5px * var(--size, 1));
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #ffffff, var(--fx-core) 58%, transparent 68%);
  box-shadow: 0 0 12px rgba(var(--fx-rgb), 0.4);
  opacity: 0;
  animation: fxParticleFloat 960ms ease-out forwards;
  animation-delay: var(--delay, 0s);
}



@keyframes fxFlash {
  0% { opacity: 0; transform: scale(0.2); }
  18% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(2.8); }
}

@keyframes fxRay {
  0% { opacity: 0; transform: rotate(var(--angle)) scaleX(0.1); }
  20% { opacity: 1; transform: rotate(var(--angle)) scaleX(1); }
  100% { opacity: 0; transform: rotate(var(--angle)) scaleX(0.25) translateX(16px); }
}

@keyframes fxCellCelebrate {
  0% { transform: scale(1); }
  18% { transform: scale(1.18); }
  38% { transform: scale(1.08); }
  60% { transform: scale(1.14); }
  100% { transform: scale(1); }
}

@keyframes fxCellGlow {
  0% { opacity: 0; transform: scale(0.85); }
  28% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 0; transform: scale(1.45); }
}

@keyframes fxPanelCelebrate {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(var(--fx-rgb), 0); }
  30% { transform: scale(1.03); box-shadow: 0 0 0 5px rgba(var(--fx-rgb), 0.18); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(var(--fx-rgb), 0); }
}

@keyframes fxClueWin {
  0% { transform: translateX(0); }
  18% { transform: translateX(4px) scale(1.02); }
  38% { transform: translateX(-2px) scale(1.01); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes fxBoardPulse {
  0% { opacity: 0; transform: scale(0.96); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.06); }
}

@keyframes fxRingBurst {
  0% { opacity: 0; transform: scale(0.25); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: scale(3.2); }
}

@keyframes fxParticleFloat {
  0% { opacity: 0; transform: translate(0, 0) scale(0.45); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.15); }
}


@media (prefers-reduced-motion: reduce) {
  .crossword-cell.fx-word-complete,
  .crossword-cell.fx-word-complete::after,
  .active-clue-panel.fx-clue-pop,
  .completion-card.fx-final-card,
  .clue-item.fx-clue-win,
  .crossword-panel.fx-board-pulse::after,
  .crossword-panel.fx-board-finale::after,
  .fx-ring,
  .fx-particle {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}
