/* =====================================================================
   منصة الشاطر — طبقة 3D للألعاب (v1.0)
   ملف واحد بيغطي الألعاب الخمسة: المليونير · لوحة الفئات · المطاردة ·
   عائلي تربح · عجلة الحظ.
   قواعد صارمة:
   - CSS 3D transforms بس (perspective / rotateX / translateZ / preserve-3d).
   - الحركة كلها على transform و opacity. مفيش box-shadow متحرك ولا filter متحرك.
   - الظلال والحروف السفلية (edges) ثابتة، والعنصر هو اللي بيتحرك فوقها.
   - كل حاجة متقيّدة بـ body.g3d (بيتضاف بالـJS لو المتصفح بيدعم 3D)، فلو الملف
     اتحمّل من غير JS الصفحة تفضل زي ما هي بالظبط.
   - كل لعبة بتتفعّل لوحدها: body.g3d-mq / g3d-jd / g3d-ch / g3d-fd / g3d-wh.
   ===================================================================== */

body.g3d{
  --g3d-ink:#05081d;            /* حرف العنصر الغامق */
  --g3d-ink-2:#0d1338;
  --g3d-gold:#ffc93c;
  --g3d-gold-deep:#9a7208;
  --g3d-gold-lite:#ffd865;
  --g3d-hi:rgba(255,255,255,.20);
  --g3d-persp:1000px;
  /* عمق ثابت: حرف سفلي + ظل أرضي. الاتنين مش بيتحركوا. */
  --g3d-lift:0 5px 0 var(--g3d-ink-2), 0 16px 26px -14px rgba(0,0,0,.85), inset 0 1px 0 var(--g3d-hi);
  --g3d-lift-sm:0 5px 0 var(--g3d-ink-2), 0 12px 20px -10px rgba(0,0,0,.85), inset 0 1px 0 rgba(255,255,255,.18);
  --g3d-sink:inset 0 2px 6px rgba(0,0,0,.55), inset 0 -1px 0 rgba(255,255,255,.07);
  --g3d-ease:cubic-bezier(.2,.7,.3,1);
}

/* ============================ ١) الأزرار ============================ */
body.g3d .mq-btn,
body.g3d .mq-life,
body.g3d .ch-offer{
  transition:transform .16s var(--g3d-ease), background-color .16s linear, border-color .16s linear;
  transform:translateZ(0);
}
body.g3d .mq-btn-gold{
  box-shadow:0 4px 0 var(--g3d-gold-deep), 0 14px 22px -12px rgba(0,0,0,.75), inset 0 1px 0 rgba(255,255,255,.45);
}
body.g3d .mq-btn-gold:hover{transform:translateY(-2px)}
body.g3d .mq-btn-gold:active{transform:translateY(3px);box-shadow:0 1px 0 var(--g3d-gold-deep), 0 6px 12px -8px rgba(0,0,0,.7)}
body.g3d .mq-btn-outline,
body.g3d .mq-btn-ghost{
  box-shadow:0 3px 0 rgba(5,8,29,.55), inset 0 1px 0 rgba(255,255,255,.10);
}
body.g3d .mq-btn-outline:hover,
body.g3d .mq-btn-ghost:hover{transform:translateY(-1px)}
body.g3d .mq-btn-outline:active,
body.g3d .mq-btn-ghost:active{transform:translateY(2px)}

/* شريحة الجائزة/الرصيد تبقى لوحة بارزة */
body.g3d .mq-pot{
  background:linear-gradient(180deg,rgba(255,201,60,.26),rgba(255,201,60,.08));
  box-shadow:0 5px 0 rgba(120,88,10,.55), 0 14px 20px -12px rgba(0,0,0,.85), inset 0 1px 0 rgba(255,255,255,.30);
  transform:perspective(600px) rotateX(4deg);
}
body.g3d .mq-back{
  box-shadow:0 2px 0 rgba(5,8,29,.5);
  transition:transform .16s var(--g3d-ease);
}
body.g3d .mq-back:active{transform:translateY(2px)}
body.g3d .mq-tgl{
  box-shadow:0 3px 0 rgba(5,8,29,.5), inset 0 1px 0 rgba(255,255,255,.12);
  transition:transform .14s var(--g3d-ease), background-color .14s linear;
}
body.g3d .mq-tgl:active{transform:translateY(2px)}

/* ==================== ٢) المليونير — كارت السؤال ==================== */
body.g3d-mq .mq-qcard{
  position:relative;
  transform:perspective(var(--g3d-persp)) rotateX(2.8deg);
  transform-origin:50% 100%;
  border-color:rgba(255,255,255,.22);
  background:
    linear-gradient(180deg,rgba(255,255,255,.15),rgba(255,255,255,.05) 38%,rgba(8,11,34,.32)),
    linear-gradient(170deg,#141a48,#241a5e);
  box-shadow:
    0 9px 0 rgba(5,8,29,.95),
    0 30px 50px -24px rgba(0,0,0,.95),
    inset 0 1px 0 rgba(255,255,255,.26),
    inset 0 -18px 26px -22px rgba(0,0,0,.7);
  will-change:transform;
}
/* إضاءة من فوق: بتدي إحساس إن الكارت بارز مش مطبوع */
body.g3d-mq .mq-qcard::before{
  content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;
  background:radial-gradient(120% 70% at 50% -20%,rgba(255,255,255,.14),rgba(255,255,255,0) 70%);
}
/* خط لمعة رفيع على الحد العلوي */
body.g3d-mq .mq-qcard::after{
  content:"";position:absolute;inset-inline:14px;top:0;height:1px;border-radius:2px;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.5),transparent);
  pointer-events:none;
}
body.g3d-mq .mq-qtext{text-shadow:0 2px 0 rgba(0,0,0,.35)}

/* الاختيارات: بلاطات بارزة بتغطس لما تتكبس */
body.g3d-mq .mq-opts{perspective:820px}
body.g3d-mq .mq-opt{
  transform:translateZ(0);
  background:linear-gradient(180deg,rgba(255,255,255,.14),rgba(255,255,255,.06));
  box-shadow:var(--g3d-lift-sm);
  transition:transform .16s var(--g3d-ease), background-color .16s linear, border-color .16s linear;
  will-change:transform;
}
body.g3d-mq .mq-opt:hover:not([disabled]){transform:translateY(-2px)}
body.g3d-mq .mq-opt:active:not([disabled]){transform:translateY(2px)}
body.g3d-mq .mq-opt em{box-shadow:0 2px 0 rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.28)}
body.g3d-mq .mq-opt.is-pick{transform:translateY(1px)}
body.g3d-mq .mq-opt.is-right{transform:translateY(-2px)}
body.g3d-mq .mq-opt.is-gone{opacity:.35;box-shadow:none;transform:none}

/* السلم: على الموبايل شريط أفقي بنميله شوية فيبان كرفّ بعمق */
body.g3d-mq .mq-ladder{box-shadow:0 10px 22px -14px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.07)}
@media (max-width:899px){
  body.g3d-mq .mq-ladder{transform:perspective(560px) rotateX(19deg);transform-origin:50% 0}
  body.g3d-mq .mq-ladder li{transition:transform .18s var(--g3d-ease), background-color .18s linear;box-shadow:0 2px 0 rgba(5,8,29,.55)}
  body.g3d-mq .mq-ladder li.is-now{transform:translateZ(16px) scale(1.03)}
}
/* النبض القديم كان بيحرّك box-shadow — بقى لمعة شفافة بتتحرك بالـopacity */
body.g3d-mq .mq-ladder li.is-now{animation:none;position:relative;overflow:hidden}
body.g3d-mq .mq-ladder li.is-now::after{
  content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;
  background:linear-gradient(90deg,transparent,rgba(255,201,60,.35),transparent);
  animation:g3d-sheen 2.4s linear infinite;
}
@keyframes g3d-sheen{
  0%{opacity:0;transform:translateX(-60%)}
  35%{opacity:1}
  100%{opacity:0;transform:translateX(60%)}
}
body.g3d-mq .mq-life{box-shadow:0 5px 0 rgba(5,8,29,.8), 0 12px 18px -12px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.20)}
body.g3d-mq .mq-life:hover:not([disabled]){transform:translateY(-2px)}
body.g3d-mq .mq-life:active:not([disabled]){transform:translateY(2px)}
body.g3d-mq .mq-bubble{box-shadow:0 3px 0 rgba(5,8,29,.45), inset 0 1px 0 rgba(255,255,255,.10)}

/* ==================== ٣) لوحة الفئات — لوحة مايلة ==================== */
body.g3d-jd .jd-wrap{perspective:1100px}
body.g3d-jd .jd-board{
  transform:rotateX(7deg);
  transform-style:preserve-3d;
  transform-origin:50% 0;
  box-shadow:
    0 8px 0 rgba(5,8,29,.85),
    0 30px 46px -26px rgba(0,0,0,.95),
    inset 0 1px 0 rgba(255,255,255,.10);
  border-color:rgba(255,201,60,.18);
}
body.g3d-jd .jd-head .jd-cat{
  transform:translateZ(10px);
  box-shadow:0 3px 0 rgba(5,8,29,.7), inset 0 1px 0 rgba(255,255,255,.16);
}
body.g3d-jd .jd-cell{
  transform:translateZ(0);
  box-shadow:0 3px 0 rgba(5,8,29,.75), inset 0 1px 0 rgba(255,255,255,.10);
  transition:transform .14s var(--g3d-ease), background-color .14s linear, border-color .14s linear;
  will-change:transform;
}
body.g3d-jd .jd-cell:hover:not(.is-used){transform:translateY(-2px) translateZ(6px)}
body.g3d-jd .jd-cell:active:not(.is-used){transform:translateY(2px)}
body.g3d-jd .jd-cell.is-used{transform:translateY(1px);box-shadow:var(--g3d-sink)}
body.g3d-jd .jd-cell.is-dbl{
  box-shadow:0 3px 0 rgba(5,8,29,.75), 0 0 14px -2px rgba(255,201,60,.55), inset 0 0 0 1px rgba(255,201,60,.5);
}
body.g3d-jd .jd-val{box-shadow:inset 0 1px 0 rgba(255,255,255,.06), inset 0 -2px 0 rgba(0,0,0,.35)}
body.g3d-jd .jd-card{
  transform:perspective(900px) rotateX(-1.2deg);
  box-shadow:0 10px 0 rgba(5,8,29,.9), 0 40px 70px -30px rgba(0,0,0,.95), inset 0 1px 0 rgba(255,255,255,.16);
}
body.g3d-jd .jd-opt{
  box-shadow:var(--g3d-lift-sm);
  transition:transform .14s var(--g3d-ease), background-color .14s linear, border-color .14s linear;
}
body.g3d-jd .jd-opt:active:not([disabled]){transform:translateY(2px)}

/* ==================== ٤) المطاردة ==================== */
body.g3d-ch .ch-card{
  position:relative;
  transform:perspective(var(--g3d-persp)) rotateX(1.2deg);
  transform-origin:50% 100%;
  box-shadow:
    0 7px 0 rgba(5,8,29,.9),
    0 26px 44px -22px rgba(0,0,0,.95),
    inset 0 1px 0 rgba(255,255,255,.18);
  will-change:transform;
}
body.g3d-ch .ch-card::after{
  content:"";position:absolute;inset-inline:16px;top:0;height:1px;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.45),transparent);
  pointer-events:none;
}
body.g3d-ch .ch-opts{perspective:820px}
body.g3d-ch .ch-opt{
  box-shadow:var(--g3d-lift-sm);
  transition:transform .16s var(--g3d-ease), background-color .16s linear, border-color .16s linear;
  will-change:transform;
}
body.g3d-ch .ch-opt:hover:not([disabled]){transform:translateY(-2px)}
body.g3d-ch .ch-opt:active:not([disabled]){transform:translateY(2px)}
body.g3d-ch .ch-opt em{box-shadow:0 2px 0 rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.26)}
body.g3d-ch .ch-opt.is-right{transform:translateY(-2px)}
body.g3d-ch .ch-track{box-shadow:0 8px 20px -14px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.06)}
body.g3d-ch .ch-step{box-shadow:0 2px 0 rgba(5,8,29,.6), inset 0 1px 0 rgba(255,255,255,.05)}
body.g3d-ch .ch-step.is-home{
  box-shadow:0 2px 0 rgba(5,8,29,.6), 0 0 16px -4px rgba(255,201,60,.6), inset 0 1px 0 rgba(255,255,255,.18);
}
body.g3d-ch .ch-offer{box-shadow:var(--g3d-lift)}
body.g3d-ch .ch-offer:hover{transform:translateY(-3px)}
body.g3d-ch .ch-offer:active{transform:translateY(2px)}
body.g3d-ch .ch-chasebar{box-shadow:var(--g3d-sink)}
body.g3d-ch .ch-pill,
body.g3d-ch .ch-tag,
body.g3d-ch .ch-timer{box-shadow:0 2px 0 rgba(5,8,29,.45), inset 0 1px 0 rgba(255,255,255,.12)}

/* ==================== ٥) عائلي تربح ==================== */
body.g3d-fd .fd-q{
  transform:perspective(900px) rotateX(2deg);
  transform-origin:50% 100%;
  box-shadow:
    0 6px 0 rgba(5,8,29,.9),
    0 24px 40px -22px rgba(0,0,0,.95),
    inset 0 1px 0 rgba(255,255,255,.18);
  will-change:transform;
}
body.g3d-fd .fd-board-list{perspective:900px}
body.g3d-fd .fd-row{
  transform:translateZ(0);
  box-shadow:var(--g3d-lift-sm);
  transition:transform .2s var(--g3d-ease), background-color .2s linear, border-color .2s linear;
  will-change:transform;
}
body.g3d-fd .fd-row.is-open{transform:translateZ(8px)}
body.g3d-fd .fd-row.is-missed{transform:translateY(1px);box-shadow:var(--g3d-sink)}
body.g3d-fd .fd-row.is-pop{
  transform:translateZ(14px) scale(1.02);
  animation:g3d-flip .42s var(--g3d-ease) both;
}
@keyframes g3d-flip{
  0%{transform:perspective(700px) rotateX(-82deg) translateZ(6px)}
  60%{transform:perspective(700px) rotateX(6deg) translateZ(12px) scale(1.02)}
  100%{transform:perspective(700px) rotateX(0) translateZ(14px) scale(1.02)}
}
body.g3d-fd .fd-row-n{box-shadow:0 2px 0 rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.26)}
body.g3d-fd .fd-strikes b{
  box-shadow:0 3px 0 rgba(5,8,29,.7), inset 0 1px 0 rgba(255,255,255,.14);
  transition:transform .18s var(--g3d-ease), background-color .18s linear;
}
body.g3d-fd .fd-strikes b.is-x{transform:rotateX(-14deg) translateY(-2px)}
body.g3d-fd .fd-form input{box-shadow:var(--g3d-sink);transition:transform .16s var(--g3d-ease)}
body.g3d-fd .fd-form input:focus{transform:translateY(1px)}

/* ==================== ٦) عجلة الحظ ==================== */
/* الميل على الحاوية عشان الـJS بيلف .wh-wheel بنفسه */
body.g3d-wh .wh-wheelwrap{
  perspective:900px;
  perspective-origin:50% 42%;
  transform:rotateX(17deg);
  transform-style:preserve-3d;
}
body.g3d-wh .wh-wheel{
  transform-style:preserve-3d;
  box-shadow:
    0 0 0 4px rgba(255,201,60,.18),
    0 22px 38px -16px rgba(0,0,0,.95),
    inset 0 0 46px rgba(0,0,0,.55);
}
body.g3d-wh .wh-hub{
  transform:translateZ(18px);
  box-shadow:0 6px 0 rgba(5,8,29,.6), 0 0 22px -4px rgba(255,201,60,.55), inset 0 1px 0 rgba(255,255,255,.25);
}
body.g3d-wh .wh-pointer{
  transform:translateX(-50%) translateZ(26px);
  text-shadow:0 3px 0 rgba(0,0,0,.55), 0 8px 14px rgba(0,0,0,.55);
}
body.g3d-wh .wh-board{
  transform:perspective(900px) rotateX(3deg);
  transform-origin:50% 0;
  box-shadow:0 6px 0 rgba(5,8,29,.85), 0 22px 36px -22px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.10);
}
body.g3d-wh .wh-tile{
  transform:translateZ(0);
  box-shadow:0 3px 0 rgba(5,8,29,.75), inset 0 1px 0 rgba(255,255,255,.35);
  transition:transform .18s var(--g3d-ease), background-color .18s linear;
}
body.g3d-wh .wh-tile.is-open{
  transform:translateY(-3px);
  box-shadow:0 6px 0 rgba(5,8,29,.8), 0 10px 16px -10px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.6);
}
body.g3d-wh .wh-tile.is-space{box-shadow:none;transform:none}
body.g3d-wh .wh-l{
  box-shadow:0 3px 0 rgba(5,8,29,.7), inset 0 1px 0 rgba(255,255,255,.10);
  transition:transform .12s var(--g3d-ease), background-color .14s linear, color .14s linear;
}
body.g3d-wh .wh-l:active{transform:translateY(2px)}
body.g3d-wh .wh-l.is-buy{box-shadow:0 3px 0 #2a5d7a, 0 0 14px -4px rgba(120,200,255,.7), inset 0 1px 0 rgba(255,255,255,.3)}
body.g3d-wh .wh-spin{box-shadow:0 5px 0 var(--g3d-gold-deep), 0 16px 24px -12px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.45)}
body.g3d-wh .wh-money,
body.g3d-wh .wh-cat,
body.g3d-wh .wh-tag,
body.g3d-wh .wh-misses b{box-shadow:0 2px 0 rgba(5,8,29,.45), inset 0 1px 0 rgba(255,255,255,.12)}
body.g3d-wh .wh-misses b.is-x{transform:rotateX(-14deg) translateY(-2px)}

/* ==================== ٧) النوافذ (فوز/خسارة) ==================== */
body.g3d .mq-modal{
  position:relative;
  overflow:hidden;
  transform:perspective(1000px) rotateX(-1deg);
  box-shadow:
    0 9px 0 rgba(5,8,29,.9),
    0 40px 70px -30px rgba(0,0,0,.95),
    inset 0 1px 0 rgba(255,255,255,.18);
}
/* مكان سينما الـWebGL — بتتحقن بس وقت الفوز على الأجهزة القادرة */
body.g3d .g3d-cinema{
  position:absolute;inset:0;z-index:0;pointer-events:none;border-radius:inherit;
  opacity:0;transition:opacity .45s linear;
}
body.g3d .g3d-cinema.is-live{opacity:1}
body.g3d .mq-modal > *:not(.g3d-cinema){position:relative;z-index:1}

/* ==================== ٨) الشاشات الصغيرة والوصول ==================== */
@media (max-width:390px){
  body.g3d-jd .jd-board{transform:rotateX(5deg)}
  body.g3d-wh .wh-wheelwrap{transform:rotateX(13deg)}
  body.g3d-mq .mq-qcard{transform:perspective(var(--g3d-persp)) rotateX(1.2deg)}
  body.g3d-ch .ch-card{transform:perspective(var(--g3d-persp)) rotateX(1deg)}
}
@media (prefers-reduced-motion:reduce){
  body.g3d .mq-btn,
  body.g3d .mq-life,
  body.g3d .ch-offer,
  body.g3d-mq .mq-opt,
  body.g3d-mq .mq-ladder li,
  body.g3d-jd .jd-cell,
  body.g3d-jd .jd-opt,
  body.g3d-ch .ch-opt,
  body.g3d-fd .fd-row,
  body.g3d-wh .wh-tile,
  body.g3d-wh .wh-l,
  body.g3d .g3d-cinema{transition:none!important}
  body.g3d .mq-btn:hover,
  body.g3d .mq-btn:active,
  body.g3d-mq .mq-opt:hover:not([disabled]),
  body.g3d-mq .mq-opt:active:not([disabled]),
  body.g3d-jd .jd-cell:hover:not(.is-used),
  body.g3d-jd .jd-cell:active:not(.is-used),
  body.g3d-ch .ch-opt:hover:not([disabled]),
  body.g3d-ch .ch-opt:active:not([disabled]),
  body.g3d-ch .ch-offer:hover,
  body.g3d-ch .ch-offer:active,
  body.g3d-wh .wh-l:active,
  body.g3d-wh .wh-tile.is-open{transform:none!important}
  body.g3d-mq .mq-ladder li.is-now::after,
  body.g3d-fd .fd-row.is-pop{animation:none!important}
}
/* الأجهزة الضعيفة (بيتحدد من الـJS): ميل أقل + مفيش will-change */
body.g3d-low{--g3d-persp:1200px}
body.g3d-low .mq-qcard,
body.g3d-low .ch-card,
body.g3d-low .jd-card,
body.g3d-low .fd-q{transform:none;will-change:auto}
body.g3d-low .jd-board{transform:rotateX(3deg)}
body.g3d-low .wh-wheelwrap{transform:rotateX(10deg)}
body.g3d-low *{will-change:auto!important}

/* ==================== ٩) قلبة الكارت عند سؤال جديد ==================== */
/* الـJS بيحط g3d-deal على كارت السؤال لما نص السؤال يتغير — ٤٢٠ms وبس. */
@keyframes g3d-deal{
  0%{transform:perspective(var(--g3d-persp)) rotateX(9deg) translateY(-10px);opacity:.55}
  100%{transform:perspective(var(--g3d-persp)) rotateX(1.6deg) translateY(0);opacity:1}
}
body.g3d-mq .mq-qcard.g3d-deal{animation:g3d-deal .42s var(--g3d-ease) both}
body.g3d-ch .ch-card.g3d-deal{animation:g3d-deal .42s var(--g3d-ease) both}
body.g3d-fd .fd-q.g3d-deal{animation:g3d-deal .42s var(--g3d-ease) both}
@media (prefers-reduced-motion:reduce){
  body.g3d-mq .mq-qcard.g3d-deal,
  body.g3d-ch .ch-card.g3d-deal,
  body.g3d-fd .fd-q.g3d-deal{animation:none!important}
}
