/* Wadi Wonders — calm, warm UI. System fonts so the prototype needs no network. */
:root {
  --ink: #2F2A26; --paper: #FBF6EC; --sand: #F1E4CC; --ochre: #8A5A2E; --halter: #3E6E8E;
  --sage: #8FA77A; --violet: #9B7BB8; --gold: #E9C46A;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #20160E; color: var(--ink); font-family: var(--round); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; }
button { font-family: inherit; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--sand); font-size: 22px; background: #20160E; transition: opacity .8s; z-index: 50; }
#loading.done { opacity: 0; pointer-events: none; }

/* Title */
#title { position: fixed; inset: 0; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity 1s; z-index: 10; }
#title.show { opacity: 1; pointer-events: auto; }
.title-inner { text-align: center; padding: 32px 40px; border-radius: 32px; background: rgba(251,246,236,.86); max-width: min(620px, 90vw); box-shadow: 0 20px 60px rgba(40,20,5,.35); }
.title-inner .kicker { margin: 0; font-size: 15px; letter-spacing: .08em; color: var(--ochre); font-weight: 700; }
.title-inner h1 { margin: 6px 0 8px; font-size: clamp(36px, 6vw, 60px); line-height: 1.05; }
.title-inner .sub { margin: 0 0 22px; font-size: clamp(16px, 2.2vw, 20px); color: #5A4C40; }
.title-inner .proto { margin: 18px 0 0; font-size: 13px; color: #6B5B4B; }

/* Meet the explorers */
#meet { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; padding: 4vh 4vw 22vh; opacity: 0; pointer-events: none; transition: opacity .8s; z-index: 12; }
#meet.show { opacity: 1; pointer-events: auto; }
#meet h2 { margin: 0; padding: 8px 22px; border-radius: 999px; background: rgba(251,246,236,.88); font-size: clamp(20px, 3vw, 30px); }
#meet .cast { display: flex; gap: clamp(16px, 5vw, 70px); align-items: flex-end; justify-content: center; width: 100%; }
#meet .char { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; opacity: 0; transform: translateY(30px) scale(.96); transition: opacity .9s, transform .9s cubic-bezier(.2,1.4,.4,1); }
#meet .char.in { opacity: 1; transform: none; }
#meet .char.talking .portrait { box-shadow: 0 0 0 6px rgba(233,196,106,.9), 0 16px 40px rgba(40,20,5,.35); }
#meet .char.talking { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
#meet .portrait { position: relative; width: clamp(150px, 26vw, 320px); aspect-ratio: 4/5; border-radius: 28px; background: radial-gradient(circle at 50% 35%, #FBF1DD, #EBD3A8); overflow: hidden; display: grid; place-items: end center; transition: box-shadow .4s; box-shadow: 0 16px 40px rgba(40,20,5,.3); }
#meet .portrait img { position: absolute; left: 4%; top: 4%; width: 92%; height: 96%; object-fit: contain; object-position: 50% 100%; }
#meet .jannah .portrait img { left: 0; top: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0%; transform: scale(1.0); padding-top: 6%; box-sizing: border-box; }
#meet .portrait .placeholder { position: absolute; inset: 12px; border: 3px dashed #B98F63; border-radius: 22px; display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #6B4A2B; gap: 4px; padding: 10px; }
#meet .portrait .placeholder span { font-size: clamp(18px, 2.4vw, 26px); font-weight: 800; }
#meet .portrait .placeholder small { font-size: 13px; }
#meet .portrait.missing .placeholder { display: flex; }
#meet .portrait.missing img { display: none; }
#meet figcaption { padding: 6px 16px; border-radius: 999px; background: rgba(251,246,236,.92); font-weight: 800; font-size: clamp(14px, 1.8vw, 18px); color: #6B4A2B; }
#meet .skip { position: fixed; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); min-height: 48px; padding: 0 20px; border-radius: 999px; border: none; background: rgba(251,246,236,.8); color: #6B4A2B; font-size: 16px; font-weight: 700; cursor: pointer; }
@media (max-height: 520px) { #meet { padding: 2vh 4vw 26vh; } #meet h2 { font-size: 18px; } #meet .portrait { width: clamp(110px, 20vw, 200px); } }

/* Big calm buttons */
.big { min-height: 64px; padding: 0 38px; border: none; border-radius: 999px; background: var(--halter); color: #fff; font-size: 24px; font-weight: 700; cursor: pointer; box-shadow: 0 8px 22px rgba(30,50,70,.35); opacity: 0; transform: translateY(10px); transition: opacity .6s, transform .6s, background .2s; }
.big.show { opacity: 1; transform: none; }
.big:active { transform: scale(.97); }
.big:focus-visible, button:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
#actions { position: fixed; left: 0; right: 0; bottom: max(150px, 18vh); display: flex; justify-content: center; z-index: 33; pointer-events: none; }
#actions .big { pointer-events: auto; }
#actions .big.onjournal { position: fixed; right: 4vw; bottom: 3.5vh; }

/* Grown-ups button: small, low-key, still 48px */
#grownups { position: fixed; top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); width: 52px; height: 52px; border-radius: 999px; border: none; background: rgba(251,246,236,.72); color: #6B5B4B; display: none; place-items: center; z-index: 30; cursor: pointer; }
#grownups.show { display: grid; }

/* Seed tracker */
#hud { position: fixed; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); display: flex; gap: 10px; padding: 10px 14px; border-radius: 999px; background: rgba(251,246,236,.8); opacity: 0; transition: opacity .6s; z-index: 15; pointer-events: none; }
#hud.show { opacity: 1; }
#hud .seed { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 50% 60%, #7A5434 0 45%, #B98F63 46% 100%); transition: transform .4s; }
#hud .seed.done { background: radial-gradient(circle at 50% 35%, #9B7BB8 0 22%, #76AE57 23% 55%, #8FA77A 56% 100%); transform: scale(1.15); }

/* Captions: always on, large, calm */
#caption { position: fixed; left: 50%; bottom: max(22px, 3.5vh); transform: translate(-50%, 12px); width: min(860px, 92vw); padding: 14px 22px 16px; border-radius: 24px; background: rgba(251,246,236,.94); box-shadow: 0 10px 30px rgba(40,20,5,.25); opacity: 0; transition: opacity .5s, transform .5s; z-index: 18; pointer-events: none; }
#caption.show { opacity: 1; transform: translate(-50%, 0); }
#caption-who { margin: 0 0 2px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ochre); }
#caption-text { margin: 0; font-size: clamp(18px, 2.4vw, 26px); line-height: 1.3; }

/* Ayah moment */
#ayah { position: fixed; left: 50%; top: 10vh; transform: translate(-50%, -8px); width: min(720px, 90vw); padding: 22px 28px; border-radius: 26px; background: rgba(251,246,236,.93); text-align: center; opacity: 0; transition: opacity 1.2s, transform 1.2s; z-index: 17; pointer-events: none; }
#ayah.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#ayah .ref, .ayahbox .ref { margin: 0; font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #6B5B4B; }
#ayah .placeholder, .ayahbox .placeholder { margin: 8px 0; padding: 12px; border: 2px dashed #B98F63; border-radius: 14px; font-size: 15px; color: #5A4C40; }
.qari { min-height: 44px; padding: 0 16px; border-radius: 999px; border: none; background: #CDBFA9; color: #4A3B2E; font-size: 14px; font-weight: 700; }
#ayah .meaning { margin: 12px 0 4px; font-size: clamp(20px, 2.6vw, 28px); line-height: 1.3; }
#ayah .note { margin: 0; font-size: 12px; color: #6B5B4B; }

/* Journal */
#journal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(40,25,10,.45); opacity: 0; pointer-events: none; transition: opacity .8s; z-index: 32; padding: 3vh 3vw 12vh; }
#journal.show { opacity: 1; pointer-events: auto; }
.book { display: grid; grid-template-columns: 1fr 1fr; width: min(1120px, 94vw); max-height: 84vh; border-radius: 20px; overflow: hidden; box-shadow: 0 18px 50px rgba(30,15,5,.45); }
.page { padding: clamp(14px, 2.6vw, 30px); overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.page.left { background: var(--paper); border-right: 2px solid #E9DDC6; }
.page.right { background: #FDF9F1; }
.page h2 { margin: 0; font-size: clamp(28px, 4vw, 44px); line-height: 1.05; }
.kicker { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #6B5B4B; }
.polaroid { margin: 4px 0; align-self: flex-start; padding: 8px 8px 10px; background: #fff; border-radius: 6px; transform: rotate(-1.5deg); box-shadow: 0 4px 12px rgba(47,42,38,.18); max-width: 100%; }
.polaroid img { display: block; width: min(460px, 100%); aspect-ratio: 16/9; object-fit: cover; border-radius: 3px; background: var(--sand); }
.polaroid figcaption { margin-top: 6px; font-size: 15px; color: #5A4C40; }
.words { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.word { padding: 10px 12px; border-radius: 14px; display: flex; flex-direction: column; gap: 2px; }
.word.sand { background: var(--sand); } .word.water { background: #E2EDEF; }
.word .ar { margin: 0; font-size: 30px; line-height: 1.2; font-family: "Geeza Pro", "Noto Naskh Arabic", "Arial", serif; }
.word .en { margin: 0; font-size: 15px; }
.listen { align-self: flex-start; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1.5px solid #B98F63; background: transparent; font-size: 14px; font-weight: 700; color: #6B4A2B; cursor: pointer; }
.ayahbox { text-align: center; }
.explain { margin: 0; font-size: clamp(17px, 2vw, 21px); line-height: 1.3; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.facts p { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--sand); font-size: 14px; line-height: 1.4; }
.mission { margin: 0; padding: 12px 14px; border-radius: 14px; background: #E8EEDF; font-size: 14px; line-height: 1.45; }

/* End card */
#endcard { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; padding: 28px 36px; border-radius: 28px; background: rgba(251,246,236,.92); opacity: 0; pointer-events: none; transition: opacity 1.2s; z-index: 21; }
#endcard.show { opacity: 1; pointer-events: auto; }
#endcard h2 { margin: 0 0 6px; font-size: 32px; }
#endcard p { margin: 0 0 18px; color: #5A4C40; }

/* Grown-ups modal */
#modal { position: fixed; inset: 0; display: none; place-items: center; background: rgba(25,15,8,.6); z-index: 40; padding: 16px; }
#modal.show { display: grid; }
#panel { width: min(560px, 94vw); max-height: 90vh; overflow: auto; padding: 22px 24px; border-radius: 22px; background: var(--paper); -webkit-user-select: text; user-select: text; }
#panel h2 { margin: 0 0 6px; font-size: 26px; }
#panel h3 { margin: 16px 0 6px; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; color: #6B5B4B; }
#panel p, #panel li { font-size: 15px; line-height: 1.45; }
#panel .tag { display: inline-block; margin: 0; padding: 4px 10px; border-radius: 999px; background: var(--sand); font-size: 12px; font-weight: 700; color: #6B4A2B; }
#panel .choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
#panel .choices button, #panel .buttons button { min-height: 48px; border-radius: 14px; border: 1.5px solid #D8C7A8; background: #fff; font-size: 18px; font-weight: 700; cursor: pointer; }
#panel .row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 6px 0; }
#panel .row label { font-size: 16px; font-weight: 700; }
#panel .row input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--halter); }
#panel .row .help { grid-column: 1 / -1; margin: 0; font-size: 13px; color: #5A4C40; }
#panel .help { font-size: 13px; color: #5A4C40; }
#panel .buttons { grid-template-columns: 1fr; gap: 8px; }
#panel .buttons button { font-size: 15px; }
#panel .buttons .primary { background: var(--halter); color: #fff; border: none; }
#panel .link { border: none; background: none; color: var(--halter); font-size: 15px; font-weight: 700; min-height: 44px; cursor: pointer; }

/* Portrait hint (game still works, letterboxed) */
#rotate { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: rgba(251,246,236,.9); font-size: 14px; display: none; z-index: 25; pointer-events: none; }
body.portrait #rotate { display: block; }
#rotate p { margin: 0; }

@media (max-height: 520px) {
  body[data-scene="water"] #caption { top: max(10px, env(safe-area-inset-top)); bottom: auto; width: min(560px, 62vw); padding: 6px 14px 8px; }
  body[data-scene="water"] #caption-text { font-size: 15px; }
  #journal { padding: 8px 8px 72px; }
  .book { max-height: calc(100vh - 84px); }
  #actions .big.onjournal { bottom: 10px; }
  #caption { padding: 8px 16px 10px; }
  #caption-text { font-size: 17px; }
  #actions { bottom: 110px; }
  .big { min-height: 52px; font-size: 20px; padding: 0 28px; }
  .title-inner { padding: 18px 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Intro: keep "Let's go!" below the cards */
body[data-scene="meet"] #actions { bottom: max(40px, 8vh); }
@media (max-height: 520px) {
  body[data-scene="meet"] #meet { justify-content: flex-start; padding-top: 8px; }
  body[data-scene="meet"] #actions { bottom: 18px; }
}

/* ---------- World 1 shell: profiles, worlds, map header, level complete, journal ---------- */
#profiles, #newprofile, #worlds { position: fixed; inset: 0; z-index: 14; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.5vh; padding: 4vh 4vw; background: radial-gradient(ellipse at center, rgba(40,24,10,0.25), rgba(30,18,8,0.65)); opacity: 0; pointer-events: none; transition: opacity .5s; }
#profiles.show, #newprofile.show, #worlds.show { opacity: 1; pointer-events: auto; }
#profiles h2, #worlds h2 { margin: 0; padding: 10px 26px; border-radius: 999px; background: rgba(251,246,236,.92); color: #4A2E18; font-size: clamp(22px, 3.2vw, 34px); }
.plist { display: flex; flex-wrap: wrap; gap: clamp(12px, 2.5vw, 28px); justify-content: center; }
.pcard { width: clamp(140px, 18vw, 200px); min-height: clamp(170px, 24vh, 230px); border: none; border-radius: 28px; background: rgba(251,246,236,.94); box-shadow: 0 14px 34px rgba(30,15,5,.35); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px 10px; cursor: pointer; font: inherit; color: #4A2E18; transition: transform .2s; }
.pcard:active { transform: scale(.96); }
.pcard.add { background: rgba(251,246,236,.7); border: 3px dashed #B98F63; }
.pname { font-weight: 800; font-size: clamp(17px, 2vw, 22px); }
.pmeta { font-size: 14px; color: #7A5A3A; }
.avatar { display: inline-grid; place-items: center; border-radius: 50%; box-shadow: inset 0 -4px 0 rgba(0,0,0,.08); }
.avatar.l { width: clamp(76px, 9vw, 104px); height: clamp(76px, 9vw, 104px); font-size: clamp(42px, 5vw, 60px); }
.avatar.m { width: 64px; height: 64px; font-size: 36px; }
.avatar.s { width: 34px; height: 34px; font-size: 20px; vertical-align: middle; }
.avatar.plus { background: #EAD8BC; color: #8A6440; font-weight: 800; }
.np-card { width: min(720px, 94vw); max-height: 94vh; overflow: auto; background: #FBF6EC; border-radius: 28px; padding: clamp(16px, 3vh, 28px) clamp(18px, 3vw, 32px); box-shadow: 0 20px 50px rgba(20,10,0,.45); color: #4A2E18; }
.np-card h2 { margin: 0 0 6px; } .np-card h3 { margin: 14px 0 8px; font-size: 18px; }
.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; }
.avatars button, .ages button { border: 3px solid transparent; background: none; border-radius: 50%; padding: 2px; cursor: pointer; }
.avatars button[aria-checked="true"] { border-color: #E9B44C; transform: scale(1.06); }
.ages { display: flex; gap: 10px; flex-wrap: wrap; }
.ages button { border-radius: 999px; background: #EFE3CF; padding: 12px 18px; font: inherit; font-weight: 700; color: #5A3B22; min-height: 48px; }
.ages button[aria-checked="true"] { border-color: #E9B44C; background: #F7E2B0; }
#np-name { width: 100%; font: inherit; font-size: 20px; padding: 12px 16px; border-radius: 16px; border: 2px solid #D9C3A0; background: #fff; }
.np-btns { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.big.ghost { background: rgba(251,246,236,.85); color: #6B4A2B; }
.whead { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.who { padding: 6px 14px; border-radius: 999px; background: rgba(251,246,236,.9); font-weight: 700; color: #4A2E18; }
.chip { min-height: 48px; padding: 0 18px; border-radius: 999px; border: none; background: rgba(251,246,236,.9); color: #5A3B22; font: inherit; font-weight: 800; font-size: 16px; cursor: pointer; }
.wgrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(8px, 1.5vw, 16px); width: min(1100px, 94vw); }
.wcard { min-height: clamp(96px, 17vh, 150px); border: none; border-radius: 22px; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; text-align: left; font: inherit; color: #4A2E18; background: rgba(251,246,236,.92); box-shadow: 0 10px 24px rgba(20,10,0,.3); cursor: pointer; }
.wcard.open { background: linear-gradient(160deg, #FBE7B8, #F2C877); outline: 4px solid #FFF3D6; }
.wcard.locked { opacity: .62; cursor: default; }
.wnum { font-size: 14px; font-weight: 800; color: #8A6440; } .wtitle { font-weight: 800; font-size: clamp(14px, 1.6vw, 19px); } .wmeta { font-size: 13px; color: #7A5A3A; }
#maphead { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 74px; right: 74px; z-index: 13; display: flex; align-items: center; justify-content: space-between; gap: 12px; opacity: 0; pointer-events: none; transition: opacity .5s; }
#maphead.show { opacity: 1; pointer-events: auto; }
#maphead h2 { margin: 0; padding: 8px 20px; border-radius: 999px; background: rgba(251,246,236,.92); color: #4A2E18; font-size: clamp(16px, 2.2vw, 24px); text-align: center; }
#complete, #book { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(30,18,8,.45); opacity: 0; pointer-events: none; transition: opacity .5s; padding: 3vh 4vw; }
#complete.show, #book.show { opacity: 1; pointer-events: auto; }
.c-body, .book-card { width: min(640px, 94vw); max-height: 92vh; overflow: auto; background: #FBF6EC; border-radius: 28px; padding: clamp(16px, 3vh, 30px); box-shadow: 0 20px 50px rgba(20,10,0,.45); color: #4A2E18; text-align: center; }
.c-body .kicker { margin: 0; color: #8A6440; font-weight: 700; } .c-body h2 { margin: 4px 0; font-size: clamp(26px, 4vw, 38px); } .ctitle { margin: 0 0 10px; font-weight: 700; }
.entry { text-align: left; background: #F3E8D4; border-radius: 16px; padding: 10px 16px; margin: 10px 0; } .entry.new { background: #E8F1D8; outline: 3px solid #A9C98A; }
.entry h4 { margin: 0 0 4px; } .entry p { margin: 0; }
.entry p.src { margin-top: 4px; font-size: 12px; color: #8A6A4A; font-style: italic; }
.treasure { font-weight: 700; color: #6B4A2B; }
.cbtns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.entries { display: grid; gap: 4px; } .treasures { text-align: left; }
#devart { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(6px, env(safe-area-inset-bottom)); z-index: 12; margin: 0; padding: 4px 12px; border-radius: 999px; background: rgba(40,24,10,.55); color: #FBEFD8; font-size: 12px; opacity: 0; pointer-events: none; transition: opacity .5s; }
#devart.show { opacity: .9; }
#panel .small { min-height: 36px; padding: 0 12px; font-size: 14px; }
#panel textarea { width: 100%; font: 13px/1.4 ui-monospace, monospace; border-radius: 12px; padding: 8px; border: 2px solid #D9C3A0; }
.plist-admin { list-style: none; padding: 0; } .plist-admin li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
@media (max-height: 520px) {
  .pcard { min-height: 140px; } .avatar.l { width: 64px; height: 64px; font-size: 38px; }
  .wcard { min-height: 76px; } .avatars { grid-template-columns: repeat(8, 1fr); } .avatar.m { width: 48px; height: 48px; font-size: 28px; }
  #profiles, #worlds { gap: 1.5vh; padding: 2vh 3vw; }
}
@media (max-width: 700px) { .wgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .avatars { grid-template-columns: repeat(4, 1fr); } }
body[data-scene="map"] #caption { bottom: max(14px, env(safe-area-inset-bottom)); }

/* During play, Jannah's captions sit at the top so they never cover the play area */
body[data-scene="water"] #caption, body[data-scene="dew"] #caption, body[data-scene="rescue"] #caption, body[data-scene="seeds"] #caption,
body[data-scene="frogs"] #caption, body[data-scene="clouds"] #caption, body[data-scene="rainbow"] #caption, body[data-scene="celebrate"] #caption, body[data-scene="mech"] #caption {
  top: max(10px, env(safe-area-inset-top)); bottom: auto; width: min(760px, calc(100vw - 230px));
}
@media (max-height: 520px) {
  body[data-scene="water"] #caption, body[data-scene="dew"] #caption, body[data-scene="rescue"] #caption, body[data-scene="seeds"] #caption,
  body[data-scene="frogs"] #caption, body[data-scene="clouds"] #caption, body[data-scene="rainbow"] #caption, body[data-scene="celebrate"] #caption, body[data-scene="mech"] #caption {
    width: min(560px, 62vw); padding: 6px 14px 8px;
  }
  body[data-scene="dew"] #caption-text, body[data-scene="rescue"] #caption-text, body[data-scene="seeds"] #caption-text, body[data-scene="frogs"] #caption-text,
  body[data-scene="clouds"] #caption-text, body[data-scene="rainbow"] #caption-text, body[data-scene="celebrate"] #caption-text { font-size: 16px; }
}

body[data-scene="map"] #caption { top: calc(max(10px, env(safe-area-inset-top)) + 60px); bottom: auto; width: min(640px, 70vw); }
@media (max-height: 520px) { body[data-scene="map"] #caption { top: 62px; padding: 6px 14px 8px; } }

/* Painted avatars, treasures and journal page */
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.treasure { display: flex; align-items: center; justify-content: center; gap: 12px; }
.treasure-img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(255,220,140,.8)); }
.treasures { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.treasures li { display: flex; align-items: center; gap: 8px; text-align: left; font-size: 14px; }
.treasures .treasure-img { width: 44px; height: 44px; }
.book-card { background: #FBF6EC url('../assets/w1/journal_page.jpg') center / cover no-repeat; }
.book-card .entries .entry { background: rgba(251,246,236,.85); }

/* Quran text (verbatim from the Tanzil Uthmani file). Best Arabic font each device has. */
.quran { margin: 10px 0 6px; font-family: 'KFGQPC Uthmanic Script HAFS', 'Amiri Quran', 'Amiri', 'Geeza Pro', 'Noto Naskh Arabic', 'Scheherazade New', 'Traditional Arabic', serif;
  font-size: clamp(22px, 3vw, 32px); line-height: 2.1; color: #3B2A1A; direction: rtl; unicode-bidi: isolate; font-feature-settings: 'calt', 'liga'; }
.ayahbox .quran { font-size: clamp(18px, 2.2vw, 24px); }
.qcredit { margin: 4px 0 0; font-size: 11px; color: #7A6A58; }

/* Show-me guide for buttons: the button to press next breathes with a warm glow. */
@keyframes nudge { 0%, 100% { box-shadow: 0 8px 22px rgba(30,50,70,.35), 0 0 0 0 rgba(255,226,150,.85); } 50% { box-shadow: 0 8px 22px rgba(30,50,70,.35), 0 0 0 22px rgba(255,226,150,0); } }
#actions .big.show, #c-next, #begin.show, #np-go.show { animation: nudge 1.6s ease-out infinite; outline: 3px solid rgba(255,236,170,.9); outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { #actions .big.show, #c-next, #begin.show, #np-go.show { animation: none; } }

/* Read-aloud: speaker buttons, and tap the caption to hear it again */
.spk { display: inline-grid; place-items: center; width: 40px; height: 40px; margin-left: 6px; padding: 0; vertical-align: middle; border: 0; border-radius: 50%; background: #F3E3C3; box-shadow: 0 2px 6px rgba(60,35,10,.25); font-size: 19px; line-height: 1; cursor: pointer; }
.spk:active { transform: scale(.92); }
.cap-spk { display: none; float: right; width: 44px; height: 44px; margin: -4px -8px 0 10px; padding: 0; border: 0; border-radius: 50%; background: #F3E3C3; box-shadow: 0 2px 6px rgba(60,35,10,.25); font-size: 21px; line-height: 1; cursor: pointer; }
#caption.show.replay .cap-spk { display: inline-grid; place-items: center; pointer-events: auto; }
.treasures li.tap { cursor: pointer; }
.treasures li .spk { width: 34px; height: 34px; font-size: 16px; margin-left: auto; }

/* treasures from Worlds 2–10 (emoji development art until final paintings arrive) */
.treasure-e { display: inline-grid; place-items: center; font-size: 34px; line-height: 1; }

/* ---------- iPhone landscape: short screens (Safari's bars can leave only ~320px) ---------- */
html, body { height: 100dvh; }
@media (max-height: 520px) {
  #newprofile { padding: 6px max(70px, env(safe-area-inset-left)) 6px max(70px, env(safe-area-inset-right)); }
  .np-card { width: 100%; max-width: 720px; box-sizing: border-box; max-height: calc(100dvh - 12px); padding: 10px 18px 12px; border-radius: 20px; }
  #newprofile .avatars { grid-template-columns: repeat(8, 1fr); } #newprofile .avatars button { justify-self: center; }
  .np-card h2 { font-size: 20px; margin: 0 0 2px; }
  .np-card h3 { margin: 6px 0 4px; font-size: 14px; }
  .np-card p { margin: 4px 0; font-size: 13px; }
  .avatars { gap: 4px; } .avatar.m { width: 40px; height: 40px; }
  #np-name { font-size: 16px; padding: 6px 12px; border-radius: 12px; }
  .ages { gap: 6px; } .ages button { min-height: 36px; padding: 4px 12px; font-size: 14px; }
  .np-btns { margin-top: 8px; }
  .big { min-height: 46px; padding: 0 24px; font-size: 18px; }
  #grownups { width: 40px; height: 40px; }
  .book-card, .c-body { max-height: calc(100dvh - 16px); }
  #caption-text { font-size: 15px; }
  #complete, #book { padding: 6px max(60px, env(safe-area-inset-left)) 6px max(60px, env(safe-area-inset-right)); }
  .c-body { width: 100%; max-width: 640px; box-sizing: border-box; padding: 10px 18px; border-radius: 20px; }
  .c-body h2 { font-size: 24px; margin: 0; } .c-body .kicker { font-size: 12px; } .c-body .ctitle { margin: 0 0 6px; }
  .c-body p, .c-body div { line-height: 1.3; }
  .cbtns { margin-top: 6px; }
}
@media (max-height: 360px) {
  .np-card h3 { margin: 4px 0 2px; font-size: 13px; }
  .np-card p { display: none; }
  .avatar.m { width: 34px; height: 34px; }
  .big { min-height: 40px; font-size: 16px; }
  #profiles h2, #worlds h2 { font-size: 18px; padding: 6px 16px; }
  .wcard { min-height: 60px; }
  .c-body h2 { font-size: 20px; } .entry { margin: 4px 0; padding: 6px 12px; font-size: 13px; } .treasure-e { font-size: 24px; }
  .c-body .treasure img { width: 34px; height: 34px; }
}

/* a clear "hear it" button for children who can't read yet */
.listen-pill { display: inline-flex; align-items: center; gap: 6px; margin: 4px auto 6px; padding: 10px 22px; min-height: 48px; border: none; border-radius: 999px; background: #E9B44C; color: #3B2410; font: inherit; font-size: 18px; font-weight: 800; cursor: pointer; box-shadow: 0 6px 14px rgba(60,35,10,.25); }
.listen-pill:active { transform: scale(.97); }
@media (max-height: 520px) { .listen-pill { min-height: 38px; padding: 6px 16px; font-size: 15px; } }
@media (max-height: 520px) {
  #ayah { top: 6px; padding: 8px 16px; max-height: calc(100dvh - 76px); overflow: auto; }
  #ayah .meaning { font-size: 15px; margin: 4px 0; }
  #ayah .note, #ayah .credit { font-size: 11px; margin: 2px 0; }
}
/* family plan (grown-ups panel) */
.plans { display: grid; gap: 8px; margin: 8px 0; }
.plan { display: grid; text-align: left; gap: 2px; padding: 10px 14px; border-radius: 14px; background: #F3E8D4; border: 2px solid transparent; }
.plan.best { border-color: #498A8A; background: #E5F0EC; }
.plan .pname { font-weight: 700; } .plan .pprice { font-size: 18px; } .plan .pnote { font-size: 13px; color: #6B5440; }
.help.small { font-size: 12px; }

.site-links { margin: 8px 0 0; font-size: 12px; color: #8B7B6B; }
.site-links a { color: #6B5B4B; }
.native .site-links { display: none; }
