:root {
  --bg: #05060a;
  --ink: #f4f1ea;
  --muted: #8a8794;
  --accent: #ff3d6e;
  --cyan: #3cf0ff;
  --gold: #ffd166;
  --violet: #b388ff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

body {
  cursor: crosshair;
}

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.filters {
  position: absolute;
  width: 0;
  height: 0;
}

.stage {
  position: relative;
  z-index: 2;
  min-height: 100%;
  display: grid;
  place-content: center;
  place-items: center;
  gap: 0.4rem;
  pointer-events: none;
  user-select: none;
}

.word {
  position: relative;
  display: flex;
  gap: 0.06em;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: clamp(7rem, 28vw, 22rem);
  line-height: 0.82;
  letter-spacing: 0.02em;
  font-weight: 400;
  color: var(--ink);
  text-transform: uppercase;
  transform-style: preserve-3d;
  perspective: 900px;
}

.letter {
  display: inline-block;
  transform-origin: 50% 60%;
  will-change: transform, filter, text-shadow, opacity;
}

.ghosts {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: "Bebas Neue", Impact, sans-serif;
  font-size: clamp(7rem, 28vw, 22rem);
  line-height: 0.82;
  letter-spacing: 0.08em;
  color: transparent;
}

.ghosts span {
  position: absolute;
  font: inherit;
  color: inherit;
  opacity: 0;
}

.hud {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.4rem 1.3rem;
  background: linear-gradient(to top, rgba(5, 6, 10, 0.92), transparent);
  pointer-events: none;
}

.hud-left,
.hud-right,
.hud-center {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}

.hud-right {
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.label {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

#effectName {
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.shuffle {
  pointer-events: auto;
  appearance: none;
  border: 1px solid rgba(244, 241, 234, 0.28);
  background: rgba(244, 241, 234, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.shuffle:hover {
  background: rgba(244, 241, 234, 0.14);
  border-color: rgba(244, 241, 234, 0.5);
}

.shuffle:active {
  transform: scale(0.96);
}

/* —— effect skins —— */

.word[data-fx="neon"] .letter {
  color: #fff;
  animation: neonPulse 1.4s ease-in-out infinite alternate;
}

.word[data-fx="neon"] .letter:nth-child(1) { text-shadow: 0 0 8px #fff, 0 0 24px var(--cyan), 0 0 48px var(--cyan); }
.word[data-fx="neon"] .letter:nth-child(2) { text-shadow: 0 0 8px #fff, 0 0 24px var(--accent), 0 0 48px var(--accent); animation-delay: 0.2s; }
.word[data-fx="neon"] .letter:nth-child(3) { text-shadow: 0 0 8px #fff, 0 0 24px var(--violet), 0 0 48px var(--violet); animation-delay: 0.4s; }

@keyframes neonPulse {
  from { filter: brightness(0.85); }
  to { filter: brightness(1.25); }
}

.word[data-fx="glitch"] {
  animation: glitchShake 0.18s steps(2) infinite;
}

.word[data-fx="glitch"] .letter {
  position: relative;
  color: #fff;
}

.word[data-fx="glitch"] .letter::before,
.word[data-fx="glitch"] .letter::after {
  content: attr(data-char);
  position: absolute;
  left: 0;
  top: 0;
  mix-blend-mode: screen;
}

.word[data-fx="glitch"] .letter::before {
  color: #ff2a6d;
  animation: rgbLeft 0.16s infinite linear;
}

.word[data-fx="glitch"] .letter::after {
  color: #05d9e8;
  animation: rgbRight 0.14s infinite linear;
}

@keyframes rgbLeft {
  0%, 100% { transform: translate(0, 0); clip-path: inset(0 0 60% 0); }
  30% { transform: translate(-6px, 2px); clip-path: inset(20% 0 20% 0); }
  60% { transform: translate(4px, -3px); clip-path: inset(55% 0 0 0); }
}

@keyframes rgbRight {
  0%, 100% { transform: translate(0, 0); clip-path: inset(40% 0 10% 0); }
  40% { transform: translate(7px, -2px); clip-path: inset(0 0 50% 0); }
  70% { transform: translate(-5px, 4px); clip-path: inset(30% 0 30% 0); }
}

@keyframes glitchShake {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-3px, 1px); }
  40% { transform: translate(4px, -2px); }
  60% { transform: translate(-2px, 3px); }
  80% { transform: translate(3px, 0); }
}

.word[data-fx="fire"] .letter {
  color: #ffe8a3;
  text-shadow:
    0 0 8px #ffb347,
    0 -8px 18px #ff6b35,
    0 -18px 36px #d62828,
    0 -28px 50px #9d0208;
  animation: fireFlicker 0.12s infinite;
}

@keyframes fireFlicker {
  0% { filter: brightness(1) hue-rotate(0deg); }
  40% { filter: brightness(1.15) hue-rotate(-8deg); }
  70% { filter: brightness(0.92) hue-rotate(6deg); }
  100% { filter: brightness(1.08) hue-rotate(0deg); }
}

.word[data-fx="hologram"] {
  color: var(--cyan);
  filter: url(#glow);
  animation: holoFlicker 2.4s infinite;
}

.word[data-fx="hologram"] .letter {
  text-shadow: 0 0 12px var(--cyan), 0 0 32px rgba(60, 240, 255, 0.45);
}

.word[data-fx="hologram"]::after {
  content: "";
  position: absolute;
  inset: -10% -8%;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.18) 0 2px,
    transparent 2px 5px
  );
  mix-blend-mode: multiply;
  pointer-events: none;
  animation: scan 2.8s linear infinite;
}

@keyframes holoFlicker {
  0%, 100% { opacity: 1; }
  8% { opacity: 0.72; }
  9% { opacity: 1; }
  52% { opacity: 0.85; }
  53% { opacity: 1; }
}

@keyframes scan {
  from { transform: translateY(-12%); }
  to { transform: translateY(12%); }
}

.word[data-fx="prism"] .letter {
  background: linear-gradient(90deg, #ff3d6e, #ffd166, #3cf0ff, #b388ff, #ff3d6e);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: prismShift 2.2s linear infinite;
  filter: drop-shadow(0 0 18px rgba(179, 136, 255, 0.45));
}

@keyframes prismShift {
  to { background-position: 220% 0; }
}

.word[data-fx="spin3d"] {
  animation: spinY 3.2s ease-in-out infinite;
}

.word[data-fx="spin3d"] .letter {
  text-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.word[data-fx="spin3d"] .letter:nth-child(1) { animation: letterTilt 3.2s ease-in-out infinite; }
.word[data-fx="spin3d"] .letter:nth-child(2) { animation: letterTilt 3.2s ease-in-out 0.12s infinite; }
.word[data-fx="spin3d"] .letter:nth-child(3) { animation: letterTilt 3.2s ease-in-out 0.24s infinite; }

@keyframes spinY {
  0%, 100% { transform: rotateY(-18deg) rotateX(8deg); }
  50% { transform: rotateY(18deg) rotateX(-6deg); }
}

@keyframes letterTilt {
  0%, 100% { transform: translateZ(0); }
  50% { transform: translateZ(40px); }
}

.word[data-fx="wave"] .letter {
  animation: letterWave 1.1s ease-in-out infinite;
}

.word[data-fx="wave"] .letter:nth-child(2) { animation-delay: 0.12s; }
.word[data-fx="wave"] .letter:nth-child(3) { animation-delay: 0.24s; }

@keyframes letterWave {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-0.12em) rotate(-4deg); }
}

.word[data-fx="shatter"] .letter {
  animation: shatter 1.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.word[data-fx="shatter"] .letter:nth-child(1) { animation-delay: 0s; }
.word[data-fx="shatter"] .letter:nth-child(2) { animation-delay: 0.08s; }
.word[data-fx="shatter"] .letter:nth-child(3) { animation-delay: 0.16s; }

@keyframes shatter {
  0% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; filter: blur(0); }
  28% { transform: translate(var(--sx, 40px), var(--sy, -80px)) rotate(var(--sr, 24deg)) scale(1.15); opacity: 0.15; filter: blur(2px); }
  100% { transform: translate(0, 0) rotate(0) scale(1); opacity: 1; filter: blur(0); }
}

.word[data-fx="drop"] .letter {
  animation: gravityDrop 1.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.word[data-fx="drop"] .letter:nth-child(1) { animation-delay: 0s; }
.word[data-fx="drop"] .letter:nth-child(2) { animation-delay: 0.12s; }
.word[data-fx="drop"] .letter:nth-child(3) { animation-delay: 0.24s; }

@keyframes gravityDrop {
  0% { transform: translateY(-120vh) rotate(-18deg); opacity: 0; }
  70% { transform: translateY(0.06em) rotate(3deg); opacity: 1; }
  85% { transform: translateY(-0.04em) rotate(-2deg); }
  100% { transform: translateY(0) rotate(0); }
}

.word[data-fx="liquid"] {
  filter: url(#goo);
}

.word[data-fx="liquid"] .letter {
  color: var(--cyan);
  text-shadow: 0 0 24px var(--cyan);
  animation: liquidBlob 2s ease-in-out infinite;
}

.word[data-fx="liquid"] .letter:nth-child(2) { animation-delay: 0.2s; color: var(--violet); }
.word[data-fx="liquid"] .letter:nth-child(3) { animation-delay: 0.4s; color: var(--accent); }

@keyframes liquidBlob {
  0%, 100% { transform: scale(1, 1) translateY(0); }
  50% { transform: scale(1.08, 0.92) translateY(0.04em); }
}

.word[data-fx="pixel"] {
  animation: pixelJitter 0.2s steps(2) infinite;
  image-rendering: pixelated;
  filter: contrast(1.3) saturate(1.4);
}

.word[data-fx="pixel"] .letter {
  color: #7dff6a;
  text-shadow: 4px 0 #ff3d6e, -4px 0 #3cf0ff;
}

@keyframes pixelJitter {
  0% { transform: translate(0, 0); }
  50% { transform: translate(2px, -1px); }
}

.word[data-fx="ghost"] .letter {
  color: rgba(244, 241, 234, 0.92);
  animation: ghostPulse 1.6s ease-in-out infinite;
}

@keyframes ghostPulse {
  0%, 100% { opacity: 1; filter: blur(0); }
  50% { opacity: 0.55; filter: blur(1px); }
}

.word[data-fx="strobe"] .letter {
  animation: strobe 0.16s steps(1) infinite;
}

@keyframes strobe {
  0% { color: #fff; text-shadow: 0 0 24px #fff; }
  50% { color: #05060a; text-shadow: none; }
}

.word[data-fx="aurora"] .letter {
  background: linear-gradient(120deg, #3cf0ff, #7dff6a, #b388ff, #ff3d6e);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: auroraMove 5s ease-in-out infinite;
  filter: drop-shadow(0 0 22px rgba(125, 255, 106, 0.28));
}

@keyframes auroraMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.word[data-fx="magnetic"] .letter {
  color: #f4f1ea;
  text-shadow: 0 0 20px rgba(244, 241, 234, 0.35);
}

.word[data-fx="lightning"] .letter {
  color: #fff8dc;
  text-shadow: 0 0 8px #fff, 0 0 22px #ffe566, 0 0 48px #3cf0ff;
  animation: lightningFlash 2.2s infinite;
}

@keyframes lightningFlash {
  0%, 88%, 100% { filter: brightness(1); }
  90% { filter: brightness(3); }
  92% { filter: brightness(0.7); }
  94% { filter: brightness(2.4); }
}

.word[data-fx="scramble"] .letter {
  animation: scramblePop 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.word[data-fx="scramble"] .letter:nth-child(2) { animation-delay: 0.1s; }
.word[data-fx="scramble"] .letter:nth-child(3) { animation-delay: 0.2s; }

@keyframes scramblePop {
  0% { transform: scale(0.2) rotate(-40deg); opacity: 0; filter: blur(8px); }
  100% { transform: scale(1) rotate(0); opacity: 1; filter: blur(0); }
}

.word[data-fx="explode"] .letter {
  animation: explodeIn 1.5s cubic-bezier(0.15, 0.9, 0.2, 1) both;
}

@keyframes explodeIn {
  0% { transform: scale(2.4); opacity: 0; filter: blur(12px); }
  55% { transform: scale(0.94); opacity: 1; filter: blur(0); }
  100% { transform: scale(1); }
}

@media (max-width: 640px) {
  .hud {
    grid-template-columns: 1fr;
    text-align: center;
    justify-items: center;
    gap: 0.45rem;
  }

  .hud-right,
  .hud-left,
  .hud-center {
    justify-content: center;
  }
}
