/* عالم حامد — games (R4). Mobile first at 390; RTL first (logical properties); transforms + opacity only for motion.
   The painted place moves by translate3d (camera), the avatar by translate3d (walk); the needle rotates with a CSS spring. */
.pg-body{--bar:64px;--spring:linear(0,.012 .9%,.05 2%,.411 9.2%,.517 11.8%,.611 14.6%,.694 17.7%,.765 21.1%,.824 24.8%,.872 28.9%,.91 33.4%,.939 38.4%,.977 50.9%,.994 68.4%,1);
  -webkit-user-select:none;user-select:none;overscroll-behavior:none}
.pg [hidden]{display:none!important}
.pg input{-webkit-user-select:text;user-select:text}
html.pg-playing,html.pg-playing body{overflow:hidden;height:100%}
.pg{min-height:100svh}
.pg-col{position:relative;min-height:100svh;display:flex;flex-direction:column;background:var(--ivory)}
.pg-info,.pg-side{display:none}

/* ---------- the bar: compass (inline-start) · title or tray · sound (inline-end) ---------- */
.pg-bar{position:sticky;top:0;z-index:30;height:calc(var(--bar) + env(safe-area-inset-top,0px));padding:env(safe-area-inset-top,0px) 12px 0;display:grid;grid-template-columns:56px 1fr 56px;align-items:center;gap:8px;background:color-mix(in srgb,var(--ivory) 94%,transparent);border-block-end:1.5px solid color-mix(in srgb,var(--gold) 55%,transparent)}
.pg-compass{width:48px;height:48px;justify-self:start}
.pg-compass svg{width:100%;height:100%}
.pg-compass .needle{transform-origin:32px 32px;transform-box:view-box;transition:transform .7s var(--spring);will-change:transform}
.pg-calm .pg-compass .needle{transition:none}
.pg-compass.shiver svg{animation:pg-shiver .3s steps(3,end) 1}
@keyframes pg-shiver{0%{transform:rotate(0)}33%{transform:rotate(-5deg)}66%{transform:rotate(4deg)}100%{transform:rotate(0)}}
.pg-bar-t{grid-column:2;text-align:center;font:700 26px/1.3 var(--display);color:var(--gold-text);padding-block:.08em .02em}
.pg-tray{grid-column:2;display:flex;justify-content:center;gap:8px;margin:0;padding:0;list-style:none}
.pg-slot{position:relative;width:52px;height:46px;display:grid;place-items:center;border-radius:14px;background:var(--ivory-2);border:1.5px solid var(--ivory-3);transform-origin:50% 50%}
.pg-slot-img{width:32px;height:32px;object-fit:contain;opacity:.32;filter:grayscale(1) sepia(.3);transition:opacity .25s var(--ease-out),filter .25s var(--ease-out)}
.pg-slot.is-held{border-color:var(--gold);border-style:dashed}
.pg-slot.is-held .pg-slot-img{opacity:.7;filter:none}
.pg-slot.is-back{background:#FFF6E2;border:2px solid var(--gold);box-shadow:inset 0 0 0 3px var(--ivory)}
.pg-slot.is-back .pg-slot-img{opacity:1;filter:none}
.pg-slot-gift{position:absolute;inset-block-end:-6px;inset-inline-end:-6px;width:24px;height:24px;object-fit:contain;filter:drop-shadow(0 1px 1px rgba(78,43,23,.35))}
.pg-mute{grid-column:3;justify-self:end;width:52px;height:52px;border-radius:50%;border:0;background:var(--wood);color:var(--ivory);display:grid;place-items:center;cursor:pointer;box-shadow:inset 0 0 0 2px var(--gold-hi),0 4px 10px -4px rgba(78,43,23,.5);transition:transform 120ms var(--ease-out)}
.pg-mute svg{width:24px;height:24px}
.pg-mute .x{display:none}
.pg-mute.is-off{background:var(--ink-soft)}
.pg-mute.is-off .x{display:block}.pg-mute.is-off .w{display:none}
.pg-mute:active{transform:scale(.94)}
.no-js .pg-mute{display:none}

/* ---------- the start screen: who walks the path + name ---------- */
.pg-main{flex:1;display:flex;flex-direction:column}
.pg-crown-wrap{height:88px;overflow:hidden;margin-inline:-1px}
.pg-crown{width:100%;height:96px}
.pg-start,.pg-end{padding:0 20px calc(28px + env(safe-area-inset-bottom,0px))}
.pg-start .pg-crown-wrap,.pg-end .pg-crown-wrap{margin-inline:-20px}
.pg-form{display:grid;gap:18px;max-width:560px;margin-inline:auto}
.pg-looks{border:0;margin:0;padding:0;min-width:0}
.pg-h{font:700 36px/1.3 var(--display);color:var(--ink);text-align:center;width:100%;padding-block:.06em .02em;margin-block-end:14px;text-wrap:balance}
.pg-looks-row{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.pg-look{min-width:0;display:grid;gap:6px;justify-items:center;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.pg-look input{position:absolute;opacity:0;width:1px;height:1px}
.pg-look-arch{position:relative;display:block;min-height:0;overflow:hidden;width:100%;aspect-ratio:5/8;border-radius:999px 999px 16px 16px;background:radial-gradient(120% 80% at 50% 70%,#FFF6E2,var(--ivory-2));border:2px solid var(--ivory-3);padding:14px 8px 10px;transition:border-color .2s ease,box-shadow .2s var(--ease-out)}
.pg-look-arch img{position:absolute;inset:16px 8px 8px;width:calc(100% - 16px);height:calc(100% - 24px);max-width:none;object-fit:contain;object-position:50% 100%}
.pg-look-name{font:600 16px/1.4 var(--text);color:var(--ink);text-align:center}
.pg-look input:checked+.pg-look-arch{border:3px solid var(--gold);box-shadow:0 10px 22px -14px rgba(107,61,34,.6),inset 0 0 0 3px #FFF9EE}
.pg-look input:focus-visible+.pg-look-arch{outline:3px solid var(--gold-text);outline-offset:3px}
.pg-look:active .pg-look-arch{transform:scale(.97)}
.pg-field label{display:block;font:600 19px/1.5 var(--text);color:var(--ink);margin-block-end:6px}
.pg-field input{width:100%;min-height:58px;font:400 20px/1.4 var(--text);color:var(--ink);background:#FFFCF5;border:2px solid var(--gold);border-radius:18px;padding:10px 16px}
.pg-field input:focus-visible{outline:3px solid var(--gold-text);outline-offset:2px}
.pg-note{font:400 15px/1.7 var(--text);color:var(--ink-soft);margin-block-start:6px}
.pg-go{justify-self:center;min-width:240px;justify-content:center;min-height:60px;font-size:20px}
.pg-grown{font-size:15px;color:var(--ink-soft)}
.pg-grown summary{display:inline-flex;align-items:center;min-height:44px;cursor:pointer;list-style:none;text-decoration:underline;text-decoration-color:color-mix(in srgb,var(--gold) 70%,transparent);text-underline-offset:5px}
.pg-grown summary::-webkit-details-marker{display:none}
.pg-grown[open]{display:grid;gap:12px}
.pg-switch{display:flex;align-items:center;justify-content:space-between;gap:14px;width:100%;min-height:56px;padding:10px 14px;background:var(--ivory-2);border:1.5px solid var(--ivory-3);border-radius:14px;cursor:pointer;text-align:start}
.pg-switch b{display:block;font:600 16px/1.4 var(--text);color:var(--ink)}
.pg-switch small{display:block;font:400 14px/1.6 var(--text);color:var(--ink-soft)}
.pg-switch .track{flex:none;width:46px;height:28px;border-radius:999px;background:var(--ivory-3);position:relative;transition:background-color .2s ease}
.pg-switch .track::after{content:"";position:absolute;top:3px;inset-inline-start:3px;width:22px;height:22px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.25);transition:transform .2s var(--ease-out)}
.pg-switch[aria-checked=true] .track{background:var(--gold)}
.pg-switch[aria-checked=true] .track::after{transform:translateX(calc(18px * var(--dir) * -1))}
html[dir=ltr] .pg-switch[aria-checked=true] .track::after{transform:translateX(18px)}
.pg-clear-row{display:flex;gap:10px;flex-wrap:wrap}
.pg-sure{background:#F6E0D6;border-color:#E2B4A0}
.pg-back{text-align:center;font-size:15px;color:var(--ink-soft)}
.pg-back .ghost{font-size:16px}
.pg-keys{background:var(--ivory-2);border:1.5px solid var(--ivory-3);border-radius:18px;padding:16px 18px}
.pg-keys-h{font:600 15px/1.4 var(--text);color:var(--gold-text);margin-block-end:8px}
.pg-keys dl{display:grid;gap:8px;margin:0 0 8px}
.pg-keys dl div{display:grid;grid-template-columns:84px 1fr;align-items:center;gap:12px}
.pg-keys dd{margin:0;font:400 15px/1.5 var(--text);color:var(--ink)}
.pg-keys kbd{display:inline-block;min-width:44px;text-align:center;font:600 14px/1 var(--text);padding:9px 10px;background:#FFFCF5;border:1.5px solid var(--gold);border-radius:10px;box-shadow:0 2px 0 var(--ivory-3)}
.pg-keys p{font:400 14px/1.6 var(--text);color:var(--ink-soft)}
.pg-nojs{display:none;text-align:center}
.no-js .pg-nojs{display:grid;gap:14px;justify-items:center}
.pg-nojs img{width:min(320px,80vw);height:auto;border-radius:16px;max-height:60svh;object-fit:cover;object-position:50% 100%}

/* ---------- the play screen: the stage owns every gesture (touch-action:none here only) ---------- */
.pg-play{position:relative;flex:1;display:flex}
.pg-stage{position:relative;flex:1;height:calc(100svh - var(--bar) - env(safe-area-inset-top,0px));overflow:hidden;touch-action:none;background:#E9D3A8;outline:none;contain:strict}
.pg-world{position:absolute;inset-inline:0;top:0;will-change:transform;contain:layout style;transform-origin:0 0}   /* origin 0 0: the thanks camera scales from the top-left (JS keeps screen = world*z - cam) */
.pg-place{position:absolute;inset:0;width:100%;height:100%;display:block;pointer-events:none}
.pg-own,.pg-obj,.pg-door{position:absolute;top:0;left:0;padding:0;margin:0;border:0;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation}
.pg-own::before,.pg-obj::before{content:"";position:absolute;inset:-14px}   /* hit area larger than the sprite (>= 56 px) */
.pg-own:focus-visible,.pg-obj:focus-visible,.pg-door:focus-visible{outline:3px solid var(--gold-text);outline-offset:4px;border-radius:14px}
.pg-mood{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;object-position:50% 100%;transform-origin:50% 100%}   /* both moods stand on the same feet line */
.pg-mood.is-glad{opacity:0}
.pg-own.is-glad .pg-mood.is-worried{opacity:0}.pg-own.is-glad .pg-mood.is-glad{opacity:1}
.pg-bub{position:absolute;bottom:100%;inset-inline-start:50%;translate:-50% 0;margin-block-end:4px;width:68px;height:68px;display:grid;place-items:center;background:#FFFCF5;border-radius:22px;box-shadow:0 6px 14px -8px rgba(78,43,23,.55),inset 0 0 0 1.5px var(--ivory-3)}
html[dir=rtl] .pg-bub{translate:50% 0}
.pg-bub::after{content:"";position:absolute;bottom:-16px;left:50%;width:12px;height:12px;margin-left:-6px;border-radius:50%;background:#FFFCF5;box-shadow:0 0 0 1.5px var(--ivory-3),6px 10px 0 -2px #FFFCF5}
.pg-bub-img{width:46px;height:46px;object-fit:contain}
.pg-obj-img{position:relative;width:100%;height:100%;object-fit:contain;filter:drop-shadow(0 3px 2px rgba(78,43,23,.3))}
/* the lost-thing cue (CD re-check D): a 2.5 px ring in the site gold at full opacity, edged by a thin light halo so it reads
   on sand and in shade; level 1 shows it from the start, level 2+ when near. One slow soft pulse ring breathes out of it
   (transform + opacity only); still under reduced motion and the calm switch. */
.pg-ring{position:absolute;inset:8% -26%;border:2.5px solid var(--gold);border-radius:50%;opacity:0;transform:scale(.92);transition:opacity .25s var(--ease-out),transform .25s var(--ease-out);pointer-events:none;box-shadow:0 0 0 1.5px rgba(255,248,228,.75),inset 0 0 0 1.5px rgba(255,248,228,.6)}
.pg-ring::after{content:"";position:absolute;inset:-2.5px;border:2px solid var(--gold-hi);border-radius:50%;opacity:0}
.pg-obj.is-near .pg-ring,.pg-obj.is-cue .pg-ring{opacity:1;transform:scale(1)}
.pg-obj.is-near .pg-ring::after,.pg-obj.is-cue .pg-ring::after{animation:pg-cue 2.6s cubic-bezier(.25,.6,.35,1) infinite}
.pg-stage.is-walking .pg-ring::after{animation-play-state:paused}   /* the pulse rests while the child walks (keeps the walk at 60 fps on slow phones) */
@keyframes pg-cue{0%{opacity:.85;transform:scale(1)}70%,100%{opacity:0;transform:scale(1.22)}}
.pg-calm .pg-ring::after{animation:none!important;opacity:0}
.pg-tuft{display:none;position:absolute;inset:38% -30% -12% -10%;pointer-events:none;background:radial-gradient(circle at 20% 70%,#6E8B4E 0 26%,transparent 27%),radial-gradient(circle at 48% 58%,#86A35F 0 28%,transparent 29%),radial-gradient(circle at 76% 72%,#6E8B4E 0 26%,transparent 27%),radial-gradient(circle at 60% 88%,#5E7A42 0 30%,transparent 31%)}
.pg-obj.is-tucked .pg-tuft{display:block}
/* the end door: no box and no ring (CD R4-1c fix 6); once open, a soft warm light falls on the painted leaves, breathes twice, stays */
.pg-door-glow{position:absolute;inset:-6% -12% 4%;border-radius:50%;pointer-events:none;opacity:0;background:radial-gradient(closest-side,rgba(255,232,170,.85),rgba(255,214,130,.40) 58%,rgba(255,214,130,0));transition:opacity .6s var(--ease-out)}
.pg-door.is-open .pg-door-glow{opacity:1;animation:pg-glow 1.8s ease-in-out 2}
/* the child reaches the open door (motion M2): the light swells and takes them in, the play screen fades to the end */
.pg-door.is-entering .pg-door-glow{opacity:1;scale:1.15;animation:none;transition:opacity .2s,scale .35s cubic-bezier(.23,1,.32,1)}
@keyframes pg-glow{0%,100%{opacity:1}50%{opacity:.45}}
/* contact shadows (CD R4-1c fix 5, made to read in re-check A): a soft cast ~85% of the sprite's width, core ~.5, pushed a
   little to the left like the painting's own cast shadows (sun on the right: jars, pigeons, neem; designer r3 note); plus a tight dark occlusion (~4 px) right under
   the soles, centred on the feet. Plain alpha, not multiply: each person is its own transformed (isolated) layer, where
   multiply would blend with nothing; on the sand the two read the same. The avatar's breathes ~5% on each step frame. */
.pg-shadow{position:absolute;left:7.5%;bottom:0;width:85%;aspect-ratio:1/.2;translate:-7% 46%;border-radius:50%;pointer-events:none;background:radial-gradient(closest-side,rgba(62,38,16,.52),rgba(62,38,16,.38) 42%,rgba(62,38,16,.14) 76%,rgba(62,38,16,0))}
.pg-shadow::after{content:"";position:absolute;left:38%;width:38%;top:54%;height:5px;margin-top:-3.5px;border-radius:50%;background:radial-gradient(closest-side,rgba(40,22,8,.78),rgba(40,22,8,.45) 60%,rgba(40,22,8,0))}   /* the dark line under the soles (offset back to the feet) */
.pg-av .pg-shadow{left:10%;width:80%;transition:scale .12s ease-out}
.pg-av .pg-shadow::after{left:39%;width:36%}
.pg-av.f2 .pg-shadow{scale:.94 1}
.pg-calm .pg-av .pg-shadow{transition:none}
.pg-calm .pg-door.is-open .pg-door-glow{animation:none}
.pg-av{position:absolute;top:0;left:0;pointer-events:none;will-change:transform}
.pg-av-f{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;object-position:50% 100%}   /* both step frames on the shadow's feet line */
.pg-av-f.b{visibility:hidden}
.pg-av.f2 .pg-av-f.a{visibility:hidden}.pg-av.f2 .pg-av-f.b{visibility:visible}
.pg-held{position:absolute;top:44%;left:50%;margin-left:-20%;height:auto;filter:drop-shadow(0 2px 2px rgba(78,43,23,.35))}
/* CD r3: carried things at hand scale, not map-icon scale (the pencil read as tall as the child). max-width beats the inline width. */
.pg-held[src*="obj-pen."]{max-width:42%;top:50%}
.pg-held[src*="obj-lunch."]{max-width:80%;top:48%}
.pg-fly{position:fixed;top:0;left:0;z-index:60;height:auto;pointer-events:none;will-change:transform}
.pg-fly-card{border-radius:6px;box-shadow:0 8px 18px -10px rgba(78,43,23,.6)}
/* the thank-you bubble (speech, with the child's name) and the caption line */
.pg-say{position:absolute;inset-inline:16px;top:16px;z-index:20;display:flex;justify-content:center;pointer-events:none;opacity:0;transition:opacity .25s var(--ease-out)}
.pg-say.is-on{opacity:1}
.pg-say-t{max-width:360px;font:600 21px/1.6 var(--text);color:var(--ink);background:#FFFCF5;border-radius:22px;padding:12px 20px;box-shadow:0 12px 24px -14px rgba(78,43,23,.6),inset 0 0 0 1.5px var(--gold);text-align:center;text-wrap:balance}
.pg-say-t .nm{color:var(--wood)}
/* the tail: JS places the bubble above the speaking owner and sets the tail's left and length so its tip lands on the head */
.pg-say-tail{position:absolute;top:calc(100% - 2px);left:50%;width:22px;height:22px;margin-left:-11px;pointer-events:none;background:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 30' preserveAspectRatio='none'%3E%3Cpath d='M0 0L9.6 28.6Q11 31 12.4 28.6L22 0' fill='%23FFFCF5' stroke='%23C29A4B' stroke-width='1.5' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") 0 0/100% 100% no-repeat;filter:drop-shadow(0 4px 4px rgba(78,43,23,.18))}
.pg-cap{position:absolute;inset-inline:12px;bottom:calc(12px + env(safe-area-inset-bottom,0px));z-index:20;display:flex;justify-content:center;pointer-events:none}
.pg-cap-t{max-width:420px;font:400 16px/1.65 var(--text);color:var(--ivory);background:color-mix(in srgb,var(--ink) 86%,transparent);border-radius:16px;padding:8px 14px;text-align:center;text-wrap:pretty}
.pg-cap-t:empty{display:none}

/* ---------- the end: postcard + reward into the box ---------- */
.pg-end{text-align:center;display:grid;justify-items:center;gap:12px;max-width:600px;margin-inline:auto;width:100%;padding-block-start:28px}   /* no empty arch panel: the postcard carries the picture (CD R4-1c fix 6) */
.pg-end-h{font:700 44px/1.3 var(--display);color:var(--ink);padding-block:.08em .02em;outline:none;text-wrap:balance}
.pg-end-line{font:400 20px/1.7 var(--text);color:var(--ink-soft)}
.pg-card{margin:10px 0 0;width:100%;max-width:440px;background:#FFFCF5;padding:12px 12px 8px;border-radius:6px;box-shadow:0 14px 30px -16px rgba(78,43,23,.55),inset 0 0 0 1px var(--ivory-3);transform:rotate(1.5deg)}
html[dir=ltr] .pg-card{transform:rotate(-1.5deg)}
.pg-card img{width:100%;height:auto;aspect-ratio:3/2;object-fit:cover;border-radius:3px}
.pg-card figcaption{display:flex;justify-content:space-between;align-items:baseline;gap:10px;padding:8px 4px 2px;text-align:start}
.pg-card-to{font:600 17px/1.5 var(--text);color:var(--ink)}
.pg-card-k{font:700 20px/1.3 var(--display);color:var(--gold-text);white-space:nowrap}
.pg-box-row{display:flex;align-items:center;gap:12px;max-width:440px;text-align:start}
.pg-box{position:relative;flex:none;width:58px;height:52px;overflow:hidden;border-radius:10px}
.pg-box svg{width:100%;height:100%}
.pg-box-glint{position:absolute;inset:-10% auto -10% 0;width:55%;opacity:0;background:linear-gradient(90deg,rgba(226,194,122,0),rgba(255,236,180,.85),rgba(226,194,122,0));transform:rotate(20deg)}
.pg-saved{font:400 16px/1.7 var(--text);color:var(--ink-soft)}
.pg-end-acts{display:grid;gap:10px;justify-items:center;margin-block-start:6px}
.pg-end-acts .btn{min-width:240px;justify-content:center;min-height:58px}
.pg-standin{position:fixed;bottom:4px;inset-inline-start:6px;z-index:70;margin:0;font:600 11px/1 var(--text);color:#8A5F1C;background:rgba(255,252,245,.85);padding:4px 7px;border-radius:6px;pointer-events:none}
@media (max-width:1023px){html.pg-playing .pg-standin{bottom:auto;top:calc(var(--bar) + 6px)}}

/* ---------- desktop (>= 1024): a phone-width stage in the middle, the story at the reading start, keys at the end ---------- */
@media (min-width:1024px){
  .pg{display:grid;grid-template-columns:1fr minmax(400px,460px) 1fr;column-gap:56px;align-items:start;min-height:100svh}
  .pg-info,.pg-side{display:block;position:sticky;top:0;padding-block:140px 40px}
  .pg-info{padding-inline-start:64px;max-width:460px;justify-self:end;text-align:start}
  .pg-info-h{font:700 54px/1.25 var(--display);margin:8px 0 14px}
  .pg-info p{color:var(--ink-soft);font-size:18px;line-height:1.8}
  .pg-side{padding-inline-end:64px;max-width:420px}
  .pg-col{border-inline:3px solid var(--ivory-3);box-shadow:0 0 0 6px var(--ivory-2)}
  .pg-start .pg-keys,.pg-grown .pg-keys{display:none}
  .pg-crown-wrap{height:72px}
}
@media (hover:hover) and (pointer:fine){
  .pg-look:hover .pg-look-arch{border-color:var(--gold)}
  .pg-own:hover .pg-mood,.pg-obj:hover .pg-obj-img{filter:drop-shadow(0 0 0 transparent) brightness(1.04)}
  .pg-mute:hover{background:var(--wood-deep)}
}
@media (prefers-reduced-motion:reduce){
  .pg-compass .needle,.pg-ring,.pg-say,.pg-slot-img,.pg-switch .track::after{transition:none}
  .pg-door.is-open .pg-door-glow,.pg-compass.shiver svg,.pg-ring::after{animation:none!important}
  .pg-av .pg-shadow,.pg-door-glow{transition:none}
}
/* round 5 · the treasure box at the end of game 1 shares the site's accent: lid and clasp in accent, 2 px accent-deep stroke */
.pg-box-lid,.pg-box-clasp{fill:var(--accent);stroke:var(--accent-deep)}
