/* بطل الحكاية — شاشة الفصل والتحديات */
.screen-chapter { display: flex; flex-direction: column; }
.screen-chapter[data-mode="story"] { --stage-h: 58%; }
.screen-chapter[data-mode="play"] { --stage-h: clamp(176px, 26dvh, 260px); }
.steps { display: flex; gap: 6px; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, .72); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(38, 51, 74, .22); transition: background .3s, transform .3s; }
.dot.on { background: var(--yellow); box-shadow: 0 0 0 2px #fff; transform: scale(1.2); }
.dot.done { background: var(--green); }

.panel {
  flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; z-index: 3; margin-top: -22px;
  padding: 16px 14px calc(14px + var(--sab)); background: var(--cream); border-radius: 26px 26px 0 0; box-shadow: 0 -6px 18px rgba(0, 0, 0, .16);
}
.say { display: flex; align-items: flex-start; gap: 10px; flex: none; }
.say-av { flex: none; }
.avatar.talk { animation: talkpulse .45s ease-in-out infinite alternate; }
@keyframes talkpulse { to { transform: scale(1.07); } }
.bubble {
  position: relative; flex: 1; min-width: 0; background: #fff; border-radius: 22px; padding: 9px 14px 10px;
  box-shadow: 0 3px 0 rgba(38, 51, 74, .1), 0 8px 16px rgba(38, 51, 74, .08);
}
.bubble::before { content: ''; position: absolute; top: 20px; right: -9px; width: 0; height: 0; border-top: 9px solid transparent; border-bottom: 9px solid transparent; border-left: 10px solid #fff; }
.bubble .who { display: block; font-size: 13px; font-weight: 800; color: var(--terra); }
.bubble .who[data-who="labib"] { color: var(--blue-d); }
.bubble .who[data-who="child"] { color: var(--green-d); }
.bubble .txt { display: block; font-size: 18px; line-height: 1.55; font-weight: 700; color: var(--navy); }
.screen-chapter[data-mode="story"] .bubble .txt { font-size: 21px; line-height: 1.6; }
.screen-chapter[data-mode="story"] .bubble { padding-bottom: 14px; }
.reader-hint {
  flex: none; width: 54px; margin-top: 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 3px 5px; border-radius: 16px;
  background: #FFF3C4; color: var(--navy); font: 800 10.5px/1.2 var(--f-body); text-align: center; box-shadow: inset 0 0 0 2px #fff, 0 2px 0 rgba(0, 0, 0, .08);
}
.reader-hint .ico { width: 20px; height: 20px; color: var(--terra); }
.screen-chapter[data-mode="play"] .bubble { min-height: 112px; }
.act-host { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: 10px; }
.screen-chapter[data-mode="story"] .act-host { display: none; }
.screen-chapter[data-mode="story"] .panel { justify-content: space-between; }
.panel-actions { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 58px; margin-top: 10px; }
.screen-chapter[data-mode="story"] .panel-actions { justify-content: center; }
.hint-slot, .main-slot { display: flex; align-items: center; gap: 8px; }
.pop-in { animation: pop .4s ease-out; }
.act { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; position: relative; }
.ask-host { flex: none; height: 84px; display: flex; align-items: flex-end; justify-content: center; }

/* الأرقام والاختيارات */
.choices { display: flex; gap: 12px; justify-content: center; width: 100%; }
.choice {
  flex: 1; max-width: 96px; height: 76px; border-radius: 22px; background: #fff; border: 4px solid var(--blue);
  font: 800 38px var(--f-head); color: var(--navy); box-shadow: 0 5px 0 rgba(47, 120, 191, .55), 0 8px 14px rgba(38, 51, 74, .12);
}
.choice:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(47, 120, 191, .55); }
.choice.right { background: var(--green); border-color: var(--green-d); color: #fff; box-shadow: 0 5px 0 var(--green-d); animation: pop .4s ease-out; }
.choice:disabled.nope { opacity: .38; box-shadow: none; }
.pulse { animation: pulse .9s ease-in-out infinite; }

/* عدّ الزيتون */
.branch-wrap {
  position: relative; flex: 1; min-height: 170px; border-radius: 24px; overflow: hidden;
  background: linear-gradient(#D9EDF8, #F4F9E8 72%, #E7EFCB); box-shadow: inset 0 0 0 4px #fff, var(--shadow-1);
}
.branch-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.brleaf { position: absolute; width: 36px; pointer-events: none; }
.brleaf svg { width: 100%; display: block; }
.ol { position: absolute; padding: 0; border: 0; background: none; transform-origin: 50% 0; animation: sway 3.4s ease-in-out infinite; touch-action: manipulation; z-index: 2; }
@keyframes sway { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(2.5deg); } }
.ol-art, .ol-art svg { display: block; width: 100%; height: 100%; }
.ol-art svg { filter: drop-shadow(0 3px 2px rgba(60, 50, 20, .28)); overflow: visible; }
.ol .num { position: absolute; left: 50%; top: 58%; translate: -50% -50%; font-family: var(--f-head); font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .4); pointer-events: none; opacity: 0; transition: opacity .2s; }
.ol.counted .num { opacity: 1; }
.ol.counted .ol-art svg { filter: drop-shadow(0 0 7px rgba(242, 200, 74, .95)) drop-shadow(0 3px 2px rgba(60, 50, 20, .28)); }
.ol.hint { animation: wiggle .6s ease-in-out infinite; }
.ol.hint .ol-art svg { filter: drop-shadow(0 0 10px #E54837); }
.branch-wrap.done .ol { animation: none; pointer-events: none; }

/* السلة */
.act-basket { gap: 8px; }
.goal-row { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.goal { display: flex; align-items: center; gap: 8px; padding: 3px 16px; border-radius: 999px; background: var(--yellow); box-shadow: 0 3px 0 var(--yellow-d); font: 800 17px var(--f-head); }
.goal b { font-size: 30px; line-height: 1; color: var(--red); }
.live { display: flex; align-items: center; gap: 6px; padding: 3px 14px; border-radius: 999px; background: #fff; box-shadow: var(--shadow-1); font: 800 15px var(--f-head); }
.live b { font-size: 26px; line-height: 1; color: var(--blue-d); }
.pile {
  position: relative; flex: 1; min-height: 0; border-radius: 22px;
  background: repeating-linear-gradient(135deg, #F3E6C7 0 12px, #EDDDB6 12px 24px); box-shadow: inset 0 0 0 3px #fff, inset 0 5px 12px rgba(120, 90, 30, .2);
}
.zone-label { position: absolute; top: 5px; inset-inline-start: 12px; font: 700 12px var(--f-body); font-style: normal; color: #a68f5b; pointer-events: none; }
.basket {
  position: relative; flex: 1.1; min-height: 0; border-radius: 16px 16px 36px 36px; border: 5px solid #8B5A24;
  background: repeating-linear-gradient(90deg, #C48A3E 0 14px, #B87B30 14px 28px); box-shadow: 0 6px 0 #6e4519, 0 10px 18px rgba(0, 0, 0, .22);
  transition: transform .15s, filter .15s;
}
.basket .zone-label { color: #f7dba4; z-index: 1; top: 3px; }
.basket-in { position: absolute; inset: 14px 10px 14px; border-radius: 10px 10px 26px 26px; background: #6f4a22; box-shadow: inset 0 6px 12px rgba(0, 0, 0, .38); }
.basket.over { transform: scale(1.03); filter: brightness(1.12); }
.olive-layer { position: absolute; inset: 0; pointer-events: none; }
.dol { position: absolute; left: 0; top: 0; pointer-events: auto; touch-action: none; cursor: grab; transition: transform .3s cubic-bezier(.3, 1.3, .5, 1); will-change: transform; }
.dol.drag { transition: none; z-index: 20; cursor: grabbing; }
.dol.drag .ol-art { transform: scale(1.2); filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .3)); }
.dol .ol-art { transition: transform .15s; }
.dol .ol-art svg { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.dol .num { position: absolute; left: 50%; top: 58%; translate: -50% -50%; font-family: var(--f-head); font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .45); pointer-events: none; font-size: 18px; }
.dol.glow .ol-art { animation: glowpulse .5s ease; }
@keyframes glowpulse { 50% { transform: scale(1.35); filter: drop-shadow(0 0 10px #F2C84A); } }

/* مقارنة وجمع وطرح */
.act-cmp, .act-arith { justify-content: flex-start; }
.cmp-row { display: flex; gap: 12px; flex: 1; min-height: 0; }
.cmp-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px 8px; border-radius: 26px; background: #fff;
  border: 5px solid #E8DCC0; box-shadow: var(--shadow-1); min-width: 0;
}
.cmp-card:active { transform: translateY(2px); }
.cmp-name { font: 800 18px var(--f-head); color: var(--terra); }
.cmp-card .group, .eq-card .group { flex: 1; display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; align-content: center; }
.mini { position: relative; display: block; width: var(--m); height: calc(var(--m) * 1.3); }
.mini svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1px rgba(60, 50, 20, .25)); }
.mini.glow svg { animation: glowpulse .5s ease; filter: drop-shadow(0 0 8px #F2C84A); }
.mini.gone { opacity: .4; filter: grayscale(1); }
.mini.gone::after { content: '×'; position: absolute; inset: 0; display: grid; place-items: center; font: 800 calc(var(--m) * 1.1) var(--f-head); color: var(--red); }
.cmp-num { font: 800 34px/1 var(--f-head); font-style: normal; color: var(--blue-d); opacity: 0; height: 36px; transition: opacity .3s; }
.cmp-card.show-num .cmp-num { opacity: 1; }
.cmp-card.right { border-color: var(--green); background: #F3F8E4; animation: pop .4s ease-out; }
.cmp-card.nope { opacity: .5; filter: grayscale(.5); }
.eq-row { display: flex; align-items: stretch; justify-content: center; gap: 8px; flex: 1; min-height: 0; }
.eq-card { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 12px 6px 8px; border-radius: 24px; background: #fff; border: 4px solid #E8DCC0; box-shadow: var(--shadow-1); min-width: 0; }
.eq-op { align-self: center; font: 800 46px var(--f-head); color: var(--red); }
.eq-n { font: 800 20px var(--f-head); font-style: normal; color: var(--blue-d); }

/* كشف الصفحة والوسام */
.reveal { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, rgba(70, 90, 120, .85), rgba(38, 51, 74, .94)); overflow: hidden; }
.reveal-say { display: flex; align-items: center; gap: 10px; width: 100%; color: #fff; }
.reveal-say p { margin: 0; font-size: 16px; line-height: 1.55; font-weight: 700; background: rgba(255, 255, 255, .14); padding: 8px 12px; border-radius: 16px; flex: 1; }
.reveal-in { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 86%; position: relative; }
.page-card { width: 100%; padding: 14px 14px 16px; text-align: center; background: #fffaf0; border-radius: 10px 26px 26px 10px; border-right: 12px solid var(--terra); box-shadow: 0 16px 36px rgba(0, 0, 0, .45); transform: rotate(-2deg); }
.page-tag { font-size: 13px; font-weight: 800; color: var(--terra); }
.page-img { height: clamp(120px, 24dvh, 230px); margin: 8px 0; border: 4px solid #fff; border-radius: 16px; background-size: cover; background-position: center; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); }
.page-title { font-size: 28px; color: var(--blue-d); }
.page-text { margin: 4px 0 0; font-size: 16px; line-height: 1.65; font-weight: 600; color: var(--navy); }
.medal { display: flex; align-items: center; gap: 8px; padding: 8px 20px 8px 14px; background: var(--yellow); color: var(--navy); border: 3px solid #fff; border-radius: 999px; box-shadow: 0 5px 0 var(--yellow-d); font: 800 20px var(--f-head); }
.medal .ico { width: 30px; height: 30px; color: #fff; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25)); }

@media (max-height: 700px) {
  .screen-chapter[data-mode="play"] { --stage-h: clamp(128px, 20dvh, 200px); }
  .screen-chapter[data-mode="play"] .panel { padding-top: 12px; }
  .goal-row .goal b { font-size: 26px; }
  .screen-chapter[data-mode="play"] .bubble { min-height: 96px; }
  .page-img { height: 110px; }
  .reveal-in { gap: 10px; }
  .bubble .txt { font-size: 16px; }
  .screen-chapter[data-mode="story"] .bubble .txt { font-size: 18px; }
  .choice { height: 64px; font-size: 32px; }
  .ask-host { height: 72px; }
}

@supports not (height: 1dvh) {
  .screen-chapter[data-mode="play"] { --stage-h: clamp(176px, 26vh, 260px); }
  .page-img { height: clamp(120px, 24vh, 230px); }
}

/* ================= الفصل الثاني: ألوان حديقة الجدة ================= */
.gi { display: block; position: relative; width: var(--is, 64px); height: var(--is, 64px); flex: none; }
.gi svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1.5px rgba(60, 50, 20, .28)); }
.gi .pf { fill: var(--pc); stroke: var(--pd); stroke-width: 2.5; stroke-linejoin: round; transition: fill .5s, stroke .5s; }
.gi .st { fill: var(--c); stroke: rgba(0, 0, 0, .18); stroke-width: 1.5; transition: fill .5s; }
.gi .stk { stroke: var(--c); transition: stroke .5s; }
.gi.gray .st { fill: #CBC6BA; }
.gi.gray .stk { stroke: #BDB8AC; }
.gi.fly { position: absolute; left: 0; top: 0; z-index: 30; pointer-events: none; will-change: transform; }
.gi.fly svg { filter: drop-shadow(0 10px 7px rgba(0, 0, 0, .3)); }

/* تلوين */
.act-paint { gap: 8px; justify-content: space-between; }
.paint-grid { flex: 1; min-height: 0; display: flex; flex-wrap: wrap; gap: 10px 10px; justify-content: center; align-content: center; padding: 2px 0; }
.pitem {
  --is: clamp(56px, 10dvh, 84px); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 6px; min-width: calc(var(--is) + 22px);
  border-radius: 22px; background: #fff; border: 4px solid #E8DCC0; box-shadow: var(--shadow-1); touch-action: manipulation; transition: border-color .25s, background .25s;
}
.pitem .pname { font: 700 13px var(--f-body); color: var(--navy); white-space: nowrap; }
.pitem.target { border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(242, 200, 74, .5), var(--shadow-1); animation: pulse 1.3s ease-in-out infinite; }
.pitem.painted { border-color: var(--green); background: #F3F8E4; animation: none; }
.act-paint.c3 .pitem { --is: clamp(64px, 12dvh, 88px); }
.act-paint.c3 .pitem .pname { font-size: 15px; }
.act-paint.c4 .pitem { --is: clamp(62px, 11.5dvh, 96px); }
.palette.p8 { display: grid; grid-template-columns: repeat(4, max-content); justify-content: center; }
.palette { flex: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 8px 8px; border-radius: 22px; background: repeating-linear-gradient(135deg, #F3E6C7 0 12px, #EDDDB6 12px 24px); box-shadow: inset 0 0 0 3px #fff, inset 0 4px 10px rgba(120, 90, 30, .18); }
.swatch {
  --ss: clamp(38px, 6.4dvh, 50px); width: var(--ss); height: var(--ss); padding: 0; border-radius: 50%; background: var(--sc); border: 4px solid #fff;
  box-shadow: 0 0 0 2px var(--sd), 0 4px 0 var(--sd); display: grid; place-items: center; color: #fff; touch-action: manipulation; transition: transform .15s;
}
.swatch .ico { width: 55%; height: 55%; opacity: 0; stroke-width: 3.2; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .4)); transition: opacity .15s; }
.swatch.on { transform: translateY(-4px) scale(1.14); box-shadow: 0 0 0 3px var(--navy), 0 6px 0 var(--sd); }
.swatch.on .ico { opacity: 1; }
.act-paint.alive .pitem { background: #F3F8E4; }

/* تصنيف في أصص */
.act-sort { gap: 8px; }
.spile {
  flex: 1; min-height: 0; display: flex; flex-wrap: wrap; gap: 6px 8px; justify-content: center; align-content: center; padding: 8px; border-radius: 22px;
  background: repeating-linear-gradient(135deg, #F3E6C7 0 12px, #EDDDB6 12px 24px); box-shadow: inset 0 0 0 3px #fff, inset 0 5px 12px rgba(120, 90, 30, .2);
}
.spile.gone { display: none; }
.sitem { padding: 3px; border-radius: 16px; touch-action: none; cursor: grab; transition: transform .15s, background .15s, box-shadow .15s; }
.sitem.sel { background: rgba(255, 255, 255, .85); box-shadow: 0 0 0 4px var(--yellow); transform: scale(1.08); }
.sitem.lift { opacity: .28; }
.pots { flex: none; display: flex; gap: 8px; align-items: stretch; justify-content: center; }
.act-sort.sorted { justify-content: center; }
.act-sort.sorted .pot-items { min-height: clamp(110px, 24dvh, 190px); align-content: center; align-items: center; gap: 4px; }
.act-sort.sorted .pmini { --is: calc(var(--ps) * 1.4); }
.pot { --ps: 34px; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; padding: 0; border: 0; background: none; touch-action: manipulation; transition: transform .15s, filter .15s; }
.act-sort.n3 .pot { --ps: 30px; }
.act-sort.n4 .pot { --ps: 24px; }
.pot-items {
  flex: 1; min-height: calc(var(--ps) * 2 + 12px); display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; align-content: flex-end; padding: 4px 3px 2px;
  background: rgba(255, 255, 255, .6); border: 3px dashed #D9C89B; border-bottom: 0; border-radius: 16px 16px 0 0;
}
.pmini { --is: var(--ps); }
.pot-body {
  display: flex; align-items: center; justify-content: center; gap: 5px; padding: 6px 6px 7px; border-radius: 0 0 22px 22px; color: #fff; font: 800 15px var(--f-head);
  background: linear-gradient(#D4825A, #BE6A40); box-shadow: 0 4px 0 #8f4a2a; text-shadow: 0 1px 0 rgba(0, 0, 0, .25); min-width: 0;
}
.act-sort.n4 .pot-body { font-size: 13px; gap: 3px; padding: 5px 3px 6px; }
.pdot { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .25); }
.pot { position: relative; }
.pcount {
  position: absolute; z-index: 2; top: -10px; left: 50%; translate: -50% 0; min-width: 32px; height: 32px; padding: 0 4px; border-radius: 16px; display: grid; place-items: center;
  background: #fff; border: 3px solid var(--navy); box-shadow: 0 3px 0 rgba(0, 0, 0, .22); font: 800 19px/1 var(--f-head); color: var(--navy); animation: pop .35s ease-out;
}
.pcount:empty { display: none; }
.pot.counted .pot-items { padding-top: 24px; }
.pot.over { transform: scale(1.05); filter: brightness(1.1); }
.pot.nope { opacity: .5; }
.pot.right .pot-body { background: linear-gradient(var(--green), var(--green-d)); }
.pots.askable .pot { cursor: pointer; }

/* تسلسل لوني / العنصر المختلف */
.act-pattern { gap: 8px; justify-content: flex-start; }
.pat-prog { flex: none; display: flex; gap: 8px; justify-content: center; }
.pat-prog .pd { width: 12px; height: 12px; border-radius: 50%; background: rgba(38, 51, 74, .2); transition: background .3s; }
.pat-prog .pd.on { background: var(--yellow); box-shadow: 0 0 0 2px #fff; }
.pat-prog .pd.done { background: var(--green); }
.act-pattern { justify-content: center; gap: 22px; }
.pat-stage { flex: none; display: flex; align-items: center; justify-content: center; }
.seq-row { --is: clamp(32px, 5.8dvh, 46px); max-width: calc(5 * (var(--is) + 12px) + 4 * 8px + 2px); }
.seq-row.one-row { --is: clamp(28px, 5dvh, 38px); max-width: 100%; flex-wrap: nowrap; gap: 6px; }
.odd-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: min(100%, 300px); }
.oddb { --is: clamp(60px, 11dvh, 92px); aspect-ratio: 1.15; border-radius: 26px; background: #fff; border: 5px solid #E8DCC0; box-shadow: var(--shadow-1); display: grid; place-items: center; touch-action: manipulation; }
.oddb:active { transform: translateY(2px); }
.oddb.right { border-color: var(--green); background: #F3F8E4; animation: pop .4s ease-out; }
.oddb.nope { opacity: .4; }
.oddb.dim { opacity: .4; }
.seq-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 100%; }
.seq-slot { width: calc(var(--is) + 12px); height: calc(var(--is) + 12px); border-radius: 50%; background: #fff; border: 3px solid #E8DCC0; display: grid; place-items: center; box-shadow: var(--shadow-1); transition: box-shadow .2s; }
.seq-slot.gap { border: 3px dashed var(--blue); background: #EAF4FD; box-shadow: none; }
.seq-slot.gap b { font: 800 28px var(--f-head); color: var(--blue-d); }
.seq-slot.filled { border-color: var(--green); }
.seq-slot.glow { box-shadow: 0 0 0 5px var(--yellow); }
.pat-choices { flex: none; display: flex; gap: 12px; justify-content: center; align-items: flex-end; }
.popt { --is: 46px; flex: 1; max-width: 92px; height: 76px; border-radius: 22px; background: #fff; border: 4px solid var(--blue); box-shadow: 0 5px 0 rgba(47, 120, 191, .55), 0 8px 14px rgba(38, 51, 74, .12); display: grid; place-items: center; touch-action: manipulation; }
.popt:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(47, 120, 191, .55); }
.popt.right { background: #F3F8E4; border-color: var(--green-d); box-shadow: 0 5px 0 var(--green-d); animation: pop .4s ease-out; }
.popt:disabled, .popt.nope { opacity: .38; box-shadow: none; }

@supports not (height: 1dvh) {
  .pitem { --is: clamp(56px, 10vh, 84px); }
  .swatch { --ss: clamp(38px, 6.4vh, 50px); }
  .oddb { --is: clamp(60px, 11vh, 92px); }
  .seq-row { --is: clamp(32px, 5.8vh, 46px); }
}
@media (max-height: 700px) {
  .pitem { --is: clamp(50px, 9dvh, 68px); padding: 5px 8px 4px; }
  .paint-grid { gap: 6px 10px; }
  .palette { padding: 6px; gap: 6px; }
  .swatch { --ss: 38px; }
  .spile { padding: 5px; gap: 3px 5px; }
  .pot-items { min-height: calc(var(--ps) * 2 + 4px); }
  .seq-row { gap: 6px; }
  .act-pattern { gap: 14px; }
  .popt { height: 64px; --is: 40px; }
}

/* ================= الفصل الثالث: بيت الأشكال التراثي ================= */
.act > .fly { position: absolute; left: 0; top: 0; z-index: 30; pointer-events: none; will-change: transform; transition: none !important; margin: 0; }
.act > .fly.sitem, .act > .fly.tpiece, .act > .fly.eopt { box-shadow: 0 12px 16px rgba(0, 0, 0, .25); background: rgba(255, 255, 255, .92); }
.lift { opacity: .28; }

/* مطابقة الأشكال */
.act-shapes { gap: 8px; }
.act-shapes .ask-host:empty { display: none; }
.sitem.obj { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 4px 3px 3px; width: calc(var(--is) + 18px); }
.ob-art { width: var(--is); height: var(--is); flex: none; }
.ob-art svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1.5px rgba(60, 50, 20, .3)); }
.ob-name { display: block; min-height: 2.3em; font: 700 11px/1.15 var(--f-body); color: var(--navy); text-align: center; max-width: 100%; }
.bins { flex: none; display: flex; gap: 8px; align-items: stretch; justify-content: center; }
.bin { --ps: 34px; position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: stretch; padding: 0; border: 0; background: none; touch-action: manipulation; transition: transform .15s, filter .15s; }
.act-shapes.n4 .bin { --ps: 28px; }
.act-shapes.n5 .bin { --ps: 23px; }
.bin-items {
  flex: 1; min-height: calc(var(--ps) * 2 + 10px); display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; align-content: flex-end; padding: 4px 3px 2px;
  background: rgba(255, 255, 255, .65); border: 3px dashed #D9C89B; border-bottom: 0; border-radius: 16px 16px 0 0;
}
.ob-mini { width: var(--ps); height: var(--ps); }
.ob-mini .ob-art { width: 100%; height: 100%; }
.bin-head {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 5px 3px 6px; border-radius: 0 0 22px 22px; color: #fff; font: 800 14px var(--f-head);
  background: linear-gradient(#5F7FA6, #46628A); box-shadow: 0 4px 0 #2F4668; text-shadow: 0 1px 0 rgba(0, 0, 0, .25); min-width: 0;
}
.act-shapes.n5 .bin-head { font-size: 12px; padding: 4px 1px 5px; }
.bin-ico { display: block; width: 34px; height: 34px; background: #fff; border-radius: 50%; padding: 3px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); }
.act-shapes.n5 .bin-ico { width: 28px; height: 28px; padding: 2px; }
.bin-ico svg { display: block; width: 100%; height: 100%; }
.bin.over { transform: scale(1.05); filter: brightness(1.1); }
.bin.nope { opacity: .5; }
.bin.right .bin-head { background: linear-gradient(var(--green), var(--green-d)); }
.bins.askable .bin { cursor: pointer; }
.act-shapes.sorted { justify-content: center; }
.act-shapes.sorted .bin-items { min-height: clamp(100px, 22dvh, 180px); align-content: center; align-items: center; gap: 4px; }
.act-shapes.n4.sorted .bin-items, .act-shapes.n5.sorted .bin-items { min-height: clamp(86px, 15dvh, 128px); }
.act-shapes.sorted .ob-mini { width: calc(var(--ps) * 1.35); height: calc(var(--ps) * 1.35); }

/* تركيب البيت الحجري / اللوحة */
.act-compose { gap: 8px; justify-content: space-between; }
.cmp-board { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board-svg { display: block; height: 100%; width: auto; max-width: 100%; max-height: 100%; border-radius: 14px; box-shadow: 0 0 0 4px #fff, var(--shadow-1); transition: filter .5s; overflow: visible; }
.slot-sh { transform-box: fill-box; transform-origin: center; }
.slot:not(.filled) .slot-sh { fill: rgba(255, 255, 255, .6); stroke: rgba(38, 51, 74, .5); stroke-width: 2.4; stroke-dasharray: 5 4; cursor: pointer; }
.slot.filled .slot-sh { stroke-width: 2.6; filter: drop-shadow(0 2px 1.2px rgba(40, 30, 10, .35)); }
.slot.over:not(.filled) .slot-sh { fill: rgba(71, 154, 230, .28); stroke: #2F78BF; stroke-width: 3.6; }
.slot.hl .slot-sh { animation: slotpulse .9s ease-in-out infinite; stroke: #E54837; stroke-width: 3.6; }
@keyframes slotpulse { 50% { transform: scale(1.1); fill: rgba(242, 200, 74, .55); } }
.slot .deco { opacity: 0; transition: opacity .5s .2s; pointer-events: none; }
.slot.filled .deco { opacity: 1; }
.tray {
  flex: none; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; padding: 8px; border-radius: 22px;
  background: repeating-linear-gradient(135deg, #F3E6C7 0 12px, #EDDDB6 12px 24px); box-shadow: inset 0 0 0 3px #fff, inset 0 4px 10px rgba(120, 90, 30, .2);
}
.tpiece { --ts: clamp(46px, 8.6dvh, 62px); width: var(--ts); height: var(--ts); padding: 3px; border-radius: 16px; background: rgba(255, 255, 255, .72); display: grid; place-items: center; cursor: grab; touch-action: none; transition: transform .15s, background .15s, box-shadow .15s; }
.tp-art { width: 100%; height: 100%; }
.tp-art svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1.5px rgba(60, 50, 20, .3)); }
.tpiece.sel { background: #fff; box-shadow: 0 0 0 4px var(--yellow); transform: scale(1.08); }
.act-compose.alive .board-svg { filter: drop-shadow(0 0 14px rgba(242, 200, 74, .95)); animation: pop .5s ease-out; }
.act-compose.alive .tray { display: none; }

/* نمط التطريز */
.act-embroid { justify-content: center; gap: 22px; }
.emb-wrap { flex: none; display: flex; justify-content: center; }
.emb-strip {
  position: relative; width: 100%; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 5px; padding: 20px 9px; border-radius: 16px; background: #FFF8EB;
  box-shadow: inset 0 0 0 3px #fff, var(--shadow-1);
}
.emb-strip::before, .emb-strip::after { content: ''; position: absolute; left: 10px; right: 10px; height: 5px; border-radius: 3px; background: repeating-linear-gradient(90deg, var(--red) 0 9px, transparent 9px 15px); }
.emb-strip::before { top: 7px; }
.emb-strip::after { bottom: 7px; background: repeating-linear-gradient(90deg, var(--blue) 0 9px, transparent 9px 15px); }
.ecell { aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; transition: background .2s, box-shadow .2s; }
.ecell svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1.5px rgba(60, 50, 20, .28)); }
.ecell.gap { border: 3px dashed var(--blue); background: #EAF4FD; }
.ecell.gap b { font: 800 22px var(--f-head); color: var(--blue-d); }
.ecell.active { box-shadow: 0 0 0 3px var(--yellow); animation: pulse 1.2s ease-in-out infinite; }
.ecell.over { background: #D6EBFB; transform: scale(1.12); }
.ecell.glow { box-shadow: 0 0 0 4px var(--yellow); background: #FFF6D8; }
.emb-opts { flex: none; display: flex; gap: 12px; justify-content: center; align-items: flex-end; flex-wrap: wrap; }
.eopt {
  width: clamp(54px, 9.6dvh, 74px); aspect-ratio: 1; padding: 8px; border-radius: 20px; background: #fff; border: 4px solid var(--blue); cursor: grab; display: grid; place-items: center; touch-action: none;
  box-shadow: 0 5px 0 rgba(47, 120, 191, .55), 0 8px 14px rgba(38, 51, 74, .12); box-sizing: border-box;
}
.eo-art { width: 100%; height: 100%; }
.eo-art svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 1.5px rgba(60, 50, 20, .28)); }
.eopt:active { transform: translateY(2px); }

@supports not (height: 1dvh) {
  .tpiece { --ts: clamp(46px, 8.6vh, 62px); }
  .eopt { width: clamp(54px, 9.6vh, 74px); }
  .act-shapes.sorted .bin-items { min-height: clamp(100px, 22vh, 180px); }
}
@media (max-height: 700px) {
  .ob-name { font-size: 10px; }
  .tray { padding: 5px; gap: 5px; }
  .act-embroid { gap: 14px; }
  .emb-strip { padding: 17px 8px; }
}

/* ================= الفصل الرابع: حكاية الزيتونة الصغيرة ================= */
.act-order, .act-seqfill { gap: 14px; justify-content: center; }
.sq-wrap, .sq-opts { display: flex; flex-direction: column; }
.ord-strip, .ord-pile {
  display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 8px; align-self: center;
  width: calc(100% - 14px); max-width: calc(var(--n) * 116px + (var(--n) - 1) * 8px);
}
.ord-strip { border-radius: 16px; box-shadow: 0 0 0 7px rgba(255, 255, 255, .72); background: rgba(255, 255, 255, .72); margin: 7px 0; }
.sq-wrap .ord-strip, .sq-opts .ord-pile { align-self: center; margin-inline: auto; }
.oslot {
  position: relative; aspect-ratio: 1; border-radius: 12px; border: 3px dashed #D9C89B; background: #FFFBF0; display: grid; place-items: center;
  transition: transform .2s, background .2s, box-shadow .2s;
}
.oslot .onum { font: 800 clamp(20px, 6vw, 28px) var(--f-head); color: #C8B67F; line-height: 1; }
.oslot.filled { border: 3px solid #fff; background: #fff; box-shadow: 0 3px 7px rgba(0, 0, 0, .22); overflow: hidden; }
.oslot.filled .onum {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--yellow); color: var(--navy);
  font: 800 14px/22px var(--f-head); text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); z-index: 2;
}
.oimg, .oimg svg, .ocard svg { display: block; width: 100%; height: 100%; }
.oslot.over { background: #FFF3C4; transform: scale(1.07); }
.oslot.glow { box-shadow: 0 0 0 4px var(--yellow), 0 3px 7px rgba(0, 0, 0, .22); transform: scale(1.05); }
.oslot.hl { border-color: var(--yellow); animation: pulse 1.1s ease-in-out infinite; }
.oslot.gap { border-color: var(--blue); background: #EAF4FD; }
.oslot.gap b { font: 800 clamp(26px, 8vw, 36px) var(--f-head); color: var(--blue-d); line-height: 1; }
.oslot.gap.active { box-shadow: 0 0 0 3px var(--yellow); animation: pulse 1.2s ease-in-out infinite; }
.oslot.gap.over { background: #D6EBFB; }
.ocard {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 3px solid #fff; background: #fff;
  box-shadow: 0 3px 7px rgba(0, 0, 0, .25); touch-action: none; cursor: grab; transition: transform .15s, box-shadow .15s; user-select: none; -webkit-user-select: none;
}
.ocard:active { transform: translateY(2px); }
.ocard.sel { transform: translateY(-5px) scale(1.07); box-shadow: 0 0 0 4px var(--yellow), 0 8px 12px rgba(0, 0, 0, .25); }
.ocard.gone { visibility: hidden; }
.ocard.pulse { animation: pulse 1.1s ease-in-out infinite; box-shadow: 0 0 0 4px var(--yellow), 0 3px 7px rgba(0, 0, 0, .25); }
.act > .fly.ocard { box-shadow: 0 12px 16px rgba(0, 0, 0, .28); }
@media (max-height: 700px) {
  .ord-strip, .ord-pile { max-width: calc(var(--n) * 92px + (var(--n) - 1) * 8px); }
  .act-order, .act-seqfill { gap: 10px; }
}

/* ================= الفصل الخامس: عين البطل (اكتشاف الفروقات) ================= */
.screen-chapter.compact[data-mode="play"] { --stage-h: clamp(92px, 15dvh, 150px); }
.screen-chapter.compact[data-mode="play"] .panel { padding-top: 12px; }
.screen-chapter.compact[data-mode="play"] .bubble { min-height: 76px; padding: 7px 12px 8px; }
.screen-chapter.compact[data-mode="play"] .bubble .txt { font-size: 16.5px; line-height: 1.45; }
.screen-chapter.compact[data-mode="play"] .act-host { padding-top: 6px; }
.screen-chapter.compact[data-mode="play"] .panel-actions { margin-top: 6px; min-height: 52px; }
.act-find { align-items: center; justify-content: flex-start; gap: 8px; }
.find-bar {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 3px 14px 3px 12px; border-radius: 999px;
  background: #fff; box-shadow: 0 2px 0 rgba(38, 51, 74, .1), 0 4px 10px rgba(38, 51, 74, .08);
}
.find-stars { display: flex; gap: 3px; }
.fstar { display: block; width: 24px; height: 24px; }
.fstar svg { display: block; width: 100%; height: 100%; fill: #E8E1CD; stroke: #C9BFA6; stroke-width: 1.6; transition: fill .3s, stroke .3s; }
.fstar.on svg { fill: var(--yellow); stroke: var(--yellow-d); }
.find-count { font: 800 16px var(--f-head); color: var(--navy); min-width: 38px; text-align: center; }
.find-imgs { flex: none; display: flex; flex-direction: column; align-items: center; gap: 8px; --fw: 100%; --fh: 66%; width: 100%; }
.find-img {
  position: relative; flex: none; width: var(--fw); height: var(--fh); border-radius: 14px; overflow: hidden; background: #DDE9C4;
  box-shadow: 0 0 0 4px #fff, 0 5px 12px rgba(38, 51, 74, .22); cursor: pointer; touch-action: manipulation;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.fi-art, .fi-art svg, .fi-mark { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.fi-mark { overflow: visible; pointer-events: none; }
.fi-mark .ring { transform-box: view-box; }
.fi-mark .hintring { animation: ringpulse .9s ease-in-out infinite alternate; }
@keyframes ringpulse { from { opacity: .55; } to { opacity: 1; } }
.fi-mark .got circle:first-child { stroke-width: 8; }
@media (max-height: 700px) {
  .screen-chapter.compact[data-mode="play"] { --stage-h: clamp(78px, 13dvh, 110px); }
  .screen-chapter.compact[data-mode="play"] .bubble { min-height: 66px; }
  .screen-chapter.compact[data-mode="play"] .bubble .txt { font-size: 15px; }
  .fstar { width: 20px; height: 20px; }
}

/* ================= نهاية القصة: كتاب تيتا، السرّ، الوسام، الشهادة ================= */
.stage-actors { transition: opacity .35s; }
.stage-actors.away { opacity: 0; pointer-events: none; }
.fin-layer { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: calc(54px + var(--sat)) 16px 18px; pointer-events: none; }
.fbook { position: relative; height: min(100%, 340px); aspect-ratio: 0.84; max-width: 100%; perspective: 1200px; }
.fb-page, .fb-cover { position: absolute; inset: 0; transform-origin: right center; border-radius: 16px 5px 5px 16px; backface-visibility: hidden; }
.fb-page {
  background: #FFFDF6; padding: 10px 10px 9px 12px; display: flex; flex-direction: column; gap: 5px; border: 3px solid #fff;
  box-shadow: 5px 0 0 #E9DDBB, 9px 0 0 #fff, 13px 0 0 #DCCB98, 0 10px 20px rgba(38, 51, 74, .3);
}
.fb-img { flex: 1 1 0; min-height: 0; border-radius: 10px; background-size: cover; background-position: center; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .22); }
.fb-t { font: 800 clamp(15px, 4.4vw, 19px)/1.2 var(--f-head); color: var(--blue-d); text-align: center; }
.fb-c { font: 700 clamp(12px, 3.5vw, 14.5px)/1.35 var(--f-body); color: var(--navy); text-align: center; }
.fb-no { position: absolute; top: 7px; left: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; background: var(--yellow); color: var(--navy); font: 800 15px/26px var(--f-head); text-align: center; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.fb-cover {
  background: linear-gradient(160deg, #5BAAEC, #2F78BF); border: 4px solid #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #fff; text-align: center; padding: 14px;
  box-shadow: 5px 0 0 #1F5E9E, 0 10px 20px rgba(38, 51, 74, .35);
}
.fb-cover::after { content: ''; position: absolute; inset: 8px; border: 3px dashed rgba(255, 255, 255, .55); border-radius: 11px 3px 3px 11px; pointer-events: none; }
.fb-logo { width: 66%; max-height: 40%; object-fit: contain; background: var(--cream); border-radius: 16px; padding: 6px 8px; box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.fb-cover b { font: 800 clamp(24px, 7.4vw, 32px)/1.1 var(--f-head); text-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.fb-cover span { font: 700 clamp(13px, 3.8vw, 16px) var(--f-body); opacity: .95; }

.fin-secret { flex-direction: column; gap: 14px; }
.fs-head { font: 800 clamp(24px, 7.5vw, 32px)/1.2 var(--f-head); color: #fff; background: var(--red); padding: 3px 22px 7px; border-radius: 999px; border: 3px solid #fff; box-shadow: 0 4px 0 var(--red-d), 0 8px 14px rgba(0, 0, 0, .25); }
.fs-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px 10px; max-width: 360px; }
.fs-chip { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100px; padding: 8px 4px 7px; border-radius: 18px; background: rgba(255, 255, 255, .95); box-shadow: 0 3px 0 rgba(38, 51, 74, .12), 0 6px 12px rgba(38, 51, 74, .2); }
.fs-chip span { font: 800 14.5px/1.2 var(--f-head); color: var(--navy); text-align: center; }
.fs-disc { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 3px solid #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); }
.fs-disc .ico { width: 26px; height: 26px; }
.fin-bunting { position: absolute; left: 0; right: 0; top: calc(46px + var(--sat)); height: 54px; z-index: 3; pointer-events: none; transform-origin: top; }
.fin-bunting svg { display: block; width: 100%; height: 100%; }

.fin-end { position: absolute; inset: 0; z-index: 40; overflow-y: auto; -webkit-overflow-scrolling: touch; background: radial-gradient(circle at 50% 14%, rgba(70, 90, 120, .94), rgba(38, 51, 74, .98)); }
.fe-in { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: calc(18px + var(--sat)) 18px calc(22px + var(--sab)); }
.fe-medal { position: relative; flex: none; width: 96px; height: 114px; }
.fe-disc {
  position: absolute; left: 50%; top: 0; translate: -50% 0; z-index: 2; width: 82px; height: 82px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 6px solid #fff;
  background: radial-gradient(circle at 35% 30%, #FFE9A0, #F2C84A 55%, #C9A12C); box-shadow: 0 6px 0 var(--yellow-d), 0 12px 22px rgba(0, 0, 0, .35);
}
.fe-disc .ico { width: 46px; height: 46px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .25)); }
.fe-rb { position: absolute; top: 60px; z-index: 1; width: 30px; height: 52px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); }
.fe-rb.r1 { left: 20px; background: var(--red); transform: rotate(14deg); }
.fe-rb.r2 { right: 20px; background: var(--blue); transform: rotate(-14deg); }
.fe-title { font: 800 clamp(22px, 6.4vw, 28px)/1.2 var(--f-head); color: var(--yellow); text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.fe-msg { margin: 0; color: #fff; font: 700 15.5px/1.5 var(--f-body); text-align: center; max-width: 340px; }
.cert-frame { flex: none; width: min(100%, 276px); aspect-ratio: 1080 / 1527; border-radius: 10px; background: #fff; box-shadow: 0 0 0 5px #fff, 0 10px 26px rgba(0, 0, 0, .45); display: grid; place-items: center; overflow: hidden; }
.cert-img { display: block; width: 100%; height: 100%; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; pointer-events: auto; }
.cert-wait { color: var(--navy); font: 700 15px var(--f-body); padding: 16px; text-align: center; }
.cert-tip { margin: 0; max-width: 320px; font: 600 13px/1.5 var(--f-body); color: rgba(255, 255, 255, .85); text-align: center; }
.fe-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
@media (max-height: 700px) {
  .fe-in { gap: 9px; }
  .fe-medal { width: 80px; height: 94px; }
  .fe-disc { width: 68px; height: 68px; border-width: 5px; }
  .fe-disc .ico { width: 38px; height: 38px; }
  .fe-rb { top: 50px; width: 26px; height: 44px; }
  .fe-rb.r1 { left: 16px; } .fe-rb.r2 { right: 16px; }
  .cert-frame { width: min(100%, 236px); }
  .fe-msg { font-size: 14.5px; }
  .fbook { height: min(100%, 270px); }
  .fs-chip { width: 92px; padding: 6px 3px 5px; }
  .fs-disc { width: 38px; height: 38px; }
  .fs-disc .ico { width: 22px; height: 22px; }
  .fs-row { gap: 7px 8px; }
  .fs-head { font-size: 22px; }
}
