/* ==========================================================================
   ASHTAR KATKOOT — ADVENTURE 4: "THE INFLATABLE FLOAT"
   --------------------------------------------------------------------------
   Mobile-first. Designed at 390 x 844, sanity-checked at 360 x 760.

   Everything is scoped to `#app .a4-` so nothing here can reach Adventures 1-3, the
   album, or any other world. No filter:blur, no shadow stacks on the scrolling layer,
   and motion is transform/opacity only.

   The layout rule that matters at this size: an activity must fit the screen WITHOUT
   scrolling. So the four friend cards are a 2x2 grid, the bubbles are a fixed 2x2,
   the memory choices are a single row of four, and the letters are one row of three -
   every one of them sized in vmin/vw so they shrink with the screen rather than
   overflowing it.
   ========================================================================== */

/* ---------------------------------------------------------------- *
 * A STORY PICTURE - FULL BLEED. NO BLUE SIDE BARS, EVER.
 *
 * MEASURED, not guessed. The five Chapter 4 story PNGs are 941 x 1672 = 0.5628.
 * The phone viewport is 390 x 844 = 0.4621.
 *
 * The previous rule forced `aspect-ratio: 2 / 3` (0.6667) with `object-fit: contain`,
 * because the BOOK artwork is 2:3. The story art is not. That boxed the layer to
 * 390 x 585, fitted the 0.5628 bitmap INSIDE it at 585 * 0.5628 = 329px wide, and left
 * 390 - 329 = 61px over: about 30px of bare blue down EACH side, plus 130px above and
 * below. That is the "narrow portrait rectangle with blue bands either side" in the
 * Android recording, and it was self-inflicted by the previous pass.
 *
 * Story backgrounds are therefore COVER, edge to edge, with NO aspect-ratio on the
 * layer:
 *
 *     cover on 390 x 844 against 0.5628 scales by height
 *       844 / 1672 = 0.5048  ->  941 * 0.5048 = 475px wide
 *       crop = (475 - 390) / 2 = 42px per side, 82% of the width retained
 *
 * A small even PERIPHERAL crop in place of dead blue bars, one scale factor for both
 * axes so the bitmap is never distorted, and `object-position: center` so the central
 * composition - the float, the friends, the lake - is what stays in frame.
 *
 * Learning-card animal images are deliberately NOT covered: they keep `contain` in
 * their own boxes so an animal is never cropped.
 *
 * OPACITY ONLY. No scale, no translate, no zoom. Both layers are the SAME full-viewport
 * box and both hold `cover`, so during the dissolve they are pixel-aligned and the
 * blue root underneath can never be exposed between them.
 * ---------------------------------------------------------------- */
#app .a4-root {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  overscroll-behavior: contain;
  /* Safe areas: browser chrome at the top, an Android navigation bar at the bottom,
     and a notch on the sides. */
  padding: calc(env(safe-area-inset-top, 0px) + 6px)
           calc(env(safe-area-inset-right, 0px) + 6px)
           calc(env(safe-area-inset-bottom, 0px) + 6px)
           calc(env(safe-area-inset-left, 0px) + 6px);
  box-sizing: border-box;
  background: linear-gradient(180deg, #59bde8 0%, #2f96cf 55%, #1d6fa3 100%);
  font-family: inherit;
  color: #123243;
}
#app .a4-root[hidden] { display: none; }

/* ---------------------------------------------------------------- *
   THE STAGE. Cross-fading scene slots.
   ---------------------------------------------------------------- */
#app .a4-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
/* ---------------------------------------------------------------- *
   * A STORY PICTURE.
   *
   * TWO REAL CHANGES, both from what the phone showed.
   *
   * NO SCALE. The old rule animated `transform: scale(1.04) -> scale(1)` as well as
   * opacity, over .34s. On a phone that slow zoom is what read as "the page is turning
   * inside the adventure", and the movement itself looked like jank. Inside an adventure
   * the change of scene is a fast dissolve; the page-turn metaphor belongs to the Book.
   *
   * THE BOX NEVER MOVES. The layer carries an explicit aspect-ratio and the bitmap is
   * contained inside it, so the box has its final size from the first painted frame.
   * Nothing can resize or shift when the bitmap arrives - which is the layout half of the
   * "drop in from above / resize while loading" fix. The decode gate in
   * animal-adventure4.js is the other half: it will not raise a picture until the bitmap
   * can actually be painted.
   * ---------------------------------------------------------------- */
#app .a4-scene {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .26s ease-out;
  pointer-events: none;
}
#app .a4-scene.is-front { opacity: 1; pointer-events: auto; }
#app .a4-scene-img {
  width: 100%;
  height: 100%;
  /* COVER, not contain. */
  object-fit: cover;
  object-position: center center;
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  #app .a4-scene { transition: none; }
}

/* ---------------------------------------------------------------- *
   THE PART COUNTER. 0/3 -> 3/3, and NEVER 4/4.
   ---------------------------------------------------------------- */
#app .a4-crates {
  position: absolute;
  z-index: 6;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 2px 6px rgba(10, 40, 60, .25);
  pointer-events: none;
}
#app .a4-crate {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(24, 62, 88, .26);
  display: block;
}
#app .a4-crate.is-done {
  background: linear-gradient(#7ede8c, #2fae4f);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .16);
}
#app .a4-crate.is-newest { animation: a4-pop .5s ease-out 1; }
#app .a4-crate-count {
  font-size: 13px;
  font-weight: 800;
  color: #123243;
  direction: ltr;
  unicode-bidi: isolate;
}
@keyframes a4-pop { 0% { transform: scale(1); } 45% { transform: scale(1.45); } 100% { transform: scale(1); } }

#app .a4-caption {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  transform: translateX(-50%) translateY(8px);
  max-width: 88%;
  padding: 7px 13px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .93);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
#app .a4-caption.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------------------------------------------------------- *
   A STORY BEAT. Full-bleed picture, nothing over it.
   ---------------------------------------------------------------- */
#app .a4-stage.is-story .a4-panel { display: none; }

/* ---------------------------------------------------------------- *
   AN ACTIVITY PANEL. One card, everything inside the viewport.
   ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- *
   * AN ACTIVITY. One column, centred, and it NEVER scrolls: an activity that
   * needs a scroll on a 390x844 phone is a layout that does not fit, and every
   * band below is sized in vw/vmin so it shrinks with the screen instead.
   * ---------------------------------------------------------------- */
#app .a4-panel {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 44px 10px calc(env(safe-area-inset-bottom, 0px) + 12px);
  box-sizing: border-box;
  overflow: hidden;
}

/* ---------------------------------------------------------------- *
 * THE GLASS SURFACE. One translucent, rounded, shadowed card.
 *
 * This is the surface every piece of Arabic text over the lake artwork sits on.
 * Bare dark text directly on the detailed artwork was unreadable on the phone.
 * Kept deliberately small in the shared rules; individual panels size their own.
 * ---------------------------------------------------------------- */
#app .a4-glass {
  width: 100%;
  max-width: 420px;
  padding: 10px 14px;
  border: 2px solid rgba(255, 255, 255, .74);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 252, 240, .95), rgba(238, 246, 252, .93));
  box-shadow: 0 5px 0 rgba(20, 62, 88, .2), 0 10px 22px rgba(4, 32, 52, .34);
  color: #0d2f42;
  text-align: center;
}

/* THE SHARED HEADING BLOCK: the activity's title, its round counter and its
   prompt, all on one glass surface. Every activity uses this, so no activity
   invents its own title treatment and none of them puts text on the artwork. */
#app .a4-head {
  width: 100%;
  max-width: 420px;
  padding: 8px 14px;
  border: 2px solid rgba(255, 255, 255, .74);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 252, 240, .95), rgba(238, 246, 252, .93));
  box-shadow: 0 5px 0 rgba(20, 62, 88, .2), 0 10px 22px rgba(4, 32, 52, .34);
  text-align: center;
}
#app .a4-title {
  margin: 0;
  font-size: clamp(16px, 4.8vw, 20px);
  font-weight: 900;
  line-height: 1.3;
  color: #0d2f42;
}
#app .a4-ask {
  margin: 4px 0 0;
  font-size: clamp(14px, 4.2vw, 18px);
  font-weight: 900;
  color: #1b4a5f;
}
/* The Bubbles target, in English and LARGE. The child must be able to see which animal
   this round wants as well as hear it, so the round never depends on speech alone. */
#app .a4-ask-en {
  font-size: clamp(20px, 6.4vw, 28px);
  font-weight: 900;
  color: #0d2f42;
  letter-spacing: .02em;
}
/* THE ROUND COUNTER. Deliberately worded per activity ("الجولة", "الحيوان",
   "الكلمة") so it can never be mistaken for the repair parts up in the corner. */
#app .a4-step {
  margin: 3px 0 0;
  font-size: clamp(11px, 3.2vw, 13px);
  font-weight: 800;
  color: #5b7488;
}
/* THE PROMPT, when an activity has one. */
#app .a4-prompt {
  margin: 4px 0 0;
  font-size: clamp(15px, 4.4vw, 19px);
  font-weight: 900;
  color: #123243;
}
#app .a4-prompt[hidden] { display: none; }

/* ONE FEEDBACK LINE, always present so nothing moves when it is written. */
#app .a4-feedback {
  margin: 0;
  min-height: 17px;
  font-size: clamp(12px, 3.5vw, 14px);
  font-weight: 800;
  text-align: center;
  color: #123243;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 0 10px rgba(0, 0, 0, .38);
}
#app .a4-feedback.is-good { color: #b6ffd0; }
#app .a4-feedback.is-soft { color: #ffe2bd; }
#app .a4-continuation {
  margin: 0;
  font-size: clamp(12px, 3.5vw, 14px);
  font-weight: 800;
  text-align: center;
  color: #eaf6ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 0 10px rgba(0, 0, 0, .38);
}
#app .a4-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#app .a4-cta {
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 24px;
  background: linear-gradient(#7ede8c, #2fae4f);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 3px 0 #1f7d38;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#app .a4-cta:active { transform: translateY(2px); box-shadow: 0 1px 0 #1f7d38; }

/* ---- the four friends: 2 x 2, so it never needs a scroll ---- */
/* ---- the four friends: 2 x 2, so it never needs a scroll ---- */
#app .a4-dgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 340px;
}
#app .a4-dcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, .93);
  box-shadow: 0 3px 0 rgba(18, 60, 82, .18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#app .a4-dcard:active { transform: translateY(2px); }
#app .a4-dcard-art {
  width: 100%;
  height: 92px;
  display: block;
}
#app .a4-dcard-art img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
#app .a4-dcard-en {
  font-size: 15px;
  font-weight: 800;
  color: #123243;
  direction: ltr;
  unicode-bidi: isolate;
}
#app .a4-dcard-ar { font-size: 13px; font-weight: 700; color: #3c6a7d; }
#app .a4-dcard.is-heard { background: #dff5e2; }
#app .a4-dcard.is-heard .a4-dcard-art { opacity: .55; }

/* ---- ACTIVITY 1: bubbles. A fixed 2 x 2, large targets. ---- */
#app .a4-bfield {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 320px;
}
#app .a4-bubble {
  width: 100%;
  aspect-ratio: 1;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .95) 0 12%, transparent 13%),
    radial-gradient(circle at 50% 50%, rgba(190, 240, 255, .95), rgba(120, 200, 240, .75));
  box-shadow: inset 0 -6px 14px rgba(30, 110, 160, .25);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
#app .a4-bubble img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
#app .a4-bubble:active { transform: scale(.94); }
#app .a4-bubble.is-right { animation: a4-pop .45s ease-out 1; }
#app .a4-bubble.is-wrong { animation: a4-shake .4s ease-out 1; }

/* ---- ACTIVITY 2: "مين اللي اختفى؟" ----
 *
 * ADVENTURE 2's who-disappeared structure and its measured sizes, reproduced.
 *
 * THE CRITICAL PROPERTY: both rows carry the SAME min-height whether or not they are
 * on screen, and a hidden slot keeps its box via `visibility`. So swapping the study
 * row for the question row cannot reflow anything, cannot push the choices down, and
 * never re-requests an image. That is what makes this fit one 390x844 viewport with no
 * scrolling - the previous 2x2 grid of aspect-ratio:1 cards plus a separate band of
 * choices could not.
 */
#app .a4-who {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
/* FOUR PICTURES ACROSS. One row, all four slots, and a slot that is switched off keeps
   its box via visibility - so the row has the same size in the study state and in the
   question state, the word grid never jumps, and no image is ever re-requested. */
#app .a4-whorow {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 2.2vw, 10px);
  width: 100%;
  /* THE SAME HEIGHT IN BOTH PHASES. */
  min-height: clamp(64px, 19vw, 92px);
  transition: opacity .3s ease;
}
#app .a4-whoslot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: clamp(50px, 16.5vw, 74px);
  height: clamp(50px, 16.5vw, 74px);
  border: 2.5px solid rgba(255, 255, 255, .95);
  border-radius: 15px;
  background: linear-gradient(180deg, #fffdf4, #e4f1fa);
  box-shadow: 0 3px 0 rgba(18, 60, 82, .22), 0 5px 10px rgba(4, 32, 52, .26);
  /* visibility, NOT display: the slot keeps its box, so nothing reflows. */
  visibility: hidden;
  opacity: 0;
  transition: opacity .38s ease, visibility 0s linear .38s;
}
#app .a4-whoslot.is-on {
  visibility: visible;
  opacity: 1;
  transition: opacity .38s ease, visibility 0s;
}
#app .a4-whoslot img {
  width: 100%;
  height: 100%;
  padding: 7%;
  box-sizing: border-box;
  object-fit: contain;
  display: block;
}
/* the four-picture choice row is GONE: it leaked the answer by comparison */
/* ---------------------------------------------------------------- *
 * THE ANSWERS: FOUR ENGLISH WORDS, AND DELIBERATELY NO PICTURES.
 *
 * The previous version put all four animal pictures underneath the three survivors, so
 * the child could read the answer off the layout by comparing two rows - the activity
 * tested nothing and never exercised picture-to-word at all. The choices are words now.
 *
 * A 2x2 grid so four labels never re-flow into 3 + 1 on a wider phone, each button
 * centred on BOTH axes (a label off-centre inside its own button is the "misaligned
 * letters" look), and sized in vw so they shrink with the screen instead of
 * overflowing it.
 * ---------------------------------------------------------------- */
#app .a4-wordgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 340px;
}
#app .a4-wordbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(56px, 17vw, 74px);
  padding: 6px 4px;
  border: 2.5px solid rgba(255, 255, 255, .9);
  border-radius: 16px;
  background: linear-gradient(180deg, #9df0b4, #3fb56f);
  box-shadow: 0 4px 0 #23794c, 0 7px 13px rgba(0, 0, 0, .28);
  color: #08301c;
  font-family: inherit;
  font-size: clamp(16px, 5vw, 22px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: .01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s ease, box-shadow .1s ease;
}
#app .a4-wordbtn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #23794c; }
#app .a4-wordbtn.is-right {
  background: linear-gradient(180deg, #c9ffd8, #57d98a);
  box-shadow: 0 0 0 3px rgba(95, 217, 127, .7), 0 4px 0 #23794c;
}
#app .a4-wordbtn.is-wrong {
  background: linear-gradient(180deg, #ffe6c9, #f3c48f);
  box-shadow: 0 4px 0 #b8763a;
}
#app .a4-wordbtn:disabled { cursor: default; }








/* ---- ACTIVITY 3: the approved Missing Letter ----
 *
 * Adventure 2's missing-letter structure and its measured sizes: a board of one slot
 * per character, the animal ABOVE the choices so a child who knows the animal can
 * finish the word without reading the letters at all, and four large letter buttons
 * that share the row.
 */
#app .a4-missing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
/* ONE SLOT PER CHARACTER. Never wraps: a wrapped board would silently change which
   letter sits in which slot. */
#app .a4-wordboard {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 6px;
}
#app .a4-wslot {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Explicit, and never derived from content: an empty flex child with no content
     would otherwise collapse, which is what makes a blank slot disappear. */
  width: clamp(36px, 11.5vw, 50px);
  height: clamp(44px, 13.5vw, 58px);
  border: 2.5px solid rgba(255, 255, 255, .95);
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf4, #e9f3fb);
  box-shadow: 0 3px 0 rgba(18, 60, 82, .22), 0 4px 9px rgba(4, 32, 52, .24);
  color: #123243;
  font-family: inherit;
  font-size: clamp(19px, 6.2vw, 27px);
  font-weight: 900;
  line-height: 1;
}
/* The blank is the only marked slot, so the missing position is obvious at a glance. */
#app .a4-wslot.is-blank {
  background: linear-gradient(180deg, #e9f4ff, #cfe6fb);
  border-style: dashed;
  border-color: rgba(90, 140, 190, .95);
  box-shadow: 0 3px 0 #6d9cc4, inset 0 0 0 2px rgba(255, 255, 255, .7);
}
/* THE PLACEHOLDER. A pseudo-element, never a text node: the letter this slot is
   waiting for must not exist anywhere in the DOM before the child chooses it - not
   as visible text, not as low-opacity text, and not as something a screen reader
   will read out. */
#app .a4-wslot.is-blank::after {
  content: "";
  display: block;
  width: 56%;
  height: 4px;
  border-radius: 2px;
  background: rgba(43, 108, 168, .85);
}
#app .a4-wslot.is-filled-ok {
  background: linear-gradient(180deg, #bdf3cf, #8fe0ad);
  border-style: solid;
  border-color: rgba(120, 230, 150, .98);
  color: #08301c;
  box-shadow: 0 3px 0 #2f9c5c, 0 0 0 3px rgba(95, 217, 127, .45);
}
#app .a4-missing-art {
  width: clamp(84px, 26vw, 112px);
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2.5px solid rgba(255, 255, 255, .95);
  border-radius: 17px;
  background: linear-gradient(180deg, #fffdf4, #eaf3fa);
  box-shadow: 0 4px 0 rgba(18, 60, 82, .22), 0 6px 12px rgba(4, 32, 52, .26);
}
#app .a4-missing-art img {
  width: 100%;
  height: 100%;
  padding: 7%;
  box-sizing: border-box;
  object-fit: contain;
  display: block;
}
/* THE LETTER ROW. The buttons SHARE the row between a floor and a ceiling, so four
   letters are always one clean line and never re-flow into 3 + 1 on a wider phone. */
#app .a4-letters {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
#app .a4-letterbtn {
  flex: 1 1 auto;
  min-width: 44px;
  max-width: 62px;
  height: clamp(50px, 15vw, 62px);
  display: flex;
  align-items: center;
  /* BOTH centring axes, explicitly. Without justify-content the glyph sits off
     centre in a flex button, which is what "letters not centred" looked like. */
  justify-content: center;
  padding: 0;
  border: 2.5px solid rgba(255, 255, 255, .9);
  border-radius: 15px;
  background: linear-gradient(180deg, #9df0b4, #3fb56f);
  box-shadow: 0 4px 0 #23794c, 0 7px 13px rgba(0, 0, 0, .28);
  color: #08301c;
  font-family: inherit;
  font-size: clamp(20px, 6.2vw, 26px);
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .1s ease, box-shadow .1s ease;
}
#app .a4-letterbtn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #23794c; }
#app .a4-letterbtn.is-correct {
  background: linear-gradient(180deg, #c9ffd8, #57d98a);
  box-shadow: 0 0 0 3px rgba(95, 217, 127, .7), 0 4px 0 #23794c;
}
/* A wrong letter is marked SOFTLY and is NEVER written into the word: the empty slot
   is both the obvious thing to retry and free of leaked information. */
#app .a4-letterbtn.is-wrong {
  background: linear-gradient(180deg, #ffe6c9, #f3c48f);
  box-shadow: 0 4px 0 #b8763a;
  opacity: .88;
}
#app .a4-letterbtn:disabled { cursor: default; }
#app .a4-letterbtn:disabled.is-wrong { opacity: .88; }


/* THE LEARNING STARS. Small, on the existing compact card, so the water-play picture
   stays visible. Lit = earned; unlit = a quiet outline, never a red or a cross. */
#app .a4-stars { display: flex; gap: 4px; align-items: center; }
#app .a4-star {
  width: 15px; height: 15px;
  display: block;
  background: rgba(20, 60, 85, .16);
  clip-path: polygon(50% 0%, 63% 35%, 100% 38%, 71% 60%, 82% 100%, 50% 76%, 18% 100%, 29% 60%, 0% 38%, 37% 35%);
}
#app .a4-star.is-on {
  background: linear-gradient(180deg, #ffe27a, #f5b91e);
  box-shadow: 0 1px 3px rgba(120, 80, 0, .4);
}
#app .a4-result {
  margin: 2px 0 0;
  font-size: clamp(13px, 3.8vw, 16px);
  font-weight: 900;
  text-align: center;
  color: #123243;
  line-height: 1.35;
}

/* ---- the ending: ONE compact card, LOWER HALF ----
 *
 * The completion information was previously spread across a full-height centred
 * column of bare dark text and was visually lost against the colourful water-play
 * artwork, while also covering most of the picture the whole adventure builds
 * towards. `justify-content: flex-end` plus a capped card keeps the picture clear
 * above and the message readable below.
 */
#app .a4-complete { justify-content: flex-end; }
#app .a4-complete .a4-glass { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#app .a4-comprow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
}
#app .a4-bigcount {
  font-size: clamp(26px, 8vw, 34px);
  font-weight: 900;
  color: #1f7d38;
  direction: ltr;
  unicode-bidi: isolate;
  line-height: 1;
}
#app .a4-donelist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 5px;
}
#app .a4-donelist li {
  width: clamp(42px, 13vw, 54px);
  padding: 3px 2px;
  border-radius: 11px;
  background: rgba(255, 255, 255, .82);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
#app .a4-donelist img { width: 100%; height: clamp(26px, 8vw, 34px); object-fit: contain; display: block; }
#app .a4-donelist span { font-size: clamp(9px, 2.7vw, 11px); font-weight: 800; color: #1b4a5f; }


/* ---------------------------------------------------------------- *
 * THE HELP STATE - "the interaction became teaching, not testing".
 *
 * Shown only after TWO genuine wrong attempts on the same question, and only while the
 * question is still unanswered. The correct choice is EMPHASISED: a slow, gentle pulse
 * that leaves the button fully usable. The child still makes the final tap, still gets
 * the existing Praise, and still moves on - there is no red, no cross, no negative
 * wording, no new audio and nothing auto-answered.
 *
 * Colour is a brightening ring, not a warning colour, so helping never reads as failing.
 * ---------------------------------------------------------------- */
@keyframes a4-hint {
  0%, 100% { box-shadow: 0 4px 0 #23794c, 0 7px 13px rgba(0, 0, 0, .28); }
  50% { box-shadow: 0 4px 0 #23794c, 0 0 0 6px rgba(255, 236, 140, .9), 0 7px 16px rgba(0, 0, 0, .3); }
}
#app .a4-bubble.is-hint {
  animation: a4-hint 1.5s ease-in-out infinite;
}
#app .a4-wordbtn.is-hint {
  animation: a4-hint 1.5s ease-in-out infinite;
}
#app .a4-letterbtn.is-hint {
  animation: a4-hint 1.5s ease-in-out infinite;
}
/* Reduced motion: the help is still shown, as a steady ring rather than a pulse. The
   child must never lose the hint because motion is switched off. */
@media (prefers-reduced-motion: reduce) {
  #app .a4-bubble.is-hint,
  #app .a4-wordbtn.is-hint,
  #app .a4-letterbtn.is-hint {
    animation: none;
    box-shadow: 0 4px 0 #23794c, 0 0 0 5px rgba(255, 236, 140, .95), 0 7px 13px rgba(0, 0, 0, .28);
  }
}

@keyframes a4-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* ---------------------------------------------------------------- *
   NARROWER PHONE, ~360px. Everything shrinks; nothing is cut off and
   nothing needs a scroll.
   ---------------------------------------------------------------- */
@media (max-width: 380px) {
  #app .a4-dcard-art { height: 74px; }
  #app .a4-dcard-en { font-size: 14px; }
  #app .a4-dcard-ar { font-size: 12px; }
  #app .a4-whorow { gap: 5px; min-height: 58px; }
  #app .a4-whoslot { width: clamp(44px, 14.5vw, 58px); height: clamp(44px, 14.5vw, 58px); }
  #app .a4-wordgrid { gap: 7px; }
  #app .a4-wordbtn { min-height: 52px; font-size: 15px; }
  #app .a4-wslot { width: clamp(32px, 10.5vw, 44px); height: clamp(40px, 12.5vw, 52px); font-size: 21px; }
  #app .a4-missing-art { width: 82px; }
  #app .a4-letters { gap: 6px; }
  #app .a4-letterbtn { min-width: 40px; max-width: 54px; }
  #app .a4-donelist li { width: 46px; }
}

/* A short screen in landscape: tighten so nothing is pushed off. */
@media (max-height: 620px) {
  #app .a4-panel { padding-top: 38px; gap: 6px; }
  #app .a4-dcard-art { height: 62px; }
  #app .a4-whorow { min-height: 62px; }
  #app .a4-missing-art { width: 72px; }
  #app .a4-wslot { height: clamp(36px, 11vw, 46px); }
}
