@font-face{font-family:"KufiT";src:url(assets/fonts/kufi800.woff2) format("woff2");font-weight:800;font-display:swap}
@font-face{font-family:"NotoAr";src:url(assets/fonts/arabic500.woff2) format("woff2");font-weight:500 600;font-display:swap}
@font-face{font-family:"NotoAr";src:url(assets/fonts/arabic700.woff2) format("woff2");font-weight:700 900;font-display:swap}
@font-face{font-family:"NunitoL";src:url(assets/fonts/nunito600.woff2) format("woff2");font-weight:500 600;font-display:swap}
@font-face{font-family:"NunitoL";src:url(assets/fonts/nunito700.woff2) format("woff2");font-weight:700 900;font-display:swap}
:root{--sky:#dff0fb;--sky2:#bfe0f5;--blue:#5b9fd6;--navy:#2c4a6b;--cream:#fff6df;--coral:#ff8a73;--green:#6cc29a;--gold:#f6b73c;--purple:#a58bd9;--ink:#27364a;--gh:#3d86c8;--ka:#d9772b;
 --vh:100dvh}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden;background:var(--sky);color:var(--ink);font-family:"NunitoL","NotoAr",system-ui,sans-serif;font-weight:600;overscroll-behavior:none;touch-action:manipulation}
html[lang=ar] body{font-family:"NotoAr","NunitoL",system-ui,sans-serif}
button{font:inherit;color:inherit;border:0;cursor:pointer;touch-action:manipulation}
.hidden{display:none!important}
#app{position:fixed;top:0;right:0;bottom:0;left:0;background:linear-gradient(180deg,#d7ecfa 0%,#eef7fd 55%,#fff6df 100%)}
.screen{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;flex-direction:column;padding:max(env(safe-area-inset-top),14px) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)}
.topbar{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px 14px;min-height:64px}
.pageind{white-space:nowrap;font-weight:800;font-size:clamp(1rem,2.6vw,1.3rem);color:var(--navy);text-align:center;flex:1}
.seg{display:inline-flex;background:#fff;border-radius:999px;padding:4px;box-shadow:0 2px 8px #2c4a6b22}
.seg button{background:transparent;min-width:56px;min-height:44px;padding:0 14px;border-radius:999px;font-weight:800;font-size:1.05rem;color:var(--navy)}
.seg button.on{background:var(--blue);color:#fff}
.icon-btn{width:52px;height:52px;border-radius:16px;background:#fff;box-shadow:0 2px 8px #2c4a6b2a;display:grid;place-items:center;color:var(--navy);flex:none}
.icon-btn svg{width:60%;height:60%}
.icon-btn.round{border-radius:50%}
.icon-btn.sm{width:48px;height:48px}
.icon-btn:active{transform:scale(.94)}
[dir=rtl] .flip{transform:scaleX(-1)}
.big{min-height:64px;padding:0 32px;border-radius:999px;font-weight:800;font-size:clamp(1.2rem,3vw,1.5rem);box-shadow:0 6px 0 #0002,0 8px 18px #2c4a6b30}
.big:active{transform:translateY(3px);box-shadow:0 3px 0 #0002}
.primary{background:var(--coral);color:#fff}
.good{background:var(--green);color:#fff}

/* home */
.home-main{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:clamp(8px,2vh,18px);gap:clamp(8px,2dvh,18px);padding:0 18px 24px;overflow:auto;text-align:center}
.mascot{width:clamp(130px,32vh,260px);width:clamp(130px,32dvh,260px);animation:bob 4s ease-in-out infinite}
.mascot img{width:100%;display:block;filter:drop-shadow(0 10px 14px #2c4a6b33)}
@keyframes bob{50%{transform:translateY(-10px) rotate(-2deg)}}
h1{margin:0;font-size:clamp(1.8rem,6vw,3rem);line-height:1.5;color:var(--navy);font-weight:800}
.sub{margin:0;color:#4d6a88;font-size:clamp(.95rem,2.4vw,1.15rem)}
.cards{display:flex;gap:12px;flex-wrap:wrap;justify-content:center;margin-top:6px}
.card{width:clamp(96px,26vw,150px);padding:14px 8px;border-radius:24px;background:#fff;box-shadow:0 4px 14px #2c4a6b26;display:flex;flex-direction:column;align-items:center;gap:6px;font-weight:800;font-size:clamp(.95rem,2.4vw,1.1rem);color:var(--navy);min-height:110px}
.card svg{width:46px;height:46px}
.card:active{transform:scale(.96)}
.card.done::after{content:"";position:absolute}
.card{position:relative}
.card .tick{position:absolute;top:6px;inset-inline-end:8px;width:24px;height:24px;border-radius:50%;background:var(--green);color:#fff;display:grid;place-items:center;font-size:14px}
.stars{display:flex;gap:6px;min-height:30px}
.stars svg{width:28px;height:28px}

/* reader */
.reader-body{flex:1;min-height:0;display:grid;gap:12px;padding:0 14px;grid-template-columns:1fr;grid-template-rows:auto minmax(0,1fr)}
.art{margin:0;justify-self:center;width:min(100%,40vh);width:min(100%,40dvh);aspect-ratio:1;border-radius:22px;overflow:hidden;box-shadow:0 6px 18px #2c4a6b30;background:#fff}
.art img{width:100%;height:100%;object-fit:cover;display:block}
.textwrap{min-height:0;background:#fff;border-radius:22px;box-shadow:0 4px 14px #2c4a6b1f;overflow:hidden;display:flex}
.text{position:relative;direction:inherit;overflow-y:hidden;text-align:start;unicode-bidi:isolate;flex:1;padding:clamp(12px,2.4vw,26px);font-size:clamp(1.2rem,4.6vw,1.9rem);line-height:2.1;scroll-behavior:smooth;-webkit-overflow-scrolling:touch}
html[lang=en] .text{line-height:1.7;font-size:clamp(1.15rem,4.2vw,1.8rem)}
.text h2{margin:0 0 8px;font-size:1.25em;color:var(--navy);line-height:1.5}
.text p{margin:0 0 .55em}
.w{border-radius:10px;padding:0 .12em;transition:background .12s,color .12s;cursor:pointer;-webkit-box-decoration-break:clone;box-decoration-break:clone}
.w.k-K{color:var(--ka)}.w.k-G{color:var(--gh)}.w.k-O{color:#c0572b}
.w.done{opacity:1}
.w.on{background:#FFE000;color:#000;box-shadow:0 0 0 .08em #FFE000;opacity:1}
.w.on.k-K,.w.on.k-G,.w.on.k-O{color:#000}
.controls{display:flex;gap:18px;justify-content:center;align-items:center;padding:12px 0 6px}
.controls .nav{width:60px;height:60px}
.controls .play{width:78px;height:78px;background:var(--coral);color:#fff;box-shadow:0 6px 0 #0002,0 8px 16px #2c4a6b30}
.controls .nav[disabled]{opacity:.35}
.pbar{height:8px;margin:4px 14px 10px;background:#fff;border-radius:6px;overflow:hidden}
.pbar i{display:block;height:100%;width:0;background:var(--blue);border-radius:6px}
@media (min-aspect-ratio:11/10) and (min-width:560px){
 .reader-body{grid-template-columns:min(46vw,calc(100vh - 230px)) minmax(0,1fr);grid-template-columns:min(46vw,calc(100dvh - 230px)) minmax(0,1fr);grid-template-rows:minmax(0,1fr);align-items:start}
 .art{width:100%;align-self:center}
 .textwrap{height:100%}
 .text{font-size:clamp(1.3rem,2.5vw,2.2rem)}
 html[lang=en] .text{font-size:clamp(1.2rem,2.2vw,2rem)}
}
@media (max-height:520px) and (orientation:landscape){
 .topbar{min-height:50px;padding:4px 10px}.icon-btn{width:44px;height:44px}.controls{padding:4px}.controls .play{width:60px;height:60px}.controls .nav{width:48px;height:48px}
 .reader-body{grid-template-columns:min(40vw,calc(100vh - 150px)) minmax(0,1fr);grid-template-columns:min(40vw,calc(100dvh - 150px)) minmax(0,1fr)}
}

html[dir=rtl] .text{direction:rtl;text-align:right}
html[dir=ltr] .text{direction:ltr;text-align:left}
.pbar i{margin-inline-start:0}
@media (max-width:640px){
 .topbar{padding:6px 10px;min-height:52px;gap:6px}
 .icon-btn{width:46px;height:46px}
 .seg{padding:3px}.seg button{min-width:44px;min-height:40px;padding:0 9px;font-size:.95rem}
 .pageind{font-size:1rem}
 .reader-body{gap:8px;padding:0 10px}
 .text{padding:10px 14px;font-size:clamp(1.5rem,6.4vw,2rem);line-height:1.95}
 html[lang=en] .text,html[lang=fr] .text,html[lang=de] .text{font-size:clamp(1.3rem,5.4vw,1.7rem);line-height:1.55}
 .controls{padding:6px 0 2px;gap:16px}.controls .nav{width:48px;height:48px}.controls .play{width:64px;height:64px}
 .pbar{margin:2px 14px 8px}
}

/* games */
.hint{font-weight:700;font-size:.95rem;color:#4d6a88;min-width:70px;text-align:center}
.game-body{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:0 14px 14px}
.color-body{flex-direction:column}
.canvas-wrap{position:relative;width:min(100%,calc(100vh - 250px));width:min(100%,calc(100dvh - 250px));aspect-ratio:1;background:#fff;border-radius:22px;box-shadow:0 6px 18px #2c4a6b30;overflow:hidden;touch-action:none}
.canvas-wrap canvas,.canvas-wrap #lineImg{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}
#lineImg{pointer-events:none;user-select:none}
.ref{position:absolute;inset-inline-end:8px;top:8px;width:34%;border-radius:12px;border:3px solid #fff;box-shadow:0 2px 10px #0004;pointer-events:none}
.palette-wrap{display:flex;flex-direction:column;align-items:center;gap:10px;width:100%;max-width:560px}
.palette{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}
.sw{width:clamp(38px,9vw,50px);height:clamp(38px,9vw,50px);border-radius:50%;border:4px solid #fff;box-shadow:0 2px 6px #0003}
.sw.on{outline:4px solid var(--navy);transform:scale(1.12)}
.tools{display:flex;gap:12px;align-items:center;justify-content:center;flex-wrap:wrap}
@media (min-aspect-ratio:11/10){
 .color-body{flex-direction:row;gap:24px}
 .canvas-wrap{width:min(60vw,calc(100vh - 100px));width:min(60vw,calc(100dvh - 100px))}
 .palette-wrap{width:auto;max-width:230px}
 .palette{max-width:220px}
}
.play{position:relative;width:100%;max-width:900px;height:calc(100vh - 190px);height:calc(100dvh - 190px);touch-action:none;flex:none}
.board{position:absolute;border-radius:14px;background:#fff8;border:3px dashed #7fb0d8;overflow:hidden}
.cell{position:absolute;border:1px dashed #9cc4e4}
.piece{position:absolute;border-radius:10px;box-shadow:0 3px 8px #0004;background-repeat:no-repeat;touch-action:none;cursor:grab;border:2px solid #fff}
.piece.drag{z-index:50;box-shadow:0 12px 24px #0005;transform:scale(1.04);cursor:grabbing}
.piece.lock{box-shadow:none;border-color:transparent;border-radius:0;cursor:default;z-index:1}
.peek{position:absolute;opacity:.55;pointer-events:none;border-radius:14px}
.puz-body .play{align-self:center}

/* trophies */
.trophy-body{flex:1;overflow:auto;display:flex;flex-direction:column;align-items:center;gap:14px;padding:6px 18px 24px;text-align:center}
.bigtrophy svg{width:clamp(130px,30vh,220px);width:clamp(130px,30dvh,220px);height:auto}
.bigtrophy.locked svg{filter:grayscale(1) opacity(.35)}
.badges{display:flex;gap:14px;flex-wrap:wrap;justify-content:center}
.badge{width:clamp(100px,26vw,150px);padding:14px 8px;border-radius:24px;background:#fff;box-shadow:0 4px 14px #2c4a6b26;display:flex;flex-direction:column;align-items:center;gap:6px;font-weight:800;color:var(--navy)}
.badge svg{width:64px;height:64px}
.badge.locked svg{filter:grayscale(1) opacity(.3)}
.badge small{font-weight:600;color:#4d6a88}
.link-btn{background:transparent;color:#6b85a0;text-decoration:underline;min-height:44px;padding:0 12px;font-size:.9rem}
.modal{position:absolute;top:0;right:0;bottom:0;left:0;background:#10253a88;display:grid;place-items:center;z-index:100;padding:20px}
.modal-card{background:#fff;border-radius:30px;padding:26px 22px;max-width:420px;width:100%;text-align:center;box-shadow:0 20px 50px #0006;animation:pop .35s cubic-bezier(.3,1.6,.5,1)}
.modal-card h2{margin:6px 0;color:var(--navy);line-height:1.5}.modal-card p{margin:0 0 14px;color:#4d6a88;line-height:1.7}
.modal-card svg{width:120px;height:120px}
.modal-btns{display:flex;gap:10px;justify-content:center;flex-wrap:wrap}
.modal-btns .big{min-height:56px;font-size:1.1rem;padding:0 24px}
@keyframes pop{from{transform:scale(.6);opacity:0}}
#confetti{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;pointer-events:none;z-index:200}
@media (prefers-reduced-motion:reduce){.mascot{animation:none}.modal-card{animation:none}.text{scroll-behavior:auto}}

@media (max-width:400px){.seg button{min-width:42px;padding:0 10px;font-size:.95rem}.topbar{padding:8px 10px;gap:6px}.icon-btn{width:46px;height:46px}.pageind{font-size:.95rem}}

/* ---- v2: themes, hub, games, transitions ---- */
html[data-theme=sky]{--bg1:#d7ecfa;--bg2:#eef7fd;--bg3:#fff6df}
html[data-theme=meadow]{--bg1:#d9f2d0;--bg2:#f1fae8;--bg3:#fff4d6;--blue:#4fae6b;--navy:#24523a;--coral:#ff9a52}
html[data-theme=dusk]{--bg1:#d9d0f4;--bg2:#efeaff;--bg3:#ffe9ef;--blue:#8a6fd6;--navy:#3a2f6b;--coral:#f4719a}
html[data-theme=sunny]{--bg1:#ffe9b0;--bg2:#fff6dc;--bg3:#ffe4d6;--blue:#f0a020;--navy:#6b4310;--coral:#e8603c}
html[data-theme=sea]{--bg1:#c9eeee;--bg2:#e8f9f8;--bg3:#e6f1ff;--blue:#2fa3a8;--navy:#1d4d57;--coral:#ff7f6e}
:root{--bg1:#d7ecfa;--bg2:#eef7fd;--bg3:#fff6df}
#app{background:linear-gradient(180deg,var(--bg1) 0%,var(--bg2) 55%,var(--bg3) 100%)}
.screen.enter{animation:scrIn .28s ease-out}
@keyframes scrIn{from{opacity:0;transform:translateY(10px)}}
.card.c-games svg,.card.c-trophy svg{width:46px;height:46px}
.srow{display:inline-flex;gap:2px;color:#c9d8e6}.srow span{display:inline-block;line-height:0}.srow svg{width:22px;height:22px}.srow .on{color:#f6b73c}
.srow.big svg{width:46px;height:46px}.srow.sm svg{width:18px;height:18px}.srow.xs svg{width:14px;height:14px}
.starsum{display:flex;align-items:center;gap:4px;font-weight:800;color:var(--navy);min-width:60px;justify-content:flex-end}.starsum svg{width:22px;height:22px;color:#f6b73c}
.hub-body{flex:1;overflow:auto;padding:6px 14px 20px}
.hub{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:14px;max-width:900px;margin:0 auto}
.hubcard{position:relative;background:#fff;border-radius:26px;padding:16px 8px 12px;display:flex;flex-direction:column;align-items:center;gap:6px;box-shadow:0 5px 0 color-mix(in srgb,var(--c) 70%,#fff),0 8px 18px #2c4a6b26;color:var(--navy)}
.hubcard:active{transform:translateY(3px)}
.hico{width:64px;height:64px;border-radius:20px;background:color-mix(in srgb,var(--c) 28%,#fff);display:grid;place-items:center}.hico svg{width:44px;height:44px}
.hubcard b{font-size:1.05rem;line-height:1.4;text-align:center}.hubcard small{color:#6b85a0;font-weight:700}
.hmedal{position:absolute;top:6px;inset-inline-end:6px;width:38px;height:38px}.hmedal svg{width:100%;height:100%}
.ginfo{text-align:center;font-weight:700;color:#4d6a88;padding:0 14px 8px;min-height:30px}
.garea{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:0 14px 16px;overflow:auto}
.spot{display:grid;gap:10px;grid-template-columns:1fr;width:min(100%,calc((100vh - 250px)/2));width:min(100%,calc((100dvh - 250px)/2))}
@media (min-aspect-ratio:11/10){.spot{grid-template-columns:1fr 1fr;width:min(100%,calc((100vh - 190px)*2 + 10px));width:min(100%,calc((100dvh - 190px)*2 + 10px))}}
.sp{position:relative;aspect-ratio:1;background:#fff;border-radius:18px;overflow:hidden;box-shadow:0 4px 14px #2c4a6b30;touch-action:manipulation;user-select:none}
.sp img{width:100%;height:100%;display:block;pointer-events:none}
.ring{position:absolute;border:4px solid #2fb36b;border-radius:50%;transform:translate(-50%,-50%);animation:pop .3s;pointer-events:none;box-shadow:0 0 0 2px #fff}
.miss{position:absolute;width:26px;height:26px;border-radius:50%;background:#ff6b6b88;transform:translate(-50%,-50%);animation:fade .5s forwards;pointer-events:none}
@keyframes fade{to{opacity:0;transform:translate(-50%,-50%) scale(1.8)}}
.g-sort{justify-content:flex-start;gap:14px}
.tray{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;min-height:96px;width:100%;max-width:760px;touch-action:none}
.titem{width:clamp(76px,22vw,120px);aspect-ratio:1;background:#fff;border-radius:18px;box-shadow:0 3px 10px #2c4a6b30;border:3px solid #fff;touch-action:none;cursor:grab;position:relative}
.titem img{width:100%;height:100%;border-radius:14px;display:block;pointer-events:none;object-fit:cover}
.titem.drag{z-index:30;box-shadow:0 14px 28px #0005}
.titem.sel{outline:4px solid var(--blue)}
.shake{animation:shake .4s}@keyframes shake{25%{transform:translateX(-8px)}75%{transform:translateX(8px)}}
.baskets{display:grid;grid-template-columns:1fr 1fr;gap:14px;width:100%;max-width:760px;flex:1;min-height:160px}
.basket{background:#fff8;border:4px dashed #9cc4e4;border-radius:26px;padding:10px;display:flex;flex-direction:column;align-items:center;gap:6px;color:var(--navy);transition:transform .2s}
.basket.p{background:#e6f3fd}.basket.t{background:#fff1d9;border-color:#e8bd7a}
.basket.pop{transform:scale(1.05)}.basket.bad{animation:shake .4s;border-color:#ff6b6b}
.bin{display:flex;flex-wrap:wrap;gap:4px;justify-content:center}.mini{width:clamp(34px,9vw,52px);aspect-ratio:1;border-radius:10px;object-fit:cover;background:#fff}
.mgrid{display:grid;grid-template-columns:repeat(var(--cols),1fr);gap:clamp(6px,1.6vw,12px);width:min(100%,calc((100vh - 200px)*var(--cols)/var(--rows)));width:min(100%,calc((100dvh - 200px)*var(--cols)/var(--rows)))}
.mcard{aspect-ratio:1;perspective:700px;background:none;padding:0;touch-action:manipulation}
.mi{display:block;position:relative;width:100%;height:100%;transition:transform .45s;transform-style:preserve-3d}
.mcard.up .mi,.mcard.ok .mi{transform:rotateY(180deg)}
.mf,.mb{position:absolute;top:0;right:0;bottom:0;left:0;border-radius:16px;backface-visibility:hidden;-webkit-backface-visibility:hidden;display:flex;flex-direction:column;align-items:center;justify-content:center;box-shadow:0 3px 10px #2c4a6b30}
.mf{background:linear-gradient(135deg,#b9a5ea,#8a6fd6);color:#fff}.mf svg{width:46%;height:46%}
.mb{background:#fff;transform:rotateY(180deg);overflow:hidden}.mb img{width:100%;height:78%;object-fit:cover}.mb em{font-style:normal;font-weight:800;font-size:clamp(.7rem,2.6vw,1rem);color:var(--navy);line-height:1.6}
.mcard.ok .mb{box-shadow:0 0 0 4px #2fb36b,0 3px 10px #2c4a6b30}
.g-match{gap:16px}
.mword{display:flex;align-items:center;gap:12px;background:#fff;border-radius:999px;padding:8px 26px;font-weight:800;font-size:clamp(1.8rem,7vw,3rem);color:var(--navy);box-shadow:0 5px 0 #0001,0 8px 18px #2c4a6b26;line-height:1.7}
.mword svg{width:34px;height:34px;color:var(--coral)}
.mopts{display:grid;grid-template-columns:repeat(var(--n,3),minmax(0,1fr));gap:12px;width:min(100%,760px)}
.mopts[style*="--n:4"]{grid-template-columns:repeat(2,1fr);width:min(100%,calc(100vh - 330px),520px);width:min(100%,calc(100dvh - 330px),520px)}
.mopts[style*="--n:6"]{grid-template-columns:repeat(3,1fr);width:min(100%,calc((100vh - 330px)*1.5),620px);width:min(100%,calc((100dvh - 330px)*1.5),620px)}
.mopt{aspect-ratio:1;background:#fff;border-radius:20px;padding:4px;box-shadow:0 4px 12px #2c4a6b2a;border:4px solid #fff;overflow:hidden}
.mopt img{width:100%;height:100%;object-fit:cover;border-radius:14px;display:block;pointer-events:none}
.mopt.right{border-color:#2fb36b;animation:pop .35s}.mopt.wrong{border-color:#ff6b6b;opacity:.45}
.arow{display:flex;align-items:center;gap:12px;background:#fff;border-radius:20px;padding:8px 14px;box-shadow:0 3px 10px #2c4a6b1f;width:100%;max-width:560px;color:var(--navy)}
.arow b{flex:1;text-align:start}.arow .am{width:48px;height:48px;flex:none}.arow .am svg{width:100%;height:100%}.arow.locked .am{filter:grayscale(1) opacity(.35)}
.arow .lv{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.trophy-body .badges{flex-direction:column;align-items:center;width:100%}
.seg button .on{}
.tools .icon-btn.on{background:var(--blue);color:#fff}
#colLevel{margin-bottom:2px}
#btnPlay.busy{position:relative}#btnPlay.busy svg{opacity:.2}#btnPlay.busy::after{content:"";position:absolute;width:30px;height:30px;border:4px solid #fff;border-top-color:transparent;border-radius:50%;animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.modal-card .srow.big{margin-bottom:6px}
@media (min-aspect-ratio:11/10){
 .g-sort{flex-direction:row;align-items:stretch;justify-content:center;gap:16px}
 .g-sort .tray{width:48%;align-content:flex-start;min-height:0}
 .g-sort .baskets{width:48%;grid-template-columns:1fr;flex:none}
 .g-sort .basket{min-height:0;padding:6px}
}
@media (max-height:520px){.hub{grid-template-columns:repeat(3,1fr)}.hubcard{padding:10px 6px 8px}.hico{width:48px;height:48px}.hico svg{width:32px;height:32px}.ginfo{padding-bottom:2px;min-height:22px}}

.lib-body{flex:1;overflow:auto;padding:0 16px 24px;text-align:center}
.lib{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:16px;max-width:980px;margin:12px auto 0}
.libcard{background:#fff;border-radius:26px;padding:10px 10px 14px;display:flex;flex-direction:column;align-items:center;gap:6px;color:var(--navy);box-shadow:0 5px 0 color-mix(in srgb,var(--c) 70%,#fff),0 8px 18px #2c4a6b26}
.libcard:active{transform:translateY(3px)}
.libcard .cov{position:relative;width:100%;aspect-ratio:1;border-radius:18px;overflow:hidden;background:#eef4fa}
.libcard .cov img{width:100%;height:100%;object-fit:cover;display:block}
.libcard b{font-size:1.02rem;line-height:1.5}.libcard small{display:flex;gap:4px;align-items:center;color:#6b85a0;font-weight:700}.libcard small svg{width:16px;height:16px;color:#f6b73c}
.libcard.soon{opacity:.6}.libcard.soon .cov img{filter:grayscale(.8)}
.lt{position:absolute;top:6px;inset-inline-end:6px;width:34px;height:34px}.lt svg{width:100%;height:100%}
.loading{position:absolute;top:0;right:0;bottom:0;left:0;background:#ffffffd9;display:grid;place-items:center;align-content:center;gap:12px;z-index:150;color:var(--navy);font-weight:800}
.spin{width:54px;height:54px;border:6px solid var(--blue);border-top-color:transparent;border-radius:50%;animation:spin .8s linear infinite}

.textwrap{position:relative}
.textwrap.more::after{content:'';position:absolute;left:0;right:0;bottom:0;height:34px;background:linear-gradient(transparent,#fff 85%);pointer-events:none;border-radius:0 0 22px 22px}

/* learn */
.card.c-learn svg{width:46px;height:46px}
.learn-body{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;gap:8px;padding:0 12px 10px;overflow:auto}
.fcard{width:min(100%,520px);background:#fff;border-radius:28px;box-shadow:0 6px 18px #2c4a6b30;padding:12px;display:flex;flex-direction:column;align-items:center;gap:8px;cursor:pointer;transition:transform .2s}
.fcard.say{transform:scale(1.02);box-shadow:0 0 0 5px var(--gold),0 6px 18px #2c4a6b30}
.fc-img{width:min(100%,31vh);width:min(100%,31dvh);aspect-ratio:1;border-radius:20px;overflow:hidden;background:#fff6df}
.fc-img img{width:100%;height:100%;object-fit:contain;display:block}
.fc-word{font-size:clamp(2rem,9vw,3rem);font-weight:900;color:var(--navy);text-align:center;line-height:1.5}
.fc-others{display:flex;flex-wrap:wrap;gap:6px;justify-content:center}
.fc-o{background:#eef6fc;border-radius:14px;padding:4px 12px;display:flex;flex-direction:column;align-items:center;min-width:76px;color:var(--navy);font-weight:800;font-size:1.05rem}
.fc-o small{font-size:.7rem;opacity:.65}
.ln-ctl{padding:4px 0}
.ln-count{font-weight:800;color:var(--navy)}
.ln-strip{display:flex;gap:8px;overflow-x:auto;max-width:100%;padding:4px 6px 8px;direction:ltr;flex:none}
.ln-th{flex:none;width:56px;height:56px;border-radius:14px;border:3px solid #fff;background:#fff;padding:0;overflow:hidden;box-shadow:0 2px 6px #2c4a6b30}
.ln-th.on{border-color:var(--blue);transform:scale(1.08)}
.ln-th img{width:100%;height:100%;object-fit:cover}
@media (max-height:520px){.fc-img{width:min(100%,30vh);width:min(100%,30dvh)}}
@media (min-aspect-ratio:11/10) and (min-width:560px){.learn-body{justify-content:center}.fc-img{width:min(100%,34vh);width:min(100%,34dvh)}}

#lnTitle{min-width:0;overflow:hidden;text-overflow:ellipsis;font-size:.95rem}
.learn-body{justify-content:flex-start}

/* brand footer */
.brand{flex:none;display:flex;flex-direction:column;align-items:center;gap:2px;padding:6px 12px 8px;color:#4d6a88;font-size:.85rem}
.brand-row{display:flex;align-items:center;gap:8px}
.brand-logo{width:34px;height:34px;border-radius:9px;display:inline-grid;place-items:center;overflow:hidden;flex:none}
.brand-logo img{width:100%;height:100%;object-fit:contain}
.brand-logo.empty{border:2px dashed #9cb6cf;background:#ffffff80}
.brand b{font-weight:800}
.brand-link{background:none;border:0;padding:6px 10px;font-size:.72rem;color:#6b84a0;text-decoration:underline;min-height:0}

/* small phones: give the text most of the height */
@media (max-width:640px){
 .art{width:min(100%,30vh);width:min(100%,30dvh)}
 .text{padding:8px 12px;font-size:clamp(1.3rem,5.4vw,1.75rem);line-height:1.85}
 html[lang=en] .text,html[lang=fr] .text,html[lang=de] .text{font-size:clamp(1.15rem,4.6vw,1.5rem);line-height:1.5}
 .text h2{font-size:1.1em;margin-bottom:4px}
 .controls{padding:4px 0 0}.controls .nav{width:44px;height:44px}.controls .play{width:56px;height:56px}
 .pbar{margin:2px 14px 6px}
 .topbar{min-height:48px;padding:4px 10px}
}
@media (max-width:640px) and (max-height:700px){.art{width:min(100%,24vh);width:min(100%,24dvh)}}
@media (max-width:640px) and (max-height:600px){.art{width:min(100%,21vh);width:min(100%,21dvh)}}

/* no-scroll layout */
.lib-body,.home-main,.trophy-body,.hub-body,.learn-body,.garea{overflow:hidden!important}
.lib-body,.home-main,.trophy-body,.hub-body,.learn-body{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:0}
.fit-inner{flex:none;width:100%}
.home-main .fit-inner{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:clamp(8px,2vh,18px);gap:clamp(8px,2dvh,18px)}
.trophy-body .fit-inner{display:flex;flex-direction:column;align-items:center;gap:12px}
.learn-body .fit-inner{display:flex;flex-direction:column;align-items:center;gap:8px}
.lib-body .fit-inner{text-align:center}
.trophy-body .badges{display:grid!important;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));gap:10px 14px;width:100%;max-width:980px}
.trophy-body .arow{max-width:none}
.ln-strip{overflow:hidden;flex-wrap:wrap;justify-content:center;direction:ltr}
.ln-th{width:44px;height:44px}
.fc-img{width:min(100%,30vh);width:min(100%,30dvh)}
.fcard{width:min(100%,460px)}
.stepdots{position:absolute;bottom:6px;inset-inline-end:12px;display:flex;gap:5px;z-index:2}
.stepdots i{width:8px;height:8px;border-radius:50%;background:#c9d8e6}
.stepdots i.on{background:var(--coral)}
.topbar .pageind{min-width:0;overflow:hidden;text-overflow:ellipsis}
.topbar>*{min-width:0}.topbar .seg{flex:0 1 auto;max-width:100%}
.seg button{white-space:nowrap}
.brand-logo{width:auto;height:56px;border-radius:0}
.brand-logo img{width:auto;height:100%;object-fit:contain;image-rendering:auto}
@media (max-height:600px){.brand-logo{height:44px}}
/* short landscape screens */
@media (max-height:660px) and (min-aspect-ratio:11/10){
 .color-body{gap:14px;padding:0 10px 6px}
 .canvas-wrap{width:min(48vw,calc(100vh - 96px));width:min(48vw,calc(100dvh - 96px))}
 .palette-wrap{gap:6px;max-width:300px}
 .palette{gap:4px;max-width:300px}
 .sw{width:30px;height:30px;border-width:3px}
 #colLevel .seg button,#colLevel button{min-height:30px;min-width:34px;padding:0 8px;font-size:.85rem}
 .tools{gap:8px}.icon-btn.sm{width:38px;height:38px}
 .mopts[style*="--n:3"]{width:min(100%,calc((100vh - 150px)*3),760px);width:min(100%,calc((100dvh - 150px)*3),760px)}
 .mopts[style*="--n:4"]{width:min(100%,calc((100vh - 150px)*2),520px);width:min(100%,calc((100dvh - 150px)*2),520px)}
 .mopts[style*="--n:6"]{width:min(100%,calc((100vh - 150px)*3),620px);width:min(100%,calc((100dvh - 150px)*3),620px)}
 .mword{font-size:1.5rem;padding:2px 18px;line-height:1.4}
 .g-match{gap:8px}
}
.brand-logo{display:block;height:56px;width:auto}
.brand-logo img{display:block;height:56px;width:auto;max-width:none}
@media (max-height:600px){.brand-logo,.brand-logo img{height:44px}}
.brand-logo.empty{width:56px}
.bigtrophy svg{width:clamp(80px,16vh,150px);width:clamp(80px,16dvh,150px)}
.lib-body{justify-content:flex-start}
.lib-body .fit-inner{padding-top:4px}

.btn-pair{display:flex;gap:8px;flex:none;align-items:center}
@media (max-width:400px){.btn-pair{gap:4px}.btn-pair .icon-btn{width:40px;height:40px}}
.art img{animation:artmove 24s ease-in-out infinite alternate;transform-origin:50% 55%;will-change:transform}
@keyframes artmove{from{transform:scale(1) translate(0,0)}to{transform:scale(1.045) translate(-1.1%,-.9%)}}
@media (prefers-reduced-motion:reduce){.art img{animation:none}}

.lib-hero{display:flex;flex-direction:column;align-items:center;gap:6px;margin:0 0 8px;text-align:center}
.hero-logo{height:clamp(54px,11vh,110px);height:clamp(54px,11dvh,110px);width:auto}
.hero-title{font-family:"KufiT","NotoAr",sans-serif;font-weight:800;color:var(--navy);font-size:clamp(1.5rem,7.4vw,3rem);line-height:1.4}
.hero-pub{font-family:"KufiT","NotoAr",sans-serif;font-weight:800;color:var(--navy);font-size:clamp(.9rem,3.2vw,1.5rem)}
#library .brand{display:none}
#libSub{display:none}

.textwrap.more::after{display:none}
@media (max-width:360px){.seg button{min-width:34px;padding:0 7px;font-size:.85rem}.topbar .pageind{font-size:.85rem;min-width:34px}.btn-pair .icon-btn{width:38px;height:38px}.btn-pair{gap:3px}.topbar{gap:4px}}

.ln-badges{width:100%;max-width:560px;display:flex;flex-direction:column;align-items:center;gap:4px;margin-top:8px}
.lrn-h{font-weight:800;color:var(--navy);font-size:1.05rem}
.lrn-sub{color:#4d6a88;font-size:.9rem}
.lrn-row{display:flex;gap:8px;justify-content:center;flex-wrap:wrap}
.lrn-b{width:54px;height:54px;border-radius:50%;background:#fff;box-shadow:0 3px 8px #2c4a6b22;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--navy);filter:grayscale(1) opacity(.45)}
.lrn-b.on{filter:none;background:linear-gradient(#ffe9a6,#f6b73c)}
.lrn-n{font-weight:800;font-size:1.05rem;line-height:1}.lrn-b small{font-size:.6rem;line-height:1.1}
@media (max-height:700px){.lrn-b{width:44px;height:44px}.lrn-sub{font-size:.8rem}}

.g-hunt{display:flex;flex-direction:column;align-items:center;gap:8px;min-height:0}
.hq{flex:none;display:flex;justify-content:center}
.hword{display:flex;align-items:center;gap:10px;background:#fff;border:0;border-radius:22px;padding:6px 16px 6px 8px;box-shadow:0 3px 10px #2c4a6b22;font:inherit;font-weight:800;color:var(--navy);font-size:clamp(1.05rem,4.5vw,1.5rem)}
.hword img{width:clamp(44px,9vh,70px);width:clamp(44px,9dvh,70px);height:clamp(44px,9vh,70px);height:clamp(44px,9dvh,70px);object-fit:cover;border-radius:14px}
.hword svg{width:24px;height:24px}
.hscene{position:relative;flex:1;min-height:0;aspect-ratio:1/1;max-width:100%;max-height:100%;border-radius:20px;overflow:hidden;box-shadow:0 4px 14px #2c4a6b33;touch-action:none;align-self:center}
.hscene img{width:100%;height:100%;object-fit:fill;display:block;pointer-events:none}
.hring,.hhint{position:absolute;border:4px solid #2fb36b;border-radius:50%;pointer-events:none;box-shadow:0 0 0 3px #fff8;animation:pop .4s}
.hhint{border-color:#ffb300;animation:pulse .6s 2}
.shq .shbox{width:clamp(110px,24vh,200px);width:clamp(110px,24dvh,200px);height:clamp(110px,24vh,200px);height:clamp(110px,24dvh,200px);background:#fff;border-radius:24px;display:flex;align-items:center;justify-content:center;box-shadow:0 3px 10px #2c4a6b22}
.shimg{width:84%;height:84%;object-fit:contain;filter:brightness(0) opacity(.8);transition:filter .5s}
.shq.reveal .shimg{filter:none}
@keyframes pulse{50%{transform:scale(1.15)}}

.shname{margin-top:8px;min-height:1.6em;font-weight:800;color:var(--navy);font-size:1.15rem;opacity:0;transition:opacity .4s}.shq.reveal .shname{opacity:1}

.mopt.hint{border-color:#ffd36e;animation:hintp 1s ease-in-out infinite}@keyframes hintp{50%{box-shadow:0 0 0 6px #ffd36e88}}@media (prefers-reduced-motion:reduce){.mopt.hint{animation:none;box-shadow:0 0 0 5px #ffd36e88}}

.tfpic{width:min(60vw,46vh);aspect-ratio:1;margin:8px auto;background:#fff;border-radius:22px;padding:6px;box-shadow:0 4px 12px #2c4a6b2a}.tfpic img{width:100%;height:100%;object-fit:cover;border-radius:16px;display:block}
.tfrow{display:flex;gap:24px;justify-content:center}.tfbtn{width:84px;height:84px;border-radius:50%;border:0;color:#fff;font-size:44px;box-shadow:0 5px 0 #0002}.tfbtn.right{animation:pop .35s}.tfbtn.wrong{opacity:.35}

.ordg{display:grid;grid-template-columns:repeat(2,1fr);gap:12px;padding:12px;max-width:min(520px,max(150px,calc((100vh - 218px)*2/3 + 4px)));max-width:min(520px,max(150px,calc((100dvh - 218px)*2/3 + 4px)));margin:0 auto}.ordb{position:relative;aspect-ratio:1;border:4px solid #fff;border-radius:18px;padding:0;background:#fff;overflow:hidden;box-shadow:0 4px 12px #2c4a6b2a}.ordb img{width:100%;height:100%;object-fit:cover;display:block;pointer-events:none}.ordb .ordn{position:absolute;top:6px;inset-inline-start:6px;min-width:34px;height:34px;border-radius:50%;background:#2fb36b;color:#fff;font:700 20px/34px sans-serif;text-align:center;display:none}.ordb.right{border-color:#2fb36b}.ordb.right .ordn{display:block}.ordb.wrong{border-color:#ff6b6b;animation:pop .35s}

.whoq{margin:14px auto;max-width:520px;padding:18px;background:#fff;border-radius:20px;font-size:22px;line-height:1.9;text-align:center;box-shadow:0 4px 12px #2c4a6b2a}.whorow{display:flex;gap:16px;justify-content:center;margin-top:18px}.whob{flex:1;max-width:170px;padding:18px 8px;border:0;border-radius:18px;background:#7fb6e6;color:#fff;font:700 22px sans-serif;box-shadow:0 5px 0 #0002}.whob.right{background:#2fb36b;animation:pop .35s}.whob.wrong{opacity:.35}
.bwslots{display:flex;gap:8px;justify-content:center;direction:rtl;margin:10px 0;flex-wrap:wrap}.bws{width:42px;height:50px;border-bottom:4px solid #7fb6e6;background:#fff;border-radius:10px;font:700 28px/50px sans-serif;text-align:center}.bws.on{border-color:#2fb36b}.bwtiles{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-top:14px}.bwt{width:54px;height:58px;border:0;border-radius:14px;background:#ffd36e;font:700 30px sans-serif;box-shadow:0 4px 0 #0002}.bwt.gone{opacity:.25}.bwt.wrong{background:#ff9b9b}

.cskyy{position:relative;height:min(58vh,440px);margin:6px auto;max-width:520px;overflow:hidden;border-radius:20px;background:linear-gradient(#cfeefc,#eaf7ff)}
.cdrop{position:absolute;top:-80px;width:68px;height:68px;border:3px solid #fff;border-radius:18px;padding:0;background:#fff;overflow:hidden;animation:cfall linear forwards;box-shadow:0 4px 10px #2c4a6b30}.cdrop img{width:100%;height:100%;object-fit:cover;display:block;pointer-events:none}.cdrop.right{border-color:#2fb36b;transform:scale(1.2)}.cdrop.wrong{border-color:#ff6b6b;opacity:.4}
@keyframes cfall{to{transform:translateY(calc(min(58vh,440px) + 100px))}}
.dotbox{position:relative;width:min(88vw,50vh);aspect-ratio:1;margin:10px auto;background:#fff;border-radius:22px;box-shadow:0 4px 12px #2c4a6b2a}.dotbox svg{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%}
.dotb{position:absolute;transform:translate(-50%,-50%);width:44px;height:44px;border-radius:50%;border:0;background:#7fb6e6;color:#fff;font:700 20px sans-serif;box-shadow:0 3px 0 #0002;direction:ltr}.dotb.right{background:#2fb36b}.dotb.wrong{background:#ff6b6b}
.mazebox{display:grid;grid-template-columns:repeat(var(--n),1fr);width:min(88vw,max(140px,calc(100vh - 370px)));width:min(88vw,max(140px,calc(100dvh - 370px)));aspect-ratio:1;margin:8px auto;background:#fff;border-radius:12px;direction:ltr}.mazebox.bump{animation:pop .2s}.mc{border:0 solid #3b4e66;box-sizing:border-box;display:flex;align-items:center;justify-content:center;font-size:clamp(14px,5vw,26px);color:#ff7a59}.mc.goal{color:#f2a900}
.mpad{display:grid;grid-template-columns:repeat(3,64px);grid-template-areas:". u ." "l . r" ". d .";gap:6px;justify-content:center;margin-top:8px;direction:ltr}.mbtn{width:64px;height:56px;border:0;border-radius:14px;background:#b39ddb;color:#fff;font-size:26px;box-shadow:0 4px 0 #0002}.mbtn.m0{grid-area:u}.mbtn.m3{grid-area:l}.mbtn.m1{grid-area:r}.mbtn.m2{grid-area:d}

.hscene img.hsprite{position:absolute;width:15%;height:auto;object-fit:contain;pointer-events:none;filter:drop-shadow(0 1px 2px #0003)}

/* library: centred heading + centred tiles */
.lib-body{display:flex!important;flex-direction:column!important;align-items:center;justify-content:flex-start!important;padding:0 16px 12px;min-height:0}
.lib-hero{flex:none;margin:0 0 4px}
.lib-head{flex:none;margin:2px 0 0;text-align:center;font-family:"KufiT","NotoAr",sans-serif;font-weight:800;color:var(--navy);font-size:clamp(1.05rem,4.6vw,1.6rem);line-height:1.4;width:100%}
.lib-mid{flex:1 1 0;min-height:0;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden}
.lib-mid .fit-inner{padding-top:0!important;display:flex;justify-content:center}
.lib{display:flex!important;flex-wrap:wrap;justify-content:center;align-content:center;gap:14px;max-width:980px;margin:0 auto!important;width:100%}
.libcard{width:min(170px,calc((100% - 28px)/3))}
.hero-title{font-size:clamp(1.3rem,min(7.4vw,6.6vh),3rem)!important;font-size:clamp(1.3rem,min(7.4vw,6.6dvh),3rem)!important}.hero-pub{font-size:clamp(.85rem,min(3.2vw,3vh),1.5rem)!important;font-size:clamp(.85rem,min(3.2vw,3dvh),1.5rem)!important}.hero-logo{height:clamp(40px,min(11vh,16vw),110px)!important;height:clamp(40px,min(11dvh,16vw),110px)!important}
.color-body{padding-bottom:max(10px,env(safe-area-inset-bottom))!important}
@media (max-width:900px) and (min-width:500px){.lib{max-width:560px}.libcard{width:170px}}
@media (max-height:600px){.bwt{width:44px;height:46px;font-size:24px}.bws{width:34px;height:40px;font:700 22px/40px sans-serif}.bwtiles{margin-top:8px;gap:7px}.bwslots{margin:6px 0}.g-bw .tfpic{width:min(60vw,26vh);width:min(60vw,26dvh)}}
