*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --blue: #4a90d9;
  --dark-blue: #2c5f8a;
  --yellow: #f5d742;
  --red: #e74c3c;
  --green: #2ecc71;
  --orange: #f39c12;
  --purple: #9b59b6;
  --pink: #e91e63;
  --bg: #f0f4ff;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --shadow: 0 4px 15px rgba(0,0,0,0.1);
  --radius: 16px;
}

html {
  font-size: 18px;
}

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

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--blue);
  text-decoration: none;
}

/* ─── Navigation ─── */

.site-header {
  background: var(--blue);
  color: white;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.site-title {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.site-title a {
  color: white;
}

.nav-toggle {
  display: none;
  background: none;
  border: 2px solid white;
  color: white;
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
}

.nav-links a {
  display: block;
  padding: 0.5rem 1rem;
  color: white;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.2s;
  font-size: 1rem;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(255,255,255,0.2);
}

/* ─── Main content ─── */

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.page-title {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  color: var(--dark-blue);
}

/* ─── Hero section ─── */

.hero {
  text-align: center;
  padding: 2rem 0 3rem;
}

.hero-emoji {
  font-size: 5rem;
  display: block;
  margin-bottom: 0.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--dark-blue);
  margin-bottom: 0.5rem;
}

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

.cta-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 2rem;
  border-radius: 50px;
  font-weight: 700;
  font-size: 1.1rem;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 54px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.btn-primary {
  background: var(--yellow);
  color: var(--text);
}

.btn-secondary {
  background: var(--green);
  color: white;
}

.btn-comic {
  background: var(--orange);
  color: white;
}

.btn-game {
  background: var(--purple);
  color: white;
}

/* ─── Preview cards ─── */

.preview-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

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

.card-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.card h2 {
  font-size: 1.3rem;
  margin-bottom: 0.3rem;
  color: var(--dark-blue);
}

.card p {
  color: var(--text-light);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.card .btn {
  font-size: 0.95rem;
  padding: 0.5rem 1.5rem;
  min-height: 44px;
}

/* ─── Comic strip ─── */

.comic-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}

.comic-panel {
  background: var(--card-bg);
  border: 3px solid var(--dark-blue);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  position: relative;
}

.comic-panel::before {
  content: attr(data-panel);
  position: absolute;
  top: -12px;
  left: 12px;
  background: var(--yellow);
  color: var(--text);
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  font-size: 0.8rem;
}

.panel-label {
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.panel-scene {
  text-align: center;
  font-size: 2.5rem;
  margin: 0.5rem 0;
  line-height: 1.2;
}

.panel-description {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
  margin-bottom: 0.5rem;
}

.speech-bubble {
  background: #f8f8f8;
  border: 2px solid #ddd;
  border-radius: 16px;
  padding: 0.5rem 0.8rem;
  margin: 0.3rem 0;
  font-size: 0.85rem;
  position: relative;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 20px;
  border: 8px solid transparent;
  border-top-color: #f8f8f8;
}

.speech-bubble .speaker {
  font-weight: 700;
}

.speech-bubble.left {
  align-self: flex-start;
  max-width: 90%;
}

.speech-bubble.right {
  align-self: flex-end;
  max-width: 90%;
}

.bubble-yellow {
  background: #fff9c4;
  border-color: #f9d71c;
}

.bubble-yellow::after {
  border-top-color: #fff9c4;
}

.bubble-green {
  background: #c8e6c9;
  border-color: #66bb6a;
}

.bubble-green::after {
  border-top-color: #c8e6c9;
}

.bubble-red {
  background: #ffcdd2;
  border-color: #ef5350;
}

.bubble-red::after {
  border-top-color: #ffcdd2;
}

.bubble-blue {
  background: #bbdefb;
  border-color: #42a5f5;
}

.bubble-blue::after {
  border-top-color: #bbdefb;
}

/* ─── Comic panel scene art ─── */

.panel-scene-art {
  position: relative;
  height: 200px;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.char {
  position: absolute;
  width: 70px;
  height: auto;
}

.char-sm {
  width: 55px;
}

.char-lg {
  width: 80px;
}

/* ─── Scene backgrounds ─── */

.scene-school {
  background: linear-gradient(180deg, #fff8e1 0%, #ffecb3 40%, #d7ccc8 100%);
}

.scene-school .wall {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60%;
  background: linear-gradient(180deg, #fff8e1, #ffecb3);
  z-index: 0;
}

.scene-school .floor {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: #d7ccc8;
  z-index: 0;
}

.scene-school .chalkboard {
  position: absolute;
  top: 15px; left: 50%;
  transform: translateX(-50%);
  width: 90px; height: 55px;
  background: #2e7d32;
  border: 4px solid #5d4037;
  border-radius: 3px;
  z-index: 1;
}

.scene-school .chalkboard::after {
  content: '2 + 2 = ?';
  position: absolute;
  bottom: 8px; left: 8px;
  color: #e8f5e9;
  font-size: 0.75rem;
  font-family: 'Comic Sans MS', cursive;
  white-space: pre;
}

.scene-school .desk {
  position: absolute;
  bottom: 30%; left: 50%;
  transform: translateX(-50%);
  width: 65px; height: 6px;
  background: #8D6E63;
  border-radius: 2px;
  z-index: 2;
}

.scene-school .desk::before {
  content: '';
  position: absolute;
  bottom: -16px; left: 10px;
  width: 4px; height: 16px;
  background: #6D4C41;
  border-radius: 2px;
}

.scene-school .desk::after {
  content: '';
  position: absolute;
  bottom: -16px; right: 10px;
  width: 4px; height: 16px;
  background: #6D4C41;
  border-radius: 2px;
}

/* ─── Library scene ─── */

.scene-library {
  background: linear-gradient(180deg, #fff3e0 0%, #ffe0b2 50%, #bcaaa4 100%);
}

.scene-library .wall {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60%;
  background: linear-gradient(180deg, #fff3e0, #ffe0b2);
  z-index: 0;
}

.scene-library .floor {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40%;
  background: #bcaaa4;
  z-index: 0;
}

.scene-library .bookshelf {
  position: absolute;
  top: 10px;
  width: 18px; height: 80px;
  background: #5D4037;
  border-radius: 2px;
  z-index: 1;
}

.scene-library .bookshelf::before {
  content: '';
  position: absolute;
  top: 5px; left: 2px;
  width: 14px; height: 3px;
  background: #e74c3c;
  border-radius: 1px;
  box-shadow:
    0 7px 0 #3498db,
    0 11px 0 #f39c12,
    0 15px 0 #2ecc71,
    0 19px 0 #9b59b6,
    0 23px 0 #e91e63,
    0 27px 0 #ff9800,
    0 31px 0 #00bcd4,
    0 35px 0 #4caf50,
    0 39px 0 #ff5722,
    0 43px 0 #3f51b5;
}

.scene-library .bookshelf:nth-child(2) { left: 10px; }
.scene-library .bookshelf:nth-child(3) { left: 35px; }
.scene-library .bookshelf:nth-child(4) { right: 35px; }
.scene-library .bookshelf:nth-child(5) { right: 10px; }

.scene-library .table {
  position: absolute;
  bottom: 35%; left: 50%;
  transform: translateX(-50%);
  width: 70px; height: 6px;
  background: #8D6E63;
  border-radius: 2px;
  z-index: 2;
}

.scene-library .table::before {
  content: '';
  position: absolute;
  bottom: -18px; left: 10px;
  width: 4px; height: 18px;
  background: #6D4C41;
  border-radius: 2px;
}

.scene-library .table::after {
  content: '';
  position: absolute;
  bottom: -18px; right: 10px;
  width: 4px; height: 18px;
  background: #6D4C41;
  border-radius: 2px;
}

/* ─── Pool scene ─── */

.scene-pool {
  background: linear-gradient(180deg, #bbdefb 0%, #90caf9 30%, #e1f5fe 100%);
}

.scene-pool .sky {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 45%;
  background: linear-gradient(180deg, #bbdefb, #90caf9);
  z-index: 0;
}

.scene-pool .sun {
  position: absolute;
  top: 8px; right: 15px;
  width: 30px; height: 30px;
  background: #fdd835;
  border-radius: 50%;
  z-index: 1;
  box-shadow: 0 0 15px rgba(253,216,53,0.5);
}

.scene-pool .grass {
  position: absolute;
  bottom: 25%; left: 0; right: 0;
  height: 12px;
  background: #66bb6a;
  z-index: 1;
}

.scene-pool .pool-water {
  position: absolute;
  bottom: 5%; left: 50%;
  transform: translateX(-50%);
  width: 85%; height: 30px;
  background: linear-gradient(180deg, #42a5f5, #1e88e5);
  border-radius: 15px;
  z-index: 2;
  border: 2px solid #1565c0;
}

.scene-pool .pool-water::after {
  content: '~~~~';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,0.4);
  font-size: 1.2rem;
  letter-spacing: 8px;
}

.scene-pool .ground {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30%;
  background: #81c784;
  z-index: 0;
}

/* ─── Grandma's kitchen scene ─── */

.scene-grandma {
  background: linear-gradient(180deg, #fff3e0 0%, #ffe0b2 40%, #ffcc80 100%);
}

.scene-grandma .wall {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, #fff3e0, #ffe0b2);
  z-index: 0;
}

.scene-grandma .floor {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(135deg, #a1887f 25%, #8d6e63 25%, #8d6e63 50%, #a1887f 50%, #a1887f 75%, #8d6e63 75%);
  background-size: 20px 20px;
  z-index: 0;
}

.scene-grandma .table {
  position: absolute;
  bottom: 30%; left: 50%;
  transform: translateX(-50%);
  width: 75px; height: 7px;
  background: #6D4C41;
  border-radius: 2px;
  z-index: 2;
}

.scene-grandma .table::before {
  content: '';
  position: absolute;
  bottom: -20px; left: 12px;
  width: 5px; height: 20px;
  background: #5D4037;
  border-radius: 2px;
}

.scene-grandma .table::after {
  content: '';
  position: absolute;
  bottom: -20px; right: 12px;
  width: 5px; height: 20px;
  background: #5D4037;
  border-radius: 2px;
}

.scene-grandma .cookies {
  position: absolute;
  bottom: calc(30% + 10px); left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 10px;
  background: #d4a574;
  border-radius: 4px;
  z-index: 3;
}

.scene-grandma .cookies::before {
  content: '';
  position: absolute;
  top: -3px; left: 3px;
  width: 8px; height: 8px;
  background: #bf8040;
  border-radius: 50%;
  box-shadow:
    10px 0 0 #bf8040,
    5px 4px 0 #bf8040;
}

.scene-grandma .window {
  position: absolute;
  top: 12px; right: 12px;
  width: 40px; height: 40px;
  background: #bbdefb;
  border: 3px solid #5D4037;
  border-radius: 3px;
  z-index: 1;
}

.scene-grandma .window::before {
  content: '';
  position: absolute;
  left: 50%; top: 0;
  width: 2px; height: 100%;
  background: #5D4037;
  transform: translateX(-50%);
}

.scene-grandma .window::after {
  content: '';
  position: absolute;
  top: 50%; left: 0;
  height: 2px; width: 100%;
  background: #5D4037;
  transform: translateY(-50%);
}

/* ─── Scene panel backgrounds with scene-art ─── */

.panel-day {
  background: linear-gradient(135deg, #fff9c4 0%, #fff3e0 100%);
}

.panel-night {
  background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
  color: white;
}

.panel-night .panel-description,
.panel-night .panel-label {
  color: rgba(255,255,255,0.7);
}

.panel-night .speech-bubble {
  background: #3949ab;
  border-color: #5c6bc0;
  color: white;
}

.panel-night .speech-bubble::after {
  border-top-color: #3949ab;
}

.panel-night .bubble-yellow {
  background: #f9a825;
  border-color: #fbc02d;
  color: var(--text);
}

.panel-night .bubble-yellow::after {
  border-top-color: #f9a825;
}

.panel-alley {
  background: linear-gradient(135deg, #37474f 0%, #455a64 100%);
  color: white;
}

.panel-alley .panel-description,
.panel-alley .panel-label {
  color: rgba(255,255,255,0.7);
}

.panel-alley .speech-bubble {
  background: #546e7a;
  border-color: #78909c;
  color: white;
}

.panel-alley .speech-bubble::after {
  border-top-color: #546e7a;
}

.panel-alley .bubble-red {
  background: #c62828;
  border-color: #ef5350;
  color: white;
}

.panel-alley .bubble-red::after {
  border-top-color: #c62828;
}

.panel-victory {
  background: linear-gradient(135deg, #e8f5e9 0%, #fff9c4 100%);
}

/* ─── Games page ─── */

.game-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-top: 1rem;
}

.game-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.game-header h2 {
  font-size: 1.5rem;
  color: var(--dark-blue);
}

.game-header p {
  color: var(--text-light);
  font-size: 0.95rem;
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
  font-size: 1rem;
  font-weight: 600;
}

/* ─── Memory game ─── */

.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  max-width: 420px;
  margin: 0 auto;
}

.memory-card {
  aspect-ratio: 1;
  background: var(--blue);
  border: 3px solid var(--dark-blue);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  transition: transform 0.3s, background 0.3s;
  min-height: 70px;
  user-select: none;
}

.memory-card:hover {
  transform: scale(1.05);
}

.memory-card.flipped {
  background: var(--yellow);
  border-color: #e6c200;
}

.memory-card.matched {
  background: var(--green);
  border-color: #27ae60;
  cursor: default;
  transform: scale(0.95);
  opacity: 0.7;
}

.game-btn {
  display: block;
  margin: 1.5rem auto 0;
  padding: 0.7rem 2rem;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
  transition: background 0.2s;
}

.game-btn:hover {
  background: var(--dark-blue);
}

.game-message {
  text-align: center;
  margin-top: 1rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green);
  min-height: 2rem;
}

/* ─── Responsive ─── */

@media (max-width: 640px) {
  html {
    font-size: 16px;
  }

  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--blue);
    padding: 0.5rem 1rem 1rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  }

  .nav-links.open {
    display: flex;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .hero-emoji {
    font-size: 4rem;
  }

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

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

  .comic-panel {
    min-height: 220px;
  }

  .panel-scene-art {
    height: 150px;
  }

  .char {
    width: 50px;
  }

  .char-sm {
    width: 40px;
  }

  .char-lg {
    width: 60px;
  }

  .scene-school .chalkboard {
    width: 65px; height: 40px;
  }

  .scene-school .desk {
    width: 50px;
  }

  .scene-library .bookshelf {
    width: 14px; height: 60px;
  }

  .scene-library .table {
    width: 55px;
  }

  .scene-grandma .table {
    width: 55px;
  }

  .scene-grandma .cookies {
    width: 22px;
  }

  .scene-pool .pool-water {
    width: 80%;
  }

  .memory-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    max-width: 320px;
  }

  .memory-card {
    font-size: 2rem;
    min-height: 60px;
  }

  .cta-buttons {
    flex-direction: column;
    align-items: center;
  }

  .btn {
    width: 100%;
    justify-content: center;
    max-width: 300px;
  }
}

@media (max-width: 380px) {
  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 260px;
  }
}
