@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@300;400;600;800&display=swap');

:root {
  --primary: #6366f1;
  --secondary: #22d3ee;
  --accent: #ec4899;
  --dark: #0f172a;
  --darker: #020617;
}

* {
  font-family: 'Inter', sans-serif;
}

h1, h2, .font-mono {
  font-family: 'Orbitron', monospace;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--darker);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(to bottom, var(--primary), var(--secondary));
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary);
}

/* Animations */
@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(5deg);
  }
}

@keyframes pulse-glow {
  0%, 100% {
    opacity: 1;
    filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.5));
  }
  50% {
    opacity: 0.8;
    filter: drop-shadow(0 0 40px rgba(34, 211, 238, 0.8));
  }
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }
  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}

@keyframes match-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.7);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 20px rgba(34, 211, 238, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(34, 211, 238, 0);
  }
}

/* Card Flip Styles */
.memory-card {
  aspect-ratio: 1;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.memory-card.flipped {
  transform: rotateY(180deg);
}

.memory-card.matched {
  animation: match-pulse 0.6s ease-out;
}

.memory-card.matched .card-front {
  border-color: var(--secondary);
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.5);
}

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

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.card-back {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid rgba(99, 102, 241, 0.3);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card-back:hover {
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
  transform: scale(1.05);
}

.card-back::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
  border-radius: inherit;
}

.card-front {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(34, 211, 238, 0.1) 100%);
  border: 2px solid var(--primary);
  transform: rotateY(180deg);
  backdrop-filter: blur(10px);
}

/* Glitch Effect for Title */
.glitch {
  position: relative;
}

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

.glitch::before {
  animation: glitch-1 2s infinite linear alternate-reverse;
  color: var(--primary);
  z-index: -1;
}

.glitch::after {
  animation: glitch-2 3s infinite linear alternate-reverse;
  color: var(--secondary);
  z-index: -2;
}

@keyframes glitch-1 {
  0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
  20% { clip-path: inset(20% 0 30% 0); transform: translate(-2px, 2px); }
  40% { clip-path: inset(50% 0 20% 0); transform: translate(2px, -2px); }
  60% { clip-path: inset(10% 0 60% 0); transform: translate(-2px, -2px); }
  80% { clip-path: inset(80% 0 5% 0); transform: translate(2px, 2px); }
}

@keyframes glitch-2 {
  0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
  20% { clip-path: inset(60% 0 10% 0); transform: translate(2px, -2px); }
  40% { clip-path: inset(30% 0 40% 0); transform: translate(-2px, 2px); }
  60% { clip-path: inset(10% 0 70% 0); transform: translate(2px, 2px); }
  80% { clip-path: inset(90% 0 5% 0); transform: translate(-2px, -2px); }
}

/* Grid Perspective */
.perspective-1000 {
  perspective: 1000px;
}

/* Pulse Ring Animation */
.pulse-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid var(--secondary);
  animation: pulse-ring 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.8);
    opacity: 0.8;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* Responsive Adjustments */
@media (max-width: 640px) {
  .memory-card {
    font-size: 1.5rem;
  }
  
  .card-face {
    border-radius: 0.75rem;
  }
}

/* Light Mode Adjustments */
html:not(.dark) .card-back {
  background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
  border-color: rgba(99, 102, 241, 0.3);
}

html:not(.dark) .card-front {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(34, 211, 238, 0.05) 100%);
  background-color: white;
}

html:not(.dark) body {
  background: linear-gradient(to bottom, #f8fafc, #e2e8f0);
  color: #1e293b;
}