/* بطل الحكاية — التصميم الأساسي (RTL، قصاصات ورق، ألوان الهوية) */
:root {
  --blue: #479AE6; --blue-d: #2F78BF;
  --green: #97B943; --green-d: #6F9028;
  --yellow: #F2C84A; --yellow-d: #C9A12C;
  --red: #E54837; --red-d: #B8301F;
  --pink: #E75F70; --orange: #ECA43F;
  --cream: #FFF8EB; --navy: #26334A; --white: #fff;
  --olive: #7f9b4a; --olive-d: #5d7a2e; --sand: #EBDDBB; --terra: #B2543A;
  --ink-soft: #5a6478;
  --f-head: 'Baloo Bhaijaan', 'Baloo Bhaijaan 2', 'Cairo', 'Tajawal', 'Noto Kufi Arabic', 'Segoe UI', Tahoma, sans-serif;
  --f-body: 'Tajawal', 'Cairo', 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;
  --shadow-1: 0 3px 0 rgba(38, 51, 74, .12), 0 8px 18px rgba(38, 51, 74, .12);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cfdcae; }
body {
  font-family: var(--f-body); font-weight: 700; color: var(--navy);
  direction: rtl; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--yellow); outline-offset: 2px; }
img { -webkit-user-drag: none; user-drag: none; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 800; margin: 0; }
.ico { width: 1.25em; height: 1.25em; flex: none; }

/* ---------- الإطار العام ---------- */
#backdrop {
  position: fixed; inset: 0; background: #cfdcae center / cover no-repeat;
  filter: blur(12px) saturate(1.1) brightness(.92); transform: scale(1.1);
}
#app {
  position: fixed; top: 0; bottom: 0; left: 0; right: 0; margin: 0 auto;
  width: min(100vw, 560px, calc(100dvh * .58));
  overflow: hidden; background: var(--cream);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06), 0 0 60px rgba(0, 0, 0, .28);
}
#screens { position: absolute; inset: 0; perspective: 1700px; overflow: hidden; }
#overlay { position: absolute; inset: 0; pointer-events: none; z-index: 100; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--cream); overflow: hidden; }

#rotate-hint {
  display: none; position: fixed; inset: 0; z-index: 999; background: var(--navy); color: #fff;
  align-items: center; justify-content: center; text-align: center; padding: 24px; font-family: var(--f-head);
}
#rotate-hint b { display: block; font-size: 26px; margin-bottom: 8px; }
#rotate-hint span { font-size: 17px; opacity: .85; font-family: var(--f-body); }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) { #rotate-hint { display: flex; } }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 54px; padding: 10px 28px; border: 0; border-radius: 999px;
  font-family: var(--f-head); font-weight: 800; font-size: 21px; line-height: 1.1; color: #fff;
  background: var(--blue); box-shadow: 0 5px 0 var(--blue-d), 0 9px 16px rgba(38, 51, 74, .2);
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--blue-d), 0 3px 6px rgba(38, 51, 74, .2); }
.btn.red { background: var(--red); box-shadow: 0 5px 0 var(--red-d), 0 9px 16px rgba(38, 51, 74, .2); }
.btn.red:active { box-shadow: 0 1px 0 var(--red-d), 0 3px 6px rgba(38, 51, 74, .2); }
.btn.green { background: var(--green); box-shadow: 0 5px 0 var(--green-d), 0 9px 16px rgba(38, 51, 74, .2); }
.btn.green:active { box-shadow: 0 1px 0 var(--green-d), 0 3px 6px rgba(38, 51, 74, .2); }
.btn.yellow { background: var(--yellow); color: var(--navy); box-shadow: 0 5px 0 var(--yellow-d), 0 9px 16px rgba(38, 51, 74, .2); }
.btn.white { background: #fff; color: var(--navy); box-shadow: 0 5px 0 #d8cdb4, 0 9px 16px rgba(38, 51, 74, .15); }
.btn.big { min-height: 64px; font-size: 25px; padding: 12px 38px; }
.btn.small { min-height: 44px; font-size: 17px; padding: 6px 20px; }
.btn.block { width: 100%; }
.btn.disabled, .btn:disabled { filter: grayscale(.7) opacity(.7); }
.btn .ico { width: 1.15em; height: 1.15em; }

.ibtn {
  width: 48px; height: 48px; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center;
  background: #fff; color: var(--navy); box-shadow: 0 3px 0 rgba(38, 51, 74, .15), 0 6px 12px rgba(38, 51, 74, .18); flex: none;
}
.ibtn:active { transform: translateY(2px); }
.ibtn .ico { width: 24px; height: 24px; }
.ibtn.small { width: 40px; height: 40px; }
.ibtn.small .ico { width: 20px; height: 20px; }
.ibtn.off { color: #9aa1b0; }
.ibtn.pulse { animation: pulse 1.1s ease-in-out infinite; }

/* ---------- الصور الدائرية ---------- */
.avatar {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 50%; overflow: hidden;
  background: #fff7de; border: 3px solid #fff; box-shadow: 0 3px 8px rgba(38, 51, 74, .22);
}
.avatar.lg { width: 60px; height: 60px; }
.avatar.xl { width: 74px; height: 74px; }
.avatar.sm { width: 38px; height: 38px; border-width: 2px; }
.avatar img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 3px; }
.avatar .limg { position: absolute; width: 132%; height: auto; left: 50%; top: 56%; translate: -50% -50%; }
.avatar.labib-avatar { background: #E6F2FF; }
.avatar.grandma-avatar svg { width: 100%; height: 100%; display: block; }

/* ---------- المشهد (الخلفية + الشخصيات) ---------- */
.stage {
  position: relative; flex: none; height: var(--stage-h, 45%); overflow: hidden; background: #9ec9e8;
  transition: height .45s ease;
}
.stage-bg { position: absolute; inset: 0; background-size: cover; background-position: center 62%; }
.stage-fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.stage-actors { position: absolute; inset: 0; z-index: 1; }
.stage-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center;
  justify-content: space-between; padding: calc(10px + var(--sat)) 12px 0; pointer-events: none;
}
.stage-top > * { pointer-events: auto; }
.actor { position: absolute; bottom: calc(var(--lap, 22px) + 2%); translate: -50% 0; transition: none; }
.actor-in { position: relative; transform-origin: 50% 100%; }
.actor .shadow {
  position: absolute; left: 50%; bottom: -3px; width: 72%; height: 12px; translate: -50% 0; z-index: 0;
  border-radius: 50%; background: rgba(48, 36, 14, .3); filter: blur(3px);
}
.actor-in { z-index: 1; }
.cimg { display: block; height: calc(var(--kc, 1px) * var(--nh)); width: auto; max-width: none; }
.limg { display: block; height: calc(var(--kl, 1px) * var(--nh)); width: auto; max-width: none; }
.actor-in.flip > img { transform: scaleX(-1); }
.actor-in.talking > img { animation: talk .34s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.actor-in.walking { animation: walkbob .4s ease-in-out infinite; }
.actor.big .limg { height: calc(var(--kl, 1px) * var(--nh) * 1.18); }
.actor.big .cimg { height: calc(var(--kc, 1px) * var(--nh) * .96); }
@keyframes talk { from { translate: 0 0; scale: 1 1; } to { translate: 0 -4px; scale: 1.015 .985; } }
@keyframes walkbob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }

.cloud { position: absolute; left: 0; width: 100px; opacity: .9; animation: drift linear infinite; }
.cloud svg { width: 100%; display: block; }
@keyframes drift { from { transform: translateX(-160px); } to { transform: translateX(560px); } }
.bfly { position: absolute; width: 26px; left: 10%; top: 40%; animation: flutter 17s ease-in-out infinite; }
.bfly.b1 { left: 70%; top: 52%; animation-duration: 21s; animation-delay: -6s; }
.bfly svg { width: 100%; display: block; overflow: visible; }
.bfly .wl, .bfly .wr { transform-origin: 15px 12px; animation: flap .26s ease-in-out infinite alternate; }
@keyframes flap { to { transform: scaleX(.3); } }
@keyframes flutter {
  0% { transform: translate(0, 0) rotate(-8deg); } 20% { transform: translate(80px, -30px) rotate(10deg); }
  40% { transform: translate(150px, 14px) rotate(-6deg); } 60% { transform: translate(60px, 40px) rotate(8deg); }
  80% { transform: translate(-30px, 8px) rotate(-10deg); } 100% { transform: translate(0, 0) rotate(-8deg); }
}
.fleaf { position: absolute; top: -24px; width: 24px; opacity: .9; animation: fall linear forwards; }
.fleaf svg { width: 100%; display: block; }
@keyframes fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 0; } 8% { opacity: .9; }
  50% { transform: translate(var(--sw), 30dvh) rotate(200deg); }
  100% { transform: translate(calc(var(--sw) * -1), 62dvh) rotate(420deg); opacity: 0; }
}
.confetti { position: absolute; width: 10px; height: 14px; border-radius: 2px; z-index: 30; pointer-events: none; animation: confetti 1.2s ease-out forwards; }
@keyframes confetti {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 200px)) rotate(var(--rot)); opacity: 0; }
}

/* ---------- البداية ---------- */
.splash-stage { position: absolute; inset: 0; height: auto; transition: none; }
.splash-stage .stage-bg { background-position: center 70%; }
.splash-stage .actor { bottom: 17%; }
.splash-ui {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; justify-content: flex-start;
  padding: calc(12px + var(--sat)) 16px calc(26px + var(--sab)); pointer-events: none;
}
.splash-ui > * { pointer-events: auto; }
.splash-top { display: flex; flex-direction: row-reverse; justify-content: space-between; align-items: center; }
.parent-btn {
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 0;
  background: rgba(255, 255, 255, .78); color: var(--navy); font: 700 14px var(--f-body); box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}
.parent-btn .ico { width: 16px; height: 16px; }
.logo-wrap { display: flex; justify-content: center; margin-top: 8px; pointer-events: none; }
.logo-fallback {
  background: var(--cream); border-radius: 26px; padding: 14px 26px 16px; text-align: center; transform: rotate(-1.5deg);
  box-shadow: 0 5px 0 var(--sand), 0 12px 26px rgba(38, 51, 74, .3); border: 4px solid #fff;
}
.logo-small { font-size: 14px; color: var(--terra); font-weight: 800; }
.logo-title { font-size: 46px; line-height: 1.1; color: var(--red); text-shadow: 3px 3px 0 var(--yellow); }
.logo-sub { font-family: var(--f-head); font-size: 22px; color: var(--blue-d); margin-top: 2px; }
.logo-img-wrap { text-align: center; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25)); }
.logo-img { width: min(70%, 270px); display: block; margin: 0 auto; }
.logo-img-wrap .logo-sub { display: inline-block; background: var(--cream); padding: 4px 18px; border-radius: 999px; margin-top: 6px; border: 3px solid #fff; }
.hello {
  align-self: center; background: #fff; border-radius: 999px; padding: 8px 20px; font: 800 20px var(--f-head); color: var(--navy);
  box-shadow: var(--shadow-1); margin-top: 10px; pointer-events: none;
}
.splash-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.splash-note { background: rgba(255, 255, 255, .85); padding: 4px 14px; border-radius: 999px; font-size: 14px; color: var(--ink-soft); }

/* ---------- الشريط العلوي + الجسم الورقي ---------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(12px + var(--sat)) 14px 10px; flex: none; background: var(--cream); }
.topbar.over { position: absolute; top: 0; left: 0; right: 0; z-index: 8; background: linear-gradient(rgba(255, 248, 235, .96) 55%, rgba(255, 248, 235, 0)); padding-bottom: 18px; }
.tb-title { flex: 1; font-size: 24px; text-align: center; color: var(--navy); }
.paper-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px calc(24px + var(--sab)); -webkit-overflow-scrolling: touch; }

/* ---------- الملفات ---------- */
.prof-list { display: flex; flex-direction: column; gap: 14px; }
.prof-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 24px; background: #fff; border: 0;
  box-shadow: var(--shadow-1); text-align: start; width: 100%;
}
.prof-card:active { transform: translateY(2px); }
.prof-info b { display: block; font: 800 24px var(--f-head); color: var(--navy); }
.prof-info span { font-size: 15px; color: var(--ink-soft); }
.prof-card.add { background: #FFF1C9; border: 3px dashed var(--orange); box-shadow: none; }
.prof-card .plus { width: 74px; height: 74px; border-radius: 50%; background: var(--yellow); color: #fff; display: grid; place-items: center; }
.prof-card .plus .ico { width: 34px; height: 34px; }

/* ---------- تخصيص البطل ---------- */
.screen-customize { --cv-h: clamp(210px, 33dvh, 320px); }
.cust-view { position: relative; flex: none; height: var(--cv-h); overflow: hidden;
  --kc: calc(var(--cv-h) * .70 / 303); --kl: calc(var(--cv-h) * .36 / 255); }
.cust-bg { position: absolute; inset: 0; background-size: cover; background-position: center 78%; }
.cust-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 12%; background: linear-gradient(rgba(0, 0, 0, 0), rgba(70, 90, 30, .22)); }
.cust-child, .cust-labib { transform: scaleX(-1); } /* ينظران إلى بعضهما */
.cust-child { position: absolute; bottom: 9%; left: 62%; translate: -50% 0; display: block; height: calc(var(--kc) * var(--nh)); width: auto; filter: drop-shadow(0 6px 4px rgba(40, 30, 10, .25)); }
.cust-labib { position: absolute; bottom: 9%; left: 22%; translate: -50% 0; height: calc(var(--kl) * var(--nh)); width: auto; filter: drop-shadow(0 6px 4px rgba(40, 30, 10, .25)); }
.name-plate {
  position: absolute; left: 4%; top: calc(64px + var(--sat)); max-width: 44%; padding: 7px 14px; border-radius: 18px; text-align: center;
  background: #fff; border: 3px solid var(--blue); font: 800 17px/1.35 var(--f-head); color: var(--navy); box-shadow: 0 4px 10px rgba(0, 0, 0, .2);
}
.name-plate::after { content: ''; position: absolute; bottom: -12px; left: 38%; width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent; border-top: 12px solid var(--blue); }
.name-plate.empty { color: #6b7488; }
.cust-scroll {
  flex: 1; min-height: 0; overflow-y: auto; position: relative; margin-top: -22px; padding: 6px 16px 10px;
  background: var(--cream); border-radius: 26px 26px 0 0; box-shadow: 0 -6px 16px rgba(0, 0, 0, .12); -webkit-overflow-scrolling: touch;
}
.cust-sec h3 { font-size: 17px; color: var(--terra); margin: 14px 0 8px; }
.name-input {
  width: 100%; font: 800 24px var(--f-body); padding: 12px 16px; border-radius: 20px; border: 4px solid var(--blue); background: #fff;
  color: var(--navy); text-align: center; -webkit-user-select: text; user-select: text;
}
.name-input::placeholder { color: #a9afbc; font-weight: 700; }
.gender-row { display: flex; gap: 12px; }
.gender-btn {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 22px; background: #fff;
  border: 4px solid transparent; box-shadow: var(--shadow-1); font: 800 22px var(--f-head); color: var(--navy);
}
.gender-btn.on { border-color: var(--green); background: #F3F8E4; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  position: relative; width: 42px; height: 42px; border-radius: 50%; border: 3px solid #fff; padding: 0;
  box-shadow: 0 0 0 2px rgba(38, 51, 74, .18), 0 3px 6px rgba(0, 0, 0, .18);
}
.swatch .tick { display: none; position: absolute; inset: 0; place-items: center; color: #fff; filter: drop-shadow(0 0 2px rgba(0, 0, 0, .65)); }
.swatch .tick .ico { width: 22px; height: 22px; }
.swatch.on { box-shadow: 0 0 0 4px var(--blue), 0 3px 8px rgba(0, 0, 0, .22); transform: scale(1.06); }
.swatch.on .tick { display: grid; }
.level-row { display: flex; gap: 10px; }
.level-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 4px; border-radius: 20px; background: #fff;
  border: 4px solid transparent; box-shadow: var(--shadow-1); color: var(--navy);
}
.level-btn.on { border-color: var(--blue); background: #E6F2FF; }
.lv-num { font: 800 24px/1.1 var(--f-head); }
.lv-unit { font-size: 14px; }
.level-btn small { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.cust-bottom { flex: none; padding: 10px 16px calc(14px + var(--sab)); background: var(--cream); box-shadow: 0 -4px 12px rgba(0, 0, 0, .06); position: relative; }
.cust-bottom .btn { width: 100%; }

/* ---------- خريطة الحكاية ---------- */
.map-head {
  flex: none; display: flex; align-items: center; gap: 12px; padding: calc(14px + var(--sat)) 16px 18px; color: #fff;
  background: var(--blue); border-radius: 0 0 28px 28px; box-shadow: 0 6px 0 var(--blue-d), 0 10px 18px rgba(38, 51, 74, .2); position: relative; z-index: 2;
}
.map-who b { display: block; font: 800 24px var(--f-head); line-height: 1.2; }
.map-who span { font-size: 14px; opacity: .95; }
.map-tools { margin-inline-start: auto; display: flex; gap: 8px; }
.map-body { padding-top: 16px; }
.pages-row { display: flex; justify-content: center; gap: 10px; margin: 2px 0 16px; }
.page-chip {
  width: 44px; height: 56px; border-radius: 6px 14px 14px 6px; background: #fff; border: 3px dashed #cdbf9d; display: grid; place-items: center;
  font: 800 20px var(--f-head); color: #b8a97f;
}
.page-chip.got { background: var(--yellow); border: 3px solid #d9a92a; color: #fff; animation: pop .5s ease-out; }
.page-chip .ico { width: 24px; height: 24px; }
.chap-list { display: flex; flex-direction: column; gap: 16px; }
.chap-card {
  position: relative; display: flex; flex-direction: column; border-radius: 26px; overflow: hidden; background: #fff; border: 0; padding: 0;
  text-align: start; box-shadow: var(--shadow-1); width: 100%;
}
.chap-card:active { transform: translateY(2px); }
.chap-thumb { position: relative; height: 140px; background-size: cover; background-position: center; }
.chap-info { padding: 10px 18px 4px; }
.chap-info small { color: var(--terra); font-weight: 800; font-size: 14px; }
.chap-info b { display: block; font: 800 23px/1.25 var(--f-head); color: var(--navy); }
.chap-sub { font-size: 15px; color: var(--ink-soft); font-weight: 500; }
.chap-cta { margin: 8px 18px 16px; align-self: flex-start; padding: 8px 24px; border-radius: 999px; background: var(--red); color: #fff; font: 800 19px var(--f-head); box-shadow: 0 4px 0 var(--red-d); }
.chap-card.locked .chap-thumb { filter: grayscale(.55) brightness(.92); }
.chap-card.locked .chap-info { opacity: .75; }
.lock-badge { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center; background: rgba(38, 51, 74, .38); color: #fff; font: 800 20px var(--f-head); }
.lock-badge .ico { width: 34px; height: 34px; }
.done-badge { position: absolute; top: 10px; left: 10px; width: 42px; height: 42px; border-radius: 50%; background: var(--yellow); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 8px rgba(0, 0, 0, .3); }
.map-links { display: flex; justify-content: center; gap: 18px; margin-top: 20px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; font: 700 15px var(--f-body); color: var(--blue-d); display: flex; align-items: center; gap: 6px; padding: 10px; text-decoration: underline; text-underline-offset: 4px; }
.link-btn .ico { width: 16px; height: 16px; }
.warn { background: #FFF1C9; border: 3px solid var(--orange); border-radius: 16px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }

/* ---------- نوافذ ورسائل ---------- */
.toast {
  position: absolute; left: 50%; bottom: calc(96px + var(--sab)); translate: -50% 20px; max-width: 86%; padding: 12px 20px;
  background: var(--navy); color: #fff; border-radius: 18px; font: 700 16px/1.5 var(--f-body); text-align: center; opacity: 0; transition: opacity .3s, translate .3s;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3); z-index: 120;
}
.toast.in { opacity: 1; translate: -50% 0; }
.modal-back { position: absolute; inset: 0; background: rgba(38, 51, 74, .58); display: flex; align-items: center; justify-content: center; padding: 16px; pointer-events: auto; opacity: 0; transition: opacity .25s; z-index: 110; }
.modal-back.in { opacity: 1; }
.modal { width: 100%; max-width: 420px; max-height: 92%; overflow-y: auto; background: var(--cream); border-radius: 28px; padding: 20px 18px 18px; box-shadow: 0 16px 44px rgba(0, 0, 0, .4); transform: scale(.92); transition: transform .25s cubic-bezier(.3, 1.4, .5, 1); -webkit-user-select: text; user-select: text; }
.modal-back.in .modal { transform: none; }
.modal-title { font-size: 24px; text-align: center; margin-bottom: 10px; color: var(--navy); }
.modal-body { font-size: 17px; line-height: 1.7; font-weight: 500; }
.modal-body p { margin: 0 0 8px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: center; flex-wrap: wrap; }

/* ---------- الانتقالات (تقليب الصفحات من الكعب اليميني) ---------- */
.flip-out { transform-origin: 100% 50%; backface-visibility: hidden; animation: flipOut .78s cubic-bezier(.55, .05, .3, 1) forwards; box-shadow: -12px 0 30px rgba(0, 0, 0, .25); }
.flip-out::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to left, rgba(40, 30, 10, 0), rgba(40, 30, 10, .45)); opacity: 0; animation: flipShade .78s ease forwards; z-index: 50; }
@keyframes flipOut { from { transform: rotateY(0); } to { transform: rotateY(105deg); } }
@keyframes flipShade { 0% { opacity: 0; } 60% { opacity: 1; } 100% { opacity: 1; } }
.fade-out { animation: fadeOut .35s ease forwards; }
@keyframes fadeOut { to { opacity: 0; } }
.slide-out { animation: slideOut .38s ease-in forwards; }
@keyframes slideOut { to { transform: translateX(-100%); } }

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 70% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }

@media (prefers-reduced-motion: reduce) {
  .cloud, .bfly, .fleaf { animation: none; }
  .flip-out { animation-duration: .01s; }
}
bdi { unicode-bidi: isolate; }

/* احتياط للمتصفحات القديمة التي لا تدعم وحدات dvh */
@supports not (height: 1dvh) {
  #app { width: min(100vw, 560px, calc(100vh * .58)); }
  .screen-customize { --cv-h: clamp(210px, 33vh, 320px); }
}

/* ---------- بطاقة الشهادة على الخريطة ---------- */
.cert-card {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 0 0 14px; padding: 10px 14px 10px 12px; border: 3px solid #fff; border-radius: 24px; text-align: start;
  background: linear-gradient(135deg, #FFE58A, #F2C84A); color: var(--navy); box-shadow: 0 5px 0 var(--yellow-d), 0 9px 16px rgba(38, 51, 74, .18);
}
.cert-card:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--yellow-d); }
.cc-medal { flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; border: 3px solid #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); }
.cc-medal .ico { width: 26px; height: 26px; }
.cc-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cc-txt b { font: 800 19px/1.2 var(--f-head); }
.cc-txt small { font: 700 13.5px/1.35 var(--f-body); color: #5a4a14; }
.cert-card > .ico { flex: none; width: 22px; height: 22px; transform: scaleX(-1); }
