/* ===================== الأساسيات ===================== */
*,*::before,*::after{box-sizing:border-box}

:root{
  --primary:#D62B6E;
  --primary-dark:#A2164F;
  --violet:#7B4BE0;
  --violet-deep:#5B2EC4;
  --violet-soft:#EFE7FF;
  --ink:#3A1030;
  --body:#6E4360;
  --muted:#9E7A8E;
  --border:#F4D9EA;
  --card:#FFFFFF;
  --lav:#FDEBF4;
  --lav-deep:#F7DBE9;
  --ok:#D62B6E;
  --warn:#C25C3E;
  --warn-bg:#FDF1ED;
  --shadow-soft:0 14px 34px -24px rgba(58,16,48,.5);
  --shadow-btn:0 14px 30px -14px rgba(198,43,140,.7);
  --r-lg:26px;
  --r-md:18px;
  --r-sm:14px;
}

html{-webkit-text-size-adjust:100%}

body{
  margin:0;
  min-height:100dvh;
  font-family:'IBM Plex Sans Arabic',system-ui,-apple-system,'Segoe UI',sans-serif;
  font-size:16px;
  line-height:1.6;
  color:var(--ink);
  background:linear-gradient(180deg,#FFF8FC 0%,#FBECF6 48%,#F3EAFF 100%);
  background-attachment:fixed;
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
  overflow-x:hidden;
}

body::before{
  content:'';
  position:fixed;
  inset:0;
  z-index:0;
  pointer-events:none;
  background:
    radial-gradient(620px 420px at 50% -12%, rgba(240,110,164,.28), transparent 70%),
    radial-gradient(460px 340px at 104% 102%, rgba(123,75,224,.18), transparent 72%),
    radial-gradient(420px 320px at -10% 72%, rgba(255,166,206,.22), transparent 75%);
}

h1,h2,h3,p,ul{margin:0}
ul{padding:0;list-style:none}
button{font:inherit;color:inherit}
:focus-visible{outline:none}

.sr-only{
  position:absolute;width:1px;height:1px;padding:0;margin:-1px;
  overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;
}

/* ===================== الهيكل ===================== */
.app{
  position:relative;
  z-index:1;
  max-width:520px;
  margin:0 auto;
  padding:0 20px 32px;
  min-height:100dvh;
  display:flex;
  flex-direction:column;
}

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 0 6px;
}

.brand{
  display:flex;
  align-items:center;
  gap:8px;
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:700;
  font-size:14px;
  color:var(--body);
  user-select:none;
}

.brand-mark{width:22px;height:22px;color:var(--primary);opacity:.9}

.icon-btn{
  width:44px;
  height:44px;
  flex:0 0 auto;
  border-radius:var(--r-sm);
  border:1px solid var(--border);
  background:rgba(255,255,255,.72);
  color:var(--primary);
  display:grid;
  place-items:center;
  cursor:pointer;
  transition:background-color .18s ease,border-color .18s ease,transform .16s ease;
}
.icon-btn svg{width:22px;height:22px}
.icon-btn:active{transform:scale(.94)}
@media (hover:hover){
  .icon-btn:hover{background:#fff;border-color:#F0A9C4}
}

main{
  flex:1;
  display:flex;
  flex-direction:column;
}

/* ===================== الشاشات ===================== */
.screen{display:none}
.screen.is-active{
  display:flex;
  flex-direction:column;
  justify-content:center;
  flex:1 0 auto;
  padding-block:10px 4px;
  animation:screenIn .34s cubic-bezier(.22,1,.36,1) both;
}

@keyframes screenIn{
  from{opacity:0;transform:translateY(12px)}
  to{opacity:1;transform:none}
}

/* ===================== الشاشة الرئيسية ===================== */
.fingerprint{
  width:112px;
  height:112px;
  margin:0 auto 18px;
  color:var(--primary);
  display:grid;
  place-items:center;
  filter:drop-shadow(0 10px 22px rgba(214,51,108,.24));
}
.fingerprint svg{width:100%;height:100%;overflow:visible}

.hero-title{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:clamp(32px,9.4vw,40px);
  line-height:1.22;
  letter-spacing:0;
  text-align:center;
  color:var(--ink);
}

.hero-lead{
  text-align:center;
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:500;
  font-size:18px;
  line-height:1.55;
  color:var(--primary-dark);
  margin-top:8px;
}

.hero-desc{
  text-align:center;
  font-size:15px;
  line-height:1.8;
  color:var(--body);
  margin:14px auto 0;
  max-width:36ch;
}

.chips{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:8px;
  margin:22px 0 26px;
}

.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:7px 13px;
  border-radius:999px;
  background:rgba(255,255,255,.78);
  border:1px solid var(--border);
  font-size:12.5px;
  font-weight:500;
  color:var(--body);
  white-space:nowrap;
  user-select:none;
}
.chip svg{width:15px;height:15px;color:var(--primary);flex:0 0 auto}

/* ===================== بطاقة التعريف ===================== */
.credit-card{
  margin:20px auto 0;
  max-width:340px;
  padding:14px 18px 16px;
  border-radius:22px;
  text-align:center;
  background:linear-gradient(155deg,#FFFFFF 0%,#FFF5FA 55%,#F4ECFF 100%);
  border:1px solid var(--border);
  box-shadow:var(--shadow-soft);
  user-select:none;
}

.credit-owner{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:16px;
  line-height:1.4;
  color:var(--primary-dark);
}
.credit-owner svg{width:19px;height:19px;color:var(--primary);flex:0 0 auto}

.credit-divider{
  display:block;
  height:1px;
  margin:10px 0 9px;
  background:linear-gradient(90deg,transparent,var(--border) 14%,var(--border) 86%,transparent);
}

.credit-label{font-size:11.5px;font-weight:600;color:var(--muted);line-height:1.5}

.credit-name{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:18px;
  line-height:1.5;
  color:var(--ink);
  margin-top:1px;
}

.credit-class{
  display:inline-block;
  margin-top:8px;
  padding:3px 13px;
  border-radius:999px;
  background:var(--violet-soft);
  color:var(--violet-deep);
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:700;
  font-size:12.5px;
}

.credit-foot{
  text-align:center;
  font-size:12.5px;
  line-height:1.8;
  color:var(--muted);
  margin-top:16px;
}

@media (max-height:730px){
  .fingerprint{width:84px;height:84px;margin-bottom:10px}
  .hero-desc{margin-top:10px;font-size:14.5px}
  .credit-card{margin-top:14px;padding:12px 16px 14px}
}

/* ===================== الأزرار ===================== */
.btn{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  width:100%;
  min-height:56px;
  padding:14px 22px;
  border-radius:var(--r-md);
  border:1px solid transparent;
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:700;
  font-size:17px;
  line-height:1.3;
  cursor:pointer;
  user-select:none;
  transition:background-color .18s ease,border-color .18s ease,transform .15s ease,box-shadow .18s ease;
}
.btn-icon{width:20px;height:20px;flex:0 0 auto}

.btn-primary{
  background:linear-gradient(135deg,#E8457E 0%,#C92F9A 52%,#8B45E6 100%);
  color:#FFFFFF;
  box-shadow:var(--shadow-btn);
}
.btn-primary:active{transform:scale(.977);box-shadow:0 8px 18px -12px rgba(198,43,140,.9)}
@media (hover:hover){
  .btn-primary:hover{background:linear-gradient(135deg,#DC3A73 0%,#BB278C 52%,#7A38D6 100%)}
}

.btn-ghost{
  background:rgba(255,255,255,.62);
  color:var(--primary);
  border-color:var(--border);
  margin-top:10px;
  box-shadow:none;
}
.btn-ghost:active{transform:scale(.977)}
@media (hover:hover){
  .btn-ghost:hover{background:#fff;border-color:#F0A9C4}
}

.btn:focus-visible{
  outline:3px solid rgba(214,51,108,.42);
  outline-offset:3px;
}

/* ===================== سطر أفضل نتيجة ===================== */
.best-line{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  margin-top:16px;
  font-size:13px;
  font-weight:500;
  color:var(--muted);
  text-align:center;
  line-height:1.6;
}
.best-line svg{width:15px;height:15px;flex:0 0 auto;color:#F3A9C6}
.best-line.is-record{color:var(--primary-dark);font-weight:600}
.best-line.is-record svg{color:var(--primary)}

/* ===================== شاشة السؤال ===================== */
.quiz-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}

.q-count{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:700;
  font-size:15px;
  color:var(--ink);
  white-space:nowrap;
}

.score-pill{
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:5px 11px;
  border-radius:999px;
  background:#fff;
  border:1px solid var(--border);
  font-size:13px;
  font-weight:600;
  font-family:'Tajawal',system-ui,sans-serif;
  color:var(--primary);
  user-select:none;
}
.score-pill svg{width:13px;height:13px}

.progress{
  display:flex;
  gap:8px;
  margin-bottom:20px;
}

.progress-block{
  flex:1;
  height:7px;
  border-radius:999px;
  background:var(--lav-deep);
  transition:background-color .4s ease;
}
.progress-block.is-current{background:#F49BC0}
.progress-block.is-done{background:linear-gradient(90deg,#E8457E 0%,#8B45E6 100%)}

.question-card{
  position:relative;
  overflow:hidden;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:22px;
  padding:20px 20px 22px;
  box-shadow:var(--shadow-soft);
  margin-bottom:18px;
}
.question-card::before{
  content:'';
  position:absolute;
  inset-inline:0;
  top:0;
  height:4px;
  background:linear-gradient(90deg,#E8457E 0%,#C134A8 55%,#7B4BE0 100%);
}

.q-kicker{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:700;
  font-size:12.5px;
  color:var(--primary);
  margin-bottom:8px;
}

.q-text{
  font-family:'IBM Plex Sans Arabic',system-ui,sans-serif;
  font-weight:600;
  font-size:19px;
  line-height:1.65;
  color:var(--ink);
}

.answers{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.answer{
  display:flex;
  align-items:center;
  gap:14px;
  width:100%;
  min-height:56px;
  padding:13px 15px;
  background:var(--card);
  border:1.5px solid var(--border);
  border-radius:var(--r-md);
  color:var(--ink);
  font-family:'IBM Plex Sans Arabic',system-ui,sans-serif;
  font-size:15.5px;
  font-weight:500;
  line-height:1.55;
  text-align:start;
  cursor:pointer;
  user-select:none;
  transition:border-color .18s ease,background-color .18s ease,transform .15s ease,box-shadow .18s ease;
}
.answer:active{transform:scale(.985)}

.answer .badge{
  flex:0 0 auto;
  width:36px;
  height:36px;
  border-radius:12px;
  background:var(--lav);
  color:var(--primary);
  display:grid;
  place-items:center;
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:14px;
  transition:background-color .18s ease,color .18s ease;
}

.answer .answer-label{flex:1 1 auto;min-width:0}

@media (hover:hover){
  .answer:hover{
    border-color:#F0A9C4;
    background:#FFF9FB;
    transform:translateY(-1px);
    box-shadow:0 12px 24px -20px rgba(74,20,48,.75);
  }
  .answer:hover .badge{background:linear-gradient(135deg,#E8457E,#B03BE0);color:#fff}
}

.answer:focus-visible{
  outline:3px solid rgba(214,51,108,.42);
  outline-offset:2px;
}

/* ===================== بطاقات التغذية الراجعة ===================== */
.feedback-card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--r-lg);
  padding:34px 24px 26px;
  text-align:center;
  box-shadow:var(--shadow-soft);
}
.feedback-card.shake{animation:shake .45s ease}

@keyframes shake{
  0%,100%{transform:translateX(0)}
  18%{transform:translateX(-7px)}
  38%{transform:translateX(6px)}
  58%{transform:translateX(-4px)}
  78%{transform:translateX(3px)}
}

.feedback-icon{
  width:88px;
  height:88px;
  border-radius:50%;
  margin:0 auto 20px;
  display:grid;
  place-items:center;
  animation:pop .42s cubic-bezier(.34,1.56,.64,1) both;
}
.feedback-icon svg{width:42px;height:42px}

@keyframes pop{
  0%{transform:scale(.55);opacity:0}
  62%{transform:scale(1.07);opacity:1}
  100%{transform:scale(1);opacity:1}
}

.icon-correct{
  background:linear-gradient(135deg,#E8457E 0%,#C134A8 55%,#8B45E6 100%);
  color:#FFFFFF;
  box-shadow:0 16px 30px -16px rgba(198,43,140,.9);
}
.icon-wrong{
  background:var(--warn-bg);
  color:var(--warn);
  border:1px solid #F3DCD3;
}

.feedback-title{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:25px;
  line-height:1.3;
  color:var(--ink);
  margin-bottom:8px;
}

.feedback-text{
  font-size:16px;
  line-height:1.65;
  color:var(--body);
  margin-bottom:24px;
}

/* ===================== شاشة النتيجة ===================== */
.result-title{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:26px;
  line-height:1.35;
  text-align:center;
  color:var(--ink);
  margin-bottom:18px;
}

.score-ring-wrap{
  position:relative;
  width:180px;
  height:180px;
  margin:0 auto 14px;
}

.ring{
  width:100%;
  height:100%;
  transform:rotate(-90deg);
  overflow:visible;
}
.ring-track{
  fill:none;
  stroke:var(--lav-deep);
  stroke-width:10;
}
.ring-value{
  fill:none;
  stroke:url(#ringGrad);
  stroke-width:10;
  stroke-linecap:round;
  stroke-dasharray:490;
  stroke-dashoffset:490;
  transition:stroke-dashoffset 1.05s cubic-bezier(.22,1,.36,1);
}

.ring-inner{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:3px;
}
.ring-score{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:58px;
  line-height:1;
  color:var(--ink);
}
.ring-total{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:700;
  font-size:24px;
  color:#B98AA1;
  transform:translateY(9px);
}

.result-sub{
  text-align:center;
  font-size:14.5px;
  font-weight:500;
  color:var(--body);
  margin-bottom:18px;
}

.result-msg{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:20px;
  padding:18px 20px;
  text-align:center;
  box-shadow:var(--shadow-soft);
  margin-bottom:4px;
}
.result-msg h2{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:19px;
  line-height:1.4;
  color:var(--primary-dark);
  margin-bottom:6px;
}
.result-msg p{
  font-size:14.5px;
  line-height:1.7;
  color:var(--body);
}

/* ===================== لوحة المعلومات ===================== */
.sheet-overlay{
  position:fixed;
  inset:0;
  z-index:60;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
}
.sheet-overlay.hidden{display:none}

.sheet-backdrop{
  position:absolute;
  inset:0;
  background:rgba(60,12,32,.46);
  -webkit-backdrop-filter:blur(3px);
  backdrop-filter:blur(3px);
  opacity:0;
  transition:opacity .26s ease;
}

.sheet{
  position:relative;
  width:100%;
  max-width:520px;
  margin:0 auto;
  background:#FFFFFF;
  color:var(--ink);
  border-radius:28px 28px 0 0;
  padding:12px 22px 26px;
  max-height:84vh;
  overflow-y:auto;
  transform:translateY(102%);
  transition:transform .32s cubic-bezier(.22,1,.36,1);
  box-shadow:0 -22px 44px -24px rgba(74,20,48,.45);
}

.sheet-overlay.open .sheet{transform:translateY(0)}
.sheet-overlay.open .sheet-backdrop{opacity:1}

.sheet-handle{
  width:44px;
  height:5px;
  border-radius:999px;
  background:var(--lav-deep);
  margin:0 auto 16px;
}

.sheet-title{
  font-family:'Tajawal',system-ui,sans-serif;
  font-weight:800;
  font-size:21px;
  color:var(--ink);
  margin-bottom:10px;
}

.sheet-text{
  font-size:15px;
  line-height:1.8;
  color:var(--body);
  margin-bottom:16px;
}

.sheet-list{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-bottom:18px;
}
.sheet-list li{
  display:flex;
  align-items:flex-start;
  gap:10px;
  font-size:14.5px;
  line-height:1.7;
  color:var(--ink);
}
.sheet-dot{
  flex:0 0 auto;
  width:8px;
  height:8px;
  margin-top:9px;
  border-radius:50%;
  background:var(--primary);
}

.sheet-note{
  font-size:12.5px;
  color:var(--muted);
  margin-bottom:20px;
  padding:10px 14px;
  background:#FFF6F9;
  border:1px solid var(--border);
  border-radius:12px;
  line-height:1.7;
}

/* ===================== شاشات عريضة ===================== */
@media (min-width:640px){
  .app{padding:0 24px 48px}
  .topbar{padding-top:22px}
  .fingerprint{width:128px;height:128px;margin-bottom:22px}
  .question-card{padding:24px 24px 26px}
  .q-text{font-size:21px}
  .feedback-card{padding:42px 32px 32px}
  .answer{font-size:16px}
}

/* ===================== تقليل الحركة ===================== */
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
  }
}