:root {
  --pink: #ff6b9d;
  --yellow: #ffd166;
  --sky: #4cc9f0;
  --green: #06d6a0;
  --purple: #7b2cbf;
  --orange: #fb8500;
  --navy: #1d3557;
  --cream: #fff8f0;
  --card: #ffffff;
  --shadow: 0 8px 24px rgba(29, 53, 87, 0.12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Tajawal", "Cairo", "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #e8f7ff 0%, #fff8f0 40%, #ffe8f3 100%);
  color: var(--navy);
  min-height: 100vh;
  line-height: 1.7;
  direction: rtl;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

.container { width: min(1180px, 92%); margin: 0 auto; }

/* Header */
.site-header {
  background: #fff;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--purple);
}
.logo-mark {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  display: grid; place-items: center;
  color: #fff; font-size: 1.4rem;
  box-shadow: 0 4px 12px rgba(255,107,157,.4);
}
nav ul {
  display: flex; gap: 8px; list-style: none; flex-wrap: wrap;
}
nav a {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  background: #f3f0ff;
  transition: .2s;
}
nav a:hover, nav a.active { background: var(--purple); color: #fff; }

/* Hero */
.hero {
  padding: 48px 0 28px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  margin-bottom: 12px;
  color: var(--navy);
}
.hero p { font-size: 1.15rem; max-width: 720px; margin: 0 auto 22px; color: #3d4f66; }
.badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.badge {
  background: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: var(--shadow);
  font-size: .95rem;
}

/* Game grid */
.section { padding: 28px 0 56px; }
.section h2 {
  font-size: 1.7rem;
  margin-bottom: 8px;
  text-align: center;
}
.section-lead { text-align: center; margin-bottom: 24px; color: #4a5d73; }

.filters {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 22px;
}
.filter-btn {
  border: 0; cursor: pointer;
  padding: 8px 16px; border-radius: 999px;
  font-family: inherit; font-weight: 700;
  background: #fff; color: var(--navy);
  box-shadow: var(--shadow);
}
.filter-btn.active { background: var(--pink); color: #fff; }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}
.game-card {
  background: var(--card);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
  display: flex; flex-direction: column;
}
.game-card:hover { transform: translateY(-6px); box-shadow: 0 16px 32px rgba(29,53,87,.16); }
.game-thumb {
  height: 140px;
  display: grid; place-items: center;
  font-size: 4rem;
  background: linear-gradient(135deg, #caf0f8, #ffc8dd);
}
.game-card.boy .game-thumb { background: linear-gradient(135deg, #4cc9f0, #4361ee); }
.game-card.girl .game-thumb { background: linear-gradient(135deg, #ffafcc, #ff6b9d); }
.game-card.edu .game-thumb { background: linear-gradient(135deg, #80ed99, #06d6a0); }
.game-body { padding: 14px 16px 18px; flex: 1; display: flex; flex-direction: column; }
.game-body h3 { font-size: 1.15rem; margin-bottom: 6px; }
.game-body p { font-size: .92rem; color: #51657c; flex: 1; margin-bottom: 12px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
  font-size: .75rem; font-weight: 700;
  background: #eef2ff; color: #3a0ca3;
  padding: 3px 8px; border-radius: 999px;
}
.play-btn {
  display: inline-block; text-align: center;
  background: var(--orange); color: #fff;
  font-weight: 800; padding: 10px 14px;
  border-radius: 12px;
}
.play-btn:hover { background: #e07600; }

/* Pages */
.prose { background: #fff; border-radius: 24px; padding: 28px; box-shadow: var(--shadow); }
.prose h1 { margin-bottom: 14px; }
.prose h2 { margin: 22px 0 10px; font-size: 1.3rem; }
.prose p, .prose li { margin-bottom: 10px; }
.prose ul { padding-right: 22px; }

/* Game page */
.game-wrap {
  background: #fff;
  border-radius: 24px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.game-top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.hud {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.hud span {
  background: #f3f0ff; padding: 6px 12px; border-radius: 999px; font-weight: 800;
}
.game-stage {
  border: 4px solid #e9ecef;
  border-radius: 16px;
  min-height: 360px;
  background: #f8fbff;
  position: relative;
  overflow: hidden;
}
canvas { display: block; width: 100%; height: auto; background: #87ceeb; touch-action: none; }

.feedback {
  margin-top: 12px;
  min-height: 48px;
  font-weight: 800;
  text-align: center;
  font-size: 1.15rem;
}
.feedback.good { color: #0a7c4a; }
.feedback.bad { color: #c1121f; }

.controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.btn {
  border: 0; cursor: pointer; font-family: inherit; font-weight: 800;
  padding: 10px 18px; border-radius: 12px; background: var(--sky); color: #083344;
}
.btn.primary { background: var(--green); }
.btn.warn { background: var(--yellow); }
.btn.pink { background: var(--pink); color: #fff; }

/* Quiz */
.quiz-q { font-size: 1.4rem; text-align: center; padding: 18px; font-weight: 800; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 16px; }
.opt {
  border: 0; background: #fff; border-radius: 14px; padding: 16px;
  font-family: inherit; font-weight: 800; font-size: 1.2rem;
  box-shadow: var(--shadow); cursor: pointer;
}
.opt:hover { background: #fff3cd; }
.memory-grid {
  display: grid; gap: 10px; padding: 16px;
  grid-template-columns: repeat(4, 1fr);
}
.mem-card {
  aspect-ratio: 1;
  border: 0; border-radius: 12px;
  background: var(--purple); color: #fff;
  font-size: 2rem; cursor: pointer;
  display: grid; place-items: center;
}
.mem-card.open, .mem-card.done { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.mem-card.done { background: #d8f3dc; }

/* Footer */
.site-footer {
  background: var(--navy); color: #e8f1f8;
  padding: 36px 0 18px; margin-top: 20px;
}
.footer-grid {
  display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px;
}
.site-footer h3 { margin-bottom: 10px; color: var(--yellow); }
.site-footer a { display: block; padding: 3px 0; opacity: .9; }
.site-footer a:hover { color: var(--yellow); }
.copy { text-align: center; margin-top: 22px; opacity: .7; font-size: .9rem; }

@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .memory-grid { grid-template-columns: repeat(3, 1fr); }
  nav ul { width: 100%; }
}
