/* ==========================================================================
   Lab Meltdown FX — the lab that really melts down.
   Pairs with meltdown-fx.js (window.LabMeltdownFX). Every selector is scoped
   to .lmfx-* so nothing here touches the game's own .lm-* styles.

   Three layers, all pointer-events:none and aria-hidden:
     .lmfx-back   behind the game UI   — lab plates + cracks/sparks/steam/molten
     .lmfx-front  above the game UI    — soft edge glow + beacons + answer pulses
                                         (edges only; the centre stays clear)
     .lmfx-cine   above everything     — 2-6 s stage change and finale cinematics

   Cost: opacity/transform animations only, no filters, no blend modes, no
   canvas. Nothing flashes faster than 2.5 times a second.
   ========================================================================== */

.lmfx-root { isolation: isolate; }
.lmfx-root-rel { position: relative; }

.lmfx {
  /* Game hues (same values the game page already uses) */
  --lmfx-calm: #2dd4bf;
  --lmfx-cool: #67e8f9;
  --lmfx-warn: #fbbf24;
  --lmfx-crit: #ef4444;
  --lmfx-melt: #ff6b35;
  --lmfx-hot: #fde68a;
  --lmfx-safe: #22c55e;
  --lmfx-ink: var(--ink, #EEF1FA);
  --lmfx-ink-2: var(--ink-2, #C3CBE3);
  --lmfx-void: var(--void, #05070F);
  --lmfx-heat: 0;

  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  overflow: hidden;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  contain: strict;
}
.lmfx * { pointer-events: none; }
.lmfx-fixed { position: fixed; }
.lmfx-back  { z-index: var(--lmfx-z-back, -1); background: var(--lmfx-void); }
.lmfx-front { z-index: var(--lmfx-z-front, 40); }
.lmfx-cine  { position: fixed; z-index: var(--lmfx-z-cine, 10020); visibility: hidden; }
.lmfx-cine[data-cine] { visibility: visible; }

.lmfx-fill,
.lmfx img.lmfx-fill {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
  max-width: none;
  border: 0;
}
.lmfx img { object-fit: cover; object-position: 50% 50%; }

/* ── BACK: plates ───────────────────────────────────────────────────────── */
.lmfx-shaker {
  position: absolute;
  top: -2%; right: -2%; bottom: -2%; left: -2%;   /* overscan so shake never shows an edge */
  transform: translate3d(0, 0, 0);
}
.lmfx-plate {
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.1s ease-in-out, visibility 0s linear 1.1s;
}
.lmfx-plate.is-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 1.1s ease-in-out, visibility 0s;
}
.lmfx-noanim .lmfx-plate,
.lmfx-noanim .lmfx-ov,
.lmfx-noanim .lmfx-set { transition: none !important; }

/* Keeps the middle of the screen calm and dark for the question card. */
.lmfx-scrim {
  background:
    radial-gradient(ellipse 60% 56% at 50% 52%, rgba(5, 7, 15, 0.74) 0%, rgba(5, 7, 15, 0.56) 58%, rgba(5, 7, 15, 0) 100%),
    radial-gradient(ellipse 64% 30% at 50% 0%, rgba(5, 7, 15, 0.62) 0%, rgba(5, 7, 15, 0) 100%),
    /* wide band behind the game's header row (room code, course name), which has no panel of its own */
    radial-gradient(ellipse 60% 18% at 50% 24%, rgba(5, 7, 15, 0.68) 0%, rgba(5, 7, 15, 0.62) 72%, rgba(5, 7, 15, 0) 100%);
  transition: opacity 0.9s ease;
}
.lmfx-back[data-stage="3"] .lmfx-scrim { opacity: 0.9; }
.lmfx-dim {
  background: var(--lmfx-void);
  opacity: 0;
  transition: opacity 1.2s ease;
}
/* After a meltdown the room is burnt out: darker, quiet, still glowing. */
.lmfx-back[data-after="meltdown"] .lmfx-dim { opacity: 0.5; }

/* ── BACK: overlays (transparent WebP) ──────────────────────────────────── */
.lmfx-ov {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease, transform 1.2s ease, visibility 0s linear 1.2s;
}
.lmfx-ov.is-on { visibility: visible; transition: opacity 0.9s ease, transform 1.2s ease, visibility 0s; }

/* Steam: light at stage 1, haze at stage 2, coolant mist when saved */
.lmfx-back[data-stage="1"] .lmfx-steam.is-on { opacity: calc(0.22 + var(--lmfx-heat) * 0.34); }
.lmfx-back[data-stage="2"] .lmfx-steam.is-on { opacity: calc(0.30 + var(--lmfx-heat) * 0.22); }
.lmfx-back[data-stage="saved"] .lmfx-steam.is-on { opacity: 0.3; }
.lmfx-steam > img { transform-origin: 50% 100%; }
.lmfx-back[data-stage="1"] .lmfx-steam.is-on > img,
.lmfx-back[data-stage="saved"] .lmfx-steam.is-on > img { animation: lmfx-drift 18s ease-in-out infinite alternate; }

/* Cracks: stage 2 and 3 */
.lmfx-back[data-stage="2"] .lmfx-cracks.is-on { opacity: calc(0.3 + var(--lmfx-heat) * 0.4); }
.lmfx-back[data-stage="3"] .lmfx-cracks.is-on { opacity: 0.7; }

/* Sparks: stage 2 and 3 */
.lmfx-back[data-stage="2"] .lmfx-sparks.is-on { opacity: calc(0.45 + var(--lmfx-heat) * 0.4); }
.lmfx-back[data-stage="3"] .lmfx-sparks.is-on { opacity: 0.9; }
.lmfx-sparks.is-on > img { animation: lmfx-sparks 1.6s linear infinite; }

/* Molten: drips from the top and a pool rising from the floor, by heat */
.lmfx-molten-top { height: 57.4%; transform: translate3d(0, -101%, 0); }
.lmfx-molten-bot { top: auto; bottom: 0; height: 40.8%; transform: translate3d(0, 101%, 0); }
.lmfx-molten-top > img { object-position: 50% 0; }
.lmfx-molten-bot > img { object-position: 50% 100%; }
.lmfx-back[data-stage="3"] .lmfx-molten-top.is-on { opacity: 1; transform: translate3d(0, calc(-58% + var(--lmfx-heat) * 46%), 0); }
.lmfx-back[data-stage="3"] .lmfx-molten-bot.is-on { opacity: 1; transform: translate3d(0, calc(52% - var(--lmfx-heat) * 40%), 0); }
.lmfx-back[data-after="meltdown"] .lmfx-molten-top.is-on { transform: translate3d(0, -8%, 0); }
.lmfx-back[data-after="meltdown"] .lmfx-molten-bot.is-on { transform: translate3d(0, 8%, 0); }
.lmfx-back[data-after="meltdown"] .lmfx-sparks.is-on { opacity: 0.35; }

/* Shake: only the lab behind the UI shakes — never the question text. */
.lmfx-back[data-shake="1"] .lmfx-shaker { animation: lmfx-shake-1 1.1s linear infinite; will-change: transform; }
.lmfx-back[data-shake="2"] .lmfx-shaker { animation: lmfx-shake-2 0.72s linear infinite; will-change: transform; }
.lmfx-back[data-shake="3"] .lmfx-shaker { animation: lmfx-shake-3 0.48s linear infinite; will-change: transform; }
.lmfx-back.lmfx-jolt .lmfx-shaker { animation: lmfx-shake-3 0.42s linear 1; }
/* Finale: the panels warp and sag as they melt. */
.lmfx-back.lmfx-warp .lmfx-shaker { animation: lmfx-warp 4.6s ease-in forwards; will-change: transform; transform-origin: 50% 0; }

@keyframes lmfx-drift {
  0%   { transform: translate3d(-1.2%, 0, 0) scale(1.04); }
  100% { transform: translate3d(1.2%, -2.5%, 0) scale(1.1); }
}
@keyframes lmfx-sparks {
  0%   { opacity: 0.55; transform: translate3d(0, -3px, 0); }
  18%  { opacity: 1;    transform: translate3d(0, 0, 0); }
  40%  { opacity: 0.6;  transform: translate3d(0, 3px, 0); }
  62%  { opacity: 0.95; transform: translate3d(0, 5px, 0); }
  100% { opacity: 0.55; transform: translate3d(0, 8px, 0); }
}
@keyframes lmfx-shake-1 {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-1px, 1px, 0); }
  50% { transform: translate3d(1px, -1px, 0); }
  75% { transform: translate3d(-1px, 0, 0); }
}
@keyframes lmfx-shake-2 {
  0%, 100% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-3px, 2px, 0); }
  40% { transform: translate3d(3px, -2px, 0); }
  60% { transform: translate3d(-2px, -2px, 0); }
  80% { transform: translate3d(2px, 2px, 0); }
}
@keyframes lmfx-shake-3 {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  12% { transform: translate3d(-8px, 5px, 0) rotate(-0.25deg); }
  27% { transform: translate3d(7px, -6px, 0) rotate(0.3deg); }
  41% { transform: translate3d(-6px, -4px, 0) rotate(-0.2deg); }
  58% { transform: translate3d(8px, 6px, 0) rotate(0.25deg); }
  74% { transform: translate3d(-5px, 3px, 0) rotate(-0.15deg); }
  88% { transform: translate3d(4px, -3px, 0) rotate(0.1deg); }
}
@keyframes lmfx-warp {
  0%   { transform: translate3d(0, 0, 0) skewX(0deg) scale(1, 1); }
  10%  { transform: translate3d(-6px, 4px, 0) skewX(-0.6deg) scale(1.01, 1.01); }
  22%  { transform: translate3d(7px, -3px, 0) skewX(0.8deg) scale(1.015, 1.02); }
  36%  { transform: translate3d(-8px, 5px, 0) skewX(-1.1deg) scale(1.02, 1.04); }
  52%  { transform: translate3d(6px, 6px, 0) skewX(1.3deg) scale(1.03, 1.07); }
  70%  { transform: translate3d(-5px, 9px, 0) skewX(-1deg) scale(1.04, 1.11); }
  100% { transform: translate3d(0, 14px, 0) skewX(0.4deg) scale(1.06, 1.18); }
}

/* ── FRONT: edge glow, beacons, pulses (edges only) ─────────────────────── */
.lmfx-set {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.9s ease, visibility 0s linear 0.9s;
}
.lmfx-set.is-on { opacity: 1; visibility: visible; transition: opacity 0.9s ease, visibility 0s; }
.lmfx-set:not(.is-on) * { animation-play-state: paused !important; }

.lmfx-edge { opacity: calc(var(--lmfx-edge-min, 0.45) + var(--lmfx-heat) * var(--lmfx-edge-gain, 0.45)); transition: opacity 0.5s ease; }
.lmfx-edge::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background:
    radial-gradient(ellipse 78% 76% at 50% 50%, rgba(0, 0, 0, 0) 66%, var(--lmfx-edge-soft) 86%, var(--lmfx-edge-hard) 100%);
}
.lmfx-beacon {
  position: absolute;
  top: 0;
  width: 46%; height: 62%;
  opacity: 0.25;
}
.lmfx-beacon-l { left: 0;  background: radial-gradient(ellipse 100% 100% at 3% 8%, var(--lmfx-beam) 0%, rgba(0, 0, 0, 0) 68%); }
.lmfx-beacon-r { right: 0; background: radial-gradient(ellipse 100% 100% at 97% 8%, var(--lmfx-beam) 0%, rgba(0, 0, 0, 0) 68%); }

.lmfx-set-0 { --lmfx-edge-soft: rgba(45, 212, 191, 0.10); --lmfx-edge-hard: rgba(45, 212, 191, 0.30); --lmfx-edge-min: 0.5; --lmfx-edge-gain: 0.3; }
.lmfx-set-0.is-on .lmfx-edge::before { animation: lmfx-breathe 7s ease-in-out infinite; }

.lmfx-set-1 { --lmfx-edge-soft: rgba(251, 191, 36, 0.16); --lmfx-edge-hard: rgba(251, 146, 60, 0.50); --lmfx-beam: rgba(251, 191, 36, 0.55); }
.lmfx-set-1.is-on .lmfx-beacon-l { animation: lmfx-beacon 2.2s ease-in-out infinite; }
.lmfx-set-1.is-on .lmfx-beacon-r { animation: lmfx-beacon 2.2s ease-in-out -1.1s infinite; }

.lmfx-set-2 { --lmfx-edge-soft: rgba(239, 68, 68, 0.22); --lmfx-edge-hard: rgba(220, 38, 38, 0.68); --lmfx-beam: rgba(239, 68, 68, 0.62); }
.lmfx-set-2.is-on .lmfx-beacon-l { animation: lmfx-beacon 1.3s ease-in-out infinite; }
.lmfx-set-2.is-on .lmfx-beacon-r { animation: lmfx-beacon 1.3s ease-in-out -0.65s infinite; }
.lmfx-set-2.is-on .lmfx-edge::before { animation: lmfx-breathe 1.3s ease-in-out infinite; }

.lmfx-set-3 { --lmfx-edge-soft: rgba(255, 107, 53, 0.30); --lmfx-edge-hard: rgba(253, 186, 116, 0.82); --lmfx-beam: rgba(239, 68, 68, 0.6); --lmfx-edge-min: 0.6; --lmfx-edge-gain: 0.4; }
.lmfx-set-3.is-on .lmfx-beacon-l { animation: lmfx-beacon 1s ease-in-out infinite; }
.lmfx-set-3.is-on .lmfx-beacon-r { animation: lmfx-beacon 1s ease-in-out -0.5s infinite; }
.lmfx-set-3.is-on .lmfx-edge::before { animation: lmfx-breathe 0.9s ease-in-out infinite; }
/* A low band of molten light along the bottom edge at full meltdown */
.lmfx-floorglow {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 22%;
  background: linear-gradient(0deg, rgba(255, 107, 53, 0.55) 0%, rgba(255, 107, 53, 0.16) 45%, rgba(0, 0, 0, 0) 100%);
  opacity: calc(0.25 + var(--lmfx-heat) * 0.6);
  transition: opacity 0.5s ease;
}

.lmfx-set-saved { --lmfx-edge-soft: rgba(34, 197, 94, 0.16); --lmfx-edge-hard: rgba(34, 197, 94, 0.50); --lmfx-beam: rgba(74, 222, 128, 0.4); --lmfx-edge-min: 0.85; --lmfx-edge-gain: 0; }
.lmfx-set-saved .lmfx-beacon { opacity: 0.7; }
.lmfx-set-saved.is-on .lmfx-edge::before { animation: lmfx-breathe 5s ease-in-out infinite; }

/* Burnt-out lab after the meltdown finale: no strobe, a slow ember glow. */
.lmfx-front[data-after="meltdown"] .lmfx-set-3 .lmfx-beacon { animation: none; opacity: 0.2; }
.lmfx-front[data-after="meltdown"] .lmfx-set-3 .lmfx-edge::before { animation-duration: 4.5s; }

@keyframes lmfx-breathe { 0%, 100% { opacity: 0.62; } 50% { opacity: 1; } }
@keyframes lmfx-beacon  { 0%, 100% { opacity: 0.12; } 50% { opacity: 1; } }

/* Answer feedback: a ring of colour around the edge of the screen. */
.lmfx-pulse { opacity: 0; }
.lmfx-pulse::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(ellipse 78% 76% at 50% 50%, rgba(0, 0, 0, 0) 58%, var(--lmfx-pulse-soft, transparent) 82%, var(--lmfx-pulse-hard, transparent) 100%);
}
.lmfx-pulse[data-kind="correct"]   { --lmfx-pulse-soft: rgba(34, 197, 94, 0.35);  --lmfx-pulse-hard: rgba(74, 222, 128, 0.9); }
.lmfx-pulse[data-kind="wrong"]     { --lmfx-pulse-soft: rgba(220, 38, 38, 0.5);   --lmfx-pulse-hard: rgba(254, 202, 202, 0.95); }
.lmfx-pulse[data-kind="stabilize"] { --lmfx-pulse-soft: rgba(103, 232, 249, 0.35); --lmfx-pulse-hard: rgba(165, 243, 252, 0.9); }
.lmfx-pulse.is-run { animation: lmfx-pulse 0.7s ease-out 1 both; }
.lmfx-pulse.is-run[data-kind="stabilize"] { animation: lmfx-pulse-cool 1.1s ease-out 1 both; }
@keyframes lmfx-pulse {
  0%   { opacity: 0; transform: scale(1.06); }
  18%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
@keyframes lmfx-pulse-cool {
  0%   { opacity: 0; transform: scale(1.18); }
  25%  { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1); }
}

/* ── CINE: stage change + finale ────────────────────────────────────────── */
.lmfx-cine > * { opacity: 0; }

/* Alarm sweep: one wide bar of light crosses the screen */
.lmfx-sweep {
  position: absolute;
  top: -20%; left: 0;
  width: 55%; height: 140%;
  background: linear-gradient(100deg, rgba(0, 0, 0, 0) 0%, var(--lmfx-cine-soft) 35%, var(--lmfx-cine-hard) 50%, var(--lmfx-cine-soft) 65%, rgba(0, 0, 0, 0) 100%);
  transform: translate3d(-110%, 0, 0);
}
.lmfx-cine.p-sweep .lmfx-sweep { animation: lmfx-sweep 1.5s cubic-bezier(0.3, 0, 0.3, 1) 2 both; }
@keyframes lmfx-sweep {
  0%   { opacity: 0; transform: translate3d(-110%, 0, 0) skewX(-12deg); }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { opacity: 0; transform: translate3d(200%, 0, 0) skewX(-12deg); }
}

/* Alarm strobe: the edge of the screen pulses twice a second */
.lmfx-strobe {
  background: radial-gradient(ellipse 74% 72% at 50% 50%, rgba(0, 0, 0, 0) 48%, var(--lmfx-cine-soft) 78%, var(--lmfx-cine-hard) 100%);
}
.lmfx-cine.p-strobe .lmfx-strobe { animation: lmfx-strobe 0.5s ease-in-out infinite; }
@keyframes lmfx-strobe { 0%, 100% { opacity: 0.15; } 50% { opacity: 1; } }

.lmfx-cine[data-tone="0"]     { --lmfx-cine-soft: rgba(45, 212, 191, 0.20); --lmfx-cine-hard: rgba(103, 232, 249, 0.55); --lmfx-card: var(--lmfx-cool); }
.lmfx-cine[data-tone="1"]     { --lmfx-cine-soft: rgba(251, 191, 36, 0.24); --lmfx-cine-hard: rgba(251, 191, 36, 0.62);  --lmfx-card: var(--lmfx-warn); }
.lmfx-cine[data-tone="2"]     { --lmfx-cine-soft: rgba(239, 68, 68, 0.30);  --lmfx-cine-hard: rgba(239, 68, 68, 0.72);   --lmfx-card: var(--lmfx-crit); }
.lmfx-cine[data-tone="3"]     { --lmfx-cine-soft: rgba(255, 107, 53, 0.34); --lmfx-cine-hard: rgba(253, 186, 116, 0.8);  --lmfx-card: var(--lmfx-melt); }
.lmfx-cine[data-tone="saved"] { --lmfx-cine-soft: rgba(34, 197, 94, 0.24);  --lmfx-cine-hard: rgba(74, 222, 128, 0.6);   --lmfx-card: var(--lmfx-safe); }

/* One soft flash (never repeated inside a second) */
.lmfx-flash { background: #fff7ed; }
.lmfx-cine.p-flash .lmfx-flash { animation: lmfx-flash 0.55s ease-out 1 both; }
@keyframes lmfx-flash { 0% { opacity: 0; } 14% { opacity: 0.62; } 100% { opacity: 0; } }

/* The glass cracks */
.lmfx-shatter { transform-origin: 50% 37%; z-index: 2; }
.lmfx-cine.p-shatter .lmfx-shatter { animation: lmfx-shatter 0.5s cubic-bezier(0.2, 0.9, 0.2, 1) 1 both; }
.lmfx-cine.p-shatter-fade .lmfx-shatter { animation: lmfx-shatter-fade 1.6s ease-in 1 both; }
@keyframes lmfx-shatter {
  0%   { opacity: 0; transform: scale(0.35); }
  30%  { opacity: 1; transform: scale(0.82); }
  100% { opacity: 1; transform: scale(1.02); }
}
.lmfx-cine.p-shatter-out .lmfx-shatter { animation: lmfx-shatter-out 1s ease-out 1 both; }
@keyframes lmfx-shatter-out { 0% { opacity: 0.55; transform: scale(1.02); } 100% { opacity: 0; transform: scale(1.02); } }
@keyframes lmfx-shatter-fade { 0% { opacity: 1; transform: scale(1.02); } 100% { opacity: 0; transform: scale(1.06); } }

/* Molten metal comes down from the ceiling and up from the floor */
.lmfx-cine-molten-top { position: absolute; top: 0; left: 0; width: 100%; height: 57.4%; transform: translate3d(0, -101%, 0); }
.lmfx-cine-molten-bot { position: absolute; bottom: 0; left: 0; width: 100%; height: 40.8%; transform: translate3d(0, 101%, 0); }
.lmfx-cine-molten-top > img { object-position: 50% 0; }
.lmfx-cine-molten-bot > img { object-position: 50% 100%; }
/* stage change: a surge that pulls back */
.lmfx-cine.p-surge .lmfx-cine-molten-top { animation: lmfx-surge-top 2.6s ease-in-out 1 both; }
.lmfx-cine.p-surge .lmfx-cine-molten-bot { animation: lmfx-surge-bot 2.6s ease-in-out 1 both; }
.lmfx-cine.p-surge[data-tone="3"] .lmfx-cine-molten-top { animation-name: lmfx-surge-top-big; }
.lmfx-cine.p-surge[data-tone="3"] .lmfx-cine-molten-bot { animation-name: lmfx-surge-bot-big; }
@keyframes lmfx-surge-top     { 0% { opacity: 1; transform: translate3d(0, -101%, 0); } 45%, 62% { opacity: 1; transform: translate3d(0, -52%, 0); } 100% { opacity: 1; transform: translate3d(0, -101%, 0); } }
@keyframes lmfx-surge-bot     { 0% { opacity: 1; transform: translate3d(0, 101%, 0); }  45%, 62% { opacity: 1; transform: translate3d(0, 46%, 0); }  100% { opacity: 1; transform: translate3d(0, 101%, 0); } }
@keyframes lmfx-surge-top-big { 0% { opacity: 1; transform: translate3d(0, -101%, 0); } 45%, 62% { opacity: 1; transform: translate3d(0, -14%, 0); } 100% { opacity: 1; transform: translate3d(0, -101%, 0); } }
@keyframes lmfx-surge-bot-big { 0% { opacity: 1; transform: translate3d(0, 101%, 0); }  45%, 62% { opacity: 1; transform: translate3d(0, 10%, 0); }  100% { opacity: 1; transform: translate3d(0, 101%, 0); } }
/* finale: it keeps coming */
.lmfx-cine.p-melt .lmfx-cine-molten-top { animation: lmfx-melt-top 2.6s cubic-bezier(0.5, 0, 0.8, 0.6) 1 both; }
.lmfx-cine.p-melt .lmfx-cine-molten-bot { animation: lmfx-melt-bot 2.6s cubic-bezier(0.4, 0, 0.7, 0.7) 1 both; }
@keyframes lmfx-melt-top { 0% { opacity: 1; transform: translate3d(0, -101%, 0) scale(1, 1); } 70% { opacity: 1; transform: translate3d(0, 0, 0) scale(1, 1); } 100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1, 1.45); } }
@keyframes lmfx-melt-bot { 0% { opacity: 1; transform: translate3d(0, 101%, 0) scale(1, 1); } 70% { opacity: 1; transform: translate3d(0, 0, 0) scale(1, 1); } 100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1, 1.5); } }
.lmfx-cine-molten-top { transform-origin: 50% 0; }
.lmfx-cine-molten-bot { transform-origin: 50% 100%; }

/* The molten glow floods up the whole screen */
.lmfx-flood {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 135%;
  background: linear-gradient(180deg,
    rgba(127, 29, 29, 0) 0%, rgba(194, 65, 12, 0.6) 14%, rgba(234, 88, 12, 0.82) 30%,
    rgba(251, 146, 60, 0.9) 52%, rgba(253, 230, 138, 0.94) 78%, #fffbeb 100%);
  transform: translate3d(0, 101%, 0);
}
.lmfx-cine.p-flood .lmfx-flood { animation: lmfx-flood 1.9s cubic-bezier(0.45, 0, 0.75, 0.75) 1 both; }
@keyframes lmfx-flood { 0% { opacity: 1; transform: translate3d(0, 101%, 0); } 100% { opacity: 1; transform: translate3d(0, -26%, 0); } }

/* White-hot peak (one slow swell), then burn-out to black */
.lmfx-white { background: radial-gradient(ellipse 90% 90% at 50% 62%, #fffbeb 0%, #fde68a 40%, #fb923c 100%); }
.lmfx-cine.p-white .lmfx-white { animation: lmfx-white 1.5s ease-in-out 1 both; }
@keyframes lmfx-white { 0% { opacity: 0; } 42% { opacity: 0.8; } 100% { opacity: 0; } }
.lmfx-burn {
  background:
    radial-gradient(ellipse 120% 60% at 50% 108%, rgba(194, 65, 12, 0.6) 0%, rgba(124, 45, 18, 0.22) 45%, rgba(0, 0, 0, 0) 75%),
    #050302;
}
.lmfx-cine.p-burn .lmfx-burn { animation: lmfx-fade-in 1.1s ease-in 1 both; }
.lmfx-cine.p-lift .lmfx-burn { animation: lmfx-fade-out 1s ease-out 1 both; }
@keyframes lmfx-fade-in  { 0% { opacity: 0; } 100% { opacity: 1; } }
@keyframes lmfx-fade-out { 0% { opacity: 1; } 100% { opacity: 0; } }

/* Saved: a wall of coolant drops through the room, steam bursts and clears */
.lmfx-coolant {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 150%;
  background: linear-gradient(180deg,
    rgba(103, 232, 249, 0) 0%, rgba(103, 232, 249, 0.38) 24%, rgba(207, 250, 254, 0.72) 50%,
    rgba(103, 232, 249, 0.38) 76%, rgba(103, 232, 249, 0) 100%);
  transform: translate3d(0, -101%, 0);
}
.lmfx-cine.p-coolant .lmfx-coolant { animation: lmfx-coolant 1.5s cubic-bezier(0.3, 0, 0.5, 1) 1 both; }
@keyframes lmfx-coolant { 0% { opacity: 1; transform: translate3d(0, -101%, 0); } 100% { opacity: 1; transform: translate3d(0, 101%, 0); } }
.lmfx-cine-steam { transform-origin: 50% 100%; }
.lmfx-cine.p-steam .lmfx-cine-steam { animation: lmfx-steam-burst 3.4s ease-out 1 both; }
@keyframes lmfx-steam-burst {
  0%   { opacity: 0;    transform: translate3d(0, 6%, 0) scale(1.25); }
  16%  { opacity: 0.96; transform: translate3d(0, 0, 0) scale(1.5); }
  40%  { opacity: 0.9;  transform: translate3d(0, -3%, 0) scale(1.62); }
  100% { opacity: 0;    transform: translate3d(0, -16%, 0) scale(1.9); }
}
.lmfx-green { background: radial-gradient(ellipse 80% 78% at 50% 50%, rgba(34, 197, 94, 0) 40%, rgba(34, 197, 94, 0.3) 78%, rgba(74, 222, 128, 0.72) 100%); }
.lmfx-cine.p-green .lmfx-green { animation: lmfx-green 3s ease-in-out 1 both; }
@keyframes lmfx-green { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }

/* Title card: one dark band across the screen, big enough for the back row */
.lmfx-card {
  position: absolute;
  left: 0; top: 50%;
  width: 100%;
  padding: clamp(0.9rem, 2.6vh, 2rem) 5vw;
  box-sizing: border-box;
  text-align: center;
  color: var(--lmfx-ink);
  background: linear-gradient(180deg, rgba(5, 7, 15, 0.86) 0%, rgba(5, 7, 15, 0.95) 50%, rgba(5, 7, 15, 0.86) 100%);
  border-top: 4px solid var(--lmfx-card);
  border-bottom: 4px solid var(--lmfx-card);
  transform: translate3d(0, -50%, 0);
  z-index: 3;
}
.lmfx-card::before,
.lmfx-card::after {
  content: '';
  position: absolute;
  left: 0; width: 100%; height: clamp(8px, 1.3vh, 14px);
  background: repeating-linear-gradient(-45deg, var(--lmfx-card) 0 18px, rgba(5, 7, 15, 0.96) 18px 36px);
  opacity: 0.9;
}
.lmfx-card::before { top: 0; }
.lmfx-card::after  { bottom: 0; }
.lmfx-card-eyebrow {
  font-family: 'Orbitron', 'Chakra Petch', 'Outfit', system-ui, sans-serif;
  font-size: clamp(0.8rem, 1.5vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--lmfx-card);
  margin: clamp(0.5rem, 1.4vh, 1rem) 0 0.2em;
}
.lmfx-card-title {
  font-family: 'Orbitron', 'Chakra Petch', 'Outfit', system-ui, sans-serif;
  font-size: calc(clamp(2.4rem, 8.4vw, 9rem) * var(--lmfx-fit, 1));
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  text-shadow: 0 0 0.35em var(--lmfx-card);
  overflow-wrap: anywhere;
}
.lmfx-card-sub {
  font-family: 'Orbitron', 'Chakra Petch', 'Outfit', system-ui, sans-serif;
  font-size: calc(clamp(1.1rem, 3.3vw, 3.6rem) * var(--lmfx-fit, 1));
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--lmfx-card);
  margin: 0.3em 0 clamp(0.5rem, 1.4vh, 1rem);
  overflow-wrap: anywhere;
}
.lmfx-cine.p-card .lmfx-card { animation: lmfx-card-in 0.42s cubic-bezier(0.2, 1.2, 0.3, 1) 1 both; }
.lmfx-cine.p-card-out .lmfx-card { animation: lmfx-card-out 0.36s ease-in 1 both; }
@keyframes lmfx-card-in  { 0% { opacity: 0; transform: translate3d(0, -50%, 0) scale(1.18, 0.4); } 100% { opacity: 1; transform: translate3d(0, -50%, 0) scale(1, 1); } }
@keyframes lmfx-card-out { 0% { opacity: 1; transform: translate3d(0, -50%, 0) scale(1, 1); } 100% { opacity: 0; transform: translate3d(0, -50%, 0) scale(1, 0.2); } }

/* Optional: game panels handed to finale('meltdown', { melt: [...] }) sag and slide away. */
.lmfx-melting {
  animation: lmfx-melting 2.8s cubic-bezier(0.55, 0, 0.9, 0.6) 1 both !important;
  transform-origin: 50% 0;
  pointer-events: none;
}
@keyframes lmfx-melting {
  0%   { transform: translate3d(0, 0, 0) skewX(0deg) scale(1, 1); opacity: 1; }
  25%  { transform: translate3d(0, 1%, 0) skewX(-1.2deg) scale(1.01, 1.04); opacity: 1; }
  55%  { transform: translate3d(0, 9%, 0) skewX(1.6deg) scale(0.99, 1.22); opacity: 0.95; }
  100% { transform: translate3d(0, 70vh, 0) skewX(-2deg) scale(0.94, 1.9); opacity: 0; }
}

/* ── Reduced motion: no shake, no strobe, no sweeps — fades and the title card only. */
.lmfx[data-motion="reduce"] .lmfx-shaker,
.lmfx[data-motion="reduce"] .lmfx-ov > img,
.lmfx[data-motion="reduce"] .lmfx-edge::before,
.lmfx[data-motion="reduce"] .lmfx-beacon,
.lmfx[data-motion="reduce"] .lmfx-pulse,
.lmfx[data-motion="reduce"].lmfx-cine > * { animation: none !important; }
.lmfx[data-motion="reduce"] .lmfx-beacon { opacity: 0.55; }
.lmfx[data-motion="reduce"] .lmfx-plate,
.lmfx[data-motion="reduce"] .lmfx-ov,
.lmfx[data-motion="reduce"] .lmfx-set { transition-duration: 0.6s; }
.lmfx[data-motion="reduce"] .lmfx-pulse { transition: opacity 0.35s ease; }
.lmfx[data-motion="reduce"] .lmfx-pulse.is-run { opacity: 0.85; }
.lmfx[data-motion="reduce"].lmfx-cine > * { transition: opacity 0.5s ease; }
.lmfx[data-motion="reduce"].lmfx-cine.p-card .lmfx-card { opacity: 1; }
.lmfx[data-motion="reduce"].lmfx-cine.p-still-shatter .lmfx-shatter { opacity: 0.85; }
.lmfx[data-motion="reduce"].lmfx-cine.p-still-glow .lmfx-strobe { opacity: 0.8; }
.lmfx[data-motion="reduce"].lmfx-cine.p-still-green .lmfx-green { opacity: 0.9; }
.lmfx[data-motion="reduce"].lmfx-cine.p-burn .lmfx-burn { opacity: 1; }
.lmfx-melting-still { opacity: 0.25 !important; transition: opacity 0.6s ease !important; }

@media (prefers-reduced-motion: reduce) {
  .lmfx-shaker, .lmfx-ov > img, .lmfx-beacon, .lmfx-edge::before { animation: none !important; }
}

@media print { .lmfx { display: none !important; } }
