/* Mobile-only compact layout for sentence practice. Loaded after the main page CSS. */
@media (max-width: 620px) {
  .sentence-rpg-page .pet-app {
    gap: 7px !important;
    width: 100% !important;
    padding: 8px 8px calc(74px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .sentence-rpg-page .topbar {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 8px 9px !important;
    border-radius: 12px !important;
  }

  .sentence-rpg-page .brand {
    gap: 7px !important;
  }

  .sentence-rpg-page .brand-ball {
    width: 42px !important;
    height: 42px !important;
  }

  .sentence-rpg-page .eyebrow {
    font-size: 10px !important;
    line-height: 1 !important;
  }

  .sentence-rpg-page .brand h1 {
    font-size: 28px !important;
  }

  .sentence-rpg-page .lesson-select-top {
    grid-template-columns: minmax(0, 1fr) minmax(94px, auto) !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }

  .sentence-rpg-page .lesson-select-top span,
  .sentence-rpg-page .top-stat-chip,
  .sentence-rpg-page .sentence-guide-button,
  .sentence-rpg-page .sentence-sound-button,
  .sentence-rpg-page .sentence-settings summary {
    min-height: 33px !important;
    padding: 6px 8px !important;
    border-width: 1.5px !important;
    border-radius: 9px !important;
    font-size: 12px !important;
  }

  .sentence-rpg-page .lesson-select-top span {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  .sentence-rpg-page .top-stats {
    display: grid !important;
    grid-template-columns: minmax(52px, 0.72fr) minmax(68px, 0.9fr) repeat(3, minmax(44px, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .sentence-rpg-page .sentence-guide-button,
  .sentence-rpg-page .sentence-sound-button {
    width: 100% !important;
  }

  .sentence-rpg-page .sentence-settings summary {
    width: 100% !important;
    min-width: 42px !important;
  }

  .sentence-rpg-page .sentence-progress-bar {
    display: none !important;
  }

  .sentence-rpg-page .sentence-progress-bar > span:first-child {
    writing-mode: horizontal-tb !important;
    font-size: 12px !important;
    white-space: nowrap !important;
  }

  .sentence-rpg-page #sentenceRemainText,
  .sentence-rpg-page #sentenceTimerText {
    display: none !important;
  }

  .sentence-rpg-page .sentence-progress-track {
    height: 10px !important;
  }

  .sentence-rpg-page .playground {
    display: block !important;
    margin: 0 !important;
  }

  .sentence-rpg-page .quiz-card {
    min-height: 0 !important;
    margin: 0 !important;
    padding: 10px 8px 12px !important;
    border-width: 1.5px !important;
    border-radius: 14px !important;
  }

  .sentence-rpg-page .sentence-deck-bar {
    margin: 0 0 8px !important;
    padding: 8px 9px !important;
    border-radius: 12px !important;
  }

  .sentence-rpg-page .sentence-deck-summary {
    gap: 8px !important;
  }

  .sentence-rpg-page .sentence-deck-summary strong {
    font-size: 13px !important;
    line-height: 1.15 !important;
  }

  .sentence-rpg-page .sentence-deck-count,
  .sentence-rpg-page .lesson-meta {
    display: none !important;
  }

  .sentence-rpg-page .cn-sentence {
    min-height: 118px !important;
    margin: 0 0 8px !important;
    padding: 16px 12px !important;
    border-radius: 13px !important;
    font-size: clamp(24px, 7vw, 34px) !important;
    line-height: 1.15 !important;
  }

  .sentence-rpg-page .answer-slots {
    gap: 8px !important;
    margin: 0 auto 10px !important;
    padding: 7px !important;
    width: fit-content !important;
    max-width: 100% !important;
  }

  .sentence-rpg-page .answer-slot {
    min-width: 96px !important;
    min-height: 48px !important;
    padding: 8px 10px !important;
    font-size: 18px !important;
  }

  .sentence-rpg-page .word-bank {
    gap: 8px 9px !important;
    margin: 8px 0 8px !important;
    padding: 0 !important;
  }

  .sentence-rpg-page .word-chip {
    min-width: 88px !important;
    min-height: 44px !important;
    padding: 8px 10px !important;
    border-radius: 10px !important;
    font-size: 15px !important;
  }

  .sentence-rpg-page .hint-line {
    margin: 8px 0 9px !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
  }

  .sentence-rpg-page .action-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin: 0 !important;
  }

  .sentence-rpg-page .action-row button {
    min-height: 42px !important;
    padding: 8px 10px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
  }

  .sentence-rpg-page .action-row #checkBtn {
    grid-column: 1 / -1 !important;
  }

  .sentence-rpg-page .buddy-card {
    margin-top: 8px !important;
    padding: 9px !important;
    border-width: 1.5px !important;
    border-radius: 14px !important;
  }
}

/* Tighten the large scenic modules on mobile; crop backgrounds instead of forcing full artwork height. */
@media (max-width: 620px) {
  .sentence-rpg-page .pet-app {
    gap: 6px !important;
    padding-bottom: calc(116px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .sentence-rpg-page .playground {
    gap: 7px !important;
  }

  .sentence-rpg-page .quiz-card,
  .sentence-rpg-page .buddy-card {
    min-height: 0 !important;
    height: auto !important;
    overflow: hidden !important;
  }

  .sentence-rpg-page .quiz-card {
    padding: 8px 8px 9px !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .sentence-rpg-page .quiz-card::before {
    background:
      linear-gradient(180deg, rgba(239, 248, 255, 0.18), rgba(255, 255, 255, 0.3)),
      url("assets/ui/cloud-kingdom-game-bg.png") center 38% / auto 128% no-repeat !important;
    opacity: 0.74 !important;
  }

  .sentence-rpg-page .sentence-deck-bar {
    margin-bottom: 7px !important;
  }

  .sentence-rpg-page .cn-sentence {
    order: 1 !important;
    min-height: 54px !important;
    margin-bottom: 2px !important;
    padding: 8px 10px !important;
    font-size: clamp(18px, 5.8vw, 25px) !important;
    line-height: 1.1 !important;
  }

  .sentence-rpg-page .answer-slots {
    order: 3 !important;
    gap: 6px 8px !important;
    margin: 3px auto 5px !important;
    padding: 0 !important;
    min-height: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  .sentence-rpg-page .answer-slot {
    min-width: 68px !important;
    width: 68px !important;
    max-width: 68px !important;
    min-height: 34px !important;
    height: 34px !important;
    max-height: 34px !important;
    padding: 5px 7px !important;
    border-radius: 9px !important;
    font-size: 13px !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
  }

  .sentence-rpg-page .word-bank {
    order: 4 !important;
    gap: 6px 8px !important;
    margin-block: 5px !important;
  }

  .sentence-rpg-page .word-chip {
    min-width: 68px !important;
    min-height: 34px !important;
    padding: 5px 7px !important;
    border-radius: 9px !important;
    font-size: 13px !important;
  }

  .sentence-rpg-page .hint-line {
    order: 2 !important;
    margin: 0 0 2px !important;
    font-size: 11px !important;
    line-height: 1.2 !important;
  }

  .sentence-rpg-page .action-row {
    order: 5 !important;
    gap: 6px !important;
  }

  .sentence-rpg-page .action-row button {
    min-height: 36px !important;
    padding: 6px 8px !important;
    border-radius: 9px !important;
    font-size: 13px !important;
  }

  .sentence-rpg-page .buddy-card {
    display: grid !important;
    gap: 7px !important;
    margin-top: 7px !important;
    padding: 8px !important;
  }

  .sentence-rpg-page .pet-compact-summary {
    margin-bottom: 0 !important;
    padding: 7px 8px !important;
    border-radius: 12px !important;
  }

  .sentence-rpg-page .buddy-stage {
    height: clamp(245px, 76vw, 300px) !important;
    min-height: 0 !important;
    margin: 0 !important;
    border-radius: 14px !important;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(20, 78, 130, 0.05)),
      url("assets/ui/sentence-sky-kingdom-stage.png") center 58% / auto 118% no-repeat,
      #e3f6ff !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor,
  .sentence-rpg-page .pet-anchor {
    bottom: 25% !important;
  }

  .sentence-rpg-page .growth-card {
    gap: 6px !important;
    margin-top: 0 !important;
    padding: 8px !important;
    border-radius: 12px !important;
  }

  .sentence-rpg-page .growth-top,
  .sentence-rpg-page #growthText,
  .sentence-rpg-page .food-shortcut-head,
  .sentence-rpg-page .pet-companion-actions {
    margin: 0 !important;
  }

  .sentence-rpg-page .food-shortcut-grid {
    min-height: 52px !important;
    padding: 7px !important;
  }

  .sentence-rpg-page .pet-companion-actions {
    margin-bottom: 44px !important;
  }

  .sentence-rpg-page .food-shortcut-grid::before,
  .sentence-rpg-page .food-shortcut-grid::after {
    display: none !important;
    content: none !important;
  }
}

/* Sentence Practice mobile Design System final layer v1. */
@media (max-width: 720px) {
  html,
  body.sentence-rpg-page {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  body.sentence-rpg-page,
  body.sentence-rpg-page:has(.pet-app) {
    background:
      linear-gradient(180deg, rgba(188, 235, 255, 0.14), rgba(255, 255, 255, 0.04)),
      url("assets/ui/cloud-kingdom-game-bg.png") center bottom / cover scroll no-repeat,
      var(--lq-bg-sky, #bdeeff) !important;
  }

  .sentence-rpg-page .pet-app {
    width: 100% !important;
    max-width: 100vw !important;
    min-height: 100vh !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto auto !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 8px 8px calc(112px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden !important;
    background: transparent !important;
  }

  .sentence-rpg-page .topbar {
    width: 100% !important;
    min-height: auto !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 7px !important;
    padding: 9px !important;
    border-radius: 20px !important;
    overflow: visible !important;
  }

  .sentence-rpg-page .brand {
    min-width: 0 !important;
    gap: 8px !important;
  }

  .sentence-rpg-page .brand-ball {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border-radius: 15px !important;
  }

  .sentence-rpg-page .brand-ball img {
    width: 28px !important;
    height: 28px !important;
  }

  .sentence-rpg-page .brand .eyebrow {
    font-size: 10px !important;
  }

  .sentence-rpg-page .brand h1 {
    font-size: 20px !important;
  }

  .sentence-rpg-page .brand .lq-topbar-subtitle {
    font-size: 10px !important;
  }

  .sentence-rpg-page .top-stats {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-content: end !important;
    gap: 5px !important;
  }

  .sentence-rpg-page .top-stat-chip {
    display: none !important;
  }

  .sentence-rpg-page .lesson-select-top {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    justify-content: space-between !important;
    gap: 6px !important;
    padding: 6px 9px !important;
  }

  .sentence-rpg-page .lesson-select-top span {
    font-size: 11px !important;
  }

  .sentence-rpg-page .sentence-guide-button,
  .sentence-rpg-page .sentence-sound-button,
  .sentence-rpg-page .sentence-settings summary {
    width: 40px !important;
    min-width: 40px !important;
    height: 38px !important;
    min-height: 38px !important;
    border-radius: 15px !important;
  }

  .sentence-rpg-page .sentence-guide-button {
    width: 52px !important;
    min-width: 52px !important;
    font-size: 13px !important;
  }

  .sentence-rpg-page .sentence-sound-icon,
  .sentence-rpg-page .sentence-settings summary img {
    width: 23px !important;
    height: 23px !important;
  }

  .sentence-rpg-page .sentence-progress-bar {
    width: 100% !important;
    min-height: 38px !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    gap: 6px !important;
    padding: 7px 9px !important;
    border-radius: 18px !important;
  }

  .sentence-rpg-page .sentence-progress-bar > span,
  .sentence-rpg-page .sentence-progress-bar strong {
    font-size: 11px !important;
  }

  .sentence-rpg-page .sentence-progress-bar #sentenceRemainText,
  .sentence-rpg-page .sentence-progress-bar #sentenceTimerText {
    display: none !important;
  }

  .sentence-rpg-page .sentence-progress-track {
    min-width: 0 !important;
    height: 9px !important;
    border-width: 1.5px !important;
  }

  .sentence-rpg-page .playground {
    width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    overflow: visible !important;
  }

  .sentence-rpg-page .quiz-card {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 7px !important;
    padding: 9px !important;
    border-radius: 20px !important;
    overflow: hidden !important;
  }

  .sentence-rpg-page .quiz-card::before {
    background:
      linear-gradient(180deg, rgba(239, 248, 255, 0.16), rgba(255, 255, 255, 0.32)),
      url("assets/ui/cloud-kingdom-game-bg.png") center 42% / auto 125% no-repeat !important;
    opacity: 0.58 !important;
  }

  .sentence-rpg-page .sentence-deck-bar {
    padding: 7px !important;
    border-radius: 15px !important;
  }

  .sentence-rpg-page .sentence-deck-summary {
    gap: 7px !important;
  }

  .sentence-rpg-page .sentence-deck-summary label,
  .sentence-rpg-page .lesson-meta span,
  .sentence-rpg-page .sentence-deck-count {
    font-size: 10px !important;
  }

  .sentence-rpg-page .sentence-deck-summary strong,
  .sentence-rpg-page .lesson-meta strong {
    font-size: 13px !important;
  }

  .sentence-rpg-page #openDeckSelectorBtn {
    min-width: 58px !important;
    min-height: 34px !important;
    padding: 5px 8px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
  }

  .sentence-rpg-page .lesson-meta {
    min-height: 32px !important;
    padding: 6px 9px !important;
  }

  .sentence-rpg-page .cn-sentence {
    order: 1 !important;
    min-height: 46px !important;
    margin: 0 !important;
    padding: 7px 9px !important;
    border-radius: 16px !important;
    font-size: clamp(17px, 5vw, 21px) !important;
    line-height: 1.12 !important;
  }

  .sentence-rpg-page .hint-line {
    order: 2 !important;
    min-height: 16px !important;
    margin: -2px 0 0 !important;
    font-size: 10.5px !important;
    line-height: 1.15 !important;
  }

  .sentence-rpg-page .answer-slots {
    order: 3 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 5px !important;
    border-radius: 14px !important;
  }

  .sentence-rpg-page .answer-slot,
  .sentence-rpg-page .word-chip {
    min-width: 68px !important;
    min-height: 34px !important;
    height: 34px !important;
    max-width: calc(50vw - 18px) !important;
    padding: 5px 8px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    line-height: 1 !important;
  }

  .sentence-rpg-page .word-bank {
    order: 4 !important;
    width: 100% !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .sentence-rpg-page .action-row {
    order: 5 !important;
    width: 100% !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin: 0 !important;
  }

  .sentence-rpg-page .action-row button {
    min-width: 0 !important;
    min-height: 38px !important;
    padding: 6px 7px !important;
    border-radius: 12px !important;
    gap: 5px !important;
    font-size: 12px !important;
    overflow: hidden !important;
  }

  .sentence-rpg-page .action-row button img {
    width: 20px !important;
    height: 20px !important;
  }

  .sentence-rpg-page .action-row #checkBtn {
    grid-column: 1 / -1 !important;
    min-height: 42px !important;
    font-size: 14px !important;
  }

  .sentence-rpg-page .buddy-card {
    width: 100% !important;
    max-width: 100% !important;
    display: grid !important;
    grid-template-rows: auto auto auto !important;
    gap: 7px !important;
    margin: 0 !important;
    padding: 8px !important;
    border-radius: 20px !important;
    overflow: hidden !important;
  }

  .sentence-rpg-page .pet-compact-summary {
    min-height: 50px !important;
    padding: 7px 8px !important;
    border-radius: 15px !important;
  }

  .sentence-rpg-page .pet-compact-summary h2 {
    font-size: 15px !important;
  }

  .sentence-rpg-page #changePetBtn {
    min-width: 68px !important;
    min-height: 34px !important;
    padding: 5px 8px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
  }

  .sentence-rpg-page .buddy-stage {
    height: 188px !important;
    min-height: 188px !important;
    margin: 0 !important;
    border-radius: 16px !important;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(24, 94, 80, 0.06)),
      url("assets/ui/sentence-sky-kingdom-stage.png") center 58% / auto 120% no-repeat,
      #dff6ff !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor,
  .sentence-rpg-page .pet-anchor {
    bottom: 20% !important;
    width: min(48%, 150px) !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .speech-bubble {
    width: clamp(112px, 92%, 150px) !important;
    font-size: 11px !important;
  }

  .sentence-rpg-page .growth-card {
    gap: 5px !important;
    padding: 7px !important;
    border-radius: 15px !important;
  }

  .sentence-rpg-page .growth-top,
  .sentence-rpg-page .food-shortcut-head {
    font-size: 11px !important;
  }

  .sentence-rpg-page .food-shortcut-grid {
    min-height: 44px !important;
    max-height: 58px !important;
    padding: 5px !important;
  }

  .sentence-rpg-page .pet-companion-actions {
    margin-bottom: 34px !important;
  }
}

@media (max-width: 540px) {
  .sentence-rpg-page .buddy-stage .pet-anchor,
  .sentence-rpg-page .pet-anchor {
    bottom: 12% !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .speech-bubble {
    bottom: calc(100% + 6px) !important;
    width: clamp(132px, 106%, 170px) !important;
    max-width: min(170px, calc(100vw - 72px)) !important;
    min-height: 0 !important;
    padding: 5px 8px !important;
    font-size: 10.5px !important;
    line-height: 1.22 !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .speech-bubble::after {
    bottom: -6px !important;
    width: 12px !important;
    height: 12px !important;
  }
}

@media (max-width: 390px) {
  .sentence-rpg-page .pet-app {
    padding-left: 7px !important;
    padding-right: 7px !important;
  }

  .sentence-rpg-page .answer-slot,
  .sentence-rpg-page .word-chip {
    min-width: 64px !important;
    height: 32px !important;
    min-height: 32px !important;
    padding: 4px 7px !important;
    font-size: 12.5px !important;
  }

  .sentence-rpg-page .buddy-stage {
    height: 176px !important;
    min-height: 176px !important;
  }
}

/* Sentence mobile DS v1 true EOF final layer. */
@media (max-width: 720px) {
  .sentence-rpg-page .topbar {
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: start !important;
  }

  .sentence-rpg-page .brand {
    max-width: 172px !important;
  }

  .sentence-rpg-page .top-stats {
    display: flex !important;
    grid-template-columns: none !important;
    grid-column: 2 !important;
    grid-row: 1 !important;
    align-self: start !important;
    justify-self: end !important;
    justify-content: flex-end !important;
    flex-wrap: nowrap !important;
    width: auto !important;
  }

  .sentence-rpg-page .sentence-progress-bar {
    display: grid !important;
  }

  .sentence-rpg-page .lesson-meta span,
  .sentence-rpg-page .lesson-meta strong {
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .sentence-rpg-page .top-stats .sentence-guide-button::before,
  .sentence-rpg-page .top-stats .sentence-sound-button::before {
    display: none !important;
    content: none !important;
  }

  .sentence-rpg-page .top-stats .sentence-guide-button {
    font-size: 13px !important;
  }

  .sentence-rpg-page .top-stats .sentence-sound-label {
    display: none !important;
  }

  .sentence-rpg-page .top-stats .sentence-sound-button {
    color: transparent !important;
    font-size: 0 !important;
  }

  .sentence-rpg-page .top-stats .sentence-sound-button::after {
    content: "" !important;
    display: block !important;
    width: 23px !important;
    height: 23px !important;
    background: url("assets/ui/sentence-pixel/sentence-icon-sound.png") center / contain no-repeat !important;
  }
}

/* Sentence topbar compact v1 mobile: keep the lesson switch in the first row and pull buddy upward. */
@media (max-width: 720px) {
  .sentence-rpg-page .pet-app {
    width: 100% !important;
    max-width: 100vw !important;
    gap: 6px !important;
    padding: 7px 7px calc(98px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .sentence-rpg-page .topbar {
    width: 100% !important;
    grid-template-columns: 40px minmax(54px, 58px) minmax(72px, 1fr) auto !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 6px !important;
    border-radius: 18px !important;
  }

  .sentence-rpg-page .sentence-back-button {
    width: 40px !important;
    min-width: 40px !important;
    height: 36px !important;
    min-height: 36px !important;
    border-radius: 13px !important;
    font-size: 12px !important;
  }

  .sentence-rpg-page .brand {
    max-width: none !important;
    min-width: 0 !important;
  }

  .sentence-rpg-page .brand-ball,
  .sentence-rpg-page .brand .eyebrow,
  .sentence-rpg-page .brand .lq-topbar-subtitle {
    display: none !important;
  }

  .sentence-rpg-page .brand h1 {
    font-size: 17px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  .sentence-rpg-page .lesson-select-top {
    grid-column: 3 !important;
    grid-row: 1 !important;
    width: 100% !important;
    height: 36px !important;
    min-height: 36px !important;
    min-width: 0 !important;
    padding: 0 7px !important;
    gap: 4px !important;
    border-radius: 13px !important;
  }

  .sentence-rpg-page .lesson-select-top img {
    width: 16px !important;
    height: 16px !important;
  }

  .sentence-rpg-page .lesson-select-top .top-deck-static {
    font-size: 11px !important;
    line-height: 1 !important;
  }

  .sentence-rpg-page .top-stats {
    grid-column: 4 !important;
    grid-row: 1 !important;
    gap: 3px !important;
  }

  .sentence-rpg-page .top-stats .top-stat-chip {
    min-width: 42px !important;
    width: 42px !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 !important;
    border-radius: 13px !important;
    font-size: 11px !important;
  }

  .sentence-rpg-page .top-stats .top-stat-chip:first-child::before {
    display: none !important;
    content: none !important;
  }

  .sentence-rpg-page .top-stats .sentence-guide-button,
  .sentence-rpg-page .top-stats .sentence-sound-button,
  .sentence-rpg-page .top-stats .sentence-settings summary {
    width: 34px !important;
    min-width: 34px !important;
    height: 36px !important;
    min-height: 36px !important;
    border-radius: 13px !important;
  }

  .sentence-rpg-page .top-stats .sentence-guide-button {
    width: 40px !important;
    min-width: 40px !important;
    font-size: 11px !important;
  }

  .sentence-rpg-page .top-stats .sentence-sound-button::after,
  .sentence-rpg-page .sentence-settings summary img {
    width: 20px !important;
    height: 20px !important;
  }

  .sentence-rpg-page .sentence-progress-bar {
    min-height: 38px !important;
    grid-template-columns: auto minmax(0, 1fr) 44px !important;
    gap: 6px !important;
    padding: 6px 8px !important;
    border-radius: 16px !important;
  }

  .sentence-rpg-page .sentence-progress-bar > span,
  .sentence-rpg-page .sentence-progress-bar strong {
    font-size: 11px !important;
  }

  .sentence-rpg-page .sentence-deck-bar,
  .sentence-rpg-page .lesson-meta,
  .sentence-rpg-page .sentence-deck-count {
    display: none !important;
  }

  .sentence-rpg-page .playground {
    gap: 6px !important;
  }

  .sentence-rpg-page .quiz-card {
    gap: 6px !important;
    padding: 8px !important;
    min-height: 0 !important;
    height: auto !important;
  }

  .sentence-rpg-page .cn-sentence {
    min-height: 42px !important;
    padding: 6px 8px !important;
    border-radius: 14px !important;
    font-size: clamp(16px, 4.6vw, 20px) !important;
  }

  .sentence-rpg-page .hint-line {
    margin: -3px 0 -1px !important;
  }

  .sentence-rpg-page .answer-slots {
    padding: 4px !important;
    gap: 5px !important;
  }

  .sentence-rpg-page .word-bank {
    gap: 5px !important;
  }

  .sentence-rpg-page .answer-slot,
  .sentence-rpg-page .word-chip {
    min-width: 62px !important;
    min-height: 31px !important;
    height: 31px !important;
    padding: 4px 7px !important;
    font-size: 12px !important;
  }

  .sentence-rpg-page .action-row {
    gap: 5px !important;
  }

  .sentence-rpg-page .action-row button {
    min-height: 36px !important;
    padding: 5px 6px !important;
  }

  .sentence-rpg-page .action-row #checkBtn {
    min-height: 39px !important;
  }

  .sentence-rpg-page .buddy-card {
    margin-top: 0 !important;
    gap: 5px !important;
    padding: 7px !important;
  }

  .sentence-rpg-page .pet-compact-summary {
    min-height: 44px !important;
    padding: 6px 7px !important;
  }

  .sentence-rpg-page .buddy-stage {
    height: 144px !important;
    min-height: 144px !important;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(24, 94, 80, 0.06)),
      url("assets/ui/sentence-sky-kingdom-stage.png") center 58% / auto 132% no-repeat,
      #dff6ff !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor,
  .sentence-rpg-page .pet-anchor {
    bottom: 16% !important;
    width: min(44%, 134px) !important;
  }

  .sentence-rpg-page .growth-card {
    max-height: 92px !important;
    overflow: hidden !important;
    padding: 6px !important;
  }

  .sentence-rpg-page .food-shortcut-grid,
  .sentence-rpg-page .pet-companion-actions {
    display: none !important;
  }
}

/* Unified sound toggle state: blue when on, gray when muted. */
.sentence-rpg-page .sentence-sound-button .sentence-sound-icon,
.sentence-rpg-page .sentence-sound-button::after {
  filter: none !important;
}

.sentence-rpg-page .sentence-sound-button.is-muted .sentence-sound-icon,
.sentence-rpg-page .sentence-sound-button.is-muted::after {
  filter: grayscale(1) saturate(0) opacity(0.58) !important;
}

/* Sentence mobile topbar clarity lock v1. */
@media (max-width: 720px) {
  .sentence-rpg-page .topbar {
    grid-template-columns: 42px minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto !important;
    gap: 6px !important;
    padding: 7px !important;
  }

  .sentence-rpg-page .sentence-back-button {
    grid-column: 1 !important;
    grid-row: 1 !important;
    width: 42px !important;
    min-width: 42px !important;
  }

  .sentence-rpg-page .brand {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  .sentence-rpg-page .brand h1 {
    font-size: 20px !important;
  }

  .sentence-rpg-page .top-stats {
    grid-column: 3 !important;
    grid-row: 1 !important;
  }

  .sentence-rpg-page .lesson-select-top {
    grid-column: 1 / -1 !important;
    grid-row: 2 !important;
    height: 34px !important;
    min-height: 34px !important;
  }

  .sentence-rpg-page .lesson-select-top .top-deck-static {
    font-size: 13px !important;
  }

  .sentence-rpg-page .lesson-select-top #topDeckLabel,
  .sentence-rpg-page .lesson-select-top #topQuestionLabel {
    display: none !important;
  }
}

/* Sentence mobile pet food and action visibility fix. */
@media (max-width: 720px) {
  .sentence-rpg-page .buddy-card {
    grid-template-rows: auto 132px auto !important;
    gap: 5px !important;
  }

  .sentence-rpg-page .buddy-stage {
    height: 132px !important;
    min-height: 132px !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor,
  .sentence-rpg-page .pet-anchor {
    bottom: 14% !important;
    width: min(42%, 128px) !important;
  }

  .sentence-rpg-page .growth-card {
    max-height: none !important;
    overflow: visible !important;
    padding: 6px !important;
  }

  .sentence-rpg-page .pet-food-shortcuts {
    display: grid !important;
    gap: 5px !important;
  }

  .sentence-rpg-page .food-shortcut-head {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 6px !important;
    min-height: 32px !important;
    padding: 5px 8px !important;
  }

  .sentence-rpg-page .food-shortcut-head span {
    font-size: 13px !important;
    line-height: 1.1 !important;
  }

  .sentence-rpg-page .food-shortcut-head small {
    font-size: 10px !important;
    line-height: 1.1 !important;
  }

  .sentence-rpg-page .food-shortcut-grid {
    display: flex !important;
    min-height: 44px !important;
    max-height: 70px !important;
    overflow: auto !important;
    padding: 5px !important;
  }

  .sentence-rpg-page .pet-companion-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px !important;
    margin: 0 0 8px !important;
  }

  .sentence-rpg-page .pet-companion-actions .soft-button,
  .sentence-rpg-page .pet-companion-actions a {
    min-height: 38px !important;
    height: 38px !important;
    padding: 5px 7px !important;
    font-size: 13px !important;
    line-height: 1.1 !important;
  }
}

@media (max-width: 390px) {
  .sentence-rpg-page .buddy-card {
    grid-template-rows: auto 124px auto !important;
  }

  .sentence-rpg-page .buddy-stage {
    height: 124px !important;
    min-height: 124px !important;
  }

  .sentence-rpg-page .food-shortcut-head small {
    display: none !important;
  }

  .sentence-rpg-page .food-shortcut-grid {
    max-height: 62px !important;
  }
}

/* Keep the sentence pet food storage as a normal wrapping box on mobile. */
@media (max-width: 720px) {
  .sentence-rpg-page .growth-top.growth-top-level {
    min-height: 30px !important;
    padding: 0 2px !important;
  }

  .sentence-rpg-page .growth-top.growth-top-level #growthText {
    display: inline-flex !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 17px !important;
    line-height: 1 !important;
  }

  .sentence-rpg-page .growth-top.growth-top-level #growthText span:last-child {
    display: none !important;
  }

  .sentence-rpg-page .food-shortcut-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    min-height: 56px !important;
    max-height: none !important;
    overflow: visible !important;
    scrollbar-width: none !important;
  }

  .sentence-rpg-page .food-shortcut-grid::-webkit-scrollbar {
    display: none !important;
  }
}

/* Tighten the narrow mobile gap between the sentence card and pet card. */
@media (max-width: 720px) {
  .sentence-rpg-page .playground {
    grid-auto-rows: min-content !important;
    align-content: start !important;
    gap: 4px !important;
    margin-top: 0 !important;
  }

  .sentence-rpg-page .quiz-card {
    margin-bottom: 0 !important;
    padding-bottom: 6px !important;
  }

  .sentence-rpg-page .buddy-card {
    margin-top: 0 !important;
  }
}

/* Keep the narrow-mobile settings menu anchored under the settings button. */
@media (max-width: 720px) {
  .sentence-rpg-page .pet-app,
  .sentence-rpg-page .topbar,
  .sentence-rpg-page .top-stats,
  .sentence-rpg-page .sentence-settings {
    overflow: visible !important;
  }

  .sentence-rpg-page .topbar {
    position: relative !important;
    overflow: visible !important;
    z-index: 9000 !important;
  }

  body.sentence-rpg-page .topbar {
    overflow: visible !important;
  }

  .sentence-rpg-page .top-stats {
    position: relative !important;
    z-index: 9100 !important;
  }

  .sentence-rpg-page .sentence-settings,
  .sentence-rpg-page .sentence-settings[open] {
    position: relative !important;
    z-index: 9200 !important;
  }

  .sentence-rpg-page .sentence-settings[open] .sentence-settings-menu {
    display: grid !important;
    position: fixed !important;
    top: calc(58px + env(safe-area-inset-top, 0px)) !important;
    right: 12px !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: min(280px, calc(100vw - 16px)) !important;
    max-height: min(72vh, 420px) !important;
    overflow: auto !important;
    z-index: 12000 !important;
  }
}

/* Final narrow-phone topbar compression: remove the large blank space between rows. */
@media (max-width: 620px) {
  .sentence-rpg-page .topbar,
  body.sentence-rpg-page .topbar,
  body.sentence-rpg-page .topbar.lq-topbar,
  body.sentence-rpg-page .pet-app > .topbar.lq-topbar {
    min-height: 0 !important;
    height: 88px !important;
    max-height: 88px !important;
    grid-template-columns: 42px minmax(0, 1fr) auto !important;
    grid-template-rows: 36px 34px !important;
    align-items: center !important;
    align-content: start !important;
    row-gap: 6px !important;
    column-gap: 6px !important;
    padding: 6px 7px !important;
    overflow: visible !important;
  }

  body.sentence-rpg-page .playground,
  .sentence-rpg-page .playground {
    margin-top: -44px !important;
  }

  .sentence-rpg-page .sentence-back-button {
    height: 34px !important;
    min-height: 34px !important;
  }

  .sentence-rpg-page .brand {
    align-self: center !important;
  }

  .sentence-rpg-page .brand h1 {
    font-size: 19px !important;
    line-height: 1 !important;
  }

  .sentence-rpg-page .top-stats {
    align-self: center !important;
  }

  .sentence-rpg-page .top-stats .sentence-guide-button,
  .sentence-rpg-page .top-stats .sentence-sound-button,
  .sentence-rpg-page .top-stats .sentence-settings summary {
    height: 34px !important;
    min-height: 34px !important;
  }

  .sentence-rpg-page .lesson-select-top {
    margin: 0 !important;
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    align-self: start !important;
  }
}

/* Final mobile buddy-stage enlargement: keep the companion readable on phones. */
@media (max-width: 720px) {
  .sentence-rpg-page .buddy-card {
    grid-template-rows: auto 190px auto !important;
  }

  .sentence-rpg-page .buddy-stage {
    height: 190px !important;
    min-height: 190px !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor,
  .sentence-rpg-page .pet-anchor {
    bottom: 10% !important;
    height: 55% !important;
    width: min(92%, 300px) !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .speech-bubble {
    top: auto !important;
    bottom: calc(100% + 22px) !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .pet-stage-egg {
    --pet-stage-scale: 0.88 !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .pet-stage-1 {
    --pet-stage-scale: 1.22 !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .pet-stage-2 {
    --pet-stage-scale: 1.38 !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .pet-stage-3 {
    --pet-stage-scale: 1.48 !important;
  }
}

@media (max-width: 390px) {
  .sentence-rpg-page .buddy-card {
    grid-template-rows: auto 182px auto !important;
  }

  .sentence-rpg-page .buddy-stage {
    height: 182px !important;
    min-height: 182px !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor,
  .sentence-rpg-page .pet-anchor {
    height: 55% !important;
    width: min(94%, 300px) !important;
  }

  .sentence-rpg-page .buddy-stage .pet-anchor .speech-bubble {
    top: auto !important;
    bottom: calc(100% + 20px) !important;
  }
}

/* Narrow phones need different top spacing while hatching because the egg preview adds a tall block below. */
@media (max-width: 620px) {
  body.sentence-rpg-page:not(.is-hatching-egg) .playground {
    margin-top: -5px !important;
  }

  body.sentence-rpg-page.is-hatching-egg .playground {
    margin-top: 4px !important;
  }
}

/* Keep pet dialogue readable on phones; most companion lines should fit in two rows. */
@media (max-width: 620px) {
  .sentence-rpg-page .buddy-stage .pet-anchor .speech-bubble,
  .sentence-rpg-page .pet-anchor .speech-bubble {
    width: min(260px, calc(100vw - 72px)) !important;
    max-width: min(260px, calc(100vw - 72px)) !important;
  }
}
