/* Phone layouts. Keep the desktop composition in the original stylesheets. */
@media (max-width: 650px) {
  html { scroll-padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  body { min-width: 0; min-height: 100svh; background: #f8f2fc; }
  .world-bg {
    background: radial-gradient(ellipse at 95% 2%, #fff0d5 0, transparent 40%),
      radial-gradient(ellipse at 0 58%, #f9dceb88 0, transparent 48%),
      linear-gradient(175deg, #f7f1ff, #fff2f4 53%, #eee5ff);
  }
  .world-bg .cloud { opacity: .45; }
  .world-bg .hill { opacity: .26; }
  .world-bg .bg-star { opacity: .42; }
  .topbar {
    height: auto;
    min-height: 54px;
    padding: max(5px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 5px max(12px, env(safe-area-inset-left));
    gap: 10px;
  }
  .brand { min-height: 44px; min-width: 0; gap: 8px; font-size: 23px; color: #6b418d; }
  .brand-light { color: #a271b7; }
  .brand-mark { width: 33px; height: 35px; border-radius: 12px; background: linear-gradient(145deg, #b58be4, #8d5ac9); box-shadow: 0 3px 0 #e3d1f0, inset 0 1px 0 #dcc0f6; }
  .brand-mark svg { width: 20px; height: 20px; }
  .brand b { font-size: 8px; padding: 0 5px; margin: 8px 0 0 4px; color: #9876ad; border-color: #dfcfec; }
  .header-actions { gap: 3px; }
  .offline-badge { margin-right: 5px; }
  .offline-badge i { width: 5px; height: 5px; }
  .icon-button { width: 44px; height: 44px; border-radius: 14px; color: #8c6aa4; background: #fff8; border-color: #fff; }
  .icon-button svg { width: 19px; height: 19px; }
  .mute-slash { width: 23px; }
  .game-shell { width: 100%; max-width: 520px; padding: 0 max(8px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .chapter-heading { margin: 0 0 7px; }
  .chapter-heading .eyebrow, .chapter-heading p { display: none; }
  .chapter-heading h1 { font-size: clamp(21px, 5.7vw, 27px); line-height: 1.15; margin: 1px 12px 5px; letter-spacing: -.5px; color: #70458f; }
  .chapter-heading h1 span { position: static; margin-left: 5px; font-size: 16px; vertical-align: 2px; color: #d9ae59; }
  .mode-switch { width: min(100%, 380px); min-height: 48px; padding: 2px; gap: 2px; margin: 0 auto; border-color: #fff; border-radius: 16px; background: #fff9; box-shadow: 0 3px 12px #8659a50b; }
  .mode-switch button { min-width: 0; min-height: 44px; padding: 5px 10px; justify-content: center; border-radius: 12px; font-size: 10px; font-weight: 800; line-height: 1.3; }
  .mode-switch #play-toggle { flex: .9; }
  .mode-switch #lab-toggle { flex: 1.4; }
  .mode-switch svg { width: 14px; height: 14px; }
  .mode-switch button[aria-pressed=true] { background: linear-gradient(120deg, #a17bd6, #8253bd); box-shadow: 0 3px 6px #6c419622, inset 0 1px 0 #c8ace9; }
  .mode-switch #lab-toggle[aria-pressed=true] { background: linear-gradient(115deg, #cf6bb6, #9558c8); }
  .play-layout { display: flex; flex-direction: column; width: 100%; gap: 4px; }
  .journey-panel { display: none; }

  /* A single compact health card and a distinct, easy-to-scan move counter. */
  .challenge-panel { order: 0; width: 100%; display: flex; gap: 7px; padding: 0; align-items: stretch; }
  .boss-card { position: relative; flex: 1; min-width: 0; min-height: 96px; padding: 5px 9px 6px 79px; border: 1px solid #fff; border-radius: 18px; text-align: left; background: linear-gradient(135deg, #fffefa, #fcecf6); box-shadow: 0 3px 0 #e3d5eb80, 0 8px 20px #98719d0a; }
  .boss-card .boss-tag { display: none; }
  .boss-card h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 0 0 1px; font-size: 13px; line-height: 17px; color: #975082; }
  .boss-card > p, .boss-card .boss-tip { display: none; }
  .boss-portrait, .lab-mode .boss-portrait { position: absolute; width: 76px; height: 88px; left: 0; top: 3px; margin: 0; }
  .portrait-orbit { width: 61px; height: 61px; margin-left: -30.5px; top: 12px; border-color: #fff; background: radial-gradient(circle at 42% 28%, #fff1c9, #fac9df 80%); box-shadow: 0 0 0 3px #fff8, 0 0 0 4px #edd9e9; }
  .portrait-star { top: 9px; right: 4px; font-size: 12px; }
  .boss-level { bottom: 1px; padding: 0 5px; border-width: 1px; border-radius: 5px; font-size: 6px; line-height: 12px; letter-spacing: .7px; background: #f2d8e7; color: #996686; }
  .boss-style-picker { margin: 0 0 1px; display: block; }
  .boss-style-picker > span { display: none; }
  .boss-style-picker select { display: block; width: 100%; min-height: 44px; height: 44px; padding: 3px 5px; border: 1px solid #ead5e8; border-radius: 9px; background: #fffc; color: #88568d; font-size: 16px; line-height: 1.2; }
  .hp-label, .hp-label span { font-size: 8px; line-height: 10px; color: #966783; }
  .hp-label { gap: 3px; }
  .hp-label span { min-width: 0; gap: 2px; white-space: nowrap; }
  .hp-label svg { width: 8px; height: 8px; }
  .hp-label b { flex-shrink: 0; font-size: 8px; color: #965977; font-variant-numeric: tabular-nums; }
  .hp-track { height: 8px; padding: 1px; margin-top: 2px; background: #e6cbdc; }
  .hp-track div { background: linear-gradient(90deg, #ee90b6, #dc5f9b); box-shadow: inset 0 1px 0 #ffd8e8; }
  .moves-card { flex: 0 0 76px; width: 76px; min-height: 96px; margin: 0; padding: 7px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px solid #fff; border-radius: 18px; background: linear-gradient(150deg, #fffaf5, #f9deec); box-shadow: 0 3px 0 #e8d3df70; }
  .moves-card .mini-label { display: block; color: #a4768e; font-size: 8px; line-height: 1.3; letter-spacing: .65px; }
  .moves-card p, .best-card { display: none; }
  .moves-card strong { font-size: 33px; line-height: 1; color: #c85691; }

  .board-column { order: 1; width: 100%; min-width: 0; }
  .current-store-banner { width: 100%; min-height: 46px; margin: 0 0 2px; padding: 5px 9px; gap: 8px; border-radius: 13px; border-color: #fff; background: #fffaf8b8; box-shadow: 0 3px 10px #8d609d08; }
  .current-store-banner > span:nth-child(2) { gap: 1px; }
  .current-store-banner b { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; line-height: 1.25; color: #75528f; }
  .current-store-banner small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 8px; line-height: 1.35; color: #9b819f; }
  .store-brand-pill { width: 32px; height: 31px; border-radius: 9px; font-size: 8px; }
  .store-banner-arrow { flex-shrink: 0; font-size: 22px; line-height: 1; color: #a080b1; }
  .board-topline { height: 29px; padding: 0 12px; }
  .level-pill { gap: 5px; font-size: 8px; letter-spacing: 1px; color: #9b77af; }
  .level-pill b { font-size: 16px; color: #8453a7; }
  .stars { font-size: 19px; gap: 5px; color: #f2bd3d; filter: drop-shadow(0 1px 0 #c99a4030); }
  .stars span:nth-child(2) { margin-top: -3px; font-size: 23px; }
  .score-pill { min-width: 65px; gap: 4px; font-size: 12px; color: #8c66a6; font-variant-numeric: tabular-nums; }
  .score-pill svg { width: 12px; height: 12px; }
  .board-stage { width: 100%; max-width: 480px; aspect-ratio: 1 / .96; margin: 0 auto; overflow: hidden; border-radius: 22px; isolation: isolate; }
  /* The renderer leaves a generous transparent rim. Crop that rim, keeping hit-testing on the actual canvas. */
  .board-stage canvas { position: absolute; top: -3%; left: -3%; width: 106%; height: 106%; max-width: none; touch-action: none; }
  .board-stage:focus-within { outline: 3px solid #a376cf; outline-offset: 2px; }
  .board-loading { inset: 4%; border-radius: 24px; }
  .board-caption { display: none; }
  .board-float { top: 23%; max-width: 94%; font-size: 23px; }
  .board-float small { font-size: 9px; }
  .effect-readout { max-width: 73%; overflow: hidden; text-overflow: ellipsis; font-size: 8px; letter-spacing: .2px; }
  .booster-bar { width: 100%; max-width: 430px; min-height: 67px; margin: 3px auto 0; padding: 5px 7px; gap: 4px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-radius: 18px; background: #fffaf9e8; border: 1px solid #fff; box-shadow: 0 3px 0 #e8d8ed80, 0 7px 20px #8a5f9c0c; }
  .booster-label, .booster-divider { display: none; }
  .booster { min-width: 44px; min-height: 55px; width: 100%; padding: 1px 4px; gap: 2px; font-size: 10px; line-height: 1.3; color: #886797; border-radius: 12px; }
  .booster-icon, .booster-icon.plain { width: 36px; height: 36px; border-radius: 12px; }
  .booster-icon svg { width: 21px; height: 21px; }
  .booster-icon.yellow { background: linear-gradient(145deg, #fff1b0, #ffd763); color: #b88624; }
  .booster-icon.mint { background: linear-gradient(145deg, #c8f6e5, #8adebf); color: #4c9f84; }
  .booster-icon.pink { background: linear-gradient(145deg, #ffd9e9, #f5a5ca); color: #bd6292; }
  .booster-icon.plain { background: #f1e8f7; color: #a68bb8; }
  .booster-icon b { width: 18px; height: 18px; line-height: 14px; right: -5px; top: -4px; font-size: 8px; background: #a579c5; }
  .board-hint, .lab-mode .board-hint { margin: 7px 8px 0; font-size: 10px; line-height: 1.4; color: #9b7eac; }
  .game-shell > footer { margin: 10px 0 2px; font-size: 8px; line-height: 1.4; color: #b39bbd; }

  /* Royal checkpoints keep their gold signature without taking a second header. */
  .checkpoint-banner { width: 100%; min-height: 31px; margin: 3px 0 1px; padding: 3px 9px; gap: 7px; border-radius: 11px; }
  .checkpoint-banner > span:nth-child(2) { flex: 1; flex-direction: row; align-items: center; gap: 7px; }
  .checkpoint-banner b { font-size: 9px; letter-spacing: .5px; white-space: nowrap; }
  .checkpoint-banner small { min-width: 0; font-size: 7px; line-height: 1.2; }
  .checkpoint-crown { width: 23px; height: 23px; border-width: 1px; border-radius: 8px; font-size: 20px; box-shadow: 0 2px 0 #9b342930; }
  .checkpoint-banner-stars { font-size: 18px; }
  .checkpoint-stage .boss-card { box-shadow: 0 3px 0 #efd6a680, 0 7px 16px #c3876412; }
  .checkpoint-stage .portrait-orbit { box-shadow: 0 0 0 3px #ffe6a266, 0 0 18px #ffc65426; }
  .checkpoint-stage .board-stage { filter: none; }
  .checkpoint-arrival { width: 85%; padding: 13px 10px; border-radius: 20px; }
  .checkpoint-arrival b { font-size: 21px; }
  .checkpoint-arrival .arrival-crown { font-size: 37px; }
  .checkpoint-arrival > span:not(.arrival-crown) { font-size: 11px; }
  .checkpoint-preview { width: 100%; margin: 0 0 6px; padding: 3px 5px; display: grid; grid-template-columns: 1fr auto; gap: 3px; border-radius: 13px; background: #fff1d6; }
  .checkpoint-preview > span { display: none; }
  .checkpoint-preview > div { gap: 3px; }
  .checkpoint-preview button { min-width: 47px; min-height: 44px; padding: 4px 7px; font-size: 10px; border-radius: 9px; }
  .checkpoint-preview > a { min-height: 44px; display: flex; align-items: center; justify-content: center; padding: 4px 7px; font-size: 9px; line-height: 1.25; text-align: center; }
  .checkpoint-preview-mode .chapter-heading h1 { display: none; }
  .checkpoint-preview-mode .topbar { min-height: 48px; padding-top: max(2px, env(safe-area-inset-top)); padding-bottom: 2px; }

  /* Every experiment remains a visible, useful touch control. */
  .lab-mode .boss-card { padding-bottom: 6px; }
  .lab-mode .boss-card:has(.boss-test-button:not([hidden])) { min-height: 119px; }
  .boss-test-button { min-height: 44px; padding: 4px 7px; margin: 2px 0 3px; font-size: 10px; border-radius: 9px; }
  .lab-mode .boss-card:has(.boss-test-button:not([hidden])) .boss-portrait { top: 12px; height: 98px; }
  .lab-tools { margin: 4px 0 0; padding: 7px; border-radius: 17px; background: #fffafce8; box-shadow: 0 3px 0 #e8d6f080, 0 7px 20px #8a5f9c0c; }
  .lab-tools-heading { min-height: 44px; gap: 6px; margin: 0 0 5px; }
  .lab-tools-heading > span { font-size: 8px; letter-spacing: .4px; line-height: 1.3; color: #a17cb1; }
  .lab-tools-heading button { flex-shrink: 0; min-height: 44px; padding: 4px 8px; border-radius: 10px; font-size: 10px; color: #9670ad; background: #f1e7f8; }
  .lab-tools-heading svg { width: 13px; height: 13px; }
  .lab-theme-button { display: block; width: 100%; min-height: 44px; padding: 7px 10px; margin: 0 0 7px; border: 1px solid #e1c6ee; border-radius: 11px; background: #f3e4fc; color: #9b5cba; font-size: 10px; line-height: 1.35; }
  .lab-theme-button[aria-pressed=true] { color: #ad387d; border-color: #edb1d8; background: linear-gradient(110deg, #ffe5ef, #f4e3ff); }
  .effect-buttons { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
  .effect-buttons button { min-width: 0; min-height: 53px; padding: 5px 0; border-radius: 12px; }
  .effect-buttons button b { font-size: 22px; }
  .effect-buttons button span { font-size: 8px; line-height: 1.25; }
  .lab-action { min-height: 44px; gap: 8px; margin-top: 7px; }
  .lab-action > span { flex: 1; min-width: 0; font-size: 9px; line-height: 1.4; color: #9c79ad; }
  .lab-action button { min-height: 44px; padding: 6px 10px; border-radius: 11px; font-size: 10px; background: linear-gradient(120deg, #ce70bc, #985dcb); }

  /* Dialogs and the atlas keep readable detail and 44px touch targets. */
  dialog { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); padding: 31px 20px 22px; overflow-y: auto; border-radius: 24px; }
  .dialog-close { width: 44px; height: 44px; right: 5px; top: 3px; display: grid; place-items: center; padding: 0; }
  dialog h2 { font-size: 25px; }
  dialog p { color: #987da8; font-size: 12px; }
  .primary-button, .text-button { min-height: 44px; }
  .setting-row { min-height: 66px; padding: 12px 0; font-size: 14px; }
  .setting-row input { width: 25px; height: 25px; }
  .toast { max-width: calc(100vw - 28px); bottom: max(16px, env(safe-area-inset-bottom)); padding: 10px 14px; font-size: 12px; line-height: 1.4; text-align: center; }
  .journey-dialog { width: calc(100vw - 12px); max-width: calc(100vw - 12px); height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); padding: 0; overflow: hidden; border-radius: 20px; }
  #journey-map-host { min-height: 0; }
  .journey-close { top: max(7px, env(safe-area-inset-top)); right: 7px; width: 44px; height: 44px; border-radius: 14px; font-size: 27px; }
  .jm-header { flex-shrink: 0; min-height: 96px; padding: 15px 56px 12px 16px; gap: 8px; }
  .jm-eyebrow { font-size: 7px; letter-spacing: 1px; line-height: 1.4; }
  .jm-header h2 { font-size: 22px; line-height: 1.15; margin: 5px 0 3px; }
  .jm-header p { font-size: 9px; line-height: 1.35; }
  .jm-counter { flex-shrink: 0; padding: 6px; border-radius: 12px; }
  .jm-counter b { font-size: 21px; }
  .jm-counter span { font-size: 5px; letter-spacing: .4px; }
  .jm-body { display: flex; flex: 1; min-height: 0; flex-direction: column; }
  .jm-atlas { flex: 1 1 auto; min-height: 190px; }
  .jm-map-tools { inset: 9px 9px auto; gap: 5px; }
  .jm-view-tabs { padding: 2px; border-radius: 13px; }
  .jm-view-tabs button { min-height: 44px; padding: 5px 9px; border-radius: 10px; font-size: 9px; }
  .jm-lap { padding: 6px 8px; font-size: 8px; }
  .jm-zoom { left: 10px; bottom: 66px; gap: 4px; }
  .jm-zoom button { width: 44px; height: 44px; font-size: 24px; border-radius: 12px; }
  .jm-zoom button:last-child { font-size: 25px; margin-top: 0; }
  .jm-map-bottom { padding: 15px 10px 9px; }
  .jm-map-legend { font-size: 7px; gap: 9px; row-gap: 4px; flex-wrap: wrap; }
  .jm-geography-note { margin-top: 4px; font-size: 7px; line-height: 1.3; }
  .jm-mini { width: 91px; right: 9px; bottom: 67px; }
  .jm-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(108px, .6fr); gap: 0 11px; flex: 0 0 auto; max-height: min(306px, 39dvh); min-height: 240px; padding: 12px 12px max(9px, env(safe-area-inset-bottom)); border-left: 0; border-top: 2px solid #fff; overflow: hidden; }
  .jm-stop-detail { min-width: 0; }
  .jm-detail-kicker { font-size: 7px; line-height: 1.4; letter-spacing: .3px; }
  .jm-detail-brand { margin-top: 6px; padding: 3px 6px; font-size: 7px; line-height: 1.3; }
  .jm-stop-detail h3 { font-size: 15px; line-height: 1.2; margin: 6px 0 4px; -webkit-line-clamp: 2; }
  .jm-stop-detail p { font-size: 9px; line-height: 1.45; max-height: 39px; color: #9e7f9d; }
  .jm-distance { font-size: 8px; margin-top: 5px; }
  .jm-challenge-card { min-height: 38px; padding: 5px 6px; margin: 6px 0 2px; gap: 5px; }
  .jm-challenge-card > svg { width: 25px; height: 25px; }
  .jm-challenge-card b { font-size: 11px; }
  .jm-challenge-card small { display: block; font-size: 6px; white-space: normal; }
  .jm-play { min-height: 44px; margin: 8px 0 3px; padding: 7px 5px; font-size: 10px; border-radius: 12px; line-height: 1.3; }
  .jm-itinerary { min-width: 0; min-height: 0; }
  .jm-itinerary-heading { min-height: 20px; padding-bottom: 4px; }
  .jm-itinerary-heading b { font-size: 8px; line-height: 1.3; }
  .jm-stop-list { min-height: 0; }
  .jm-stop, .jm-stop.challenge { min-height: 44px; padding: 5px 2px; gap: 5px; }
  .jm-stop > i { width: 24px; height: 24px; font-size: 8px; border-radius: 8px; }
  .jm-stop b { font-size: 8px; }
  .jm-stop small { font-size: 7px; }
  .jm-stop .jm-stop-challenge { font-size: 6px; }
  .jm-stop.challenge > i > svg { width: 21px; height: 21px; }
  .jm-source { grid-column: 1 / -1; margin: 7px 0 0; font-size: 6px; line-height: 1.4; }

  /* An editorial welcome with the start action immediately below the illustration. */
  .cw-wrap { width: 100%; min-height: 100svh; padding: max(15px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(17px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); }
  .cw-header { min-height: 44px; gap: 10px; }
  .cw-brand { gap: 9px; font-size: 22px; }
  .cw-brand-symbol { width: 35px; height: 37px; border-radius: 12px; box-shadow: 0 3px 0 #dfcdef, inset 0 1px 0 #d6b6f0; }
  .cw-brand-symbol .cw-icon { width: 22px; height: 22px; }
  .cw-brand small { margin-top: 4px; font-size: 6px; letter-spacing: 1.3px; }
  .cw-brand b { font-size: 8px; padding: 2px 4px; }
  .cw-header-note { max-width: 119px; padding: 7px 8px; gap: 5px; font-size: 7px; line-height: 1.4; }
  .cw-header-note .cw-icon { width: 14px; height: 14px; }
  .cw-main { display: flex; flex-direction: column; align-items: center; margin: 0; padding: 24px 0 19px; }
  .cw-copy { width: 100%; max-width: 440px; text-align: center; }
  .cw-eyebrow { justify-content: center; font-size: 7px; line-height: 1.3; letter-spacing: .9px; gap: 7px; }
  .cw-eyebrow i { height: 5px; width: 5px; box-shadow: 0 0 0 3px #f0e6f8; }
  .cw-copy h1 { margin: 11px auto 12px; font-size: clamp(35px, 10.5vw, 46px); line-height: 1.04; letter-spacing: -1.1px; }
  .cw-title-spark { font-size: 18px; top: 1px; right: -19px; }
  .cw-description { max-width: 350px; font-size: 12px; line-height: 1.5; margin: 0 auto; }
  .cw-visual { width: min(100%, 330px); max-width: 100%; align-self: center; margin: 9px 0 0; overflow: visible; }
  .cw-art-bubble { top: 3%; left: 27%; padding: 6px 8px; border-radius: 10px 10px 10px 3px; font-size: 7px; }
  .cw-art-bubble .cw-icon { width: 10px; height: 10px; }
  .cw-art-orbit-one { inset: 15% 0 12% 3%; }
  .cw-art-orbit-two { inset: 25% 0 24%; }
  .cw-art-caption { margin-top: -10px; font-size: 8px; line-height: 1.4; gap: 5px; }
  .cw-art-dot { width: 4px; height: 4px; }
  .cw-details { display: flex; flex-direction: column; width: 100%; max-width: 440px; }
  .cw-purpose { display: none; }
  .cw-actions { order: 0; width: 100%; margin: 16px 0 0; gap: 5px; }
  .cw-start { min-height: 54px; padding: 11px 15px; font-size: 16px; border-radius: 15px; }
  .cw-map { min-height: 44px; padding: 8px 14px; font-size: 11px; }
  .cw-origin { order: 1; width: 100%; margin-top: 12px; padding: 10px 11px; gap: 9px; border-radius: 14px; }
  .cw-origin > .cw-icon { width: 22px; height: 22px; }
  .cw-origin small { font-size: 6px; letter-spacing: .8px; }
  .cw-origin b { font-size: 11px; line-height: 1.35; }
  .cw-store-address { font-size: 8px; line-height: 1.35; }
  .cw-origin-level { min-width: 27px; height: 29px; border-radius: 9px; }
  .cw-steps { order: 2; width: 100%; gap: 6px; margin: 18px 0 0; }
  .cw-steps > span { gap: 6px; align-items: center; text-align: center; }
  .cw-steps i { width: 31px; height: 31px; border-radius: 11px; }
  .cw-steps .cw-icon { width: 18px; height: 18px; }
  .cw-steps b { font-size: 10px; line-height: 1.3; }
  .cw-steps small { font-size: 7px; line-height: 1.35; margin-top: 2px; }
  .cw-checkpoint { order: 3; max-width: 330px; margin: 15px auto 0; font-size: 8px; line-height: 1.5; justify-content: center; }
  .cw-checkpoint .cw-icon { width: 13px; height: 13px; }
  .cw-footer { gap: 6px; padding-top: 14px; font-size: 8px; line-height: 1.4; }
}

@media (max-width: 370px) {
  .brand { font-size: 21px; gap: 7px; }
  .offline-badge { display: none; }
  .topbar { padding-left: 11px; padding-right: 9px; }
  .game-shell { padding-left: 7px; padding-right: 7px; }
  .chapter-heading h1 { font-size: 22px; }
  .mode-switch button { padding-left: 6px; padding-right: 6px; font-size: 9px; }
  .boss-card { padding-left: 69px; padding-right: 7px; }
  .boss-portrait, .lab-mode .boss-portrait { left: -2px; width: 69px; }
  .portrait-orbit { width: 54px; height: 54px; margin-left: -27px; top: 17px; }
  .boss-card h2 { font-size: 12px; }
  .boss-style-picker select { font-size: 16px; }
  .hp-label span { font-size: 7px; }
  .hp-label b { font-size: 7px; }
  .moves-card { flex-basis: 65px; width: 65px; }
  .moves-card .mini-label { font-size: 7px; }
  .moves-card strong { font-size: 31px; }
  .checkpoint-banner small { font-size: 6px; }
  .checkpoint-preview > a { font-size: 8px; padding-left: 3px; padding-right: 3px; }
  .lab-tools { padding: 6px; }
  .effect-buttons { gap: 4px; }
  .effect-buttons button span { font-size: 7px; }
  .jm-header { padding-left: 13px; padding-right: 52px; }
  .jm-header h2 { font-size: 20px; }
  .jm-counter b { font-size: 19px; }
  .jm-sidebar { padding-left: 10px; padding-right: 10px; gap: 0 9px; grid-template-columns: minmax(0, 1fr) 105px; }
  .jm-stop-detail h3 { font-size: 13px; }
  .jm-stop-detail p { font-size: 8px; }
  .jm-stop b { font-size: 7px; }
  .jm-view-tabs button { font-size: 8px; padding-left: 7px; padding-right: 7px; }
  .cw-wrap { padding-left: 18px; padding-right: 18px; }
  .cw-brand { font-size: 19px; gap: 8px; }
  .cw-header-note { max-width: 106px; font-size: 6px; padding: 6px; }
  .cw-copy h1 { font-size: 35px; }
  .cw-eyebrow { font-size: 6px; letter-spacing: .8px; }
  .cw-title-spark { right: -17px; font-size: 16px; }
  .cw-description { font-size: 11px; }
  .cw-visual { width: min(100%, 290px); }
  .cw-steps b { font-size: 9px; }
  .cw-steps small { font-size: 6px; }
}

/* A short phone scrolls naturally; the board keeps usable cells instead of being squeezed. */
@media (max-width: 650px) and (max-height: 780px) {
  .topbar { min-height: 48px; padding-top: max(2px, env(safe-area-inset-top)); padding-bottom: 2px; }
  .chapter-heading h1 { display: none; }
  .chapter-heading { margin-bottom: 5px; }
  .boss-card, .moves-card { min-height: 94px; }
  .current-store-banner { min-height: 44px; padding-top: 4px; padding-bottom: 4px; }
  .board-topline { height: 27px; }
  .booster-bar { min-height: 63px; margin-top: 2px; padding-top: 3px; padding-bottom: 3px; }
  .booster { min-height: 54px; }
  .board-hint { margin-top: 6px; }
  .game-shell > footer { margin-top: 8px; }
  .jm-header { min-height: 87px; padding-top: 12px; padding-bottom: 10px; }
  .jm-sidebar { max-height: min(285px, 42dvh); min-height: 231px; padding-top: 9px; }
  .jm-challenge-card small { display: none; }
  .jm-atlas { min-height: 175px; }
  .cw-main { padding-top: 20px; }
  .cw-copy h1 { margin-top: 9px; margin-bottom: 10px; }
  .cw-visual { width: min(100%, 300px); margin-top: 5px; }
  .cw-actions { margin-top: 13px; }
}

@media (max-width: 650px) and (max-height: 620px) {
  .cw-wrap { padding-top: max(10px, env(safe-area-inset-top)); }
  .cw-main { padding-top: 15px; }
  .cw-copy h1 { font-size: 35px; }
  .cw-description { font-size: 11px; }
  .cw-visual { width: min(100%, 250px); }
  .cw-actions { margin-top: 12px; }
  .cw-steps, .cw-origin { margin-top: 16px; }
  .jm-body { overflow-y: auto; overscroll-behavior: contain; }
  .jm-atlas { flex: 1 0 205px; }
  .jm-sidebar { max-height: none; min-height: 250px; flex-shrink: 0; }
}

/* Keep the small-screen board vivid without adding another render pass. The
   canvas filter is compositor work, so glossy candy colors stay bright while
   low-end phones avoid extra DOM or particle layers. */
@media (max-width: 650px) {
  .board-stage canvas#board { filter: saturate(1.10) contrast(1.025); }
  #boss-canvas { filter: saturate(1.08) contrast(1.02); }
  .board-stage { box-shadow: inset 0 0 0 1px #ffffff75, 0 9px 28px #70458f1c; }
}

/* Small landscape phones retain a full board and ordinary vertical scrolling. */
@media (max-width: 950px) and (max-height: 500px) and (orientation: landscape) {
  .topbar { min-height: 48px; height: auto; padding: max(2px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 2px max(14px, env(safe-area-inset-left)); }
  .icon-button { width: 44px; height: 44px; }
  .game-shell { max-width: 600px; padding: 0 max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .chapter-heading .eyebrow, .chapter-heading h1, .chapter-heading p { display: none; }
  .chapter-heading { margin: 0 0 8px; }
  .mode-switch { min-height: 48px; margin: 0 auto; }
  .mode-switch button { min-height: 44px; font-size: 11px; }
  .play-layout { display: flex; flex-direction: column; gap: 7px; }
  .journey-panel { display: none; }
  .challenge-panel { order: 0; width: 100%; display: flex; padding: 0; gap: 8px; }
  .boss-card { position: relative; flex: 1; min-height: 104px; padding: 6px 12px 7px 95px; text-align: left; }
  .boss-card .boss-tag, .boss-card > p, .best-card { display: none; }
  .boss-card h2 { font-size: 14px; line-height: 18px; margin: 0; }
  .boss-portrait, .lab-mode .boss-portrait { position: absolute; left: 2px; top: 4px; width: 88px; height: 94px; margin: 0; }
  .portrait-orbit { width: 70px; height: 70px; margin-left: -35px; top: 11px; }
  .boss-style-picker { margin: 0 0 2px; }
  .boss-style-picker > span { display: none; }
  .boss-style-picker select { width: 100%; min-height: 44px; height: 44px; font-size: 16px; }
  .hp-label, .hp-label b { font-size: 9px; }
  .hp-track { height: 9px; margin-top: 2px; }
  .moves-card { width: 85px; flex: 0 0 85px; margin: 0; display: flex; flex-direction: column; justify-content: center; }
  .moves-card .mini-label { font-size: 8px; }
  .moves-card p { display: none; }
  .moves-card strong { font-size: 35px; }
  .board-column { order: 1; width: 100%; }
  .board-stage { max-width: 520px; }
  .current-store-banner { min-height: 44px; }
  .booster-bar { max-width: 430px; }
  .booster { min-height: 54px; min-width: 52px; }
  .lab-tools-heading button, .lab-theme-button, .lab-action button, .boss-test-button, .checkpoint-preview button, .checkpoint-preview > a { min-height: 44px; }
  .effect-buttons button { min-height: 53px; }
  .journey-dialog { height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); }
  #journey-map-host { min-height: 0; }
  .journey-close, .jm-zoom button { width: 44px; height: 44px; }
  .jm-header { min-height: 84px; padding-top: 10px; padding-bottom: 10px; }
  .jm-body { overflow-y: auto; }
  .jm-atlas { min-height: 280px; }
  .jm-view-tabs button, .jm-play, .jm-stop { min-height: 44px; }
  .cw-overlay { overflow-x: hidden; }
  .cw-wrap { min-height: 100svh; padding-top: 12px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .cw-main { margin: 0; padding-top: 26px; }
  .cw-start { min-height: 54px; }
  .cw-map { min-height: 44px; }
}
