/* ==========================================================
   «قاعة التحدّي» — تصميم صفحة اختبر نفسك
   لوح طيني بإطار مسماري، ميدالية ذهبية، وبطاقة ستوري
   (يعتمد على متغيرات الألوان في style.css)
   ========================================================== */
.qz { position: relative; max-width: 1100px; margin: 0 auto; }
.qz * { min-width: 0; }

/* ---------- shared bits ---------- */
.qz-panel {
  position: relative; border-radius: 30px; padding: clamp(22px, 4vw, 40px);
  background: var(--card); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); overflow: hidden; isolation: isolate;
}
.qz-panel::before { /* cuneiform frieze along the top edge */
  content: ""; position: absolute; inset-inline: 0; top: 0; height: 10px; z-index: -1; opacity: .55;
  background:
    linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent) top / 100% 2px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='10'%3E%3Cpath d='M2 2 L9 5 L2 8 Z M11 5 h6 M18 2 L24 5 L18 8 Z' fill='%23f2c25b' stroke='%23f2c25b' stroke-width='.6'/%3E%3C/svg%3E") 0 2px / 26px 8px repeat-x;
}
.qz-h { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.4rem, 3.2vw, 2rem); margin: 0 0 6px; }
.qz-sub { color: var(--muted); margin: 0 0 22px; }
.qz-enter { animation: qzIn .8s var(--ease) both; }
@keyframes qzIn { from { opacity: 0; transform: perspective(1200px) translateY(40px) rotateX(-10deg); filter: blur(6px); } }

/* ---------- LOBBY ---------- */
.qz-lobby { display: grid; gap: 22px; }
@media (min-width: 980px) { .qz-lobby { grid-template-columns: 1.45fr 1fr; align-items: start; } }
.qz-modes { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 22px; }
.qz-mode {
  position: relative; text-align: start; cursor: pointer; padding: 18px; border-radius: 22px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-2); display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center;
  transition: transform .45s var(--ease), border-color .3s, background .3s, box-shadow .4s;
}
.qz-mode:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
.qz-mode .ico { grid-row: span 2; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); border: 1px solid var(--stroke); transition: .4s var(--ease); }
.qz-mode .ico svg { width: 24px; height: 24px; }
.qz-mode b { font-size: 1.02rem; }
.qz-mode small { color: var(--muted); font-size: .8rem; line-height: 1.5; }
.qz-mode .n { position: absolute; top: 12px; inset-inline-end: 14px; font-family: var(--font-mega); font-size: 1.05rem; color: var(--gold); opacity: .8; }
.qz-mode.active { border-color: var(--gold); background: linear-gradient(150deg, var(--gold-soft), transparent 70%); box-shadow: var(--glow); }
.qz-mode.active .ico { background: var(--btn-gold); color: var(--on-gold); transform: rotate(-8deg) scale(1.06); }
.qz-mode.active::after { content: ""; position: absolute; top: 14px; inset-inline-start: 14px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px var(--gold); }

.qz-settings { display: grid; gap: 14px; margin-bottom: 24px; }
@media (min-width: 640px) { .qz-settings { grid-template-columns: auto 1fr; align-items: center; } }
.qz-switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; user-select: none; }
.qz-switch input { position: absolute; opacity: 0; pointer-events: none; }
.qz-switch .track { width: 52px; height: 30px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-2); position: relative; transition: .3s; flex-shrink: 0; }
.qz-switch .track::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--muted); transition: .35s var(--ease); }
.qz-switch input:checked + .track { background: var(--btn-gold); border-color: transparent; }
.qz-switch input:checked + .track::after { background: var(--on-gold); inset-inline-start: 25px; }
.qz-switch input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 3px; }
.qz-name { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--border-2); }
.qz-name svg { width: 18px; height: 18px; color: var(--gold); flex-shrink: 0; margin-inline-start: 8px; }
.qz-name input { flex: 1; border: 0; background: none; outline: none; padding: 9px 4px; color: var(--text); }
.qz-start { width: 100%; justify-content: center; font-size: 1.1rem; padding: 18px; }
.qz-fact { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: 20px; background: var(--gold-soft); border: 1px solid var(--stroke); margin-bottom: 22px; }
.qz-fact .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--btn-gold); color: var(--on-gold); flex-shrink: 0; }

/* rank ladder */
.qz-ladder h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.3rem; margin: 0 0 16px; }
.qz-rungs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; position: relative; }
.qz-rungs::before { content: ""; position: absolute; top: 20px; bottom: 20px; inset-inline-start: 23px; width: 2px; background: linear-gradient(var(--gold), var(--lapis), transparent); opacity: .5; }
.qz-rung { position: relative; display: flex; align-items: center; gap: 14px; padding: 8px 12px 8px 8px; border-radius: 16px; transition: .3s; }
.qz-rung .ico { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border-2); color: var(--muted); margin-inline-start: 7px; }
.qz-rung .ico svg { width: 16px; height: 16px; }
.qz-rung b { flex: 1; font-size: .95rem; }
.qz-rung span { font-family: var(--font-mega); color: var(--muted); font-size: .95rem; }
.qz-rung.reached .ico { background: var(--btn-gold); color: var(--on-gold); border-color: transparent; box-shadow: 0 0 16px rgba(242, 194, 91, .45); }
.qz-rung.reached b { color: var(--gold); }
.qz-rung.me { background: var(--gold-soft); border: 1px solid var(--stroke); }
.qz-stats-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.qz-stats-mini div { padding: 14px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); text-align: center; }
.qz-stats-mini strong { display: block; font-family: var(--font-mega); font-weight: 400; font-size: 1.8rem; color: var(--gold); line-height: 1.2; }
.qz-stats-mini small { color: var(--muted); }

/* ---------- PLAY ---------- */
.qz-hud { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.qz-orbs { display: flex; gap: 7px; flex-wrap: wrap; }
.qz-orb { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-mega); font-size: .85rem; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-2); transition: .45s var(--ease); }
.qz-orb.ok { background: var(--btn-gold); color: var(--on-gold); border-color: transparent; box-shadow: 0 0 14px rgba(242, 194, 91, .5); }
.qz-orb.bad { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.qz-orb.now { border-color: var(--gold); color: var(--gold); transform: scale(1.18); box-shadow: 0 0 0 4px var(--gold-soft); animation: orbPulse 1.6s ease-in-out infinite; }
@keyframes orbPulse { 50% { box-shadow: 0 0 0 8px rgba(242, 194, 91, 0); } }
@media (max-width: 520px) { .qz-orbs { gap: 4px; flex-wrap: nowrap; } .qz-orb { width: 26px; height: 26px; font-size: .75rem; } .qz-orb svg { width: 13px; height: 13px; } .qz-hud { justify-content: center; } }
.qz-hud-r { display: flex; gap: 8px; align-items: center; }
.qz-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-2); font-weight: 600; font-size: .9rem; }
.qz-chip svg { width: 16px; height: 16px; color: var(--gold); }
.qz-chip.hot { background: linear-gradient(135deg, rgba(255, 122, 80, .2), rgba(242, 194, 91, .2)); border-color: rgba(255, 150, 80, .5); animation: pop .5s var(--ease); }
.qz-chip.hot svg { color: #ff8a50; }

/* the clay tablet */
.qz-tablet {
  position: relative; border-radius: 32px; padding: clamp(24px, 4.5vw, 46px); padding-top: clamp(30px, 5vw, 52px);
  background:
    radial-gradient(ellipse at 20% 0%, rgba(242, 194, 91, .14), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(75, 116, 255, .16), transparent 55%),
    var(--card);
  border: 1px solid var(--border-2); box-shadow: var(--shadow-lg), inset 0 0 0 10px rgba(242, 194, 91, .03);
  overflow: hidden; isolation: isolate;
}
.qz-tablet::before { /* engraved inner frame */
  content: ""; position: absolute; inset: 12px; border-radius: 24px; border: 1px dashed rgba(242, 194, 91, .22); pointer-events: none; z-index: -1;
}
.qz-tablet::after { /* faint cuneiform watermark */
  content: ""; position: absolute; inset-inline-end: 26px; top: 26px; width: 176px; height: 80px; opacity: .07; pointer-events: none; z-index: -1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='40'%3E%3Cg fill='%23f2c25b'%3E%3Cpath d='M2 4 L14 9 L2 14 Z'/%3E%3Crect x='13' y='8' width='14' height='2'/%3E%3Cpath d='M24 22 L29 34 L34 22 Z'/%3E%3Crect x='28' y='8' width='2' height='16'/%3E%3Cpath d='M4 24 L16 29 L4 34 Z'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 44px 40px;
}
.qz-top { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.qz-timer { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.qz-timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.qz-timer .bg { fill: none; stroke: var(--surface-2); stroke-width: 5; }
.qz-timer .fg { fill: none; stroke: var(--gold); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset 1s linear, stroke .3s; filter: drop-shadow(0 0 6px rgba(242, 194, 91, .6)); }
.qz-timer.low .fg { stroke: var(--danger); filter: drop-shadow(0 0 6px rgba(255, 122, 107, .7)); }
.qz-timer.low { animation: shake .5s infinite; }
.qz-timer span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-mega); font-size: 1.3rem; }
.qz-qno { font-family: var(--font-mega); color: var(--gold); font-size: 1rem; letter-spacing: .04em; }
.qz-src { color: var(--muted); font-size: .85rem; display: flex; gap: 6px; align-items: center; margin: 2px 0 0; }
.qz-src svg { width: 15px; height: 15px; color: var(--gold); flex-shrink: 0; }
.qz-q { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.35rem, 3.6vw, 2.05rem); line-height: 1.55; margin: 18px 0 26px; }
.qz-opts { display: grid; gap: 12px; }
@media (min-width: 760px) { .qz-opts.four { grid-template-columns: 1fr 1fr; } }
.qz-opt {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: start; padding: 18px 18px; border-radius: 20px; cursor: pointer;
  color: var(--text); font-size: 1.04rem; font-weight: 500; background: var(--surface-2); border: 1px solid var(--border-2);
  transition: transform .4s var(--ease), border-color .25s, background .25s, box-shadow .3s; overflow: hidden;
  animation: optIn .6s var(--ease) both; animation-delay: calc(var(--k) * 70ms + 120ms);
}
@keyframes optIn { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.qz-opt .lt { width: 40px; height: 40px; border-radius: 13px; flex-shrink: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; color: var(--gold); background: var(--gold-soft); border: 1px solid var(--stroke); transition: .35s var(--ease); }
.qz-opt .kb { margin-inline-start: auto; font-family: var(--font-mega); font-size: .8rem; color: var(--muted); opacity: .6; border: 1px solid var(--border-2); border-radius: 7px; padding: 0 7px; }
@media (hover: none) { .qz-opt .kb { display: none; } }
.qz-opt:hover:not(:disabled) { transform: translateY(-3px); border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 14px 30px -18px rgba(242, 194, 91, .6); }
.qz-opt:hover:not(:disabled) .lt { background: var(--btn-gold); color: var(--on-gold); transform: rotate(-8deg); }
.qz-opt:disabled { cursor: default; }
.qz-opt.dim { opacity: .45; }
.qz-opt.correct { border-color: var(--success); background: var(--success-soft); box-shadow: 0 0 0 1px var(--success), 0 0 34px -6px var(--success); animation: pop .5s var(--ease); }
.qz-opt.correct .lt { background: var(--success); color: #04150c; border-color: transparent; }
.qz-opt.wrong { border-color: var(--danger); background: var(--danger-soft); animation: shake .45s; }
.qz-opt.wrong .lt { background: var(--danger); color: #1a0402; border-color: transparent; }
.qz-opt.tf { justify-content: center; font-size: 1.25rem; padding: 22px; }

/* feedback drawer */
.qz-fb { margin-top: 16px; padding: 20px 22px; border-radius: 24px; display: grid; gap: 14px; border: 1px solid; animation: fbIn .55s var(--ease) both; }
@keyframes fbIn { from { opacity: 0; transform: translateY(24px); } }
.qz-fb.ok { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.qz-fb.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.qz-fb.late { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.qz-fb .row { display: flex; gap: 14px; align-items: flex-start; }
.qz-fb .ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; }
.qz-fb.ok .ic { background: var(--success); color: #04150c; }
.qz-fb.bad .ic { background: var(--danger); color: #1a0402; }
.qz-fb.late .ic { background: var(--warn); color: #1a0f00; }
.qz-fb strong { font-size: 1.1rem; display: block; }
.qz-fb p { margin: 2px 0 0; color: var(--text); opacity: .9; }
.qz-fb .acts { display: flex; gap: 10px; flex-wrap: wrap; }
.qz-fb .acts .btn-primary { flex: 1; justify-content: center; min-width: 200px; }

/* ---------- RESULT ---------- */
.qz-result { display: grid; gap: 22px; }
.qz-crown { text-align: center; padding-top: clamp(30px, 6vw, 56px); }
.qz-medal-stage { perspective: 900px; width: 210px; height: 210px; margin: 0 auto 18px; position: relative; }
.qz-medal-stage::after { content: ""; position: absolute; inset: -30%; border-radius: 50%; background: radial-gradient(circle, rgba(242, 194, 91, .35), transparent 65%); z-index: -1; animation: glowP 3s ease-in-out infinite; }
@keyframes glowP { 50% { transform: scale(1.12); opacity: .7; } }
.qz-medal { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; animation: coin 7s var(--ease-io) infinite; }
@keyframes coin { 0%, 18% { transform: rotateY(0); } 50%, 68% { transform: rotateY(180deg); } 100% { transform: rotateY(360deg); } }
.qz-medal .face { position: absolute; inset: 0; border-radius: 50%; display: grid; place-items: center; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: radial-gradient(circle at 35% 30%, #fff3c4, #f4bd4f 40%, #a86c0c 85%); box-shadow: inset 0 0 0 10px rgba(255, 240, 200, .35), inset 0 0 0 14px rgba(120, 70, 0, .4), 0 30px 60px -20px rgba(242, 180, 60, .7); color: #3b2402; }
.qz-medal .face svg { width: 84px; height: 84px; filter: drop-shadow(0 2px 0 rgba(255, 240, 200, .6)); }
.qz-medal .back { transform: rotateY(180deg); font-family: var(--font-mega); font-size: 4.2rem; direction: ltr; }
.qz-rank { font-family: var(--font-display); font-weight: 600; font-size: clamp(2.2rem, 7vw, 4rem); line-height: 1.2; margin: 6px 0 8px; }
.qz-msg { color: var(--muted); font-size: 1.08rem; margin: 0 auto 18px; max-width: 520px; }
.qz-record { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; background: var(--btn-gold); color: var(--on-gold); font-weight: 700; margin-bottom: 18px; animation: pop .6s var(--ease); }
.qz-record svg { width: 18px; height: 18px; }
.qz-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .qz-kpis { grid-template-columns: repeat(4, 1fr); } }
.qz-kpi { padding: 18px 12px; border-radius: 22px; text-align: center; background: var(--surface-2); border: 1px solid var(--border-2); }
.qz-kpi strong { display: block; font-family: var(--font-mega); font-weight: 400; font-size: 2.1rem; line-height: 1.15; }
.qz-kpi small { color: var(--muted); }
.qz-kpi.g strong { color: var(--success); } .qz-kpi.r strong { color: var(--danger); } .qz-kpi.y strong { color: var(--gold); } .qz-kpi.b strong { color: var(--lapis-2); }

/* story card */
.qz-story { display: grid; gap: 26px; align-items: center; }
@media (min-width: 860px) { .qz-story { grid-template-columns: 320px 1fr; } }
.qz-phone { position: relative; width: min(300px, 76vw); aspect-ratio: 9 / 16; margin: 0 auto; border-radius: 34px; padding: 8px; background: linear-gradient(150deg, #2a2f45, #0b0e1a); box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .08), var(--glow); transform: perspective(1100px) rotateY(-10deg) rotateX(4deg); transition: transform .8s var(--ease); }
.qz-phone:hover { transform: perspective(1100px) rotateY(0) rotateX(0) scale(1.02); }
.qz-phone::before { content: ""; position: absolute; top: 16px; left: 50%; width: 70px; height: 18px; margin-left: -35px; border-radius: 10px; background: #05060c; z-index: 2; }
.qz-phone img, .qz-phone .ph { width: 100%; height: 100%; object-fit: cover; border-radius: 27px; display: block; background: #070b1f; }
.qz-phone .ph { display: grid; place-items: center; color: var(--gold); }
.qz-phone .ph svg { width: 40px; height: 40px; }
.qz-story h3 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.5rem, 3.4vw, 2.1rem); margin: 0 0 6px; }
.qz-story .steps-mini { list-style: none; padding: 0; margin: 14px 0 20px; display: grid; gap: 8px; color: var(--muted); font-size: .93rem; }
.qz-story .steps-mini li { display: flex; gap: 10px; align-items: center; }
.qz-story .steps-mini b { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); font-family: var(--font-mega); font-weight: 400; flex-shrink: 0; }
.qz-story .btns { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.qz-story .btns .btn { justify-content: center; }
.qz-story .btns .wide { grid-column: 1 / -1; }

/* review */
.qz-review { display: grid; gap: 10px; }
.qz-rv { border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.qz-rv summary { list-style: none; cursor: pointer; display: flex; gap: 12px; align-items: center; padding: 14px 16px; font-weight: 600; }
.qz-rv summary::-webkit-details-marker { display: none; }
.qz-rv summary .st { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.qz-rv.ok summary .st { background: var(--success-soft); color: var(--success); }
.qz-rv.bad summary .st { background: var(--danger-soft); color: var(--danger); }
.qz-rv summary .st svg { width: 17px; height: 17px; }
.qz-rv summary span.t { flex: 1; font-size: .95rem; line-height: 1.6; }
.qz-rv summary > svg { width: 18px; height: 18px; color: var(--gold); transition: transform .3s; flex-shrink: 0; }
.qz-rv[open] summary > svg { transform: rotate(180deg); }
.qz-rv .body { padding: 0 16px 16px 58px; color: var(--muted); font-size: .92rem; }
.qz-rv .body .btn { margin-top: 8px; }

/* confetti */
.qz-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 300; overflow: hidden; }
.qz-confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; opacity: .95; animation: fall var(--t) cubic-bezier(.2, .6, .4, 1) forwards; animation-delay: var(--dl); }
@keyframes fall { to { transform: translate3d(var(--dx), 110vh, 0) rotate(var(--rot)); opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .qz-medal { animation: none; } .qz-confetti { display: none; } .qz-opt, .qz-enter, .qz-fb { animation: none; } }
