/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0f;
  --bg-card: #12121a;
  --surface: #1a1a2e;
  --border: #2a2a3e;
  --text: #e0e0f0;
  --text-dim: #7a7a9a;
  --accent: #f9a8d4;
  --accent-glow: #fbcfe8;
  --accent-2: #f0abfc;
  --accent-3: #fda4af;
  --gradient-1: linear-gradient(135deg, #f9a8d4, #f0abfc);
  --gradient-2: linear-gradient(135deg, #fda4af, #f9a8d4);
  --font-main: 'Space Grotesk', system-ui, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'Space Mono', monospace;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== BACKGROUND CANVAS ===== */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ===== OVERLAY ===== */
.overlay {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
}

/* ===== HEADER ===== */
.header {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.logo-symbol {
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.8rem;
  animation: pulse-glow 3s ease-in-out infinite;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-style: italic;
  font-weight: 400;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.04em;
}

/* ===== HERO ===== */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.5rem;
  padding: 2rem 0;
}

/* Glitch effect */
.glitch-wrapper {
  position: relative;
}

.hero-title {
  font-size: clamp(3rem, 10vw, 7rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  animation: title-entrance 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(40px);
}

.hero-title::before,
.hero-title::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-title::before {
  animation: glitch-1 4s infinite linear alternate-reverse;
  clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
}

.hero-title::after {
  animation: glitch-2 4s infinite linear alternate-reverse;
  clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
}

.hero-subtitle {
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  color: var(--text-dim);
  font-weight: 300;
  letter-spacing: 0.05em;
  animation: fade-up 1s 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(20px);
}

.hero-hint {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  animation: fade-up 1s 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(20px);
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: fade-up 1s 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(20px);
}

.divider-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.divider-line {
  width: 60px;
  height: 1px;
  background: var(--gradient-1);
}

/* Play button */
.play-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 2rem;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 100px;
  color: var(--accent-glow);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  animation: fade-up 1s 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(20px);
}

.play-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-1);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: -1;
}

.play-btn:hover {
  color: white;
  border-color: transparent;
  box-shadow: 0 0 30px rgba(249, 168, 212, 0.3);
  transform: translateY(-2px) !important;
}

.play-btn:hover::before {
  opacity: 1;
}

.play-btn.small {
  padding: 0.7rem 1.5rem;
  font-size: 0.85rem;
  animation: none;
  opacity: 1;
  transform: none;
}

.play-btn-icon {
  font-size: 0.8rem;
}

/* ===== GAME CONTAINER ===== */
.game-container {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: scale-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
  margin-bottom: 2rem;
}

.game-container.active {
  display: flex;
}

.game-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  width: 100%;
  max-width: 400px;
  justify-content: center;
  position: relative;
}

.game-score, .game-high-score {
  color: var(--text-dim);
}

.game-score span {
  color: var(--accent-glow);
  font-weight: 700;
}

.game-high-score span {
  color: var(--accent-2);
  font-weight: 700;
}

.game-close {
  position: absolute;
  right: 0;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.game-close:hover {
  border-color: var(--accent-3);
  color: var(--accent-3);
}

#game-canvas {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: 0 0 40px rgba(249, 168, 212, 0.05), inset 0 0 40px rgba(0,0,0,0.3);
  max-width: 100%;
}

.game-controls-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  opacity: 0.6;
}

.mobile-hint {
  display: none;
}

.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  z-index: 5;
  pointer-events: auto;
}

.game-overlay.hidden {
  display: none;
}

.game-overlay-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.game-overlay-content h2 {
  font-size: 1.5rem;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-overlay-content p {
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ===== FOOTER ===== */
.footer {
  padding: 2rem 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ===== ANIMATIONS ===== */
@keyframes title-entrance {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes glitch-1 {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

@keyframes glitch-2 {
  0% { transform: translate(0); }
  20% { transform: translate(2px, -2px); }
  40% { transform: translate(2px, 2px); }
  60% { transform: translate(-2px, -2px); }
  80% { transform: translate(-2px, 2px); }
  100% { transform: translate(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .overlay {
    padding: 1rem;
  }

  .hero {
    gap: 1.2rem;
  }

  #game-canvas {
    width: 300px;
    height: 300px;
  }

  .mobile-hint {
    display: block;
  }
}

@media (max-width: 480px) {
  .header {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
  }

  .hero-title {
    letter-spacing: 0.08em;
  }

  #game-canvas {
    width: 260px;
    height: 260px;
  }
}

/* ===== SELECTION ===== */
::selection {
  background: rgba(249, 168, 212, 0.3);
  color: white;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
  width: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

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