*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

body {
  background: #0a0a0f;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Courier New', monospace;
}

/* 動態漸層背景 */
.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0, 255, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(255, 0, 100, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(120, 0, 255, 0.04) 0%, transparent 50%);
  animation: bgShift 12s ease-in-out infinite alternate;
}

@keyframes bgShift {
  0% {
    filter: hue-rotate(0deg) brightness(1)
  }

  50% {
    filter: hue-rotate(15deg) brightness(1.2)
  }

  100% {
    filter: hue-rotate(-10deg) brightness(0.9)
  }
}

/* 網格背景 */
.grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  animation: gridPulse 4s ease-in-out infinite;
}

@keyframes gridPulse {

  0%,
  100% {
    opacity: 0.4
  }

  50% {
    opacity: 1
  }
}

/* 水平雜訊條 */
.noise {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(0deg,
      transparent,
      transparent 3px,
      rgba(0, 255, 255, 0.03) 3px,
      rgba(0, 255, 255, 0.03) 4px);
}

.noise.active {
  animation: noiseBurst 0.15s steps(3) forwards;
}

@keyframes noiseBurst {
  0% {
    opacity: 1;
    transform: translateY(-5px)
  }

  50% {
    opacity: 0.6;
    transform: translateY(3px)
  }

  100% {
    opacity: 0;
    transform: translateY(0)
  }
}

/* CRT 掃描線 */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.12) 2px,
      rgba(0, 0, 0, 0.12) 4px);
}

/* 暗角 */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.75) 100%);
}

/* 粒子畫布 */
#particles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none
}

/* 主文字容器 */
.main-text {
  position: relative;
  z-index: 5;
  font-size: clamp(3rem, 10vw, 8rem);
  font-weight: bold;
  color: #e0e0ff;
  letter-spacing: 0.08em;
  text-align: center;
  min-height: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Glitch 進場效果 === */
.glitch {
  position: relative;
  animation: glitchAnim 0.3s steps(2) forwards;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.glitch::before {
  color: #ff0040;
  animation: glitchR 0.3s steps(3) forwards;
  clip-path: inset(0 0 60% 0);
}

.glitch::after {
  color: #00ffff;
  animation: glitchB 0.3s steps(3) forwards;
  clip-path: inset(60% 0 0 0);
}

@keyframes glitchAnim {
  0% {
    transform: translate(8px, 0) skewX(12deg);
    filter: brightness(2)
  }

  25% {
    transform: translate(-6px, 2px) skewX(-8deg);
    filter: brightness(0.5)
  }

  50% {
    transform: translate(4px, -2px) skewX(5deg);
    filter: brightness(1.8);
    clip-path: inset(10% 0 30% 0)
  }

  75% {
    transform: translate(-3px, 1px) skewX(-3deg);
    filter: brightness(0.8);
    clip-path: none
  }

  100% {
    transform: translate(0) skewX(0);
    filter: brightness(1);
    clip-path: none
  }
}

@keyframes glitchR {
  0% {
    transform: translate(-4px, -2px)
  }

  33% {
    transform: translate(3px, 1px)
  }

  66% {
    transform: translate(-2px, 2px)
  }

  100% {
    transform: translate(0)
  }
}

@keyframes glitchB {
  0% {
    transform: translate(4px, 2px)
  }

  33% {
    transform: translate(-3px, -1px)
  }

  66% {
    transform: translate(2px, -2px)
  }

  100% {
    transform: translate(0)
  }
}

/* === 最終持續態：脈動 + 週期性 glitch === */
.final {
  position: relative;
  text-shadow:
    0 0 10px rgba(0, 255, 255, 0.5),
    0 0 30px rgba(0, 255, 255, 0.2),
    0 0 60px rgba(0, 255, 255, 0.1);
  animation: pulseGlow 2.5s ease-in-out infinite;
}

.final::before,
.final::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.final::before {
  color: #ff0040
}

.final::after {
  color: #00ffff
}

/* JS 控制的週期性 glitch 爆發 */
.final.glitch-burst {
  animation: finalGlitch 0.2s steps(2);
}

.final.glitch-burst::before {
  opacity: 0.8;
  animation: burstR 0.2s steps(3);
  clip-path: inset(20% 0 40% 0);
}

.final.glitch-burst::after {
  opacity: 0.8;
  animation: burstB 0.2s steps(3);
  clip-path: inset(50% 0 10% 0);
}

@keyframes pulseGlow {

  0%,
  100% {
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.4), 0 0 30px rgba(0, 255, 255, 0.15), 0 0 60px rgba(0, 255, 255, 0.05)
  }

  50% {
    text-shadow: 0 0 25px rgba(0, 255, 255, 0.8), 0 0 60px rgba(0, 255, 255, 0.4), 0 0 100px rgba(0, 255, 255, 0.2)
  }
}

@keyframes finalGlitch {
  0% {
    transform: translate(3px, 0) skewX(5deg);
    filter: brightness(1.6)
  }

  50% {
    transform: translate(-2px, 1px) skewX(-3deg);
    filter: brightness(0.7)
  }

  100% {
    transform: translate(0) skewX(0);
    filter: brightness(1)
  }
}

@keyframes burstR {
  0% {
    transform: translate(-3px, -1px)
  }

  50% {
    transform: translate(2px, 1px)
  }

  100% {
    transform: translate(0)
  }
}

@keyframes burstB {
  0% {
    transform: translate(3px, 1px)
  }

  50% {
    transform: translate(-2px, -1px)
  }

  100% {
    transform: translate(0)
  }
}

/* 四角裝飾 */
.corner {
  position: fixed;
  z-index: 6;
  width: 40px;
  height: 40px;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.corner.show {
  opacity: 1
}

.corner-tl {
  top: 20px;
  left: 20px;
  border-top: 2px solid #00ffff;
  border-left: 2px solid #00ffff
}

.corner-tr {
  top: 20px;
  right: 20px;
  border-top: 2px solid #00ffff;
  border-right: 2px solid #00ffff
}

.corner-bl {
  bottom: 20px;
  left: 20px;
  border-bottom: 2px solid #ff0040;
  border-left: 2px solid #ff0040
}

.corner-br {
  bottom: 20px;
  right: 20px;
  border-bottom: 2px solid #ff0040;
  border-right: 2px solid #ff0040
}

/* 底部裝飾線 */
.bottom-line {
  position: fixed;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, #00ffff, transparent);
  transition: width 1s ease, opacity 1s ease;
  opacity: 0;
}

.bottom-line.show {
  width: min(300px, 60vw);
  opacity: 1
}