/* =====================================================================
   أصدقاء الحيوانات — التنسيق
   ===================================================================== */
:root {
  --ink: #2b3a67;
  --ink-soft: #5a6b99;
  --orange: #ff9f1c;
  --orange-d: #d9780c;
  --green: #4cc45a;
  --green-d: #2f9d3d;
  --blue: #3d9bff;
  --blue-d: #1f6fd0;
  --pink: #ff6fa5;
  --card-bd: #ffd36b;
  --mh: min(36vh, 290px);                 /* ارتفاع الشخصية */
  --font: 'Baloo Bhaijaan 2', 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, 'Noto Sans Arabic', 'Noto Naskh Arabic', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fdcff; }
body { font-family: var(--font); color: var(--ink); -webkit-user-select: none; user-select: none; touch-action: manipulation; overscroll-behavior: none; }
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
img { -webkit-user-drag: none; user-drag: none; pointer-events: none; }
#app { position: fixed; inset: 0; overflow: hidden; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* ---------- الخلفيات ---------- */
#scenery { position: absolute; inset: 0; z-index: 0; overflow: hidden; transition: background .6s; }
#scenery .sun { position: absolute; top: 3%; left: 5%; font-size: clamp(50px, 11vh, 120px); animation: sunspin 40s linear infinite; filter: drop-shadow(0 0 20px #fff6); }
#scenery .cloud { position: absolute; font-size: clamp(50px, 12vh, 120px); opacity: .9; animation: drift 60s linear infinite; }
#scenery .hill { position: absolute; left: -10%; width: 120%; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
#scenery .hill.h1 { bottom: -18%; height: 46%; }
#scenery .hill.h2 { bottom: -26%; height: 40%; left: -30%; width: 90%; }
#scenery .deco { position: absolute; font-size: clamp(40px, 9vh, 100px); filter: drop-shadow(0 6px 4px #0002); animation: sway 5s ease-in-out infinite; }
@keyframes sunspin { to { transform: rotate(360deg); } }
@keyframes drift { from { transform: translateX(-20vw); } to { transform: translateX(120vw); } }
@keyframes sway { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }

/* ---------- الشاشات ---------- */
.screen { position: absolute; inset: 0; z-index: 1; display: none; flex-direction: column; padding: env(safe-area-inset-top) 0 0; }
.screen.active { display: flex; animation: screenIn .35s ease-out; }
@keyframes screenIn { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- أزرار ---------- */
.btn-big {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font-size: clamp(22px, 4.6vh, 44px); font-weight: 800; color: #4a2a00;
  padding: .45em 1.3em; border-radius: 999px;
  background: linear-gradient(#ffe066, var(--orange));
  box-shadow: 0 .16em 0 var(--orange-d), 0 .4em .7em #0003;
  transition: transform .1s, box-shadow .1s; min-height: 64px;
}
.btn-big:active { transform: translateY(.1em); box-shadow: 0 .06em 0 var(--orange-d), 0 .2em .4em #0003; }
.btn-big.alt { background: linear-gradient(#9ee0ff, var(--blue)); color: #fff; box-shadow: 0 .16em 0 var(--blue-d), 0 .4em .7em #0003; }
.btn-big.small { font-size: clamp(20px, 3.6vh, 32px); }
.btn-big .ico { font-size: 1.15em; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
.icon-btn {
  width: clamp(52px, 8.5vh, 72px); height: clamp(52px, 8.5vh, 72px); border-radius: 50%;
  display: grid; place-items: center; font-size: clamp(26px, 4.4vh, 38px);
  background: #fff; box-shadow: 0 4px 0 #0002, 0 6px 12px #0002; transition: transform .1s;
}
.icon-btn:active { transform: translateY(3px) scale(.95); }
.icon-btn.off { opacity: .6; filter: grayscale(.8); }
.star-counter { display: flex; align-items: center; gap: .25em; background: #fff; border-radius: 999px; padding: .1em .75em .1em .5em; font-size: clamp(22px, 4vh, 34px); font-weight: 800; box-shadow: 0 4px 0 #0002, 0 6px 12px #0002; min-height: clamp(52px, 8.5vh, 72px); color: #c97a00; }
.star-counter.bump { animation: bump .5s; }
@keyframes bump { 40% { transform: scale(1.3) rotate(-4deg); } }

/* ---------- شاشة البداية ---------- */
#screen-start { align-items: center; justify-content: center; }
.start-center { position: relative; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 2.2vh; text-align: center; }
.title {
  margin: 0; font-size: clamp(34px, 9vh, 92px); line-height: 1.1; font-weight: 800; color: #fff;
  text-shadow: 0 .06em 0 #2f9d3d, 0 .12em 0 #1f7a2e, 0 .3em .5em #0004; -webkit-text-stroke: .03em #2f9d3d; paint-order: stroke fill;
  animation: titleBob 3s ease-in-out infinite;
}
@keyframes titleBob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-1.2vh) rotate(1deg); } }
.start-mascot { height: min(40vh, 340px); aspect-ratio: 220/300; }
.start-animals { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.start-animals .sa { position: absolute; width: min(20vh, 17vw); aspect-ratio: 1; animation: bobA 3.2s ease-in-out infinite; filter: drop-shadow(0 8px 6px #0003); }
@keyframes bobA { 0%,100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-2vh) rotate(3deg); } }
.start-bar { position: absolute; top: 2vh; inset-inline: 2vw; display: flex; gap: 1.2vw; align-items: center; z-index: 5; }
.start-bar .star-counter { margin-inline-start: auto; }

/* ---------- HUD ---------- */
.hud { display: flex; align-items: center; gap: 1.2vw; padding: 1vh 2vw; background: rgba(255,255,255,.5); backdrop-filter: blur(6px); border-radius: 0 0 26px 26px; flex: none; }
.hud-info { flex: 1; min-width: 0; }
.hud-line { display: flex; justify-content: space-between; gap: 10px; font-weight: 800; font-size: clamp(16px, 3vh, 26px); }
.progress { display: flex; gap: 6px; margin-top: 4px; }
.progress i { flex: 1; height: clamp(10px, 1.8vh, 16px); border-radius: 99px; background: rgba(43,58,103,.18); transition: background .4s; }
.progress i.on { background: linear-gradient(90deg, #7be06a, #3dbf4d); box-shadow: 0 0 8px #7be06a; }
.progress i.cur { background: #ffd54a; animation: pulse 1.4s infinite; }
.hud-end { display: flex; gap: .8vw; align-items: center; }
.map-title { margin: 0; flex: 1; text-align: center; font-size: clamp(20px, 4.4vh, 40px); }

/* ---------- الشخصية ---------- */
.mascot { width: 100%; height: 100%; overflow: visible; animation: idle 3.2s ease-in-out infinite; }
@keyframes idle { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-1.2%); } }
.mascot .arm { transform-box: view-box; transition: transform .28s cubic-bezier(.3,1.5,.5,1); }
.mascot .armL { transform-origin: 80px 162px; transform: rotate(8deg); }
.mascot .armR { transform-origin: 139px 162px; transform: rotate(-8deg); }
.mascot .m-head { transform-box: view-box; transform-origin: 110px 150px; transition: transform .3s; }
.mascot .eyes-happy, .mascot .mouth-open, .mascot .mouth-o, .mascot .m-q { display: none; }
.mascot .eyes-normal { transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
@keyframes blink { 0%,94%,100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
.mascot .pupils { transition: transform .3s; }
.mascot .brow { transition: transform .3s; }
.mascot[data-mood=think] .mouth-smile { display: none; }
.mascot[data-mood=think] .mouth-o, .mascot[data-mood=think] .m-q { display: inline; }
.mascot[data-mood=think] .pupils { transform: translate(5px, -5px); }
.mascot[data-mood=think] .brow.br { transform: translateY(-6px) rotate(-8deg); transform-box: fill-box; transform-origin: center; }
.mascot[data-mood=think] .m-head { transform: rotate(-6deg); }
.mascot[data-mood=listen] .m-head { transform: rotate(7deg); }
.mascot[data-mood=listen] .armR { transform: rotate(-156deg); }
.mascot[data-mood=listen] .brow { transform: translateY(-3px); }
.mascot[data-mood=point] .armL { transform: rotate(104deg); }
.mascot[data-mood=point] .m-head { transform: rotate(-4deg); }
.mascot[data-mood=clap] .eyes-normal, .mascot[data-mood=celebrate] .eyes-normal { display: none; }
.mascot[data-mood=clap] .eyes-happy, .mascot[data-mood=celebrate] .eyes-happy { display: inline; }
.mascot[data-mood=clap] .mouth-smile, .mascot[data-mood=celebrate] .mouth-smile { display: none; }
.mascot[data-mood=clap] .mouth-open, .mascot[data-mood=celebrate] .mouth-open { display: inline; }
.mascot[data-mood=clap] .armL { animation: clapL .28s infinite alternate; }
.mascot[data-mood=clap] .armR { animation: clapR .28s infinite alternate; }
@keyframes clapL { from { transform: rotate(-34deg); } to { transform: rotate(-52deg); } }
@keyframes clapR { from { transform: rotate(34deg); } to { transform: rotate(52deg); } }
.mascot[data-mood=celebrate] { animation: jump .55s ease-in-out infinite; }
.mascot[data-mood=celebrate] .armL { animation: waveL .3s infinite alternate; }
.mascot[data-mood=celebrate] .armR { animation: waveR .3s infinite alternate; }
@keyframes jump { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-9%); } }
@keyframes waveL { from { transform: rotate(150deg); } to { transform: rotate(172deg); } }
@keyframes waveR { from { transform: rotate(-150deg); } to { transform: rotate(-172deg); } }

/* ---------- الخريطة ---------- */
#screen-map .hud { z-index: 3; }
.map-wrap { flex: 1; min-height: 0; display: grid; place-items: center; padding: 1.2vh 1.5vw 2vh; }
.mapboard {
  position: relative; container-type: size; aspect-ratio: 16/9;
  width: min(100%, calc((100dvh - 14vh - 24px) * 16 / 9)); max-height: 100%;
  border-radius: 34px; background: rgba(255,255,255,.35); box-shadow: 0 10px 30px #0003, inset 0 0 0 6px #fff9;
}
.mapboard.portrait { aspect-ratio: 9/14; width: min(100%, calc((100dvh - 14vh - 24px) * 9 / 14)); }
.mapboard .zone { position: absolute; border-radius: 26px; background: linear-gradient(145deg, var(--c1), var(--c2)); box-shadow: inset 0 0 0 4px #fff7, 0 4px 10px #0002; overflow: hidden; }
.mapboard .zone .zl { position: absolute; top: 4%; inset-inline-start: 6%; background: #fff; border-radius: 99px; padding: .1em .7em; font-weight: 800; font-size: clamp(11px, 3.8cqmin, 30px); box-shadow: 0 3px 0 #0002; white-space: nowrap; z-index: 2; }
.mapboard .zone .zd { position: absolute; font-size: clamp(18px, 7cqmin, 64px); opacity: .85; }
.mapboard .zone.locked { filter: saturate(.55) brightness(.92); }
.mapboard svg.path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.node {
  position: absolute; transform: translate(-50%, -50%); width: clamp(40px, 13cqmin, 96px); aspect-ratio: 1; border-radius: 50%; z-index: 4;
  display: grid; place-items: center; font-weight: 800; font-size: clamp(16px, 5.6cqmin, 40px);
  background: linear-gradient(#fff, #ffe9a8); border: .13em solid #fff; box-shadow: 0 5px 0 #0003, 0 8px 14px #0003; color: var(--ink);
}
.node .nico { position: absolute; top: -26%; inset-inline-end: -16%; font-size: .85em; filter: drop-shadow(0 2px 2px #0003); }
.node .nstars { position: absolute; bottom: -34%; left: 50%; transform: translateX(-50%); font-size: .46em; white-space: nowrap; background: #fffd; border-radius: 99px; padding: 0 .4em; color: #d98a00; letter-spacing: -1px; }
.node.done { background: linear-gradient(#d6ffd0, #7be06a); }
.node.cur { animation: nodeGlow 1.3s ease-in-out infinite; background: linear-gradient(#fff6b0, #ffc928); }
.node.locked { background: linear-gradient(#e5e9f2, #aeb7cc); color: #7b869f; filter: saturate(.7); }
.node.locked .nlock { position: absolute; font-size: .8em; }
.node.locked .nnum { opacity: .35; font-size: .7em; position: absolute; bottom: 6%; }
@keyframes nodeGlow { 0%,100% { box-shadow: 0 5px 0 #0003, 0 0 0 0 #ffe066aa, 0 0 18px 4px #ffd54a; transform: translate(-50%,-50%) scale(1); } 50% { box-shadow: 0 5px 0 #0003, 0 0 0 14px #ffe06600, 0 0 30px 12px #ffd54a; transform: translate(-50%,-50%) scale(1.12); } }
.map-mascot { position: absolute; bottom: 2vh; inset-inline-start: 1.5vw; height: min(26vh, 220px); aspect-ratio: 220/300; z-index: 6; pointer-events: none; }

/* ---------- اللعب ---------- */
#screen-game { }
.prompt {
  align-self: center; margin: 1.2vh 0 0; max-width: min(92%, 980px); display: flex; align-items: center; gap: .6em;
  background: #fff; border-radius: 30px; padding: .25em .9em .25em .5em; box-shadow: 0 5px 0 #0002, 0 8px 18px #0002;
  font-size: clamp(18px, 3.6vh, 34px); font-weight: 800; min-height: clamp(48px, 7.5vh, 74px); flex: none; position: relative; z-index: 4;
}
.prompt-replay { width: 1.7em; height: 1.7em; border-radius: 50%; background: linear-gradient(#9ee0ff, var(--blue)); color: #fff; font-size: .9em; flex: none; box-shadow: 0 3px 0 var(--blue-d); }
.prompt-replay:active { transform: translateY(2px); }
#prompt-text { line-height: 1.25; }
#stage { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; align-items: center; padding: 1vh 2vw 1.2vh; padding-right: calc(var(--mh) * .78 + 2vw); }
.game-mascot { position: absolute; right: 1vw; bottom: 1vh; height: var(--mh); aspect-ratio: 220/300; z-index: 3; pointer-events: none; }
.stage-in { flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 1.4vh; animation: stageIn .4s ease-out; }
@keyframes stageIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.top-zone { flex: none; display: flex; align-items: center; justify-content: center; gap: 2vw; min-height: 0; }
.opts { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.grid { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: var(--gap, 14px); }
.grid > * { width: var(--w); height: calc(var(--w) * var(--ar, 1.12)); flex: none; }

/* بطاقات الخيارات */
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 6% 6% 4%; gap: 2%;
  background: #fff; border: .06em solid var(--card-bd); border-width: 5px; border-radius: 26px;
  box-shadow: 0 6px 0 #0002, 0 10px 18px #0002; transition: transform .15s, box-shadow .15s, opacity .3s, background .3s, border-color .3s;
  font-size: calc(var(--w) * .13); font-weight: 800; overflow: visible;
}
.card:hover { transform: translateY(-4px) scale(1.03); }
.card:active { transform: translateY(2px) scale(.97); }
.card .apic { flex: 1 1 0; min-height: 0; width: 100%; overflow: hidden; }
.card .apic > img, .card .apic > svg { max-height: 100%; }
.card .lbl { line-height: 1.1; padding-bottom: 2%; white-space: nowrap; }
.apic { display: grid; place-items: center; }
.apic > img, .apic > svg { width: 100%; height: 100%; object-fit: contain; display: block; filter: drop-shadow(0 4px 3px #0002); }
.card.correct { border-color: #4cd964; background: #eaffea; animation: hop .7s ease-out; }
.card.wrong, .shake { animation: shake .45s; }
.card.wrong { border-color: #ffb36b; background: #fff3e6; }
.card.dim { opacity: .45; transform: scale(.94); }
.card.glow, .glow { animation: glow 1s ease-in-out infinite; border-color: #ffd21a; }
@keyframes glow { 0%,100% { box-shadow: 0 6px 0 #0002, 0 0 0 0 #ffd21a99; } 50% { box-shadow: 0 6px 0 #0002, 0 0 0 14px #ffd21a00, 0 0 26px 8px #ffd21a; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-10px) rotate(-2deg); } 40% { transform: translateX(10px) rotate(2deg); } 60% { transform: translateX(-7px); } 80% { transform: translateX(7px); } }
@keyframes hop { 0% { transform: translateY(0) scale(1); } 30% { transform: translateY(-26px) scale(1.1, .94) rotate(-3deg); } 55% { transform: translateY(0) scale(.96, 1.05); } 75% { transform: translateY(-10px) rotate(3deg); } 100% { transform: translateY(0); } }
.hop { animation: hop .7s ease-out; }
.locked-card { pointer-events: none; }

/* زر السماعة */
.speaker {
  position: relative; width: clamp(80px, 17vh, 170px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  font-size: clamp(40px, 8vh, 84px); background: linear-gradient(#9ee0ff, var(--blue)); box-shadow: 0 .09em 0 var(--blue-d), 0 .2em .5em #0004; color: #fff;
}
.speaker:active { transform: translateY(5px); }
.speaker::after, .speaker::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 5px solid #fff; opacity: 0; }
.speaker.playing::after { animation: ring 1s ease-out infinite; }
.speaker.playing::before { animation: ring 1s ease-out .35s infinite; }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
.mystery { background: linear-gradient(#d9a8ff, #8e4dff); box-shadow: 0 .09em 0 #5d24c4, 0 .2em .5em #0004; }
.mystery .q { font-size: 1.15em; text-shadow: 0 3px 0 #0003; animation: wob 1.6s ease-in-out infinite; }
@keyframes wob { 0%,100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.1); } }
.bigname { font-size: clamp(26px, 5.5vh, 54px); font-weight: 800; color: var(--ink); background: #fff; padding: .1em .7em; border-radius: 99px; box-shadow: 0 4px 0 #0002; }

/* بطاقة التعريف */
.intro { align-items: center; justify-content: center; text-align: center; }
.intro .big-animal { flex: 1; min-height: 0; width: min(100%, 60vh); animation: introBob 1.8s ease-in-out infinite; }
.intro .big-animal .apic { width: 100%; height: 100%; }
@keyframes introBob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-2vh) rotate(2deg) scale(1.03); } }
.intro .info { font-size: clamp(18px, 3.4vh, 32px); background: #fffd; padding: .25em .9em; border-radius: 22px; max-width: 90%; font-weight: 700; }

/* مصابيح مساعدة */
.print-plate { width: clamp(120px, 28vh, 260px); aspect-ratio: 1; border-radius: 50%; padding: 7%; background: radial-gradient(circle at 35% 30%, #f5deb3, #d9b27c 70%); box-shadow: inset 0 0 0 .07em #b98a50, 0 8px 18px #0003; }
.print-plate svg { width: 100%; height: 100%; filter: drop-shadow(1px 2px 0 #fff6); }
.part-view { width: clamp(130px, 31vh, 280px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 8px solid #fff; box-shadow: 0 8px 18px #0003; background: #fff; }
.part-view img { width: 100%; height: 100%; object-fit: cover; }
.part-view.reveal { animation: hop .7s; }

/* أزرار الأصوات (من الحيوان إلى الصوت) */
.sbtn { position: relative; border-radius: 50%; background: linear-gradient(#9ee0ff, var(--blue)); box-shadow: 0 .07em 0 var(--blue-d), 0 .16em .4em #0004; color: #fff; display: grid; place-items: center; font-weight: 800; aspect-ratio: 1; transition: transform .15s, opacity .3s, background .3s; }
.sbtn .n { font-size: calc(var(--w) * .38); line-height: 1; }
.sbtn .sp { position: absolute; bottom: 8%; font-size: calc(var(--w) * .22); }
.sbtn:active { transform: translateY(5px); }
.sbtn.playing { animation: pulse .6s infinite; }
.sbtn.correct { background: linear-gradient(#b8ffb0, #3dd45a); animation: hop .7s; }
.sbtn.dim { opacity: .45; }
.sbtn.glow { animation: glow 1s infinite; }

/* بيئات */
.hab { border-radius: 26px; background: linear-gradient(160deg, var(--c1), var(--c2)); border: 5px solid #fff; box-shadow: 0 6px 0 #0002, 0 10px 18px #0002; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4%; font-weight: 800; color: #fff; text-shadow: 0 2px 0 #0003; font-size: calc(var(--w) * .15); transition: transform .15s, opacity .3s; position: relative; }
.hab .hi { font-size: 2.6em; line-height: 1; filter: drop-shadow(0 3px 2px #0003); }
.hab:hover { transform: translateY(-4px) scale(1.03); }
.hab.correct { animation: hop .7s; border-color: #4cd964; }
.hab.wrong { animation: shake .45s; }
.hab.dim { opacity: .5; }
.hab.over { transform: scale(1.08); box-shadow: 0 0 0 8px #ffd21acc, 0 10px 18px #0002; }
.hab .got { position: absolute; bottom: 4%; inset-inline: 0; display: flex; justify-content: center; gap: 2%; }
.hab .got .apic { width: 34%; aspect-ratio: 1; }

/* سحب وإفلات */
.dual { flex: 1; min-height: 0; width: 100%; display: flex; gap: 2vw; align-items: stretch; }
.dual > .opts { flex: 1; min-width: 0; background: #ffffff55; border-radius: 28px; padding: 1.2%; }
@media (orientation: portrait) { .dual { flex-direction: column; } }
.drag { touch-action: none; cursor: grab; position: relative; z-index: 2; background: #fff; border-radius: 24px; border: 5px solid var(--card-bd); box-shadow: 0 6px 0 #0002, 0 10px 18px #0002; padding: 5%; display: grid; place-items: center; transition: transform .25s, opacity .3s; }
.drag .apic { width: 100%; height: 100%; }
.drag.dragging { transition: none; z-index: 100; cursor: grabbing; filter: drop-shadow(0 16px 12px #0004); }
.drag.sel { border-color: #ff9f1c; box-shadow: 0 0 0 6px #ffd21acc, 0 6px 0 #0002; }
.drag.done { opacity: 0; pointer-events: none; transform: scale(.4); }
.sil { border-radius: 24px; border: 5px dashed #7f9bd1; background: #ffffffaa; padding: 5%; display: grid; place-items: center; transition: transform .2s, background .3s, border-color .3s; }
.sil .apic { width: 100%; height: 100%; }
.sil .apic > * { filter: brightness(0) opacity(.42) !important; transition: filter .4s; }
.sil.over { background: #fff8c8; border-color: #ff9f1c; transform: scale(1.06); }
.sil.matched { border-style: solid; border-color: #4cd964; background: #eaffea; }
.sil.matched .apic > * { filter: drop-shadow(0 4px 3px #0002) !important; }

/* العد */
.count-field { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; background: #ffffff66; border-radius: 28px; padding: 1.2%; }
.cnt { position: relative; cursor: pointer; transition: transform .2s; }
.cnt .apic { width: 100%; height: 100%; }
.cnt .num { position: absolute; top: -6%; inset-inline-end: -4%; background: #ff6fa5; color: #fff; border-radius: 50%; width: 38%; aspect-ratio: 1; display: none; place-items: center; font-weight: 800; font-size: calc(var(--w) * .25); box-shadow: 0 3px 0 #0003; }
.cnt.counted .num { display: grid; animation: pop .35s; }
.cnt.counted { filter: saturate(1.2); }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.numrow { flex: none; display: flex; gap: 2vw; justify-content: center; padding: 0 0 .5vh; }
.numbtn { width: clamp(70px, 14vh, 130px); aspect-ratio: 1; border-radius: 28px; background: linear-gradient(#fff, #e6f1ff); border: 5px solid var(--blue); font-size: clamp(36px, 8vh, 72px); font-weight: 800; box-shadow: 0 6px 0 var(--blue-d), 0 10px 16px #0003; transition: transform .1s; color: var(--blue-d); }
.numbtn:active { transform: translateY(4px); }
.numbtn.correct { background: #eaffea; border-color: #4cd964; animation: hop .7s; color: #1f9d3a; }
.numbtn.wrong { animation: shake .45s; border-color: #ffb36b; }
.numbtn.dim { opacity: .45; }
.numbtn.glow { animation: glow 1s infinite; }

/* الذاكرة */
.mem { perspective: 700px; padding: 0; background: none; border: 0; box-shadow: none; }
.mem-in { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.mem.flip .mem-in { transform: rotateY(180deg); }
.mem-face { position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; box-shadow: 0 6px 0 #0002, 0 10px 16px #0002; }
.mem-back { background: repeating-linear-gradient(45deg, #ff9f1c, #ff9f1c 12px, #ffb84a 12px, #ffb84a 24px); border: 5px solid #fff; font-size: calc(var(--w) * .45); }
.mem-front { background: #fff; border: 5px solid var(--card-bd); transform: rotateY(180deg); padding: 8%; }
.mem-front .apic { width: 100%; height: 100%; }
.mem.matched .mem-front { border-color: #4cd964; background: #eaffea; }
.mem.matched { animation: hop .6s; }

/* الحيوان المختلف */
.odd-grid .card { }

/* ---------- المؤثرات البصرية ---------- */
#fx { position: absolute; inset: 0; z-index: 500; pointer-events: none; overflow: hidden; }
.spark { position: absolute; font-size: 28px; will-change: transform, opacity; }
.conf { position: absolute; top: -20px; width: 12px; height: 18px; border-radius: 3px; will-change: transform; }
.flystar { position: absolute; font-size: 56px; will-change: transform; filter: drop-shadow(0 4px 6px #0005); }

/* ---------- نهاية المستوى ---------- */
#screen-level, #screen-final { align-items: center; justify-content: center; }
.center-col { display: flex; flex-direction: column; align-items: center; gap: 2vh; text-align: center; max-height: 100%; padding: 2vh 3vw; }
.big-title { margin: 0; font-size: clamp(36px, 10vh, 100px); color: #fff; font-weight: 800; text-shadow: 0 .06em 0 #2f9d3d, 0 .12em 0 #1f7a2e, 0 .3em .5em #0004; -webkit-text-stroke: .03em #2f9d3d; paint-order: stroke fill; animation: titleBob 2.4s ease-in-out infinite; }
.trophy { font-size: clamp(60px, 18vh, 170px); line-height: 1; animation: jump .9s ease-in-out infinite; filter: drop-shadow(0 8px 10px #0005); }
.dance-row { display: flex; gap: 2vw; justify-content: center; flex-wrap: wrap; }
.dance-row .apic { width: min(15vh, 14vw); aspect-ratio: 1; animation: dance .7s ease-in-out infinite alternate; }
@keyframes dance { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-3vh) rotate(6deg) scale(1.05); } }
.lc-mascot { height: min(26vh, 230px); aspect-ratio: 220/300; }
.stars-row { display: flex; gap: 1vw; justify-content: center; font-size: clamp(36px, 9vh, 84px); min-height: 1.2em; }
.stars-row .st { filter: grayscale(1) opacity(.35); transition: filter .3s; }
.stars-row .st.on { filter: none; animation: pop .5s; }
.fin-stars { background: #fff; border-radius: 99px; padding: 0 .6em; font-weight: 800; color: #c97a00; font-size: .7em; box-shadow: 0 5px 0 #0002; }
.btn-row { display: flex; gap: 2vw; flex-wrap: wrap; justify-content: center; }

/* ---------- النوافذ ---------- */
.modal { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; background: rgba(20,40,80,.5); backdrop-filter: blur(3px); padding: 2vh 3vw; }
.modal-card { background: linear-gradient(#fff, #f2f9ff); border-radius: 34px; padding: 3vh 4vw; box-shadow: 0 10px 0 #0003, 0 20px 40px #0005; display: flex; flex-direction: column; align-items: center; gap: 2.6vh; max-width: min(96vw, 820px); max-height: 96vh; overflow: auto; animation: stageIn .3s; }
.modal-card h2 { margin: 0; font-size: clamp(26px, 5vh, 46px); }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2vh 2vw; width: 100%; }
.set-btn { position: relative; display: flex; flex-direction: column; align-items: center; gap: .2em; padding: .7em .5em; border-radius: 26px; background: #fff; border: 5px solid var(--green); font-size: clamp(18px, 3.4vh, 30px); font-weight: 800; box-shadow: 0 6px 0 #0002; overflow: hidden; }
.set-btn .ico { font-size: 1.9em; line-height: 1; }
.set-btn .onoff::after { content: '✔ مفعّل'; color: var(--green-d); font-size: .8em; font-style: normal; }
.set-btn[data-on="0"] { border-color: #b8c0d6; filter: grayscale(.7); }
.set-btn[data-on="0"] .onoff::after { content: '✖ متوقف'; color: #7b869f; }
.set-btn.danger { border-color: #ff8a80; }
.set-btn small { font-size: .6em; color: var(--ink-soft); }
.set-btn .hold { position: absolute; bottom: 0; left: 0; height: 8px; width: 0; background: #ff5252; }
.set-btn.holding .hold { width: 100%; transition: width 1.5s linear; }
.help-steps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2vh 2vw; }
.help-steps > div { display: flex; align-items: center; gap: .6em; background: #fff; border-radius: 22px; padding: .5em .8em; box-shadow: 0 4px 0 #0002; font-size: clamp(16px, 3vh, 26px); font-weight: 800; }
.help-steps p { margin: 0; }
.hs-ico { font-size: 2.4em; }

/* ---------- تجاوب ---------- */
@media (orientation: portrait) {
  :root { --mh: min(19vh, 190px); }
  #stage { padding-right: 2vw; padding-bottom: calc(var(--mh) * .92); }
  .game-mascot { right: 2vw; bottom: .5vh; }
  .hud { gap: 2vw; padding: 1vh 3vw; }
  .hud-line { font-size: clamp(14px, 2.4vh, 22px); }
  .set-grid { grid-template-columns: 1fr; }
  .help-steps { grid-template-columns: 1fr; }
  .start-mascot { height: min(34vh, 300px); }
  .map-mascot { height: min(14vh, 130px); }
}
@media (max-height: 520px) and (orientation: landscape) {
  :root { --mh: min(40vh, 190px); }
  .prompt { margin-top: .6vh; }
  .modal-card { padding: 2vh 3vw; gap: 1.6vh; }
  .set-grid { grid-template-columns: repeat(4, 1fr); }
  .set-btn .ico { font-size: 1.4em; }
}
@media (prefers-reduced-motion: reduce) {
  .pulse, .title, .big-title, .deco, .cloud, .sun { animation: none !important; }
}

.speech-bubble{position:relative;background:#fff;border-radius:24px;padding:.4em 1em;font-weight:800;font-size:clamp(18px,3.6vh,32px);box-shadow:0 5px 0 #0002;animation:stageIn .3s;margin-bottom:14px}
.speech-bubble::after{content:'';position:absolute;bottom:-14px;left:50%;margin-left:-14px;border:14px solid transparent;border-top-color:#fff;border-bottom:0}
.map-mascot{display:none}
.hab.zone-h{overflow:hidden}
@media (orientation: portrait) {
  .icon-btn { width: 44px; height: 44px; font-size: 22px; }
  .star-counter { min-height: 44px; font-size: 20px; padding: 0 .6em; }
  .map-title { display: none; }
  .hud { justify-content: space-between; }
  .hud-line { flex-wrap: wrap; font-size: 14px; }
  .prompt { font-size: clamp(16px, 2.6vh, 24px); }
  .map-wrap { padding: 1vh 2vw; }
  .mapboard.portrait { height: auto; width: min(100%, calc((100dvh - 110px) * 9 / 14)); aspect-ratio: 9/14; }
}
