/* Phone layouts reserve room for artwork and controls instead of layering them.
   Desktop keeps its authored map. No extra images, fonts or animation loops. */
.world-hello,
.world-playgrounds { display: contents; }
.raqi-companion { bottom: max(9%, 86px); }
.sound-toggles { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.sound-toggles button { min-height: 44px; min-width: 80px; }

@media (max-width: 949px) and (orientation: portrait), (min-width: 480px) and (max-height: 479px) {
  :root { --hud: 66px; --dock: 88px; }
  .app, .app.dashboard-view { padding-left: 12px; padding-right: 12px; }
  .app::before, .bottom-nav { backdrop-filter: none; }
  .adventure-header { gap: 6px; }
  .game-logo { font-size: 28px; gap: 5px; }
  .game-logo small, .player-level, .player-stat.flame, .player-stat small { display: none; }
  .game-logo .logo-book { width: 30px; height: 34px; }
  .player-stats { gap: 5px; margin-right: 44px; }
  .player-stat { min-height: 36px; padding: 5px 7px; max-width: 88px; }
  .player-stat strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  .parent-control { width: 40px; height: 44px; padding: 7px; }
  .music-btn { width: 40px; height: 44px; top: 11px; right: 12px; }
  .music-btn .game-icon { width: 24px; height: 24px; }
  .bottom-nav { left: 12px; right: 12px; width: auto; height: 64px; bottom: calc(12px + env(safe-area-inset-bottom)); padding: 4px; transform: none; margin: 0; }
  .bottom-nav .bn-item { min-height: 52px; height: auto; padding: 4px 1px; }
  .bottom-nav .bn-label { font-size: 12px; line-height: 1.2; }
  .bottom-nav .bn-icon { height: 24px; }
  .bottom-nav .world-icon { width: 24px; height: 24px; }
  .footer-note { font-size: 9px; bottom: 1px; }

  /* A small greeting scene, six places to play, and a separate resume ticket. */
  .dashboard-view .screen-stage {
    display: grid;
    grid-template-rows: minmax(116px, 1fr) minmax(224px, 2.3fr) 70px;
    gap: 12px;
    padding-bottom: 4px;
  }
  .world-hello {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 108px;
    align-items: center;
    min-height: 0;
    padding: 4px 8px;
    border-radius: 30px;
    background: linear-gradient(115deg, #eef6d5e6, #eff8dc80);
  }
  .world-hello::after {
    content: "";
    position: absolute;
    right: 12px;
    bottom: 6px;
    width: 96px;
    height: 12px;
    border-radius: 50%;
    background: #5b825039;
    z-index: -1;
  }
  .world-welcome { position: static; min-width: 0; pointer-events: auto; }
  .world-welcome h1 { font-size: clamp(27px, 7.4vw, 36px); line-height: 1.05; margin: 0 0 9px; letter-spacing: -0.6px; }
  .world-welcome > .eyebrow, .world-welcome > p, .world-welcome .age-chip { display: none; }
  .world-welcome-actions .intro-replay { min-height: 36px; padding: 6px 12px; font-size: 13px; }
  .raqi-companion {
    position: static;
    align-self: stretch;
    justify-content: center;
    align-items: flex-end;
    width: 100%;
    min-height: 0;
    padding-bottom: 4px;
  }
  .raqi-companion > div { display: none; }
  .raqi-companion > img { width: 100%; height: 100%; max-height: 180px; object-fit: contain; object-position: bottom; animation: none; filter: none; }
  .world-playgrounds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 12px 10px; min-height: 0; }
  .world-map { display: contents; }
  .map-ambient { display: none; }
  .map-destination, .world-race-link {
    position: static;
    transform: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    width: 100%;
    gap: 7px;
    padding: 10px 8px;
    border: 1.5px solid #b1ba8f;
    border-radius: 26px;
    background: #fff9e9f2;
    box-shadow: 0 4px #7b965966;
    text-align: left;
  }
  /* Static grid tiles must not inherit the desktop map's centering transform. */
  .map-destination:is(:hover, :active) { transform: none; }
  .destination-marker { display: grid; place-items: center; flex: 0 0 34px; width: 34px; height: 38px; margin: 0; padding: 5px; border-radius: 50%; transform: none; box-shadow: none; }
  .destination-marker .world-icon { width: 26px; height: 26px; transform: none; }
  .destination-label { min-width: 0; padding: 0; border: 0; background: none; box-shadow: none; border-radius: 0; }
  .destination-label small { font-size: 10px; line-height: 1.2; letter-spacing: 0.3px; margin: 0 0 4px; }
  .destination-label strong { display: block; font-size: 19px; line-height: 1.12; }
  .destination-label > span { display: none; }
  .world-race-link { background: #fff0c9f2; }
  .world-race-friends { padding: 0; flex: 0 0 40px; }
  .world-race-friends .runner-sprite { display: none; }
  .world-race-friends .runner-sprite:first-child { display: block; width: 40px; margin: 0; }
  .world-race-link strong { font-size: 19px; line-height: 1.12; }
  .world-race-link small, .world-race-link .world-icon { display: none; }
  .continue-ticket { position: static; min-width: 0; width: 100%; min-height: 0; padding: 7px 12px; gap: 9px; border-radius: 26px; }
  .continue-ticket > span:nth-child(2) { min-width: 0; }
  .continue-ticket small { font-size: 10px; letter-spacing: 0.6px; }
  .continue-ticket strong { font-size: 21px; line-height: 1.1; }
  .continue-ticket > span:nth-child(2) > span { font-size: 12px; }
  .ticket-play { width: 36px; height: 36px; flex-shrink: 0; }

  /* Readable labels; short phones paginate instead of squeezing more cards in. */
  .screen-stage > .topbar { min-height: 36px; height: auto; flex-shrink: 0; }
  .topbar .brand-title { font-size: 14px !important; }
  .back-btn { font-size: 13px; min-height: 36px; }
  .section-intro .eyebrow { display: none; }
  .section-intro h1 { font-size: 27px; margin: 5px 0; line-height: 1.1; }
  .section-intro p { font-size: 13px; line-height: 1.3; }
  .topic-card small, .activity-copy small { font-size: 11px; letter-spacing: 0.3px; }
  .topic-card p, .activity-copy p, .card-open > span { font-size: 14px; line-height: 1.3; }
  .activity-copy h2, .card-open h2 { font-size: 24px; }
  .topic-copy { padding: 10px 24px 10px 12px; }
  .activity-card { padding: 12px; gap: 12px; }
  .activity-art { width: 60px; height: 70px; min-width: 60px; }
  .topic-grid:has(> .topic-card:only-child),
  .activity-grid:has(> .activity-card:only-child),
  .surah-grid:has(> .surah-book:only-child) { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  .page-controls { font-size: 13px; min-height: 44px; gap: 18px; }
  .page-controls .round-control { width: 44px; height: 44px; }
  .round-control, .mini-action { min-width: 40px; min-height: 40px; }
  .quiet-note { font-size: 11px; line-height: 1.2; }
  .stage-caption { font-size: 11px; letter-spacing: 0.3px; }
  .stage-stop p, .stage-stop > small { font-size: 13px; line-height: 1.25; }
  .stage-stop h2 { font-size: 23px; }
  .stage-actions .mini-action { font-size: 13px; padding: 5px 8px; min-height: 40px; }
  .stage-island[data-stops="1"] { grid-template: 1fr / 1fr; }
  .stage-island[data-stops="1"] .stage-stop { grid-column: 1; grid-row: 1; }
  .stage-island[data-stops="1"] .stage-stop p { max-width: 220px; margin: 6px auto; }
  .stage-island[data-stops="1"] .trail-line { display: none; }
  .parent-panel { min-height: 0; }
  .setting-row { padding: 12px; gap: 10px; }
  .setting-row h2 { font-size: 18px; }
  .setting-row p { font-size: 13px; line-height: 1.3; }
  .setting-btn, .setting-toggle, .setting-row select { font-size: 13px; min-height: 44px; }
  .sound-toggles { flex: 0 0 90px; }
  .sound-toggles button { width: 100%; }
  .audio-tool-btn { font-size: 12px; }
  .audio-source { font-size: 11px; }
  .btn { font-size: 14px; }
  .flashcard .ket { font-size: 13px; line-height: 1.3; }
  .bubble { font-size: 13px; line-height: 1.3; }
  .topic-card.compact p, .surah-book small, .surah-number { font-size: 12px; }
  .reader-heading > .eyebrow, .race-heading > .eyebrow { display: none; }
  .reader-heading, .reader-heading b, .reader-controls .btn span { font-size: 13px; }
  .reader-source { font-size: 11px; }
  .exam-island .eyebrow { font-size: 11px; }
  .exam-details, .challenge-progress, .challenge-progress span { font-size: 12px; }
  .exam-meta span, .challenge-meter, .challenge-meter span { font-size: 12px; }
  .exam-description p { font-size: 13px; }
  .age-tab { min-height: 40px; font-size: 13px; padding: 7px 10px; }
  .challenge-play > .eyebrow, .challenge-explanation { font-size: 12px; }
  .pill, .match-review p, .match-card.face-latin { font-size: 13px; }
  .tf-card .tf-hint { font-size: 12px; line-height: 1.25; }
  .ws-instruction, .ws-result, .worksheet-pagination, .ws-score p { font-size: 12px !important; }
  .achievement-summary > div > span { font-size: 12px; }
  .runner-choice small, .race-lane-label, .race-help small { font-size: 11px; }
  .race-heading p, .race-ready-footer .race-coach p, .race-scoreboard { font-size: 13px; }
  .race-ready-footer > div > small { font-size: 11px; }
  .race-result .quiet-note { font-size: 11px; }
}

@media (min-width: 700px) and (max-width: 949px) and (orientation: portrait) {
  .world-playgrounds { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .topic-grid, .activity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 699px) and (max-height: 759px) and (orientation: portrait) {
  .dashboard-view .screen-stage { grid-template-rows: 112px minmax(200px, 1fr) 64px; gap: 9px; }
  .world-hello { grid-template-columns: minmax(0, 1fr) 88px; }
  .world-welcome h1 { font-size: 29px; margin-bottom: 5px; }
  .world-playgrounds { gap: 9px; }
  .destination-label strong, .world-race-link strong { font-size: 18px; }
  .destination-label small { display: none; }
  .continue-ticket strong { font-size: 19px; }
  .topic-grid, .activity-grid, .surah-grid { grid-template-rows: 1fr; }
}

@media (max-width: 359px) and (orientation: portrait) {
  .dashboard-view .screen-stage { grid-template-rows: 102px minmax(188px, 1fr) 64px; }
  .world-welcome h1 { font-size: 27px; }
  .map-destination, .world-race-link { gap: 5px; padding: 7px; border-radius: 23px; }
  .destination-marker { flex-basis: 28px; width: 28px; height: 32px; padding: 3px; }
  .destination-marker .world-icon { width: 24px; height: 24px; }
  .world-race-friends { flex-basis: 30px; }
  .world-race-friends .runner-sprite:first-child { width: 30px; }
  .destination-label strong, .world-race-link strong { font-size: 17px; }
  .continue-ticket small { display: none; }
  .section-intro h1 { font-size: 24px; }
  .stage-caption { display: none; }
  .screen-stage:has(.exam-island) .section-intro p, .exam-illustration { display: none; }
}

/* Rotation uses the same six choices beside the greeting, never on top of it. */
@media (min-width: 480px) and (max-height: 479px) {
  :root { --hud: 48px; --dock: 64px; }
  .app, .app.dashboard-view { padding-left: 12px; padding-right: 12px; }
  .music-btn { top: 2px; }
  .bottom-nav { height: 52px; bottom: 6px; }
  .bottom-nav .bn-item { min-height: 40px; }
  .bottom-nav .bn-label { font-size: 11px; }
  .bottom-nav .bn-icon { height: 20px; }
  .bottom-nav .world-icon { width: 20px; height: 20px; }
  .dashboard-view .screen-stage { grid-template: minmax(0, 1fr) 64px / minmax(145px, 0.8fr) minmax(250px, 1.4fr); gap: 8px; }
  .world-hello { grid-column: 1; grid-row: 1; grid-template-columns: minmax(0, 1fr) 64px; padding: 4px 8px; }
  .world-welcome h1 { font-size: 26px; margin-bottom: 5px; }
  .world-welcome-actions .intro-replay { min-height: 32px; padding: 4px 10px; }
  .world-playgrounds { grid-column: 2; grid-row: 1 / 3; gap: 8px; }
  .map-destination, .world-race-link { padding: 7px; gap: 5px; border-radius: 23px; }
  .destination-label strong, .world-race-link strong { font-size: 17px; }
  .destination-label small { display: none; }
  .continue-ticket { grid-column: 1; grid-row: 2; padding: 5px 8px; gap: 5px; }
  .continue-ticket small, .continue-ticket .ticket-icon { display: none; }
  .continue-ticket strong { font-size: 19px; }
  .continue-ticket > span:nth-child(2) > span { font-size: 11px; }
  .section-intro h1 { font-size: 23px; margin: 2px 0; }
  .section-intro p, .quiet-note { display: none; }
  .screen-stage > .topbar { min-height: 28px; }
  .back-btn { min-height: 28px; font-size: 12px; padding-top: 3px; padding-bottom: 3px; line-height: 1.1; }
  .page-controls { min-height: 32px; }
  .page-controls .round-control { min-height: 32px; height: 32px; width: 40px; }
  .stage-caption, .stage-stop p, .stage-stop > small { display: none; }
  .setting-row { padding: 6px 10px; }
  .setting-row h2 { font-size: 16px; }
  .setting-row p { font-size: 12px; }
  .sound-toggles { flex-basis: auto; flex-wrap: nowrap; }
  .sound-toggles button { width: auto; }
  .module-card .card-open > small { display: none; }
  .card-open h2 { margin: 0 0 4px; font-size: 22px; }
  .challenge-play > .eyebrow { display: none; }
  .challenge-play { gap: 5px; }
  .flashcard { gap: 3px; padding-top: 6px; padding-bottom: 6px; }
  .quiz-card { padding-top: 4px; padding-bottom: 4px; }
  .tf-card { gap: 3px; padding-top: 4px; padding-bottom: 4px; }
  .tf-card .tf-hint { display: none; }
  .screen-stage:has(.exam-island) .section-intro, .exam-illustration { display: none; }
  .exam-meta { margin: 4px 0; }
  .audio-tool-btn { max-width: 84px; }
}
@media (min-width: 480px) and (max-width: 549px) and (max-height: 479px) {
  .world-hello { grid-template-columns: 1fr; }
  .world-hello .raqi-companion { display: none; }
  .world-hello::after { display: none; }
}
@media (min-width: 480px) and (max-height: 359px) {
  :root { --hud: 44px; }
  .exam-description p, .listen-illustration { display: none; }
  .flashcard { padding-top: 1px; padding-bottom: 1px; gap: 1px; }
  .flashcard .ket { font-size: 12px; line-height: 1.15; }
  .challenge-bottom { flex-direction: row; align-items: center; min-height: 40px; }
  .challenge-bottom .btn { flex: 0 0 auto; width: auto; min-width: 128px; }
  .challenge-bottom .challenge-explanation { flex: 1; min-width: 0; }
  .match-review .btn { flex: 0 0 auto; white-space: nowrap; min-height: 36px; padding: 5px 8px; font-size: 13px; }
  .long-faces .match-card { padding-top: 2px; padding-bottom: 2px; }
}

/* Short portrait windows still reserve real space for the dock and pager.
   Reflow the content, rather than allowing minimum grid tracks to cover them. */
@media (max-width: 699px) and (max-height: 599px) and (orientation: portrait) {
  :root { --hud: 52px; --dock: 72px; }
  .music-btn { top: 4px; }
  .bottom-nav { height: 52px; }
  .bottom-nav .bn-item { min-height: 40px; }
  .bottom-nav .bn-icon { height: 20px; }
  .bottom-nav .world-icon { width: 20px; height: 20px; }
  .dashboard-view .screen-stage { grid-template-rows: 96px minmax(162px, 1fr) 50px; gap: 6px; }
  .world-hello { grid-template-columns: minmax(0, 1fr) 72px; }
  .world-welcome h1 { font-size: 25px; margin-bottom: 4px; }
  .world-welcome-actions .intro-replay { min-height: 30px; padding: 3px 8px; font-size: 12px; }
  .world-playgrounds { gap: 6px; }
  .map-destination, .world-race-link { padding-top: 4px; padding-bottom: 4px; }
  .destination-label strong, .world-race-link strong { font-size: 17px; }
  .continue-ticket { padding-top: 4px; padding-bottom: 4px; }
  .continue-ticket small { display: none; }
  .continue-ticket strong { font-size: 19px; }
  .continue-ticket .ticket-icon { display: none; }

  .screen-stage:has(.stage-island) .section-intro h1,
  .screen-stage:has(.stage-island) > .quiet-note,
  .screen-stage:has(.exam-island) .section-intro,
  .screen-stage:has(.exam-island) > .quiet-note,
  .exam-illustration, .exam-description > .eyebrow { display: none; }
  .stage-island[data-stops="1"] { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
  .stage-island[data-stops="1"] .stage-stop {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 4px 12px;
    align-items: center;
    text-align: left;
    min-height: 0;
  }
  .stage-island[data-stops="1"] .stage-caption { display: none; }
  .stage-island[data-stops="1"] .stage-node { grid-column: 1; grid-row: 1 / 5; }
  .stage-island[data-stops="1"] .stage-stop h2 { grid-column: 2; grid-row: 1; margin: 0; }
  .stage-island[data-stops="1"] .stage-stop p { grid-column: 2; grid-row: 2; margin: 0; max-width: none; }
  .stage-island[data-stops="1"] .stage-stop > small { grid-column: 2; grid-row: 3; }
  .stage-island[data-stops="1"] .stage-actions { grid-column: 2; grid-row: 4; margin: 0; }

  .age-tab { flex-direction: row; min-height: 40px; padding: 4px 3px; font-size: 12px; white-space: nowrap; }
  .exam-island { padding: 10px 12px; }
  .exam-description { width: 100%; }
  .exam-description h2 { font-size: 24px; margin: 4px 0; }
  .exam-description p { line-height: 1.3; }
  .exam-meta { margin: 6px 0; }
}
