/* ===== قائمة رئيسية بنمط تطبيق ألعاب — هوية رَصَّة (جوخ أخضر + ذهبي) ===== */
/* الألوان تُقرأ من app-chrome tokens في tokens.css فتتبدّل مع الثيم (أخضر/أسود). */

.menu-body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden; /* تطبيق مثبّت: القائمة تملأ الشاشة بلا تمرير عام */
  background:
    radial-gradient(120% 80% at 50% -10%, var(--app-bg-a) 0%, var(--app-bg-b) 45%, var(--app-bg-c) 100%);
  color: var(--app-ink);
  font-family: "Cairo", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app-menu {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  padding: calc(env(safe-area-inset-top, 0) + 8px) 12px calc(env(safe-area-inset-bottom, 0) + 66px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

/* ---------- الشريط العلوي (هيدر) ---------- */
/* نُبطل قاعدة style.css العامة header{} (خلفية خضراء/لصق علوي) عشان الهيدر يبقى
   شفاف فوق خلفية الثيم — كانت مخفية بالثيم الأخضر وتبان كشريط أخضر بثيم «كملنا». */
.menu-topbar {
  display: flex;
  flex-direction: row;   /* يتغلّب على media query في style.css اللي يخلي header عمودي بالجوال */
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: transparent;
  box-shadow: none;
  position: static;
  padding: 0;
  flex-wrap: nowrap;
}
/* زر الإعدادات — يسار الهيدر (top-left بصرياً في RTL: آخر عنصر بالصف).
   Flexbox لتوسيط الترس أفقياً وعمودياً داخل الزر بالضبط. */
.mt-settings {
  flex: 0 0 auto;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; line-height: 1; cursor: pointer;
  color: var(--app-accent);
  background: linear-gradient(var(--app-panel-a), var(--app-panel-b));
  border: 1.5px solid var(--app-border);
  box-shadow: 0 3px 8px rgba(0,0,0,.5), inset 0 1px 2px rgba(255,255,255,.12);
  transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.mt-settings:active { transform: scale(.9); }
.mt-settings:hover { box-shadow: 0 0 0 2px rgba(255,215,102,.4), 0 3px 8px rgba(0,0,0,.5); }

/* عمود يسار الهيدر: الإعدادات فوق، وزر الإحصائيات تحته مباشرة */
.mt-actions { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 0 0 auto; }
/* زر الإحصائيات (صكّاتك + فوزك) — نُقل من داخل الملف الشخصي إلى زر مستقل تحت الإعدادات */
.mt-stats {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 5px 12px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(var(--app-panel-a), var(--app-panel-b));
  border: 1.5px solid var(--app-border);
  color: var(--app-ink); font-family: inherit; line-height: 1.25;
  box-shadow: 0 3px 8px rgba(0,0,0,.5), inset 0 1px 2px rgba(255,255,255,.12);
  transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.mt-stats:active { transform: scale(.94); }
.mt-stats:hover { box-shadow: 0 0 0 2px rgba(255,215,102,.4), 0 3px 8px rgba(0,0,0,.5); }
.mt-stats .mt-stat { font-size: .7rem; font-weight: 700; white-space: nowrap; }
.mt-stats .mt-stat b { color: var(--app-accent); font-size: .82rem; }

/* الملف الشخصي موسّع: صورة + اسم + إحصائيات كلها بصف واحد بلا التفاف */
.mt-profile {
  flex: 1 1 auto;
  display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: nowrap;
  background: linear-gradient(var(--app-panel-a), var(--app-panel-b));
  border: 1px solid var(--app-border); border-radius: 16px;
  padding: 8px 12px; cursor: pointer;
  font-family: inherit; text-align: inherit;
  -webkit-tap-highlight-color: transparent;
}
.mt-profile:active { opacity: .75; }
.mt-avatar {
  width: 52px; height: 52px; flex: 0 0 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.6rem;
  background: radial-gradient(circle at 35% 30%, #f3c14e, #c8891f);
  border: 2px solid #ffe08a;
  box-shadow: 0 3px 10px rgba(0,0,0,.5), inset 0 2px 4px rgba(255,255,255,.35);
}
.mt-id { display: flex; flex-direction: column; min-width: 0; align-items: flex-start; }
.mt-name {
  font-weight: 900; font-size: 1.02rem; color: var(--app-accent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 44vw;
}
.mt-sub { font-size: .72rem; color: var(--app-muted); }
.mt-edit {
  margin-top: 2px; color: var(--app-muted);
  font-family: inherit; font-size: .7rem;
}

/* الإحصائيات داخل الملف الشخصي: صف واحد على الطرف (يسار بصرياً)، بلا التفاف */
.mt-wallet {
  display: flex; flex-direction: row; gap: 6px; align-items: center;
  margin-inline-start: auto; flex: 0 0 auto;
}
.mt-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .78rem; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  background: linear-gradient(var(--app-panel-a), var(--app-panel-b));
  border: 1px solid var(--app-border);
  color: var(--app-ink); white-space: nowrap;
}
.mt-chip b { color: var(--app-accent); }

/* ---------- المسرح ---------- */
.menu-stage {
  position: relative;
  flex: 0 1 auto;
  border-radius: 20px;
  padding: 16px 14px 18px;
  min-height: 150px;
  display: grid; place-items: center;
  background:
    radial-gradient(80% 120% at 50% 120%, var(--app-stage-glow) 0%, var(--app-panel-b) 45%, transparent 72%),
    linear-gradient(160deg, var(--app-panel-a), var(--app-panel-b));
  border: 1px solid var(--app-border);
  box-shadow: inset 0 0 60px rgba(0,0,0,.55);
  overflow: hidden;
}
.stage-logo { text-align: center; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.brand-logo {
  width: min(58vw, 210px);
  max-height: 26vh;
  object-fit: contain;
  border-radius: 22px;           /* الزوايا الناعمة للّوقو */
  box-shadow: 0 10px 26px rgba(0,0,0,.55);
  transform: scale(0.9);         /* تصغير طفيف للّوقو الرئيسي */
}
.live-players { margin: 10px 0 0; font-size: .8rem; color: #9fe6bf; }
.live-players b { color: #d6ffe6; }

/* أيقونات جانبية عائمة — مواضع فيزيائية (يمين/يسار) عمداً */
.side-icons {
  position: absolute; top: 14px; z-index: 5;
  display: flex; flex-direction: column; gap: 10px;
}
.side-left { left: 10px; }
.side-right { right: 10px; }
.side-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.15rem; text-decoration: none; cursor: pointer;
  color: var(--app-accent);
  background: linear-gradient(var(--app-panel-a), var(--app-panel-b));
  border: 1.5px solid var(--app-border);
  box-shadow: 0 3px 8px rgba(0,0,0,.5), inset 0 1px 2px rgba(255,255,255,.12);
  transition: transform .12s ease, box-shadow .12s ease;
}
.side-btn:active { transform: scale(.9); }
.side-btn:hover { box-shadow: 0 0 0 2px rgba(255,215,102,.4), 0 3px 8px rgba(0,0,0,.5); }

/* ---------- ودجت آخر ٥ أقيام ---------- */
.history-widget {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--app-panel-3);
  border: 1px solid var(--app-border);
  border-radius: 14px;
  overflow: hidden;
  backdrop-filter: blur(3px);
}
.hw-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  background: linear-gradient(var(--app-panel-a), var(--app-panel-b));
  border-bottom: 1px solid var(--app-border);
}
.hw-title { font-weight: 900; font-size: .95rem; color: var(--app-accent); }
.hw-more { font-size: .78rem; color: var(--app-muted); text-decoration: none; border: 1px solid var(--app-border); padding: 2px 10px; border-radius: 999px; }
.hw-body { padding: 6px 8px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.hw-empty { text-align: center; color: var(--app-muted); font-size: .85rem; padding: 16px 8px; }
.hw-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center; gap: 8px;
  padding: 8px 8px;
  border-radius: 8px;
}
.hw-row:nth-child(odd) { background: rgba(255,255,255,.03); }
.hw-res { font-size: .78rem; font-weight: 800; padding: 2px 9px; border-radius: 6px; white-space: nowrap; }
.hw-res.win { color: #063; background: #7ee6ab; }
.hw-res.lose { color: #4a0f0f; background: #f0a0a0; }
.hw-score { font-size: .92rem; color: var(--app-ink); letter-spacing: 1px; }
.hw-score b { color: var(--app-ink); }
.hw-grade { font-size: .75rem; color: var(--app-accent); font-weight: 700; }
.hw-date { font-size: .7rem; color: var(--app-muted); white-space: nowrap; }

/* ---------- زر اللعب الرئيسي (العب) ---------- */
.main-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 2px; }
.action-btn {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 20px; border-radius: var(--btn-radius);
  text-decoration: none; color: #06301d;
  font-family: inherit; cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,.35), 0 8px 18px rgba(0,0,0,.4);
  transition: transform .1s ease, box-shadow .1s ease;
  position: relative;
}
.action-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.4); }
.action-btn.play { background: linear-gradient(135deg, var(--app-green-2), var(--app-green)); }
.action-btn .ab-ic {
  font-size: 1.7rem; width: 46px; height: 46px; flex: 0 0 46px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.28); border-radius: 12px;
}
.action-btn .ab-text { display: flex; flex-direction: column; line-height: 1.3; }
.action-btn .ab-text b { font-size: 1.28rem; font-weight: 900; }
.action-btn .ab-text small { font-size: .76rem; opacity: .82; }

/* ---------- شريط سفلي ---------- */
.menu-bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  max-width: 480px; margin: 0 auto;
  display: flex; justify-content: space-around; align-items: center;
  padding: 6px 4px calc(env(safe-area-inset-bottom, 0) + 6px);
  background: linear-gradient(var(--app-panel-a), var(--app-bg-c));
  border-top: 1px solid var(--app-border);
}
.menu-bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 1.25rem; text-decoration: none; color: var(--app-muted);
  padding: 4px 10px; border-radius: 10px; flex: 1; text-align: center;
}
.menu-bottomnav a span { font-size: .68rem; }
.menu-bottomnav a.active { color: var(--app-accent); }

/* الحفاظ على لافتة التثبيت فوق الشريط السفلي */
#install-banner { z-index: 30; }

/* ---------- أول دخول / الملف الشخصي ---------- */
.fr-overlay {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(120% 80% at 50% -10%, var(--app-bg-a) 0%, var(--app-bg-b) 45%, var(--app-bg-c) 100%);
}
.fr-overlay[hidden] { display: none; }
.fr-card {
  width: 100%; max-width: 340px; text-align: center;
  background: linear-gradient(var(--app-panel-a), var(--app-panel-b));
  border: 1px solid var(--app-border); border-radius: 18px;
  padding: 26px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.6);
}
img.fr-logo { width: 96px; height: 96px; object-fit: contain; border-radius: 20px; box-shadow: 0 8px 20px rgba(0,0,0,.5); }
.pf-avatar {
  width: 74px; height: 74px; margin: 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 2.2rem;
  background: radial-gradient(circle at 35% 30%, #f3c14e, #c8891f);
  border: 2px solid #ffe08a;
}
.fr-card h2 { margin: 10px 0 4px; color: var(--app-accent); font-size: 1.4rem; font-weight: 900; }
.fr-card p { margin: 0 0 16px; color: var(--app-muted); font-size: .9rem; }
.fr-card input {
  width: 100%; box-sizing: border-box; text-align: center;
  padding: 12px; font-size: 1.1rem; font-family: inherit;
  border-radius: 12px; border: 1px solid var(--app-border); background: rgba(0,0,0,.28); color: var(--app-ink);
}
.fr-card input:focus { outline: none; border-color: var(--app-accent); }
.fr-card button {
  width: 100%; margin-top: 12px; padding: 13px;
  font-family: inherit; font-weight: 900; font-size: 1.05rem; cursor: pointer;
  border: none; border-radius: var(--btn-radius);
  background: linear-gradient(135deg, var(--app-accent), var(--app-accent-2)); color: var(--app-accent-ink);
}
.fr-card button:active { transform: translateY(1px); }
.fr-card button.pf-danger {
  background: none; border: 1px solid var(--app-danger); color: var(--app-danger);
}
.fr-card button.pf-close {
  background: none; border: 1px solid var(--app-border); color: var(--app-muted);
  font-weight: 700;
}

@media (max-width: 360px) {
  .action-btn .ab-text b { font-size: 1.3rem; }
}
/* شاشات قصيرة: قلّل ارتفاع المسرح عشان تبقى القائمة بلا تمرير */
@media (max-height: 700px) {
  .menu-stage { min-height: 110px; padding: 10px; }
  .brand-logo { max-height: 20vh; width: min(48vw, 170px); }
  .action-btn { padding: 11px 16px; }
  .action-btn .ab-ic { width: 42px; height: 42px; flex-basis: 42px; font-size: 1.55rem; }
}
