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

:root {
  --bg: #0a0e1a;
  --bg2: #111827;
  --card: #1a2235;
  --border: #2a3450;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== HEADER ===== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: white;
}
.logo span { color: var(--accent); }

nav { display: flex; gap: 1.5rem; align-items: center; }
nav a { color: var(--text-muted); text-decoration: none; font-size: 0.95rem; }
nav a:hover { color: var(--text); }

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--accent);
  color: white;
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent2); }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  border: 2px solid var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--accent); color: white; }

.btn-cta {
  background: var(--accent);
  color: white !important;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
}

.btn-back {
  background: var(--card);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-back:hover { background: var(--border); }

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: 5rem 2rem 4rem;
  max-width: 720px;
  margin: 0 auto;
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1.2rem;
  color: white;
}
.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}
.hero-btns {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.hero-sub {
  font-size: 0.85rem !important;
  color: var(--text-muted) !important;
  margin-bottom: 0 !important;
}

/* ===== MODULES ===== */
.modules-section {
  padding: 4rem 2rem;
  max-width: 1000px;
  margin: 0 auto;
}
.modules-section h2 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 2.5rem;
  color: white;
}
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.module-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.module-icon { font-size: 2rem; margin-bottom: 1rem; }
.module-card h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 0.6rem; color: white; }
.module-card p { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 1rem; }
.badge { font-size: 0.78rem; padding: 0.2rem 0.6rem; border-radius: 20px; font-weight: 600; }
.badge.free { background: rgba(34, 197, 94, 0.15); color: var(--green); border: 1px solid var(--green); }

/* ===== PRICING ===== */
.pricing-section {
  padding: 4rem 2rem;
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
}
.pricing-section h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 2.5rem; color: white; }
.pricing-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.pricing-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  position: relative;
}
.pricing-card.featured { border-color: var(--accent); }
.popular-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.8rem;
  border-radius: 20px;
  white-space: nowrap;
}
.pricing-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; color: white; }
.price { font-size: 2rem; font-weight: 800; color: white; margin-bottom: 1.5rem; }
.price span { font-size: 0.85rem; color: var(--text-muted); font-weight: 400; }
.pricing-card ul { list-style: none; text-align: left; margin-bottom: 1.5rem; }
.pricing-card ul li { font-size: 0.88rem; color: var(--text-muted); padding: 0.3rem 0; }

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ===== MODULE PAGE ===== */
.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.module-header h2 { font-size: 1.1rem; font-weight: 700; }
#module-score { font-size: 0.95rem; color: var(--text-muted); }
#module-score span { color: var(--accent); font-weight: 700; }

#module-content {
  padding: 2rem;
  max-width: 900px;
  margin: 0 auto;
}

/* ===== GAME ELEMENTS ===== */
canvas {
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #050a14;
}

.game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.game-info {
  display: flex;
  gap: 2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  align-items: center;
}
.game-info span { color: white; font-weight: 600; }

.math-overlay {
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  text-align: center;
  min-width: 320px;
}
.math-question { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; }
.math-options {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.math-btn {
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 60px;
  transition: background 0.15s;
}
.math-btn:hover { background: var(--accent); border-color: var(--accent); }
.math-btn.correct { background: var(--green); border-color: var(--green); }
.math-btn.wrong { background: var(--red); border-color: var(--red); }

.target-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.target-btn {
  background: var(--bg2);
  border: 2px solid #3b82f6;
  color: #3b82f6;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  min-width: 54px;
  transition: all 0.15s;
}
.target-btn:hover { background: #3b82f6; color: white; }
.target-btn.zero { border-color: var(--green); color: var(--green); }
.target-btn.zero:hover { background: var(--green); color: white; }

/* Spatial Game */
.spatial-scene {
  background: #050a14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  height: 360px;
  position: relative;
  overflow: hidden;
}

.yn-buttons {
  display: flex;
  gap: 1rem;
}
.yn-btn {
  padding: 0.75rem 2.5rem;
  border-radius: 8px;
  border: none;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.yn-btn.yes { background: var(--green); color: white; }
.yn-btn.no { background: var(--red); color: white; }
.yn-btn:hover { opacity: 0.85; }
.yn-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.direction-label {
  background: var(--yellow);
  color: #000;
  padding: 0.4rem 1.2rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 1.2rem;
}

/* Memory Game */
.memory-display {
  background: #050a14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.memory-number {
  font-size: 5rem;
  font-weight: 800;
  color: white;
}
.memory-prompt {
  font-size: 2.5rem;
  color: var(--accent);
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  max-width: 340px;
}
.num-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  transition: background 0.15s;
}
.num-btn:hover { background: var(--accent); border-color: var(--accent); }
.num-btn.correct { background: var(--green); border-color: var(--green); }
.num-btn.wrong { background: var(--red); border-color: var(--red); }

/* Round result feedback */
.round-result {
  text-align: center;
  padding: 1rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
}
.round-result.correct-result { color: var(--green); }
.round-result.wrong-result { color: var(--red); }

/* Score screen */
.score-screen {
  text-align: center;
  padding: 3rem 1rem;
}
.score-screen h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.final-score { font-size: 4rem; font-weight: 800; color: var(--accent); margin: 1rem 0; }
.score-screen p { color: var(--text-muted); margin-bottom: 2rem; }
.score-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* Start screen */
.start-screen {
  text-align: center;
  padding: 3rem 1rem;
  max-width: 500px;
  margin: 0 auto;
}
.start-screen h2 { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.75rem; }
.start-screen p { color: var(--text-muted); margin-bottom: 0.5rem; font-size: 0.95rem; }
.start-screen .tips {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  text-align: left;
  margin: 1.5rem 0;
}
.start-screen .tips h4 { font-size: 0.88rem; color: var(--accent); margin-bottom: 0.5rem; font-weight: 600; }
.start-screen .tips ul { list-style: none; }
.start-screen .tips ul li { font-size: 0.85rem; color: var(--text-muted); padding: 0.2rem 0; }
.start-screen .tips ul li::before { content: "→ "; color: var(--accent); }

/* Difficulty selector */
.difficulty-selector {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
}
.diff-btn {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.diff-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* Timer bar */
.timer-bar-wrap {
  width: 100%;
  max-width: 640px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.timer-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.1s linear;
  border-radius: 3px;
}
.timer-bar.warn { background: var(--yellow); }
.timer-bar.danger { background: var(--red); }

/* On-screen numpad — hidden on desktop, shown on mobile via media query */
.mobile-numpad {
  display: none;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.mobile-numpad button {
  background: var(--card);
  border: 2px solid var(--border);
  color: white;
  font-size: 1.4rem;
  font-weight: 700;
  padding: 0.9rem 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.mobile-numpad button:active { background: var(--accent); border-color: var(--accent); }

/* ===== MOBILE ===== */
@media (max-width: 600px) {
  /* Layout */
  .pricing-cards { grid-template-columns: 1fr; }
  .modules-grid { grid-template-columns: 1fr; }
  header { padding: 0.75rem 1rem; }
  header nav .btn-cta { font-size: 0.78rem; padding: 0.4rem 0.8rem; }
  .hero { padding: 2rem 1rem 1.5rem; }
  .hero p { font-size: 0.95rem; }

  /* Module page */
  .module-header { padding: 0.75rem 1rem; }
  .module-header h2 { font-size: 0.95rem; }
  #module-content { padding: 1rem; }

  /* Start screen */
  .start-screen { padding: 1.5rem 0.5rem; }
  .start-screen h2 { font-size: 1.4rem; }

  /* Difficulty buttons — wrap on mobile */
  .difficulty-selector { flex-wrap: wrap; gap: 0.4rem; }
  .diff-btn { font-size: 0.78rem; padding: 0.4rem 0.7rem; }

  /* YES/NO buttons — bigger tap targets */
  .yn-btn { padding: 1rem 1.5rem; font-size: 1rem; min-width: 80px; }

  /* Direction label */
  .direction-label { font-size: 1.3rem !important; }

  /* Spatial — stack canvas below buttons on narrow screens */
  #sp-game-row { flex-direction: column-reverse !important; align-items: stretch !important; }
  #sp-game-row canvas { max-width: 100% !important; width: 100% !important; }
  #sp-ynbtns { flex-direction: row !important; justify-content: center; }

  /* Variables game buttons */
  .vg-answer-btn { font-size: 1.2rem !important; padding: 0.8rem 0 !important; }

  /* On-screen numpad */
  .mobile-numpad { display: grid !important; }

  /* Score screen */
  .final-score { font-size: 3rem; }
  .score-actions { flex-direction: column; align-items: center; }
  .score-actions button { width: 100%; }

  /* Game info row */
  .game-info { gap: 1rem; font-size: 0.82rem; }
}
