/* ============================================================
   تطبيقات عبدالله الصارم — نظام التصميم الموحّد
   © 2026 عبدالله الصارم — جميع الحقوق محفوظة
   ============================================================ */

/* ---------- 1. المتغيرات ---------- */
:root {
  --brand-50:  #e9faf3;
  --brand-100: #c9f2e1;
  --brand-200: #97e6c8;
  --brand-400: #34d399;
  --brand-500: #10b981;
  --brand-600: #059669;
  --brand-700: #047857;
  --brand-900: #064e3b;

  --accent-400: #fbbf24;
  --accent-500: #f59e0b;
  --accent-600: #d97706;

  --ink-900: #0d1520;
  --ink-700: #2b3646;
  --ink-500: #55637a;
  --ink-400: #7b879b;

  --bg: #f6f8fa;
  --bg-alt: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #e3e8ef;
  --line-strong: #cfd7e2;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 16px -4px rgba(16, 24, 40, .10);
  --shadow-lg: 0 18px 44px -18px rgba(16, 24, 40, .28);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --maxw: 1200px;
  --font: "Cairo", "Tajawal", "Noto Kufi Arabic", "Segoe UI", Tahoma, sans-serif;
  --font-en: "Outfit", "Cairo", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --header-h: 62px;
  --ease: cubic-bezier(.22, .8, .3, 1);
}

html[data-theme="dark"] {
  --bg: #0c1118;
  --bg-alt: #111823;
  --surface: #151d28;
  --surface-2: #1b2432;
  --line: #26313f;
  --line-strong: #35414f;
  --ink-900: #eef2f7;
  --ink-700: #cbd5e1;
  --ink-500: #94a3b8;
  --ink-400: #7c8aa0;
  --brand-50: #0d2a20;
  --brand-100: #10392b;
  --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, .5);
  --shadow-lg: 0 18px 44px -18px rgba(0, 0, 0, .7);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
}

/* ---------- 2. الأساس ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink-900);
  line-height: 1.7;
  font-size: 16px;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-700); text-decoration: none; }
html[data-theme="dark"] a { color: var(--brand-400); }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.35; font-weight: 800; letter-spacing: -.01em; }
p { color: var(--ink-700); }
:focus-visible { outline: 2.5px solid var(--brand-500); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-200); color: var(--ink-900); }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }
@media (max-width: 640px) { .wrap { padding-inline: 16px; } }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-1 { gap: 6px } .gap-2 { gap: 10px } .gap-3 { gap: 16px } .gap-4 { gap: 24px }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num { font-family: var(--font-en); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); direction: ltr; unicode-bidi: embed; }
.ltr-num { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num, .mono { unicode-bidi: isolate; }

/* ---------- 3. الهيدر ---------- */
.site-header {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  display: flex; align-items: center;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.site-header .wrap { display: flex; align-items: center; gap: 14px; width: 100%; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink-900); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; font-weight: 800; }
.brand-text span { font-size: 11px; color: var(--ink-400); font-weight: 600; }

.nav { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.nav a {
  padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--ink-500); text-decoration: none; white-space: nowrap;
}
.nav a:hover { background: var(--bg-alt); color: var(--ink-900); text-decoration: none; }
.nav a.active { color: var(--brand-700); background: var(--brand-50); }
html[data-theme="dark"] .nav a.active { color: var(--brand-200); }

.icon-btn {
  width: 38px; height: 38px; flex: 0 0 38px; display: grid; place-items: center;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; color: var(--ink-700); transition: .18s var(--ease);
}
.icon-btn:hover { border-color: var(--brand-400); color: var(--brand-600); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }

.burger { display: none; }
@media (max-width: 900px) {
  .burger { display: grid; }
  .nav {
    position: fixed; inset: var(--header-h) 0 auto 0; margin: 0;
    background: var(--surface); border-bottom: 1px solid var(--line);
    flex-direction: column; align-items: stretch; padding: 10px 16px 16px;
    box-shadow: var(--shadow-lg); transform: translateY(-120%);
    transition: transform .28s var(--ease);
  }
  .nav.open { transform: translateY(0); }
  .nav a { padding: 12px 14px; border-radius: var(--r-sm); font-size: 15px; }
}

/* ---------- 4. الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: .18s var(--ease); background: var(--brand-600); color: #fff;
  box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--brand-600) 70%, transparent);
}
.btn:hover { background: var(--brand-700); transform: translateY(-1px); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; }
.btn-ghost { background: var(--surface); color: var(--ink-900); border-color: var(--line-strong); box-shadow: none; }
.btn-ghost:hover { background: var(--bg-alt); color: var(--ink-900); border-color: var(--brand-400); }
.btn-accent { background: var(--accent-500); color: #2a1a02; }
.btn-accent:hover { background: var(--accent-400); color: #2a1a02; }
.btn-sm { padding: 8px 14px; font-size: 13.5px; }
.btn-lg { padding: 14px 26px; font-size: 16.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- 5. البطل (Hero) ---------- */
.hero { position: relative; overflow: hidden; padding: 54px 0 64px; }
.hero::before {
  content: ""; position: absolute; inset: -40% 30% 40% -20%;
  background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--brand-500) 16%, transparent), transparent 62%);
  pointer-events: none;
}
.hero::after {
  content: ""; position: absolute; inset: 20% -20% -50% 50%;
  background: radial-gradient(circle at 70% 40%, color-mix(in srgb, var(--accent-500) 12%, transparent), transparent 60%);
  pointer-events: none;
}
.hero-grid { position: relative; display: grid; grid-template-columns: 1.15fr .85fr; gap: 46px; align-items: center; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; gap: 34px; } .hero { padding: 34px 0 46px; } }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px;
  border-radius: 999px; background: var(--brand-50); color: var(--brand-700);
  font-size: 13px; font-weight: 700; border: 1px solid color-mix(in srgb, var(--brand-500) 22%, transparent);
}
html[data-theme="dark"] .eyebrow { color: var(--brand-200); }
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); }

.hero h1 { font-size: clamp(30px, 5.2vw, 52px); margin: 18px 0 14px; }
.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand-600), var(--brand-400) 55%, var(--accent-500));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead { font-size: clamp(15.5px, 2.2vw, 18.5px); max-width: 56ch; color: var(--ink-500); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 26px; margin-top: 34px; }
.hero-stats .st b { display: block; font-size: 25px; font-weight: 800; font-family: var(--font-en); color: var(--ink-900); line-height: 1.2; }
.hero-stats .st span { font-size: 13px; color: var(--ink-400); font-weight: 600; }

.hero-art { position: relative; }
.hero-art .phone {
  width: min(300px, 84%); margin-inline: auto; aspect-ratio: 9/17.5;
  border-radius: 34px; padding: 11px;
  background: linear-gradient(160deg, var(--ink-900), #233043);
  box-shadow: var(--shadow-lg); position: relative; overflow: hidden;
}
.hero-art .screen {
  width: 100%; height: 100%; border-radius: 26px; background: var(--bg);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 11px; overflow: hidden;
}
.hero-art .screen .bar { height: 8px; border-radius: 6px; background: var(--line); }
.hero-art .screen .row-ic { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.hero-art .screen .row-ic i { aspect-ratio: 1; border-radius: 11px; display: block; }
.hero-art .float {
  position: absolute; display: flex; align-items: center; gap: 9px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 9px 13px; box-shadow: var(--shadow-md); font-size: 12.5px; font-weight: 700;
  animation: floaty 6s ease-in-out infinite;
}
.hero-art .float.f1 { top: 11%; inset-inline-start: -14px; }
.hero-art .float.f2 { bottom: 13%; inset-inline-end: -12px; animation-delay: -3s; }
@keyframes floaty { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-9px) } }
@media (max-width: 480px) { .hero-art .float { display: none; } }

/* ---------- 6. الأقسام ---------- */
.section { padding: 56px 0; }
.section.tight { padding: 36px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(21px, 3.2vw, 29px); }
.section-head p { font-size: 14.5px; color: var(--ink-400); margin-top: 4px; }
.section-head .more { font-size: 14px; font-weight: 700; color: var(--brand-700); display: inline-flex; gap: 6px; align-items: center; }
html[data-theme="dark"] .section-head .more { color: var(--brand-200); }

/* ---------- 7. بطاقات التطبيقات ---------- */
.app-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
@media (max-width: 420px) { .app-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }

.app-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 12px; position: relative;
  transition: .2s var(--ease); overflow: hidden;
}
.app-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); text-decoration: none; }
.app-card .top { display: flex; gap: 13px; align-items: flex-start; }
.app-card .ic { width: 54px; height: 54px; flex: 0 0 54px; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.app-card .ic svg { width: 100%; height: 100%; }
.app-card h3 { font-size: 15.5px; font-weight: 800; color: var(--ink-900); }
.app-card .cat { font-size: 11.5px; font-weight: 700; color: var(--ink-400); display: flex; align-items: center; gap: 6px; }
.app-card .cat i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand-500); display: inline-block; }
.app-card p { font-size: 13px; line-height: 1.65; color: var(--ink-500); flex: 1; }
.app-card .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--ink-400); font-weight: 600; padding-top: 10px; border-top: 1px solid var(--line); }
.app-card .meta .stars { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-600); }
.app-card .meta .stars svg { width: 13px; height: 13px; }
.badge-free {
  position: absolute; top: 12px; inset-inline-end: 12px; font-size: 10.5px; font-weight: 800;
  color: var(--brand-700); background: var(--brand-50); border-radius: 999px; padding: 3px 9px;
  border: 1px solid color-mix(in srgb, var(--brand-500) 25%, transparent);
}
html[data-theme="dark"] .badge-free { color: var(--brand-200); }

/* ---------- 8. البحث والتصنيفات ---------- */
.search-bar {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 16px; box-shadow: var(--shadow-sm);
}
.search-bar:focus-within { border-color: var(--brand-400); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-500) 12%, transparent); }
.search-bar svg { width: 19px; height: 19px; color: var(--ink-400); flex: 0 0 19px; }
.search-bar input { flex: 1; border: 0; outline: 0; background: none; padding: 13px 0; font-size: 15px; min-width: 0; }
.chips { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 18px; }
.chip {
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13.5px; font-weight: 700; cursor: pointer;
  color: var(--ink-500); transition: .16s var(--ease);
}
.chip:hover { border-color: var(--brand-400); color: var(--brand-700); }
.chip.on { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-400); }
.empty-state svg { width: 54px; height: 54px; margin: 0 auto 14px; opacity: .5; }

/* ---------- 9. البطاقات العامة ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 24px; box-shadow: var(--shadow-sm);
}
@media (max-width: 560px) { .panel { padding: 18px; border-radius: var(--r-md); } }
.feature-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.feature {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 26px 22px; display: flex; flex-direction: column; gap: 11px;
}
.feature .fic {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-700);
}
html[data-theme="dark"] .feature .fic { color: var(--brand-200); }
.feature .fic svg { width: 22px; height: 22px; }
.feature h3 { font-size: 16px; }
.feature p { font-size: 13.5px; color: var(--ink-500); line-height: 1.7; }

/* ---------- 10. الفوتر ---------- */
.site-footer {
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 46px 0 30px; margin-top: 30px;
}
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 34px; }
@media (max-width: 820px) { .footer-grid { grid-template-columns: 1fr 1fr; gap: 26px; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-grid h4 { font-size: 13.5px; margin-bottom: 14px; color: var(--ink-900); }
.footer-grid ul { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.footer-grid a { font-size: 13.5px; color: var(--ink-500); }
.footer-grid a:hover { color: var(--brand-700); }
.footer-bottom {
  margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-400);
}
.social { display: flex; gap: 9px; }
.social a { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--ink-500); }
.social a:hover { border-color: var(--brand-400); color: var(--brand-600); text-decoration: none; }
.social svg { width: 16px; height: 16px; }

/* ---------- 11. صفحة التطبيق ---------- */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.app-topbar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
  padding-top: calc(11px + env(safe-area-inset-top));
}
.app-topbar .ic { width: 34px; height: 34px; border-radius: 10px; overflow: hidden; flex: 0 0 34px; }
.app-topbar h1 { font-size: 15.5px; font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-topbar .sp { display: flex; gap: 8px; }
.app-main { flex: 1; width: 100%; max-width: 900px; margin-inline: auto; padding: 18px 16px 30px; }
.app-hero {
  display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px;
}
.app-hero .ic { width: 74px; height: 74px; flex: 0 0 74px; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-md); }
.app-hero h2 { font-size: 19px; }
.app-hero p { font-size: 13.5px; margin-top: 5px; line-height: 1.7; }
.app-hero .facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pill {
  font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--bg-alt); color: var(--ink-500); border: 1px solid var(--line);
}
.app-stage {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-sm);
}
@media (max-width: 560px) { .app-stage { padding: 15px; border-radius: var(--r-md); } }
.app-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------- 12. عناصر واجهة التطبيقات ---------- */
.tool { display: flex; flex-direction: column; gap: 14px; }
.tool-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
label.fld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink-700); }
input[type="text"], input[type="number"], input[type="email"], input[type="search"],
input[type="url"], input[type="password"], input[type="date"], input[type="time"],
select, textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface-2); outline: 0; transition: .16s var(--ease); font-size: 15px;
}
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: #0f1620; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-500); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand-500) 13%, transparent); }
textarea { resize: vertical; min-height: 110px; line-height: 1.8; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237b879b' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; padding-left: 34px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.switch input { display: none; }
.switch .tr { width: 44px; height: 25px; border-radius: 999px; background: var(--line-strong); position: relative; transition: .2s var(--ease); flex: 0 0 44px; }
.switch .tr::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: .2s var(--ease); box-shadow: var(--shadow-sm); }
.switch input:checked + .tr { background: var(--brand-500); }
.switch input:checked + .tr::after { inset-inline-start: 22px; }
.btn-tile {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-md);
  padding: 16px; cursor: pointer; font-weight: 700; transition: .16s var(--ease); text-align: center;
}
.btn-tile:hover { border-color: var(--brand-400); background: var(--brand-50); color: var(--brand-700); }
.btn-tile.on { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.readout {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 16px; text-align: center;
}
.readout .val { font-size: clamp(26px, 6vw, 38px); font-weight: 800; font-family: var(--font-en); color: var(--brand-700); line-height: 1.25; }
html[data-theme="dark"] .readout .val { color: var(--brand-200); }
.readout .lbl { font-size: 12.5px; color: var(--ink-400); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }
.note { font-size: 12.5px; color: var(--ink-400); line-height: 1.7; }
.list-reset { list-style: none; padding: 0; }
.muted { color: var(--ink-400); }
.center { text-align: center; }
.hide { display: none !important; }
.mt-2 { margin-top: 10px } .mt-3 { margin-top: 18px } .mt-4 { margin-top: 28px }
.mb-2 { margin-bottom: 10px } .mb-3 { margin-bottom: 18px }
.pill-row { display: flex; flex-wrap: wrap; gap: 7px; }

/* بطاقات اللعبة */
.game-shell { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.game-board { width: 100%; max-width: 460px; margin-inline: auto; }
.game-controls { display: flex; gap: 9px; flex-wrap: wrap; justify-content: center; }
.game-stats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.game-stats .st { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 14px; text-align: center; min-width: 78px; }
.game-stats .st b { display: block; font-family: var(--font-en); font-size: 18px; font-weight: 800; }
.game-stats .st span { font-size: 11px; color: var(--ink-400); font-weight: 600; }
canvas { border-radius: var(--r-md); touch-action: none; }

/* ---------- 13. الإعلان ---------- */
.ad-slot {
  margin: 18px 0; border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  display: grid; place-items: center; text-align: center; padding: 12px;
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 10px, var(--bg-alt) 10px, var(--bg-alt) 20px);
  color: var(--ink-400); font-size: 12px; font-weight: 700; min-height: 62px;
}
.ad-slot[data-ad-state="filled"] { border-style: solid; border-color: transparent; background: var(--surface-2); padding: 0; overflow: hidden; min-height: 0; }
.ad-slot span { opacity: .8; }
.ad-slot.ad-leaderboard { min-height: 92px; }
.ad-slot.ad-rect { min-height: 258px; }

/* إعلان بين الصفحات (overlay) */
.ad-interstitial {
  position: fixed; inset: 0; z-index: 120;
  display: none; place-items: center;
  background: rgba(13, 21, 32, .62);
  padding: 20px;
}
.ad-interstitial.show { display: grid; }
.ad-interstitial-card {
  position: relative; width: min(380px, 94vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 14px;
}
.ad-interstitial-card .ad-slot { margin: 6px 0 0; }
.ad-interstitial-close {
  position: absolute; top: -14px; inset-inline-end: -14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink-900); color: #fff; font-size: 15px; line-height: 1;
  box-shadow: var(--shadow-sm);
}
.ad-native-note { font-size: 11px; font-weight: 700; }

/* ---------- 14. المساعد الذكي ---------- */
.ai-fab {
  position: fixed; inset-inline-start: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 80;
  width: 54px; height: 54px; border-radius: 18px; border: 0; cursor: pointer;
  background: linear-gradient(145deg, var(--brand-500), var(--brand-700)); color: #fff;
  box-shadow: 0 12px 28px -10px color-mix(in srgb, var(--brand-600) 75%, transparent);
  display: grid; place-items: center; transition: .2s var(--ease);
}
.ai-fab:hover { transform: translateY(-2px) scale(1.03); }
.ai-fab svg { width: 25px; height: 25px; }
.ai-panel {
  position: fixed; inset-inline-start: 18px; bottom: calc(82px + env(safe-area-inset-bottom)); z-index: 81;
  width: min(370px, calc(100vw - 32px)); height: min(520px, 72dvh);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(16px) scale(.97); opacity: 0; pointer-events: none; transition: .22s var(--ease);
}
.ai-panel.open { transform: none; opacity: 1; pointer-events: auto; }
.ai-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ai-head .av { width: 36px; height: 36px; border-radius: 12px; background: linear-gradient(145deg, var(--brand-500), var(--brand-700)); display: grid; place-items: center; color: #fff; flex: 0 0 36px; }
.ai-head .av svg { width: 19px; height: 19px; }
.ai-head b { font-size: 14px; display: block; }
.ai-head span { font-size: 11.5px; color: var(--ink-400); }
.ai-head button { margin-inline-start: auto; }
.ai-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 11px; scroll-behavior: smooth; }
.msg { max-width: 86%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.75; white-space: pre-wrap; }
.msg.bot { align-self: flex-start; background: var(--bg-alt); border-end-start-radius: 5px; color: var(--ink-900); }
.msg.me { align-self: flex-end; background: var(--brand-600); color: #fff; border-end-end-radius: 5px; }
.msg.bot a { color: var(--brand-700); font-weight: 700; }
html[data-theme="dark"] .msg.bot a { color: var(--brand-200); }
.ai-quick { display: flex; gap: 7px; flex-wrap: wrap; padding: 0 14px 12px; }
.ai-quick button {
  font-size: 11.5px; font-weight: 700; padding: 6px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--ink-500);
}
.ai-quick button:hover { border-color: var(--brand-400); color: var(--brand-700); }
.ai-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.ai-input input { flex: 1; padding: 10px 13px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-2); outline: 0; font-size: 14px; }
.ai-input button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--brand-600); color: #fff; cursor: pointer; display: grid; place-items: center; }
.ai-input button svg { width: 18px; height: 18px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-400); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .18s } .typing i:nth-child(3) { animation-delay: .36s }
@keyframes blink { 0%,60%,100% { opacity: .25 } 30% { opacity: 1 } }

/* ---------- 15. التنبيه ---------- */
.toast-wrap { position: fixed; bottom: 22px; inset-inline-end: 22px; z-index: 95; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--ink-900); color: #fff; padding: 11px 17px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toastin .25s var(--ease);
  max-width: 320px;
}
html[data-theme="dark"] .toast { background: var(--surface); border: 1px solid var(--line); }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) } }

/* ---------- 16. صفحة قانونية / مقالي ---------- */
.doc { max-width: 780px; margin-inline: auto; }
.doc h1 { font-size: clamp(25px, 4.4vw, 36px); margin-bottom: 8px; }
.doc .meta { color: var(--ink-400); font-size: 13px; margin-bottom: 26px; }
.doc h2 { font-size: 19px; margin: 30px 0 10px; }
.doc h3 { font-size: 16px; margin: 20px 0 8px; }
.doc p, .doc li { font-size: 14.5px; line-height: 1.95; color: var(--ink-700); }
.doc ul, .doc ol { padding-inline-start: 22px; margin: 10px 0; }
.doc li { margin-bottom: 6px; }
.doc .box {
  background: var(--surface); border: 1px solid var(--line); border-inline-start: 3px solid var(--brand-500);
  border-radius: var(--r-md); padding: 16px 18px; margin: 18px 0;
}
.doc .box p { font-size: 14px; }
.doc .box .mono { overflow-wrap: anywhere; word-break: break-word; white-space: pre-wrap; }
.doc .box, .panel { overflow-x: hidden; }
.doc .box > .mono { display: block; max-width: 100%; overflow-x: auto; }
@media (max-width: 420px) { .doc .box .mono { font-size: 11.5px !important; } }
.doc table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.doc th, .doc td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.doc th { background: var(--surface-2); font-weight: 800; }
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 26px; }
.toc b { font-size: 14px; display: block; margin-bottom: 8px; }
.toc ol { margin: 0; padding-inline-start: 20px; }
.toc a { font-size: 13.5px; }

/* ---------- 17. بانر التثبيت ---------- */
.install-bar {
  position: fixed; inset-inline: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 70;
  max-width: 470px; margin-inline: auto; display: none; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 13px 15px; box-shadow: var(--shadow-lg);
}
.install-bar.show { display: flex; }
.install-bar .tx { flex: 1; font-size: 13px; line-height: 1.6; }
.install-bar .tx b { display: block; font-size: 14px; }
.install-bar .close { margin-inline-start: auto; }

/* ---------- 18. الاستجابة ---------- */
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .section { padding: 42px 0; }
  .app-hero { padding: 15px; }
  .app-hero .ic { width: 62px; height: 62px; flex-basis: 62px; }
  .ai-fab { width: 50px; height: 50px; }
}
@media (min-width: 1500px) { :root { --maxw: 1320px; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .ai-fab, .ai-panel, .ad-slot, .install-bar, .site-footer { display: none !important; }
  body { background: #fff; }
}
