/* ========================================
   PSYCHO MINI-GAME MARATHON - Stylesheet
   Dark psychedelic aesthetic with glitch effects
   ======================================== */

:root {
  --bg: #0b0b0f;
  --text: #e8e8f0;
  --accent: #7c3aed;
  --cyan: #06b6d4;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  
  --font-display: 'Orbitron', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ========================================
   BACKGROUND EFFECTS
   ======================================== */

/* Noise Canvas */
#noise-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.03;
  z-index: 1;
  pointer-events: none;
}

/* Scanlines */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.1),
    rgba(0, 0, 0, 0.1) 1px,
    transparent 1px,
    transparent 2px
  );
  z-index: 2;
  pointer-events: none;
  opacity: 0.4;
}

/* Vignette */
.vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, transparent 0%, rgba(11, 11, 15, 0.7) 100%);
  z-index: 2;
  pointer-events: none;
}

/* Psycho Overlay Images */
#psycho-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.15;
  mix-blend-mode: overlay;
}

#psycho-overlay img {
  position: absolute;
  width: 120%;
  height: 120%;
  object-fit: cover;
  filter: url(#displace) blur(2px);
  animation: psychoFloat 20s ease-in-out infinite;
}

@keyframes psychoFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  25% { transform: translate(-3%, 2%) rotate(1deg) scale(1.05); }
  50% { transform: translate(2%, -2%) rotate(-0.5deg) scale(1); }
  75% { transform: translate(-2%, 3%) rotate(0.5deg) scale(1.03); }
}

/* Reduce motion support */
@media (prefers-reduced-motion: reduce) {
  #psycho-overlay img, .glitch::before, .glitch::after, .scanlines {
    animation: none !important;
  }
}

/* ========================================
   GLITCH TEXT EFFECT
   ======================================== */

.glitch {
  position: relative;
  font-family: var(--font-display);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

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

.glitch::before {
  color: var(--cyan);
  animation: glitch1 2.5s infinite;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  transform: translate(-2px, 0);
}

.glitch::after {
  color: var(--err);
  animation: glitch2 2.8s infinite reverse;
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  transform: translate(2px, 0);
}

@keyframes glitch1 {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(-3px, 2px); }
  66% { transform: translate(2px, -1px); }
}

@keyframes glitch2 {
  0%, 100% { transform: translate(0, 0); }
  33% { transform: translate(2px, -2px); }
  66% { transform: translate(-2px, 1px); }
}

/* ========================================
   HUD (Header)
   ======================================== */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(11, 11, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(124, 58, 237, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.1);
}

.hud.hidden {
  display: none;
}

.hud-left, .hud-center, .hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.progress {
  font-size: 12px;
  color: var(--cyan);
  opacity: 0.8;
}

.hud-center {
  position: relative;
}

.timer-ring {
  position: relative;
}

.timer-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

.hud-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(232, 232, 240, 0.2);
  background: transparent;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.hud-btn:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--accent);
  transform: scale(1.05);
}

.hud-btn:active {
  transform: scale(0.95);
}

.hidden {
  display: none !important;
}

/* ========================================
   MAIN APP CONTAINER
   ======================================== */

.app-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 70px 16px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========================================
   VIEWS & CARDS
   ======================================== */

.view {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: rgba(20, 20, 28, 0.8);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 18px;
  padding: 32px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(124, 58, 237, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.card:hover {
  filter: url(#chromatic);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(124, 58, 237, 0.2);
  transition: all 0.3s;
}

.card-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  text-align: center;
  margin-bottom: 24px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

.card-text {
  text-align: center;
  line-height: 1.6;
  margin-bottom: 24px;
  color: var(--text);
  opacity: 0.9;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn-primary, .btn-secondary {
  width: 100%;
  min-height: 52px;
  padding: 14px 24px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #6d28d9 100%);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.6);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(124, 58, 237, 0.1);
  color: var(--accent);
  border: 1px solid rgba(124, 58, 237, 0.5);
}

.btn-secondary:hover {
  background: rgba(124, 58, 237, 0.2);
  border-color: var(--accent);
}

/* ========================================
   OVERLAY
   ======================================== */

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 11, 15, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s;
  padding: 20px;
}

.overlay-card {
  background: rgba(20, 20, 28, 0.95);
  border: 2px solid var(--accent);
  border-radius: 18px;
  padding: 48px 32px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 48px rgba(124, 58, 237, 0.5);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.overlay-title {
  font-size: 36px;
  margin-bottom: 16px;
  color: var(--err);
}

.overlay-message {
  font-size: 18px;
  margin-bottom: 32px;
  color: var(--text);
  opacity: 0.9;
}

/* ========================================
   INTRO SCREEN
   ======================================== */

.intro-logo {
  font-size: 48px;
  text-align: center;
  margin-bottom: 32px;
  line-height: 1.2;
}

.intro-rules {
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 12px;
  padding: 20px;
  margin: 24px 0;
}

.intro-rules h3 {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--cyan);
  margin-bottom: 12px;
}

.intro-rules ul {
  list-style: none;
  padding: 0;
}

.intro-rules li {
  padding: 8px 0;
  padding-left: 24px;
  position: relative;
  font-size: 14px;
  line-height: 1.5;
}

.intro-rules li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* ========================================
   MEMORY GAME
   ======================================== */

.memory-grid {
  display: grid;
  gap: 12px;
  margin: 24px 0;
  grid-template-columns: repeat(4, 1fr);
}

.memory-card {
  aspect-ratio: 1;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.2s;
  min-height: 60px;
}

.memory-card.flipped .memory-card-front,
.memory-card.matched .memory-card-front {
  opacity: 0;
  visibility: hidden;
}

.memory-card.flipped .memory-card-back,
.memory-card.matched .memory-card-back {
  opacity: 1;
  visibility: visible;
}

.memory-card.matched {
  cursor: default;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
  filter: brightness(1.1);
}

.memory-card.shake {
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-2deg); }
  75% { transform: translateX(8px) rotate(2deg); }
}

.memory-card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(124, 58, 237, 0.3);
  transition: opacity 0.2s, visibility 0.2s;
}

.memory-card-front {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(109, 40, 217, 0.2));
  opacity: 1;
  visibility: visible;
}

.memory-card-back {
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
}

.memory-card-back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.memory-card.matched .memory-card-back img {
  filter: brightness(1.2) contrast(1.1);
  opacity: 1;
}

.memory-icon {
  font-size: 24px;
  color: var(--accent);
}

.memory-stats {
  display: flex;
  justify-content: space-around;
  margin-top: 20px;
  font-size: 14px;
}

.memory-stat {
  text-align: center;
}

.memory-stat-value {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--cyan);
  font-weight: 700;
}

.memory-stat-label {
  font-size: 12px;
  opacity: 0.7;
  margin-top: 4px;
}

/* ========================================
   SNAKE GAME
   ======================================== */

.snake-container {
  position: relative;
}

.snake-canvas {
  width: 100%;
  max-width: 400px;
  height: 400px;
  margin: 0 auto;
  display: block;
  background: rgba(11, 11, 15, 0.6);
  border: 2px solid rgba(6, 182, 212, 0.4);
  border-radius: 12px;
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.2);
}

.snake-dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 200px;
  margin: 24px auto 0;
}

.snake-dpad button {
  width: 60px;
  height: 60px;
  background: rgba(124, 58, 237, 0.2);
  border: 1px solid rgba(124, 58, 237, 0.5);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.1s;
}

.snake-dpad button:hover {
  background: rgba(124, 58, 237, 0.4);
  transform: scale(1.05);
}

.snake-dpad button:active {
  transform: scale(0.95);
  background: rgba(124, 58, 237, 0.6);
}

.snake-dpad button:nth-child(2) { grid-column: 2; }
.snake-dpad button:nth-child(3) { grid-column: 1; grid-row: 2; }
.snake-dpad button:nth-child(4) { grid-column: 2; grid-row: 2; }
.snake-dpad button:nth-child(5) { grid-column: 3; grid-row: 2; }

.snake-score {
  text-align: center;
  margin-top: 16px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--cyan);
}

/* ========================================
   TILT GAME
   ======================================== */

.tilt-container {
  position: relative;
}

.tilt-canvas {
  width: 100%;
  max-width: 400px;
  height: auto;
  max-height: 70vh;
  margin: 0 auto;
  display: block;
  background: rgba(11, 11, 15, 0.6);
  border: 2px solid rgba(6, 182, 212, 0.4);
  border-radius: 12px;
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.2);
}

.tilt-permission {
  text-align: center;
  margin-top: 24px;
}

.tilt-joystick {
  width: 150px;
  height: 150px;
  margin: 24px auto 0;
  position: relative;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.1);
  border: 2px solid rgba(124, 58, 237, 0.3);
}

.tilt-joystick-stick {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.5);
  pointer-events: none;
}

/* ========================================
   FINALE SCREEN
   ======================================== */

.finale-address {
  font-family: var(--font-display);
  font-size: 20px;
  text-align: center;
  margin: 24px 0;
  padding: 24px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid var(--cyan);
  border-radius: 12px;
  color: var(--cyan);
  line-height: 1.6;
  text-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.finale-qr {
  display: flex;
  justify-content: center;
  margin: 32px 0;
  padding: 20px;
  background: white;
  border-radius: 12px;
  max-width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.finale-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
  .card {
    padding: 24px 16px;
  }
  
  .card-title {
    font-size: 24px;
  }
  
  .intro-logo {
    font-size: 32px;
  }
  
  .memory-grid {
    gap: 8px;
  }
  
  .snake-canvas {
    height: 300px;
  }
  
  .tilt-canvas {
    max-height: 60vh;
  }
}

/* ========================================
   ANIMATIONS & EFFECTS
   ======================================== */

.pulse {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.flash-green {
  animation: flashGreen 0.6s;
}

@keyframes flashGreen {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(34, 197, 94, 0.3); }
}

.flash-red {
  animation: flashRed 0.6s;
}

@keyframes flashRed {
  0%, 100% { background-color: transparent; }
  50% { background-color: rgba(239, 68, 68, 0.3); }
}

/* ========================================
   PSYCHOTIC FINALE ANIMATION
   ======================================== */

.psychotic-message {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 11, 15, 0.98);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: psychoticFadeIn 0.3s ease-out;
}

.psychotic-message.fade-out {
  animation: psychoticFadeOut 0.5s ease-out forwards;
}

.psychotic-text {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 48px);
  font-weight: 900;
  text-align: center;
  line-height: 1.4;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: psychoticPulse 0.8s ease-in-out infinite, psychoticShake 0.15s ease-in-out infinite;
}

.psychotic-text .highlight {
  color: var(--err);
  font-size: 1.2em;
  text-shadow: 0 0 20px var(--err);
}

.psychotic-bockwurst {
  position: absolute;
  max-width: 60%;
  max-height: 60%;
  object-fit: contain;
  opacity: 0.3;
  filter: blur(2px) contrast(1.5) saturate(2);
  animation: bockwurstFloat 3s ease-in-out infinite, bockwurstGlitch 0.5s infinite;
  z-index: 0;
}

@keyframes bockwurstFloat {
  0%, 100% {
    transform: translate(-20%, -20%) rotate(-5deg) scale(0.9);
  }
  50% {
    transform: translate(20%, 20%) rotate(5deg) scale(1.1);
  }
}

@keyframes bockwurstGlitch {
  0%, 100% {
    filter: blur(2px) contrast(1.5) saturate(2) hue-rotate(0deg);
  }
  25% {
    filter: blur(3px) contrast(2) saturate(3) hue-rotate(90deg);
  }
  50% {
    filter: blur(1px) contrast(2.5) saturate(1) hue-rotate(180deg);
  }
  75% {
    filter: blur(4px) contrast(1.8) saturate(2.5) hue-rotate(270deg);
  }
}

@keyframes psychoticFadeIn {
  from {
    opacity: 0;
    transform: scale(1.2);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes psychoticFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes psychoticPulse {
  0%, 100% { 
    opacity: 1; 
    text-shadow: 
      0 0 10px var(--accent),
      0 0 20px var(--accent),
      0 0 30px var(--cyan);
  }
  50% { 
    opacity: 0.8; 
    text-shadow: 
      0 0 20px var(--err),
      0 0 30px var(--err),
      0 0 40px var(--accent);
  }
}

@keyframes psychoticShake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-2px, 1px) rotate(-0.5deg); }
  50% { transform: translate(2px, -1px) rotate(0.5deg); }
  75% { transform: translate(-1px, 2px) rotate(-0.3deg); }
}

/* ========================================
   DISTURBING ANIMATION OVERLAY
   ======================================== */

.disturbing-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.5s;
}

.disturbing-overlay.active {
  opacity: 1;
}

.disturbing-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.disturbing-image {
  position: absolute;
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  opacity: 0;
  filter: contrast(1.5) saturate(1.5);
  animation: disturbingFlash 6s infinite;
}

.disturbing-image-1 {
  animation-delay: 0s;
}

.disturbing-image-2 {
  animation-delay: 0.15s;
}

@keyframes disturbingFlash {
  0%, 10% {
    opacity: 0;
    transform: scale(1) rotate(0deg);
    filter: contrast(1.5) saturate(1.5) hue-rotate(0deg);
  }
  12%, 24% {
    opacity: 1;
    transform: scale(1.1) rotate(-2deg);
    filter: contrast(2) saturate(2) hue-rotate(180deg);
  }
  26%, 38% {
    opacity: 0.9;
    transform: scale(0.95) rotate(2deg);
    filter: contrast(3) saturate(0.5) hue-rotate(90deg);
  }
  40%, 52% {
    opacity: 1;
    transform: scale(1.15) rotate(-3deg);
    filter: contrast(1.8) saturate(1.8) hue-rotate(270deg);
  }
  54%, 66% {
    opacity: 0.8;
    transform: scale(1.05) rotate(1deg);
    filter: contrast(2.5) saturate(1) hue-rotate(45deg);
  }
  68%, 80% {
    opacity: 1;
    transform: scale(1.2) rotate(-1deg);
    filter: contrast(2) saturate(2.5) hue-rotate(180deg);
  }
  82%, 100% {
    opacity: 0;
    transform: scale(0.9) rotate(0deg);
    filter: contrast(1.5) saturate(1.5) hue-rotate(360deg);
  }
}

/* ========================================
   GLITCH MATRIX ANIMATION
   ======================================== */

.glitch-matrix-overlay {
  overflow: hidden;
}

.glitch-matrix-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

.matrix-column {
  position: absolute;
  top: -100%;
  width: 3%;
  height: 100%;
  display: flex;
  flex-direction: column;
  font-family: 'Courier New', monospace;
  font-size: 20px;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
  animation: matrixFall 3s linear infinite;
}

.matrix-char {
  display: block;
  opacity: 0;
  animation: matrixChar 0.5s linear infinite;
}

.matrix-glitch-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
}

.matrix-message {
  font-family: var(--font-display);
  font-size: clamp(32px, 8vw, 72px);
  font-weight: 900;
  color: var(--err);
  text-shadow: 
    0 0 20px var(--err),
    0 0 40px var(--err),
    0 0 60px var(--accent);
  animation: matrixGlitchPulse 0.3s infinite, extremeShake 0.1s infinite;
}

@keyframes matrixFall {
  0% {
    top: -100%;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

@keyframes matrixChar {
  0%, 100% {
    opacity: 0.1;
  }
  50% {
    opacity: 1;
    text-shadow: 0 0 20px var(--cyan), 0 0 40px var(--accent);
  }
}

@keyframes matrixGlitchPulse {
  0%, 100% {
    filter: hue-rotate(0deg) brightness(1);
  }
  25% {
    filter: hue-rotate(90deg) brightness(1.5);
  }
  50% {
    filter: hue-rotate(180deg) brightness(2);
  }
  75% {
    filter: hue-rotate(270deg) brightness(1.5);
  }
}

@keyframes extremeShake {
  0% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg); }
  20% { transform: translate(-50%, -50%) translate(-5px, 5px) rotate(-2deg) scale(1.02); }
  40% { transform: translate(-50%, -50%) translate(5px, -5px) rotate(2deg) scale(0.98); }
  60% { transform: translate(-50%, -50%) translate(-3px, -3px) rotate(-1deg) scale(1.01); }
  80% { transform: translate(-50%, -50%) translate(3px, 3px) rotate(1deg) scale(0.99); }
  100% { transform: translate(-50%, -50%) translate(0, 0) rotate(0deg); }
}

/* ========================================
   REALITY TEAR ANIMATION
   ======================================== */

.reality-tear-overlay {
  background: radial-gradient(circle, rgba(124, 58, 237, 0.3), #000);
}

.reality-tear-container {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 1000px;
}

.reality-fragment {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150px;
  height: 150px;
  transform: translate(-50%, -50%);
  animation: fragmentExplode 2s ease-out infinite;
}

.fragment-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    var(--accent),
    var(--cyan),
    var(--err),
    var(--accent)
  );
  border-radius: 20%;
  box-shadow: 
    0 0 30px var(--accent),
    0 0 60px var(--cyan),
    inset 0 0 30px rgba(255, 255, 255, 0.5);
  animation: fragmentRotate 3s linear infinite;
}

.tear-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  text-align: center;
}

.tear-text {
  font-family: var(--font-display);
  font-size: clamp(40px, 10vw, 96px);
  font-weight: 900;
  color: var(--text);
  text-shadow: 
    0 0 30px var(--accent),
    0 0 60px var(--cyan),
    0 0 90px var(--err);
  animation: tearTextPulse 0.5s infinite, intenseSpin 2s linear infinite;
  transform-origin: center;
}

.tear-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300px;
  height: 300px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--err), transparent);
  animation: tearPulse 1s ease-out infinite;
  z-index: -1;
}

@keyframes fragmentExplode {
  0% {
    transform: translate(-50%, -50%) 
               translate(0, 0) 
               rotate(0deg) 
               scale(0);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) 
               translate(calc(var(--x) * 0.8), calc(var(--y) * 0.8)) 
               rotate(calc(var(--rotation) * 0.5)) 
               scale(var(--scale));
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) 
               translate(var(--x), var(--y)) 
               rotate(var(--rotation)) 
               scale(0);
    opacity: 0;
  }
}

@keyframes fragmentRotate {
  0% {
    transform: rotate(0deg) rotateY(0deg);
    filter: hue-rotate(0deg) brightness(1);
  }
  33% {
    transform: rotate(120deg) rotateY(180deg);
    filter: hue-rotate(120deg) brightness(1.5);
  }
  66% {
    transform: rotate(240deg) rotateY(360deg);
    filter: hue-rotate(240deg) brightness(2);
  }
  100% {
    transform: rotate(360deg) rotateY(540deg);
    filter: hue-rotate(360deg) brightness(1);
  }
}

@keyframes tearTextPulse {
  0%, 100% {
    opacity: 1;
    filter: brightness(1) contrast(1);
  }
  50% {
    opacity: 0.7;
    filter: brightness(2) contrast(2);
  }
}

@keyframes intenseSpin {
  0% {
    transform: rotate(0deg) scale(1);
  }
  25% {
    transform: rotate(90deg) scale(1.1);
  }
  50% {
    transform: rotate(180deg) scale(0.9);
  }
  75% {
    transform: rotate(270deg) scale(1.05);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

@keyframes tearPulse {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}
