/* ===========================
   CSS Custom Properties (Design System)
   =========================== */
:root {
  /* Colors */
  --primary: #667eea;
  --primary-light: #764ba2;
  --primary-dark: #4c63d2;
  --secondary: #f093fb;
  --accent: #ffeaa7;
  --success: #00b894;
  --warning: #fdcb6e;
  --error: #e17055;
  
  /* Neutral Colors */
  --background: #f8f9fa;
  --surface: #ffffff;
  --surface-hover: #f1f3f4;
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --text-muted: #95a5a6;
  --border: #e9ecef;
  --shadow: rgba(0, 0, 0, 0.1);
  --shadow-hover: rgba(0, 0, 0, 0.15);
  
  /* Typography */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-accent: 'Poppins', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;
  
  /* Font Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  
  /* Borders */
  --border-radius: 0.5rem;
  --border-radius-lg: 0.75rem;
  --border-radius-xl: 1rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-base: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Breakpoints */
  --mobile: 768px;
  --tablet: 1024px;
  --desktop: 1200px;
}

/* ===========================
   Base Styles & Reset
   =========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-primary);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ===========================
   Layout System
   =========================== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-6);
  }
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  padding: var(--space-8) 0;
}

/* ===========================
   Header & Navigation
   =========================== */
.app-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: var(--space-4) 0;
  box-shadow: var(--shadow-base);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.logo h1 {
  font-family: var(--font-accent);
  font-size: var(--text-2xl);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.tagline {
  font-size: var(--text-sm);
  opacity: 0.9;
  font-weight: 300;
}

/* Navigation */
.nav-toggle {
  display: none;
  flex-direction: column;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
}

.nav-toggle span {
  width: 25px;
  height: 3px;
  background: white;
  margin: 3px 0;
  transition: var(--transition-fast);
  border-radius: 2px;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: var(--space-6);
  align-items: center;
}

.nav-link {
  color: white;
  text-decoration: none;
  font-weight: 500;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius);
  transition: var(--transition-fast);
  position: relative;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* Mobile Navigation */
@media (max-width: 767px) {
  .nav-toggle {
    display: flex;
  }
  
  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--primary);
    flex-direction: column;
    padding: var(--space-4);
    box-shadow: var(--shadow-lg);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-base);
  }
  
  .nav-menu.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }
  
  .nav-link {
    width: 100%;
    text-align: center;
    padding: var(--space-3);
  }
}

/* ===========================
   Hero Section
   =========================== */
.hero-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  align-items: center;
  min-height: 60vh;
  margin-bottom: var(--space-16);
}

@media (min-width: 768px) {
  .hero-section {
    grid-template-columns: 1fr 1fr;
    min-height: 70vh;
  }
}

.hero-content {
  text-align: center;
}

@media (min-width: 768px) {
  .hero-content {
    text-align: left;
  }
}

.hero-title {
  font-family: var(--font-accent);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-4);
  line-height: 1.2;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: var(--text-4xl);
  }
}

.hero-description {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  max-width: 500px;
}

.hero-actions {
  display: flex;
  gap: var(--space-4);
  flex-direction: column;
}

@media (min-width: 480px) {
  .hero-actions {
    flex-direction: row;
    justify-content: center;
  }
}

@media (min-width: 768px) {
  .hero-actions {
    justify-content: flex-start;
  }
}

/* Hero Visual */
.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

.puzzle-preview {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.mini-tower {
  position: relative;
  width: 120px;
  height: 150px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.tower-base {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 10px;
  background: linear-gradient(145deg, #8b5cf6, #7c3aed);
  border-radius: 5px;
  box-shadow: var(--shadow-base);
}

.tower-pole {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 100px;
  background: linear-gradient(145deg, #6366f1, #4f46e5);
  border-radius: 2px;
  box-shadow: var(--shadow-sm);
}

.mini-disk {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 15px;
  box-shadow: var(--shadow-base);
  animation: glow 2s ease-in-out infinite alternate;
}

.disk-1 {
  width: 80px;
  height: 15px;
  background: linear-gradient(145deg, #f59e0b, #d97706);
  bottom: 10px;
}

.disk-2 {
  width: 60px;
  height: 15px;
  background: linear-gradient(145deg, #ef4444, #dc2626);
  bottom: 25px;
}

.disk-3 {
  width: 40px;
  height: 15px;
  background: linear-gradient(145deg, #10b981, #059669);
  bottom: 40px;
}

@keyframes glow {
  from { box-shadow: var(--shadow-base); }
  to { box-shadow: var(--shadow-lg), 0 0 20px rgba(59, 130, 246, 0.3); }
}

/* ===========================
   Sections
   =========================== */
.section-header {
  text-align: center;
  margin-bottom: var(--space-12);
}

.section-title {
  font-family: var(--font-accent);
  font-size: var(--text-3xl);
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-3);
}

.section-description {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* ===========================
   Games Section
   =========================== */
.games-section {
  margin-bottom: var(--space-16);
}

.games-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .games-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ===========================
   Stats Section
   =========================== */
.stats-section {
  margin-bottom: var(--space-16);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--surface);
  border-radius: var(--border-radius-lg);
  padding: var(--space-6);
  text-align: center;
  box-shadow: var(--shadow-base);
  transition: var(--transition-base);
  border: 1px solid var(--border);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-3);
}

.stat-number {
  font-family: var(--font-accent);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-2);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===========================
   Footer
   =========================== */
.app-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: var(--space-8) 0;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-direction: column;
  gap: var(--space-4);
  text-align: center;
}

@media (min-width: 768px) {
  .footer-content {
    flex-direction: row;
    text-align: left;
  }
}

.footer-content p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.footer-links {
  display: flex;
  gap: var(--space-6);
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: var(--transition-fast);
}

.footer-links a:hover {
  color: var(--primary);
}

/* ===========================
   Utility Classes
   =========================== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.hidden { display: none; }
.visible { display: block; }

/* ===========================
   Responsive Utilities
   =========================== */
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 768px) {
  .show-mobile { display: none !important; }
}

/* ===========================
   Animation & Loading States
   =========================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-base);
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-4);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: white;
  font-size: var(--text-lg);
  font-weight: 500;
}

/* ===========================
   Accessibility
   =========================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus styles */
*:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}