/* ألعابي — تصميم الموقع.
   الألوان هي ألوان ثيمات التطبيق نفسها: «حبر» في الوضع الغامق و«ورق» في الفاتح.
   مفيش أي ملف بيتحمّل من برّه (لا خطوط ولا تحليلات) — الموقع ماشي على نفس كلام
   سياسة الخصوصية. */

:root {
  --bg: #141418;
  --bg-glow-1: rgba(227, 179, 65, 0.10);
  --bg-glow-2: rgba(127, 209, 174, 0.08);
  --surface: #1d1d23;
  --surface-2: #24242c;
  --line: #2c2c34;
  --ink: #ededf2;
  --muted: #9a9aad;
  --gold: #e3b341;
  --mint: #7fd1ae;
  --red: #e5484d;
  --orange: #e0803c;
  --ivory: #ededf2;
  --on-accent: #17171c;
  --header-bg: rgba(20, 20, 24, 0.72);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  --radius: 22px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f1e8;
    --bg-glow-1: rgba(194, 65, 12, 0.08);
    --bg-glow-2: rgba(29, 122, 95, 0.07);
    --surface: #fffdf8;
    --surface-2: #f1eadc;
    --line: #e2d9c7;
    --ink: #2e2a21;
    --muted: #6f6758;
    --gold: #b68900;
    --mint: #1d7a5f;
    --red: #b91c1c;
    --orange: #c2410c;
    --ivory: #2e2a21;
    --on-accent: #fffdf8;
    --header-bg: rgba(246, 241, 232, 0.8);
    --shadow: 0 16px 36px rgba(107, 91, 69, 0.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 85% -10%, var(--bg-glow-1), transparent 70%),
    radial-gradient(700px 480px at 0% 30%, var(--bg-glow-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 17px/1.75 ui-rounded, "SF Arabic Rounded", "SF Arabic", "Geeza Pro",
        "Segoe UI", Tahoma, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 10px;
}

.container {
  width: min(1120px, 100%);
  margin-inline: auto;
  padding-inline: 16px;
}

/* ---------- الهيدر ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.2rem;
}

.brand img {
  width: 36px;
  height: 36px;
  border-radius: 22.4%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}

.nav a:hover { background: var(--surface-2); color: var(--ink); }

@media (max-width: 560px) {
  .nav a.optional { display: none; }
}

/* ---------- البطل ---------- */

.hero {
  position: relative;
  padding-block: 56px 72px;
  isolation: isolate;
}

.hero .container {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 48px;
}

@media (max-width: 860px) {
  .hero { padding-block: 32px 48px; }
  .hero .container { grid-template-columns: 1fr; gap: 32px; text-align: center; }
  .hero .actions, .hero .stats { justify-content: center; }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint) 25%, transparent);
}

.hero h1 {
  font-size: clamp(3rem, 9vw, 5.2rem);
  line-height: 1.1;
  margin: 18px 0 10px;
  font-weight: 900;
  letter-spacing: 0;
}

.hero h1 .accent {
  background: linear-gradient(135deg, var(--gold), var(--orange) 55%, var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lead {
  font-size: clamp(1.1rem, 2.6vw, 1.35rem);
  color: var(--muted);
  margin: 0 0 24px;
  max-width: 34ch;
}

@media (max-width: 860px) {
  .lead { margin-inline: auto; }
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

/* شرائح زي `GameStatChipView` جوه التطبيق */
.stat {
  min-width: 96px;
  padding: 10px 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
}

.stat b {
  display: block;
  font-size: 1.6rem;
  line-height: 1.2;
  color: var(--gold);
}

.stat:nth-child(2) b { color: var(--mint); }
.stat:nth-child(3) b { color: var(--red); }

.stat span { font-size: 0.85rem; color: var(--muted); }

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary {
  background: var(--gold);
  color: var(--on-accent);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--gold) 35%, transparent);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.soon {
  color: var(--muted);
  font-size: 0.95rem;
}

/* اللوحة الحيّة — الأيقونة وهي بتلعب */
.board-wrap {
  position: relative;
  justify-self: center;
  width: min(380px, 82vw);
}

.board-wrap svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 28px 50px rgba(0, 0, 0, 0.45));
  animation: bob 6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-10px) rotate(1.5deg); }
}

.board-wrap svg .anim { transform-box: fill-box; transform-origin: center; }

.digit-fill { animation: digit 7s ease-in-out infinite; }
@keyframes digit {
  0%, 12% { opacity: 0; transform: scale(0.4); }
  20%, 70% { opacity: 1; transform: scale(1); }
  80%, 100% { opacity: 0; transform: scale(0.4); }
}

.empty-cell { animation: cell 7s ease-in-out infinite; }
@keyframes cell {
  0%, 12% { stroke-opacity: 1; }
  18%, 76% { stroke-opacity: 0.35; }
  84%, 100% { stroke-opacity: 1; }
}

.disc-flip { animation: disc 6s ease-in-out infinite; }
@keyframes disc {
  0%, 18% { transform: scaleX(1); fill: #fafafc; }
  24% { transform: scaleX(0); fill: #fafafc; }
  24.01% { fill: #17171c; }
  30%, 68% { transform: scaleX(1); fill: #17171c; }
  74% { transform: scaleX(0); fill: #17171c; }
  74.01% { fill: #fafafc; }
  80%, 100% { transform: scaleX(1); fill: #fafafc; }
}

.card-flip { animation: card 5s ease-in-out infinite; }
@keyframes card {
  0%, 30% { transform: scaleX(1); }
  38% { transform: scaleX(0); }
  46%, 80% { transform: scaleX(1); }
  88% { transform: scaleX(0); }
  96%, 100% { transform: scaleX(1); }
}

.card-face { animation: face 5s linear infinite; }
@keyframes face {
  0%, 37.9% { opacity: 1; }
  38%, 87.9% { opacity: 0; }
  88%, 100% { opacity: 1; }
}

.path-draw {
  stroke-dasharray: 100;
  animation: draw 5.5s ease-in-out infinite;
}
@keyframes draw {
  0% { stroke-dashoffset: 100; opacity: 1; }
  40%, 82% { stroke-dashoffset: 0; opacity: 1; }
  94% { stroke-dashoffset: 0; opacity: 0; }
  100% { stroke-dashoffset: 100; opacity: 0; }
}

.ring-pop { animation: pop 5.5s ease-in-out infinite; }
@keyframes pop {
  0%, 38% { transform: scale(1); }
  44% { transform: scale(1.3); }
  50%, 100% { transform: scale(1); }
}

/* قطع ألعاب طايرة في الخلفية */
.pieces {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.piece {
  position: absolute;
  inset-inline-start: var(--x);
  top: var(--y);
  width: var(--s, 34px);
  opacity: 0.22;
  color: var(--c, var(--gold));
  animation: drift var(--d, 11s) ease-in-out var(--delay, 0s) infinite alternate;
}

@keyframes drift {
  from { transform: translate(0, 0) rotate(var(--r, 0deg)); }
  to { transform: translate(12px, -22px) rotate(calc(var(--r, 0deg) + 18deg)); }
}

.piece.digit {
  width: auto;
  font-size: var(--s, 34px);
  font-weight: 900;
  line-height: 1;
}

@media (max-width: 860px) {
  .piece.wide-only { display: none; }
}

/* ---------- الأقسام ---------- */

section { padding-block: 56px; }

.section-head {
  text-align: center;
  margin-bottom: 32px;
}

.section-head h2 {
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  margin: 0 0 8px;
  font-weight: 900;
}

.section-head p {
  margin: 0 auto;
  color: var(--muted);
  max-width: 52ch;
}

/* شريط «كل لغز له حل وحيد» */
.promise {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 28px;
  align-items: center;
  box-shadow: var(--shadow);
}

@media (max-width: 700px) {
  .promise { grid-template-columns: 1fr; text-align: center; }
  .promise .mini-grid { margin-inline: auto; }
}

.promise h2 { margin: 0 0 6px; font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 900; }
.promise p { margin: 0 0 14px; color: var(--muted); }

.tags { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 700px) {
  .tags { justify-content: center; }
}

.tag {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  background: color-mix(in srgb, var(--mint) 16%, transparent);
  color: var(--mint);
}

.tag:nth-child(2) {
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  color: var(--gold);
}

.tag:nth-child(3) {
  background: color-mix(in srgb, var(--red) 14%, transparent);
  color: var(--red);
}

/* سودوكو صغيرة بتتحل لوحدها */
.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 6px;
  direction: ltr;
}

.mini-grid span {
  display: grid;
  place-items: center;
  height: 44px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 1.2rem;
}

.mini-grid .given { color: var(--ink); }

.mini-grid .solve {
  color: var(--gold);
  animation: solve 6s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}

@keyframes solve {
  0%, 20% { opacity: 0; transform: scale(0.5); }
  30%, 80% { opacity: 1; transform: scale(1); }
  90%, 100% { opacity: 0; transform: scale(0.5); }
}

/* شبكة الألعاب — نفس روح كروت التطبيق */
.group + .group { margin-top: 36px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 1.25rem;
  font-weight: 800;
}

.group-title small {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.game-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.game-card:hover {
  transform: translateY(-4px) rotate(-0.6deg);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--c) 45%, var(--line));
}

.game-card .glyph {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}

.game-card .glyph svg { width: 26px; height: 26px; }

.game-card h3 { margin: 0; font-size: 1.15rem; font-weight: 800; }

.game-card p {
  margin: 2px 0 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

@media (max-width: 480px) {
  .game-card { padding: 14px 12px 12px; }
  .game-card .glyph { width: 44px; height: 44px; margin-bottom: 10px; }
  .game-card .glyph svg { width: 22px; height: 22px; }
  .game-card h3 { font-size: 1.05rem; }
}

.kid-badge {
  position: absolute;
  top: 14px;
  inset-inline-end: 14px;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--orange) 16%, transparent);
  color: var(--orange);
}

.gold { --c: var(--gold); }
.mint { --c: var(--mint); }
.red { --c: var(--red); }
.orange { --c: var(--orange); }

/* ---------- جرّبها: ذاكرة الأزواج ---------- */

.play .section-head { margin-bottom: 0; }

.play {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 28px 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.pairs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 88px));
  justify-content: center;
  gap: 12px;
  margin: 22px auto 18px;
  perspective: 800px;
}

.pair-card {
  aspect-ratio: 3 / 4;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 16px;
}

.pair-card .inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.3, 0.9, 0.35, 1.2);
}

.pair-card.is-up .inner,
.pair-card.is-matched .inner { transform: rotateY(180deg); }

.pair-card .side {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.pair-card .back {
  background:
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--gold) 30%, transparent) 0 18%, transparent 19%),
    repeating-linear-gradient(45deg, var(--surface-2) 0 8px, color-mix(in srgb, var(--surface-2) 70%, var(--line)) 8px 16px);
  border: 1px solid var(--line);
}

.pair-card .front {
  transform: rotateY(180deg);
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--c) 50%, var(--line));
  color: var(--c);
}

.pair-card .front svg { width: 44%; height: 44%; }

.pair-card.is-matched .front {
  background: color-mix(in srgb, var(--c) 18%, var(--surface-2));
  animation: matched 0.5s ease;
}

@keyframes matched {
  50% { transform: rotateY(180deg) scale(1.08); }
}

.play-status {
  min-height: 1.75em;
  margin: 0 0 12px;
  font-weight: 700;
}

/* ---------- الصور ---------- */

.shots {
  display: flex;
  gap: 22px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 8px 16px 24px;
  margin-inline: -16px;
  scrollbar-width: thin;
}

.shot {
  flex: 0 0 auto;
  scroll-snap-align: center;
  margin: 0;
  text-align: center;
}

.device {
  width: 230px;
  padding: 9px;
  border-radius: 44px;
  background: linear-gradient(145deg, #3a3a44, #121216);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.device img {
  width: 100%;
  height: auto;
  border-radius: 36px;
}

.shot figcaption {
  margin-top: 12px;
  font-size: 0.92rem;
  color: var(--muted);
}

/* ---------- المميزات ---------- */

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
}

.feature .glyph {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
}

.feature .glyph svg { width: 24px; height: 24px; }
.feature h3 { margin: 0 0 4px; font-size: 1.1rem; font-weight: 800; }
.feature p { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* ---------- الفوتر ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 28px 40px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
}

.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }

/* خانة لسه محتاجة تتملي — معلّمة عشان متتنسيش */
.todo {
  background: color-mix(in srgb, var(--gold) 22%, transparent);
  border-radius: 6px;
  padding: 1px 6px;
}

/* ---------- صفحات الخصوصية والدعم ---------- */

.doc-page main { padding-block: 40px 56px; }

.doc {
  width: min(760px, 100%);
  margin-inline: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 24px;
}

.doc + .doc { margin-top: 24px; }

.doc h1 { font-size: 1.7rem; margin: 0 0 4px; font-weight: 900; }
.doc h2 { font-size: 1.1rem; margin: 26px 0 6px; color: var(--gold); }
.doc p, .doc li { margin: 6px 0; }
.doc ul { padding-inline-start: 22px; margin: 8px 0; }
.doc .date { color: var(--muted); margin: 0 0 18px; }
.doc .lead-line { font-weight: 700; }
.doc a { color: var(--gold); }

/* ---------- الحركة المخفّفة ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .digit-fill, .mini-grid .solve { opacity: 1; }
}
