/* ---------- special effects layer (js/effects.js) ---------- */
.fxl { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.fxl.fxl-top { z-index: 7; }
.fxl:not(.fxl-top) { animation: fxlIn 1.8s ease-out; }
@keyframes fxlIn { from { opacity: 0; } }
.fxl > *, .fxl-wavelayer { position: absolute; pointer-events: none; }
.fxl-wavelayer { z-index: 3; }

/* light rays */
.fxl-ray {
  transform-origin: 50% 0; mix-blend-mode: screen; filter: blur(10px);
  mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
  animation: raySway 9s ease-in-out infinite alternate;
}
@keyframes raySway { 0% { opacity: calc(var(--o) * .55); } 50% { opacity: var(--o); } 100% { opacity: calc(var(--o) * .7); } }
.fxl-mote {
  position: absolute; width: 3px; height: 3px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px 2px rgba(255,255,255,.6);
  animation: mote 12s linear infinite;
}
@keyframes mote { 0% { transform: translate(0, 0); opacity: 0; } 15%, 85% { opacity: .9; } 100% { transform: translate(18px, 90px); opacity: 0; } }

/* flame glow */
.fxl-flame {
  width: calc(14% * var(--s)); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle, rgba(255,200,110,.55), rgba(255,140,50,.22) 35%, transparent 68%);
  mix-blend-mode: screen; animation: flicker 2.3s infinite;
}
@keyframes flicker {
  0%, 100% { opacity: .85; transform: translate(-50%, -50%) scale(1); }
  12% { opacity: .65; transform: translate(-50%, -51%) scale(.94); }
  27% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  41% { opacity: .75; } 58% { opacity: .95; transform: translate(-50%, -50%) scale(1.02); }
  73% { opacity: .7; transform: translate(-50%, -49%) scale(.96); } 86% { opacity: .9; }
}
.fxl-roomflicker { inset: 0; background: rgba(255,150,60,.07); mix-blend-mode: overlay; animation: roomFlicker 3.1s infinite; }
@keyframes roomFlicker { 0%, 100% { opacity: .6; } 20% { opacity: 1; } 35% { opacity: .4; } 60% { opacity: .9; } 80% { opacity: .5; } }

/* ground mist */
.fxl-mist {
  left: 0; width: 200%; height: 45%; background-repeat: repeat-x; background-size: 50% 100%;
  filter: blur(6px); mix-blend-mode: screen;
  animation: mist 70s linear infinite;
}
@keyframes mist { to { transform: translateX(-50%); } }

/* rippling water: the background itself, displaced, inside the water mask */
.fxl-water {
  inset: 0; background-size: 100% 100%; filter: url(#fxlRipple) brightness(1.08) saturate(1.1);
  mask-size: 100% 100%; -webkit-mask-size: 100% 100%;
}
.fxl-caustics {
  inset: 0; mix-blend-mode: screen; opacity: .45; mask-size: 100% 100%; -webkit-mask-size: 100% 100%;
  background:
    radial-gradient(ellipse 3% 1.2% at 20% 30%, rgba(200,255,250,.9), transparent),
    radial-gradient(ellipse 4% 1% at 60% 80%, rgba(200,255,250,.8), transparent),
    radial-gradient(ellipse 2% 1% at 80% 40%, rgba(200,255,250,.9), transparent),
    radial-gradient(ellipse 3% 1.3% at 40% 60%, rgba(200,255,250,.8), transparent);
  background-size: 22% 18%; animation: caustics 6s linear infinite;
}
@keyframes caustics { to { background-position: 22% 9%, -22% 18%, 11% -18%, -11% 9%; } }

/* glyph light-wave */
.fxl-wave {
  inset: 0; background-size: 100% 100%;
  filter: grayscale(1) brightness(1.9) contrast(1.5) sepia(1) saturate(4) hue-rotate(5deg);
  mix-blend-mode: screen;
}
.fxl-wavecore {
  width: 6%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; mix-blend-mode: screen;
  background: radial-gradient(circle, #fff, rgba(255,215,120,.7) 30%, transparent 70%);
  animation: waveCore 1.6s ease-out forwards;
}
@keyframes waveCore { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(5); } }

.fxl-canvas { inset: 0; width: 100%; height: 100%; }

/* guardian spirit */
.fxl-spirit { width: 13%; transform: translate(-50%, -100%); }
.fxl-spirit img {
  width: 100%; display: block;
  filter: drop-shadow(0 0 8px rgba(90,255,210,.75)) drop-shadow(0 0 26px rgba(60,230,190,.45)) brightness(1.08);
  animation: spiritFloat 4s ease-in-out 2.4s infinite alternate, spiritFlicker 3.3s steps(1) infinite;
}
.fxl-spirit { animation: spiritIn 2.4s ease-out both; }
.fxl-spirit.out { animation: spiritOut 2s ease-in forwards; }
@keyframes spiritIn { 0% { opacity: 0; transform: translate(-50%, -88%) scaleY(.6); filter: blur(14px); } 100% { opacity: 1; transform: translate(-50%, -100%); filter: none; } }
@keyframes spiritFloat { to { transform: translateY(-3%); } }
@keyframes spiritFlicker { 0%, 100% { opacity: 1; } 47% { opacity: .6; } 49% { opacity: 1; } 81% { opacity: .8; } }
@keyframes spiritOut { from { opacity: 1; transform: translate(-50%, -100%); } to { opacity: 0; transform: translate(-50%, -112%) scaleX(.7); filter: blur(16px); } }
.fxl-whisper {
  bottom: 4%; width: 56%; transform: translateX(-50%); text-align: center;
  font: italic 22px/1.35 Spectral, Georgia, serif; color: #c9fff0;
  text-shadow: 0 0 10px rgba(80,230,190,.9), 0 0 2px #000; opacity: 0; animation: whisper 6s ease 1.4s forwards;
}
@keyframes whisper { 0% { opacity: 0; letter-spacing: .3em; filter: blur(4px); } 25%, 80% { opacity: 1; letter-spacing: .02em; filter: none; } 100% { opacity: 0; } }
.fxl-whisper.out { opacity: 0; transition: opacity 1s; }
