:root{--sky:#9ad8ff;--ink:#22264b;--orange:#ff9f43;--yellow:#ffc93c;--green:#61cb89;--red:#ff5d5d;--blue:#447ce9;--white:#fff;--cream:#fff8e5;--shadow:#c7d4e3;--grass:#8fd66f}
*{box-sizing:border-box}html,body{margin:0;min-height:100%;font-family:Baloo,system-ui,sans-serif;font-weight:600}body{background:var(--sky);color:var(--ink);touch-action:pan-y;-webkit-tap-highlight-color:transparent}
button{font:inherit;color:inherit;border:0;cursor:pointer;touch-action:manipulation}button:focus-visible{outline:5px solid var(--blue);outline-offset:3px}button:disabled{opacity:.48;cursor:not-allowed}.app{max-width:960px;margin:auto;min-height:100svh;position:relative;overflow:hidden}
.screen{display:none;min-height:100svh;padding:20px max(16px,env(safe-area-inset-right)) 26px max(16px,env(safe-area-inset-left));}.screen.active{display:flex;flex-direction:column}
.circle{width:62px;height:62px;border-radius:50%;background:white;box-shadow:0 6px 0 var(--shadow);display:flex;align-items:center;justify-content:center;flex-shrink:0}.circle svg{width:28px;height:28px}.circle:active,.big-btn:active,.chapter:active{transform:translateY(5px);box-shadow:0 1px 0 var(--shadow)}
.boot{position:fixed;inset:0;background:var(--sky);z-index:100;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.spinner{width:60px;height:60px;border:8px solid #fff;border-top-color:var(--orange);border-radius:50%;animation:spin .7s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}
.home{position:relative;align-items:center}.home .exit{position:absolute;top:16px;left:16px;z-index:3}.home .sound-home{position:absolute;top:16px;right:16px;z-index:3}.home .sound-home.off{background:#d7d8dc}
.home-body{padding:58px 0 20px;width:min(100%,540px);display:flex;align-items:center;flex-direction:column;text-align:center}.brand{background:white;border-radius:50px;padding:4px 19px;font-size:21px;box-shadow:0 5px 0 var(--shadow)}.brand span{color:var(--blue);font-weight:800}
h1{font-size:clamp(42px,11vw,68px);font-weight:800;line-height:1.2;margin:13px 0}.intro{max-width:450px;font-size:21px;line-height:1.65;margin:0;color:#344064}
.home-picture{height:280px;width:min(95%,400px);position:relative;margin:2px auto 18px}.home-sound-circle{width:163px;height:163px;position:absolute;top:64px;right:calc(50% - 81px);border-radius:48%;border:5px solid var(--ink);background:var(--yellow);box-shadow:0 12px 0 #d6a43e;display:flex;align-items:center;justify-content:center;transform:rotate(-7deg)}.home-sound-circle svg{width:80px;height:80px}.floating-symbol{position:absolute;width:79px;height:79px;background:#fff;border-radius:24px;box-shadow:0 7px 0 var(--shadow);display:grid;place-items:center;transform:rotate(8deg)}.floating-symbol img{height:65px;width:65px;object-fit:contain}.symbol-a{top:6px;right:12px;transform:rotate(12deg)}.symbol-b{top:13px;left:17px;transform:rotate(-13deg)}.symbol-c{bottom:8px;left:38px;transform:rotate(7deg)}.symbol-d{bottom:5px;right:35px;transform:rotate(-10deg)}
.big-btn{display:inline-flex;align-items:center;justify-content:center;gap:12px;background:var(--green);border:3px solid var(--ink);border-radius:25px;min-height:69px;min-width:228px;padding:10px 25px;font-size:29px;font-weight:800;box-shadow:0 8px 0 #319e5a}.big-btn svg{width:28px;height:28px}
.chapters{display:flex;flex-wrap:wrap;gap:12px;justify-content:center;margin-top:26px;width:100%;padding-bottom:14px}.chapter{border-radius:20px;background:white;box-shadow:0 6px 0 var(--shadow);min-height:68px;padding:9px 16px;font-size:19px;display:flex;align-items:center;gap:9px}.chapter b{height:39px;width:39px;border-radius:15px;background:var(--yellow);display:flex;align-items:center;justify-content:center;font-size:22px}.chapter.locked{background:#e9edf4;color:#8f9cb0}
.game{gap:9px}.hud{display:flex;align-items:center;gap:10px;justify-content:space-between}.hud-middle{text-align:center;min-width:0;flex:1}.hud-middle strong{font-weight:800;font-size:clamp(21px,4.7vw,31px)}.score{display:flex;align-items:center;justify-content:center;gap:3px;min-width:76px;font-size:25px;font-weight:800;background:white;border-radius:23px;padding:7px 9px}.score svg{height:29px;width:29px}.dots{display:flex;gap:3px;align-items:center;justify-content:center;direction:ltr;margin:4px 0}.dots i{width:min(5.1vw,20px);max-width:20px;height:9px;border-radius:10px;background:#c9eafd}.dots i.done{background:var(--green)}.dots i.now{background:var(--yellow);height:14px}
.prompt{display:flex;align-items:center;justify-content:center;gap:15px;margin:4px auto 0;background:white;border-radius:23px;box-shadow:0 6px 0 var(--shadow);min-height:66px;padding:9px 16px;width:min(100%,560px);font-size:clamp(20px,4.8vw,29px);font-weight:800;z-index:4;text-align:center}.prompt-icon{height:35px;display:flex;gap:4px;align-items:center;justify-content:center;direction:ltr;flex-shrink:0}.prompt-icon span{width:6px;background:var(--blue);height:15px;border-radius:8px}.prompt-icon span:nth-child(2),.prompt-icon span:nth-child(4){height:28px}.prompt-icon span:nth-child(3){height:34px}.prompt.playing .prompt-icon span{animation:wave .55s ease-in-out infinite alternate}.prompt.playing .prompt-icon span:nth-child(2){animation-delay:.12s}.prompt.playing .prompt-icon span:nth-child(3){animation-delay:.24s}.prompt.playing .prompt-icon span:nth-child(4){animation-delay:.36s}@keyframes wave{from{transform:scaleY(.4)}to{transform:scaleY(1)}}
.world{position:relative;isolation:isolate;flex:1;min-height:415px;max-height:760px;border-radius:32px;overflow:hidden;background:#b7eaff;border:4px solid white;box-shadow:0 7px 0 #80b6dd;margin-top:5px}
.world.city{background:#a9dafc}.world.station{background:#b9d6ee}.world.noisy{background:#d3d6fa}.world.duo{background:#b0d9f5}
.sky-sun{position:absolute;top:30px;right:13%;width:81px;height:81px;background:#ffe26a;border-radius:50%}.cloud{position:absolute;width:100px;height:32px;left:11%;top:50px;border-radius:40px;background:white}.cloud:before,.cloud:after{content:'';position:absolute;background:white;border-radius:50%}.cloud:before{width:58px;height:58px;bottom:0;left:23px}.cloud:after{width:40px;height:40px;bottom:0;left:7px}.cloud-two{top:125px;left:66%;transform:scale(.76)}
.hill{position:absolute;bottom:27%;width:130%;height:55%;border-radius:50% 50% 0 0}.hill-back{left:-30%;background:#a2dda0;transform:rotate(-8deg)}.hill-front{right:-31%;bottom:17%;height:40%;background:var(--grass);transform:rotate(7deg)}.world.city .hill-front,.world.station .hill-front{background:#b2df91}.world.noisy .hill-front{background:#b7c996}.world.duo .hill-front{background:#aed98a}
.lane-road{position:absolute;bottom:0;left:-12%;width:124%;height:29%;background:#7889a7;transform:rotate(-5deg);border-top:8px solid #fff1bb;box-shadow:0 -8px 0 #93bc64}.lane-road:after{content:'';position:absolute;top:50%;left:0;width:100%;border-top:6px dashed #ffe8a7}.rail-track{position:absolute;bottom:22%;left:-8%;width:120%;height:36px;background:#b07f5a;border-block:7px solid #565e76;transform:rotate(3deg)}.world.noisy .rail-track{opacity:.55}
.town-building{position:absolute;width:90px;height:160px;background:#fcdeaa;bottom:28%;border:5px solid #b78064;border-radius:12px 12px 0 0;opacity:.68}.building-one{left:26%}.building-two{right:23%;height:190px;background:#d7d0f7}.town-building:after{content:'';position:absolute;width:36px;height:43px;left:23px;top:27px;border-radius:9px;background:#a1c8e0;box-shadow:0 64px 0 #a1c8e0}.world.farm .town-building{opacity:.24}
.scenery{position:absolute;object-fit:contain;pointer-events:none}.scenery-house{width:118px;height:118px;top:31%;right:3%}.scenery-tree{width:93px;height:125px;top:33%;left:4%}.scenery-tree-two{width:68px;height:106px;top:25%;left:62%}
.objects{position:absolute;inset:0;z-index:3}.source{position:absolute;width:clamp(65px,13vw,105px);height:clamp(65px,13vw,105px);padding:5px;background:#fff;border-radius:26px;box-shadow:0 8px 0 #5e7284,0 0 0 3px #31405e;display:flex;align-items:center;justify-content:center;transform:translate(-50%,-50%);transition:filter .15s,box-shadow .15s;touch-action:manipulation}.source img{width:90%;height:90%;object-fit:contain;pointer-events:none}.source:active{box-shadow:0 2px 0 #5e7284;translate:0 5px}.source.revealed{background:var(--green);box-shadow:0 7px 0 #348c55,0 0 0 3px var(--ink)}.source.hint{animation:hint 1s ease-in-out infinite}.source.miss{animation:shake .35s linear 1}@keyframes shake{25%{margin-left:-8px}75%{margin-left:8px}}@keyframes hint{50%{scale:1.13}}.source .burst{position:absolute;width:48%;right:-14%;top:-10%}
.source.rooster{left:74%;top:50%}.source.airplane{left:24%;top:17%}.source.train{left:28%;top:63%}.source.motorcycle{left:83%;top:83%}.source.telephone{left:49%;top:42%}.source.fire-engine{left:50%;top:80%}.source.car{left:21%;top:87%}.source.glass{left:80%;top:33%}
.sound-mark{position:absolute;left:50%;top:45%;transform:translate(-50%,-50%);padding:14px 23px;background:white;border-radius:22px;box-shadow:0 7px 0 #bbc4d4;z-index:8;font-size:29px;font-weight:800;white-space:nowrap}
.listen{position:absolute;right:14px;bottom:12px;z-index:9;width:84px;height:84px;border-radius:50%;background:var(--yellow);border:4px solid var(--ink);box-shadow:0 9px 0 #cf9a2f;display:flex;justify-content:center;align-items:center}.listen svg{width:60px;height:60px}.listen:active{translate:0 6px;box-shadow:0 3px 0 #cf9a2f}.listen.playing{animation:listen-beat .7s ease-in-out infinite alternate}@keyframes listen-beat{to{scale:1.08}}
.game-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:9px 4px 2px;font-size:18px;min-height:42px}.game-footer p{margin:0;line-height:1.25}.small-progress{flex-shrink:0;border-radius:19px;background:white;padding:7px 15px;min-width:85px;text-align:center}
.finish{align-items:center;justify-content:center}.finish-card{text-align:center;background:white;border-radius:37px;padding:36px 25px 28px;width:min(100%,470px);box-shadow:0 11px 0 var(--shadow);display:flex;flex-direction:column;align-items:center;gap:15px}.finish-card h2{font-size:clamp(37px,8vw,56px);line-height:1.3;margin:0;font-weight:800}.finish-card p{font-size:23px;line-height:1.6;margin:0}.finish-stars{display:flex;gap:9px;justify-content:center}.finish-stars svg{height:59px;width:59px}.finish-count{font-size:25px;font-weight:800;color:#2b8755}.finish-card .big-btn{width:100%;font-size:24px;min-height:66px}.finish-card .secondary{background:var(--yellow);box-shadow:0 7px 0 #cda431}.plain-btn{background:transparent;font-size:22px;text-decoration:underline;min-height:58px}
.wrong-flash,.correct-flash{position:fixed;inset:0;z-index:50;pointer-events:none;display:flex;align-items:center;justify-content:center}.wrong-flash span{display:flex;align-items:center;justify-content:center;width:122px;height:122px;font-family:Arial,sans-serif;font-size:100px;color:#fff;background:var(--red);border:9px solid #fff;border-radius:50%;box-shadow:0 9px 0 #bc4c5e}.wrong-flash[hidden],.correct-flash[hidden],.sound-mark[hidden]{display:none}
.correct-flash{background:transparent}
@media(max-width:420px){.screen{padding:13px 10px 20px}.home-body{padding-top:69px}.home-picture{height:248px}.home-sound-circle{width:142px;height:142px;right:calc(50% - 71px)}.floating-symbol{width:68px;height:68px}.floating-symbol img{width:58px;height:58px}.world{border-radius:25px;min-height:420px}.source{width:clamp(59px,17vw,83px);height:clamp(59px,17vw,83px);border-radius:19px}.source.car{left:18%;top:87%}.source.motorcycle{left:78%;top:87%}.source.fire-engine{left:48%;top:80%}.source.train{left:24%;top:62%}.source.rooster{left:82%;top:54%}.source.glass{left:78%;top:32%}.scenery-house{right:-20px}.cloud-two{left:65%}.prompt{font-size:21px;min-height:60px}.hud-middle strong{font-size:23px}}
@media(max-height:650px) and (min-width:600px){.screen{min-height:100svh}.world{min-height:255px}.home-picture{height:180px}.home-sound-circle{top:28px;width:112px;height:112px;right:calc(50% - 56px)}.home-body{padding-top:28px}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}

[hidden]{display:none!important}
.exit-overlay{position:fixed;inset:0;z-index:120;background:#22264baf;display:flex;align-items:center;justify-content:center;padding:22px}.exit-card{background:white;border-radius:35px;box-shadow:0 9px 0 #bfc8d4;width:min(100%,410px);padding:28px 22px;text-align:center;display:flex;flex-direction:column;align-items:center;gap:17px}.exit-card p{font-size:29px;line-height:1.45;font-weight:800;margin:0}.exit-card .big-btn{width:100%;font-size:24px;min-height:65px}.exit-card .secondary{background:#ffc93c;box-shadow:0 7px 0 #cf9a2f}


/* نسخة البيئة الجديدة: المجسمات جزء من العالم وليست صوراً على بطاقات. */
.world.has-three{
  background:#bceaff;
  border:0;
  box-shadow:none;
  border-radius:24px;
  isolation:isolate;
  overflow:hidden;
  transform:translateZ(0);
}
.world.has-three > .sky-sun,
.world.has-three > .cloud,
.world.has-three > .hill,
.world.has-three > .town-building,
.world.has-three > .lane-road,
.world.has-three > .rail-track,
.world.has-three > .scenery{display:none!important}
.world .three-scene{position:absolute;inset:0;z-index:1;overflow:hidden;pointer-events:none}
.world .three-scene canvas{display:block;width:100%;height:100%;object-fit:cover}
.world.has-three .objects{z-index:3;pointer-events:none}
.world.has-three .source{
  position:absolute;
  width:clamp(74px,11vw,120px);
  height:clamp(72px,11vw,108px);
  padding:0;
  background:transparent;
  border:0;
  border-radius:50%;
  box-shadow:none;
  outline:0;
  pointer-events:auto;
  cursor:pointer;
  transform:translate(-50%,-50%);
  transition:none;
}
.world.has-three .source img{display:none}
.world.has-three .source.revealed{
  background:transparent;
  border:0;
  box-shadow:none;
}
.world.has-three .source.revealed::after{
  content:'✓';position:absolute;right:-5px;top:-5px;
  display:flex;align-items:center;justify-content:center;
  width:31px;height:31px;line-height:1;background:#61cb89;
  border:3px solid white;border-radius:50%;font:800 24px Baloo,system-ui,sans-serif;
  color:#22264b;box-shadow:0 3px 0 #3b9870;
}
.world.has-three .source.hint{animation:none}
.world.has-three .source.miss{animation:shake .35s linear 1}
.world.has-three .source:focus-visible{outline:4px dashed #ffc93c;outline-offset:2px}
@media(hover:hover) and (pointer:fine){
  .world.has-three .source:hover:not(.revealed){
    outline:3px solid rgba(255,255,255,.85);
    outline-offset:-4px;
    background:rgba(255,255,255,.065);
  }
}
.world.has-three .source .burst{display:none}
.world.has-three .listen{z-index:12}
.world.has-three .sound-mark{z-index:11}
@media(max-width:420px){
  .world.has-three{min-height:470px;border-radius:22px}
  .world.has-three .source{width:clamp(66px,19vw,88px);height:clamp(66px,19vw,88px)}
}


/* FULL-SCREEN GAMEPLAY — the 3D world reaches every screen edge.
   HUD, instruction, progress and listen control float above the scene. */
body.playing{overflow:hidden;overscroll-behavior:none}
body.playing .app{max-width:none;width:100%;min-height:100dvh;overflow:visible}
body.playing .screen.game.active{
  display:block;
  position:fixed;
  inset:0;
  width:100%;
  height:100dvh;
  min-height:0;
  padding:0;
  margin:0;
  overflow:hidden;
  isolation:isolate;
  z-index:8;
}
body.playing .game #world{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  max-height:none;
  min-height:0;
  flex:none;
  padding:0;
  margin:0;
  border:0;
  border-radius:0;
  box-shadow:none;
  overflow:hidden;
  transform:none;
}
body.playing .game #world.has-three{
  border:0;
  border-radius:0;
  box-shadow:none;
}
body.playing .game .three-scene,
body.playing .game .three-scene canvas{
  width:100%;
  height:100%;
  border-radius:0;
}
body.playing .game .hud{
  position:absolute;
  z-index:12;
  top:max(13px,env(safe-area-inset-top));
  right:max(15px,env(safe-area-inset-right));
  left:max(15px,env(safe-area-inset-left));
  margin:0;
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  pointer-events:none;
}
body.playing .game .hud .circle,
body.playing .game .hud .score{pointer-events:auto}
body.playing .game .hud-middle{
  max-width:min(64vw,600px);
  margin:0 auto;
  padding:0 4px;
}
body.playing .game .hud-middle strong{
  font-size:clamp(22px,3vw,31px);
  line-height:1.1;
  display:block;
  margin:1px 0 8px;
}
body.playing .game .hud .dots{
  direction:ltr;
  margin:0;
  gap:5px;
}
body.playing .game .hud .dots i{width:clamp(12px,2.2vw,22px)}
body.playing .game .prompt{
  position:absolute;
  z-index:12;
  top:calc(max(13px,env(safe-area-inset-top)) + 80px);
  left:50%;
  transform:translateX(-50%);
  width:max-content;
  max-width:calc(100% - 32px);
  min-height:61px;
  margin:0;
  padding:8px 24px;
  border-radius:21px;
  text-align:center;
  line-height:1.25;
  pointer-events:none;
}
body.playing .game .game-footer{
  position:absolute;
  z-index:12;
  left:max(17px,env(safe-area-inset-left));
  right:max(17px,env(safe-area-inset-right));
  bottom:calc(max(12px,env(safe-area-inset-bottom)) + 2px);
  min-height:0;
  margin:0;
  padding:0;
  display:flex;
  flex-direction:row;
  align-items:flex-end;
  gap:15px;
  pointer-events:none;
}
body.playing .game .game-footer #hint{
  background:#fffdf6;
  border-radius:17px;
  padding:7px 12px 5px;
  max-width:min(76%,560px);
  font-weight:600;
  font-size:clamp(14px,2vw,19px);
  line-height:1.35;
}
body.playing .game .game-footer .small-progress{
  font-size:20px;
  font-weight:800;
  min-width:77px;
  flex-shrink:0;
  padding:7px 13px 4px;
  box-shadow:0 3px 0 #b8c6dc;
}
body.playing .game .world .listen{
  z-index:11;
  right:max(17px,env(safe-area-inset-right));
  bottom:calc(max(12px,env(safe-area-inset-bottom)) + 65px);
}
body.playing .game .world .sound-mark{top:48%;z-index:10}
@media (max-width:600px){
  body.playing .game .hud .circle{width:55px;height:55px}
  body.playing .game .hud .circle svg{height:26px;width:26px}
  body.playing .game .hud .score{font-size:20px;padding:7px;min-width:62px}
  body.playing .game .hud .score svg{height:23px;width:23px}
  body.playing .game .hud-middle{max-width:calc(100% - 140px)}
  body.playing .game .hud-middle strong{font-size:clamp(18px,5vw,25px);margin-top:5px}
  body.playing .game .hud .dots{gap:2px}
  body.playing .game .hud .dots i{width:clamp(7px,1.9vw,15px);height:7px}
  body.playing .game .hud .dots i.now{height:11px}
  body.playing .game .prompt{
    top:calc(max(13px,env(safe-area-inset-top)) + 74px);
    width:calc(100% - 34px);
    max-width:430px;
    min-height:60px;
    padding:10px 10px;
    font-size:clamp(18px,4.5vw,23px);
    gap:8px;
  }
  body.playing .game .prompt-icon{transform:scale(.82)}
  body.playing .game .game-footer{gap:8px;align-items:flex-end}
  body.playing .game .game-footer #hint{font-size:14px;max-width:calc(100% - 94px)}
  body.playing .game .game-footer .small-progress{font-size:16px;min-width:73px}
  body.playing .game .world .listen{
    height:75px;width:75px;
    bottom:calc(max(15px,env(safe-area-inset-bottom)) + 78px);
  }
  body.playing .game .world .listen svg{width:51px;height:51px}
}
@media (max-height:520px) and (min-width:601px){
  body.playing .game .hud{top:max(7px,env(safe-area-inset-top))}
  body.playing .game .hud .circle{height:48px;width:48px}
  body.playing .game .hud-middle strong{font-size:21px;margin:1px 0 3px}
  body.playing .game .prompt{
    top:calc(max(7px,env(safe-area-inset-top)) + 54px);
    min-height:49px;
    padding:5px 14px;
    font-size:21px;
  }
  body.playing .game .world .listen{width:65px;height:65px;bottom:62px}
  body.playing .game .world .listen svg{width:48px;height:48px}
}
