
/* Base Styles for William's Gamebox */
:root {
  /* Calm, child-friendly color palette */
  --bg-primary: #f8f9ff;
  --bg-secondary: #e8ecff;
  --text-primary: #2a2a72;
  --text-secondary: #4a4a8a;
  --accent-primary: #4facfe;
  --accent-secondary: #00f2fe;
  
  /* Additional colors */
  --success: #4ade80;
  --error: #ff6b6b;
  --neutral: #f1f5f9;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  
  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

.hero {
  text-align: center;
  padding: var(--space-lg) 0;
}

.hero-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 0 auto var(--space-xl);
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .hero {
    padding: var(--space-md) 0;
  }
  
  .hero-image {
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-lg);
  }
}

@media (max-width: 480px) {
  .hero {
    padding: var(--space-sm) 0;
  }
  
  .hero-image {
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
}
  --success: #4ade80;
  --error: #ff6b6b;
  --neutral: #f1f5f9;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
}
/* Base Reset */
* { 
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Typography */
body {
  font-family: 'Nunito', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
/* Layout */
.wrap { 
  width: min(1200px, 95vw);
  margin: 0 auto;
  padding: var(--space-md);
}

/* Header */
.site-header {
  background: white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { 
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.25rem;
}

.site-nav {
  display: flex;
  gap: var(--space-lg);
}

.site-nav a { 
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 700;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] { 
  background: var(--bg-secondary);
  color: var(--text-primary);
}
/* How to Play Section */
.howto {
  background: white;
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.howto h2 {
  color: var(--text-primary);
  font-size: 1.5rem;
  margin-bottom: var(--space-md);
}

.howto p {
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

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

.howto li {
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.howto li:before {
  content: "•";
  color: var(--accent-primary);
  font-weight: bold;
}

.kbd {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  font-weight: 600;
}

/* Hero Section */
.hero {
  padding: var(--space-xl) 0;
  text-align: center;
  background: linear-gradient(135deg, var(--bg-secondary), var(--bg-primary));
  border-radius: var(--radius-lg);
  margin: var(--space-lg) 0;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1.2rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Game Grid */
.games-grid {
  padding: var(--space-lg) 0;
}

.games-grid h2 {
  color: var(--text-primary);
  font-size: 1.75rem;
  margin-bottom: var(--space-lg);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  list-style: none;
  padding: var(--space-md) 0;
}

.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0,0,0,0.05);
  transition: transform 0.2s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  padding: var(--space-lg);
}

.thumb {
  height: 160px;
  display: grid;
  place-items: center;
  font-size: 4rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.thumb-math {
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
  color: white;
}

.card h3 {
  color: var(--text-primary);
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.card p {
  color: var(--text-secondary);
  line-height: 1.5;
}
/* Game Layout */
.game-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Game Overlays */
.game-intro-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.game-intro-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-content {
  background: #FFF;
  padding: 2rem;
  border-radius: 16px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.5s ease-out;
}

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

.intro-instructions {
  color: var(--text-1);
}

.intro-instructions h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.instruction-steps {
  display: grid;
  gap: 1rem;
  margin: 2rem 0;
  text-align: left;
}

.step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
}

.step-icon {
  font-size: 1.5rem;
  min-width: 2rem;
  text-align: center;
}

.step p {
  margin: 0;
  font-size: 1.1rem;
}

/* Game Components */
.game-header {
  text-align: center;
  margin-bottom: 1rem;
}

.game-header h1 {
  font-size: 2.5rem;
  margin: 0 0 1rem;
  color: var(--text-1);
}

.game-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  margin: 1.5rem 0;
  padding: 0.5rem;
}

/* Game Buttons */
.btn-secondary {
  background: #4a90e2;
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: #357abd;
  transform: translateY(-1px);
}

.btn-primary {
  background: #2ecc71;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: #27ae60;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}

.btn-primary:disabled {
  background: #95a5a6;
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(46, 204, 113, 0.2);
}

/* Game Board */
.game-board {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1rem 0;
}

/* Buttons */
.btn {
  background: linear-gradient(45deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  border: none;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease;
  font-size: 1.1rem;
}

.btn:hover {
  transform: scale(1.05);
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Keyboard Shortcuts */
.kbd {
  background: var(--neutral);
  border: 1px solid var(--text-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
  font-weight: 600;
}

/* Footer */
.site-footer {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: var(--space-xl) var(--space-lg);
  margin-top: var(--space-xl);
  text-align: center;
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--accent-primary);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Ad Units */
.ad-container {
  width: 100%;
  min-height: 90px;
  margin: var(--space-lg) auto;
  text-align: center;
  overflow: hidden;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.adsbygoogle {
  display: block;
  min-width: 250px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* Game Specific Overrides */
.intro-content h1 {
  font-size: 2.5rem;
  color: var(--text-1);
  margin: 0 0 1.5rem;
}

#start-btn {
  margin-top: 2rem;
  padding: 1rem 3rem;
  font-size: 1.2rem;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#start-btn:hover {
  transform: translateY(-2px);
  background: var(--brand-hover, var(--brand));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

#scoreboard {
  font-size: 1.2rem;
  font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
  :root {
    --space-lg: 1rem;
    --space-xl: 1.5rem;
  }

  .site-header {
    padding: var(--space-sm);
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }
  
  .site-nav {
    gap: var(--space-sm);
    flex-wrap: wrap;
    justify-content: center;
  }

  .hero {
    padding: var(--space-lg);
  }
  
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero p {
    font-size: 1rem;
  }
  
  .game-header {
    flex-direction: column;
    text-align: center;
    padding: var(--space-md);
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .thumb {
    height: 120px;
    font-size: 3rem;
  }

  .card h3 {
    font-size: 1.25rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

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

:focus:not(:focus-visible) {
  outline: none;
}

/* High Contrast Mode */
@media (forced-colors: active) {
  .card,
  .btn,
  .site-nav a {
    border: 2px solid currentColor;
  }
}
