/*
 * Rongguang responsive layer
 * Desktop: >= 901px. Mobile/tablet: <= 900px.
 * This file is intentionally additive. Page-specific CSS remains the source of
 * visual identity; these rules normalize layout behavior across entry pages.
 */

:root {
  --rg-mobile-gap: 14px;
  --rg-mobile-pad: 16px;
  --rg-mobile-radius: 8px;
  --rg-mobile-header: 64px;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

/* 宽表格滚动容器：在所有宽度下都允许横向滚动，避免窄屏被 body 的 overflow-x:hidden 裁掉。 */
.rg-pc-scroll-table,
.table-scroll,
.evidence-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.rg-mobile-only {
  display: none !important;
}

@media (min-width: 901px) {
  .rg-desktop-only {
    display: initial !important;
  }
}

@media (max-width: 900px) {
  .rg-desktop-only {
    display: none !important;
  }

  .rg-mobile-only {
    display: initial !important;
  }

  body {
    min-width: 0 !important;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }

  .auth-page,
  .register-page {
    min-height: 100svh;
    overflow-x: hidden;
  }

  .auth-page {
    display: block !important;
  }

  .auth-visual {
    min-height: auto !important;
    padding: 20px var(--rg-mobile-pad) 0 !important;
  }

  .auth-visual .visual-content {
    display: none !important;
  }

  .auth-form-wrap,
  .register-page {
    width: 100% !important;
    padding: var(--rg-mobile-pad) !important;
  }

  .auth-card,
  .auth-card.wide {
    width: 100% !important;
    max-width: none !important;
    margin: 0 auto !important;
    padding: 20px !important;
    border-radius: var(--rg-mobile-radius) !important;
  }

  .form-grid,
  .student-fields,
  .teacher-fields {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .role-switch {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .role-switch a,
  .role-switch button,
  .primary-btn,
  .primary-action,
  .btn {
    width: 100%;
    min-width: 0;
  }

  .home-stage {
    min-height: 100svh;
    grid-template-rows: auto minmax(0, 1fr) !important;
    padding: 12px !important;
    overflow: hidden !important;
  }

  .top-tools {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
  }

  .digital-human {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    min-height: 0 !important;
    display: grid !important;
    place-items: center !important;
    padding: 8px 0 max(104px, env(safe-area-inset-bottom)) !important;
  }

  .video-guide {
    width: min(calc(100vw - 24px), calc(100svh - 150px), 520px) !important;
    max-width: 100% !important;
  }

  .wave-entry {
    position: absolute !important;
    top: auto !important;
    right: auto !important;
    bottom: max(18px, env(safe-area-inset-bottom)) !important;
    left: 50% !important;
    transform: translateX(-50%) scale(0.76) !important;
  }

  .wave-entry.is-visible {
    transform: translateX(-50%) scale(1) !important;
  }

  .game-topbar,
  .teacher-topbar {
    position: sticky !important;
    top: 0;
    height: auto !important;
    min-height: var(--rg-mobile-header);
    padding: 12px var(--rg-mobile-pad) !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }

  .game-topbar,
  .teacher-topbar,
  .brand-wrap {
    flex-direction: column !important;
  }

  .teacher-nav,
  .game-nav {
    width: 100%;
    margin-left: 0 !important;
    display: flex !important;
    gap: 8px !important;
    overflow-x: auto !important;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .teacher-nav a,
  .game-nav a {
    flex: 0 0 auto;
    min-height: 40px;
    white-space: nowrap;
  }

  .teacher-actions {
    width: 100%;
    justify-content: space-between !important;
  }

  .teacher-main,
  .game-main {
    width: 100% !important;
    padding: var(--rg-mobile-pad) !important;
  }

  .teacher-card,
  .student-hero,
  .review-toolbar,
  .dashboard-filter,
  .student-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .metric-grid,
  .stats-grid,
  .focus-grid,
  .class-kpi-grid,
  .dashboard-pair,
  .dashboard-detail-grid,
  .split-section,
  .section-grid,
  .hero-band,
  .process-grid,
  .schema-grid,
  .data-kpi-grid,
  .dimension-evidence {
    grid-template-columns: 1fr !important;
  }

  .metric-card,
  .class-kpi,
  .panel,
  .data-panel,
  .side-panel,
  .review-card,
  .process-card,
  .data-kpi {
    min-width: 0 !important;
  }

  .report-row,
  .record-row {
    grid-template-columns: 1fr !important;
    align-items: stretch !important;
  }

  .report-actions,
  .student-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .student-hero-stats {
    width: 100%;
    justify-content: space-between;
    gap: 12px !important;
  }

  .class-table,
  .report-table,
  .evidence-table,
  .ai-admin-report table {
    min-width: 760px;
  }

  .class-list-card {
    position: static !important;
  }

  .map-stage {
    min-height: 100svh !important;
  }

  .campus-map {
    width: min(94vw, calc(78svh * 4 / 3)) !important;
    max-width: 94vw !important;
    max-height: 78svh !important;
  }

  .home-button {
    top: 12px !important;
    left: 12px !important;
  }

  .map-guide {
    width: clamp(104px, 28vw, 148px) !important;
  }

  .topbar,
  .report-topbar,
  .ai-admin-report .report-topbar {
    position: sticky !important;
    top: 0;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    padding: 12px var(--rg-mobile-pad) !important;
  }

  main,
  .ai-admin-report main {
    width: 100% !important;
    padding-left: var(--rg-mobile-pad) !important;
    padding-right: var(--rg-mobile-pad) !important;
  }

  .hero,
  .grid-2,
  .grid-3,
  .summary-strip,
  .evidence-chain,
  .dimension-matrix,
  .interest-layout,
  .interest-cards,
  .placement-grid,
  .game-evidence-grid,
  .timeline,
  .hero-metrics,
  .student-grid,
  .evidence-grid {
    grid-template-columns: 1fr !important;
  }

  .hero-main,
  .student-card,
  .card,
  .table-card,
  .review-card {
    padding: 18px !important;
  }

  .ability-row,
  .island-row,
  .review-row,
  .match-row {
    grid-template-columns: 1fr !important;
  }

  .admin-hero,
  .game-admin .stat-grid,
  .game-admin .form-grid,
  .game-admin .class-grid,
  .game-admin .report-mini {
    grid-template-columns: 1fr !important;
  }

  .content-wrapper,
  .right-side,
  .main-footer {
    margin-left: 0 !important;
  }

  .content {
    padding: 12px !important;
  }

  /* FastAdmin 后台：Bootstrap .row 的 -15px 负边距在窄屏会撑出约 30px 横向滚动。
     内容区内把行负边距归零，并裁掉残余溢出（宽表格仍在各自的 .fixed-table-container 内横向滚动）。 */
  .content-wrapper,
  .tab-content {
    overflow-x: hidden;
  }

  .tab-content .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .fixed-table-toolbar,
  .bootstrap-table,
  .fixed-table-container {
    width: 100%;
    overflow-x: auto;
  }

  .wave-screen {
    width: 100% !important;
    min-height: 100svh !important;
    height: 100svh !important;
  }

  .wave-screen .camera-video,
  .wave-screen .pose-overlay {
    inset: 12px !important;
    width: calc(100% - 24px) !important;
    height: calc(100% - 24px) !important;
    border-radius: 24px !important;
  }

  .wave-screen .home-button,
  .wave-screen .camera-button {
    width: clamp(48px, 13vw, 58px) !important;
    height: clamp(48px, 13vw, 58px) !important;
    border-width: 4px !important;
  }

  .wave-screen .home-button {
    top: max(12px, env(safe-area-inset-top)) !important;
    left: 12px !important;
  }

  .wave-screen .progress-badge {
    top: max(12px, env(safe-area-inset-top)) !important;
    right: 12px !important;
    width: clamp(58px, 16vw, 78px) !important;
    height: clamp(58px, 16vw, 78px) !important;
    font-size: clamp(18px, 5vw, 26px) !important;
  }

  .wave-screen .camera-button {
    right: 12px !important;
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
  }

  .map-page {
    width: 100% !important;
    min-height: 100svh !important;
    overflow: hidden !important;
  }

  .map-frame {
    max-width: 100vw !important;
    max-height: 100svh !important;
  }

  .sr-app {
    width: 100% !important;
    min-height: 100svh !important;
    padding: 12px !important;
  }

  .sr-shell {
    width: 100% !important;
    min-height: calc(100svh - 24px) !important;
  }

  .sr-topbar,
  .sr-feedback {
    width: 100% !important;
  }

  .sr-stage {
    min-width: 0 !important;
  }
}

@media (max-width: 520px) {
  :root {
    --rg-mobile-pad: 12px;
  }

  h1 {
    overflow-wrap: anywhere;
  }

  .teacher-profile span:last-child,
  .game-brand span:last-child,
  .brand-wrap span:last-child {
    max-width: calc(100vw - 92px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .metric-card strong,
  .class-kpi strong,
  .data-kpi strong {
    font-size: clamp(24px, 10vw, 34px) !important;
  }
}

/*
 * Student mobile policy: portrait is supported directly — no rotation prompt.
 * Map/game surfaces scale to fit the viewport in any orientation.
 * (The previous "请旋转手机横屏继续" overlay was removed per product decision.)
 */

@media (max-width: 900px) and (orientation: landscape) {
  .home-stage {
    width: 100% !important;
    height: 100svh !important;
    min-height: 100svh !important;
    grid-template-rows: minmax(0, 1fr) !important;
    padding: 10px 72px !important;
    place-items: center !important;
    overflow: hidden !important;
  }

  .home-stage .top-tools {
    position: fixed !important;
    top: 10px !important;
    right: 10px !important;
    left: 10px !important;
    z-index: 60 !important;
    width: auto !important;
  }

  .home-stage .tool-button {
    width: clamp(46px, 13svh, 58px) !important;
    height: clamp(46px, 13svh, 58px) !important;
    border-width: 4px !important;
  }

  .home-stage .logout-button {
    min-width: clamp(46px, 13svh, 58px) !important;
    padding: 0 !important;
    border-radius: 50% !important;
  }

  .home-stage .logout-button span {
    display: none !important;
  }

  .home-stage .digital-human {
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    padding: 0 !important;
    place-items: center !important;
  }

  .home-stage .video-guide {
    width: min(calc(100svh - 20px), calc(100svw - 156px), 620px) !important;
    max-width: 100% !important;
    max-height: calc(100svh - 20px) !important;
    border-radius: 22px !important;
  }

  .home-stage .wave-entry {
    position: absolute !important;
    top: 58% !important;
    bottom: auto !important;
    left: 50% !important;
    right: auto !important;
    width: clamp(76px, 26svh, 112px) !important;
    transform: translate(-50%, -50%) scale(.76) !important;
  }

  .home-stage .wave-entry.is-visible {
    transform: translate(-50%, -50%) scale(1) !important;
  }

  .map-stage {
    width: 100% !important;
    height: 100svh !important;
    min-height: 100svh !important;
    overflow: hidden !important;
  }

  .map-stage .campus-map {
    width: min(calc(100svh * 4 / 3), calc(100svw - 112px)) !important;
    max-width: calc(100svw - 112px) !important;
    max-height: calc(100svh - 12px) !important;
  }

  .map-stage .home-button {
    top: 10px !important;
    left: 10px !important;
    width: clamp(46px, 13svh, 58px) !important;
    height: clamp(46px, 13svh, 58px) !important;
    border-width: 4px !important;
  }

  .map-stage .map-guide {
    width: clamp(82px, 18svh, 122px) !important;
  }

  body.map-mode .app,
  body.map-mode .shell {
    width: 100% !important;
    height: 100svh !important;
    min-height: 100svh !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  body.map-mode .topbar,
  body.map-mode .progress,
  body.map-mode .prompt,
  body.map-mode .footer,
  body.map-mode #replayButton {
    display: none !important;
  }

  body.map-mode .stage {
    width: 100% !important;
    height: 100svh !important;
    min-height: 100svh !important;
  }

  body.map-mode .task-map {
    padding: 6px !important;
  }

  body.map-mode .task-map-frame {
    width: min(calc((100svh - 12px) * 1024 / 1792), calc(100svw - 12px)) !important;
    height: calc(100svh - 12px) !important;
    max-width: calc(100svw - 12px) !important;
    max-height: calc(100svh - 12px) !important;
  }
}

/* 2026-06-08 student fullscreen polish */
html,
body {
  min-height: 100dvh;
}

.home-stage,
.map-stage,
.wave-screen,
.map-page,
.practice-game-body,
.practice-app,
.app:has(.gallery-map) {
  min-height: 100dvh;
}

.home-stage {
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr);
  padding: clamp(12px, 2vw, 24px);
}

.home-stage .top-tools {
  z-index: 90;
}

.home-stage .digital-human {
  display: grid;
  grid-template-columns: minmax(340px, min(64dvh, 680px)) minmax(280px, 420px);
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 3vw, 42px);
  width: min(100%, 1260px);
  height: 100%;
  margin: 0 auto;
  padding: 0;
}

.home-stage .video-guide {
  width: 100%;
  max-height: min(76dvh, 680px);
}

.student-guide-card {
  display: grid;
  align-content: center;
  gap: 14px;
  min-height: min(62dvh, 520px);
  padding: clamp(18px, 2.4vw, 28px);
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 8px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 18px 44px rgba(46,64,87,.14);
}

.student-guide-card h1 {
  margin: 0;
  color: #2e4057;
  font-size: clamp(28px, 3.2vw, 46px);
  line-height: 1.12;
  font-weight: 900;
}

.student-guide-card p {
  margin: 0;
  color: #58708c;
  font-size: clamp(16px, 1.45vw, 20px);
  line-height: 1.7;
  font-weight: 800;
}

.student-guide-steps {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.student-guide-steps span {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: 8px;
  color: #2e4057;
  background: rgba(232,246,255,.82);
  font-size: clamp(14px, 1.2vw, 17px);
  font-weight: 900;
}

.student-guide-steps b {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #5ba7ff;
}

.home-stage .wave-entry {
  bottom: clamp(18px, 3dvh, 34px);
  top: auto;
}

.rg-extend-surface {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--rg-extend-base, #bfe878) !important;
}

.rg-extend-surface::before {
  content: "";
  position: fixed;
  inset: -36px;
  z-index: 0;
  pointer-events: none;
  background:
    var(--rg-extend-image, none) center / cover no-repeat,
    var(--rg-extend-base, #bfe878);
  filter: blur(var(--rg-extend-blur, 22px)) saturate(var(--rg-extend-saturate, 1.04));
  opacity: var(--rg-extend-image-opacity, .22);
  transform: scale(1.08);
}

.rg-extend-surface::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--rg-extend-overlay, radial-gradient(circle at 14% 18%, rgba(255, 245, 177, .24), transparent 28%), linear-gradient(90deg, rgba(255,255,255,.16), rgba(255,255,255,.04) 44%, rgba(255,255,255,.14)));
}

.rg-extend-surface > * {
  position: relative;
  z-index: 1;
}

.map-stage,
.map-page,
.practice-app {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.map-stage:not(.rg-extend-surface)::after,
.map-page:not(.rg-extend-surface)::after,
.practice-app:not(.rg-extend-surface)::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.map-stage > *,
.map-page > *,
.practice-app > * {
  position: relative;
  z-index: 1;
}

.map-stage .campus-map {
  width: min(100dvh, 100vw) !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
}

.map-page .map-frame {
  height: 100dvh !important;
  max-height: 100dvh !important;
}

.practice-map {
  width: min(100vw, calc(100dvh * 941 / 1672)) !important;
  max-width: 100vw !important;
  max-height: 100dvh !important;
}

.gallery-map {
  width: min(calc(100vw - 16px), calc(100dvh * 1672 / 941));
  max-width: calc(100vw - 16px);
}

@media (min-width: 901px) {
  .map-stage .campus-map {
    width: min(100dvh, 100vw) !important;
  }

  .map-page .map-frame {
    height: 122dvh !important;
    max-height: none !important;
    width: min(100vw, calc(122dvh * 941 / 1672)) !important;
  }

  .practice-map {
    width: min(100vw, calc(122dvh * 941 / 1672)) !important;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  .home-stage {
    min-height: 100dvh !important;
    height: 100dvh !important;
    overflow: hidden !important;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)) !important;
  }

  .home-stage .top-tools {
    width: 100% !important;
    margin: 0 !important;
  }

  .home-stage .digital-human {
    width: 100%;
    height: calc(100dvh - 76px);
    display: grid !important;
    place-items: center !important;
    padding: 0 0 max(84px, env(safe-area-inset-bottom)) !important;
  }

  .home-stage .video-guide {
    width: min(calc(100vw - 12px), calc(100dvh - 118px), 640px) !important;
    max-height: calc(100dvh - 118px) !important;
    border-radius: 16px !important;
  }

  .home-stage .wave-entry {
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
    width: clamp(74px, 22vw, 96px) !important;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .home-stage .digital-human {
    width: calc(100vw - 120px);
    display: grid !important;
    place-items: center !important;
  }

  .home-stage .video-guide {
    width: min(100%, calc(100dvh - 20px)) !important;
    max-height: calc(100dvh - 20px) !important;
    border-radius: 8px !important;
  }

  .home-stage .wave-entry {
    left: auto !important;
    right: 12px !important;
    bottom: 12px !important;
    width: clamp(58px, 15dvh, 70px) !important;
    transform: scale(.9) !important;
  }

  .home-stage .wave-entry.is-visible {
    transform: scale(1) !important;
  }

  .home-stage .wave-ripple {
    inset: -10px;
    border-width: 3px;
  }
}

/* 2026-06-09 digital-human entrance: make the guide the only visual focus. */
.home-stage {
  height: 100dvh !important;
  min-height: 100dvh !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  place-items: stretch center !important;
  padding: clamp(10px, 1.6dvh, 18px) clamp(10px, 1.6vw, 24px) !important;
}

.home-stage .digital-human {
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-rows: auto auto !important;
  place-items: center !important;
  align-content: center !important;
  row-gap: clamp(8px, 1.6dvh, 16px) !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
}

.home-stage .student-welcome-title {
  max-width: min(92vw, 760px) !important;
  margin: 0 !important;
  padding: clamp(8px, 1.1vw, 14px) clamp(18px, 3vw, 34px) !important;
  border: 2px solid rgba(255, 255, 255, .92) !important;
  border-radius: 999px !important;
  color: #264469 !important;
  background: rgba(255, 255, 255, .9) !important;
  box-shadow: 0 16px 38px rgba(46, 64, 87, .14) !important;
  font-size: clamp(26px, 3vw, 42px) !important;
  line-height: 1.1 !important;
  font-weight: 900 !important;
  text-align: center !important;
}

.home-stage .video-guide {
  width: min(calc(100dvh - clamp(184px, 23dvh, 244px)), calc(100vw - 48px), 820px) !important;
  max-width: 100% !important;
  max-height: none !important;
  aspect-ratio: 1 !important;
  border-radius: clamp(22px, 2.6vw, 38px) !important;
}

.home-stage .human-video {
  object-fit: cover !important;
  object-position: center center !important;
}

.home-stage .wave-entry {
  left: auto !important;
  right: clamp(28px, 4vw, 72px) !important;
  bottom: clamp(12px, 2dvh, 24px) !important;
  top: auto !important;
  width: clamp(96px, 7vw, 132px) !important;
  transform: scale(.76) !important;
}

.home-stage .wave-entry.is-visible {
  transform: scale(1) !important;
}

@media (max-width: 900px) and (orientation: portrait) {
  .home-stage {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom)) !important;
  }

  .home-stage .top-tools {
    width: 100% !important;
  }

  .home-stage .digital-human {
    height: 100% !important;
    align-items: center !important;
    padding: 0 0 clamp(60px, 9dvh, 78px) !important;
  }

  .home-stage .student-welcome-title {
    max-width: calc(100vw - 20px) !important;
    padding: 7px 16px !important;
    font-size: clamp(22px, 7vw, 30px) !important;
  }

  .home-stage .video-guide {
    width: min(calc(100vw - 16px), calc((100dvh - 210px) * 2 / 3), 500px) !important;
    aspect-ratio: 2 / 3 !important;
    border-width: 5px !important;
    border-radius: 18px !important;
  }

  .home-stage .wave-entry {
    left: 50% !important;
    right: auto !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
    width: clamp(68px, 19vw, 84px) !important;
    transform: translateX(-50%) scale(.76) !important;
  }

  .home-stage .wave-entry.is-visible {
    transform: translateX(-50%) scale(1) !important;
  }
}

@media (max-width: 420px) and (orientation: portrait) {
  .home-stage .video-guide {
    width: min(calc(100vw - 12px), calc((100dvh - 198px) * 2 / 3)) !important;
    border-radius: 16px !important;
  }

  .home-stage .digital-human {
    padding-bottom: clamp(54px, 8dvh, 70px) !important;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .home-stage {
    padding: 8px 64px !important;
  }

  .home-stage .digital-human {
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
  }

  .home-stage .video-guide {
    width: min(calc(100dvh - 140px), calc(100vw - 148px), 580px) !important;
    aspect-ratio: 1 !important;
    border-radius: 18px !important;
  }

  .home-stage .wave-entry {
    right: 10px !important;
    bottom: 10px !important;
    left: auto !important;
    width: clamp(56px, 15dvh, 70px) !important;
  }
}

/* Forest S1_Q04 catch game: keep the page fullscreen while giving the playfield priority. */
html[data-rg-device] body.task-mode[data-task-type="catch"] {
  width: 100vw !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .app {
  width: 100% !important;
  max-width: none !important;
  height: 100dvh !important;
  min-height: 0 !important;
  padding: clamp(8px, 1.3vw, 18px) !important;
  overflow: hidden !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .shell {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 0 !important;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto !important;
  gap: clamp(6px, 1dvh, 10px) !important;
  overflow: hidden !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .topbar,
html[data-rg-device] body.task-mode[data-task-type="catch"] .progress,
html[data-rg-device] body.task-mode[data-task-type="catch"] .prompt,
html[data-rg-device] body.task-mode[data-task-type="catch"] .footer {
  border-radius: 16px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .topbar {
  min-height: 0 !important;
  padding: clamp(5px, .8vw, 9px) clamp(8px, 1vw, 12px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .home-link,
html[data-rg-device] body.task-mode[data-task-type="catch"] .audio-button {
  width: clamp(42px, 4.6dvh, 50px) !important;
  height: clamp(42px, 4.6dvh, 50px) !important;
  min-width: clamp(42px, 4.6dvh, 50px) !important;
  padding: 0 !important;
  border-radius: 14px !important;
  font-size: clamp(19px, 2.2dvh, 24px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .audio-button span:last-child {
  display: none !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .chapter strong {
  font-size: clamp(20px, 2.1vw, 26px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .chapter span {
  font-size: clamp(12px, 1.2vw, 15px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .progress {
  grid-template-columns: auto minmax(120px, 1fr) auto !important;
  gap: 10px !important;
  padding: 5px 12px !important;
  font-size: clamp(13px, 1.3vw, 18px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .track {
  height: 10px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .stars {
  margin-top: 0 !important;
  font-size: clamp(15px, 1.8vw, 20px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .prompt {
  padding: 6px 10px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .prompt-text {
  gap: 10px !important;
  font-size: clamp(18px, 1.8vw, 24px) !important;
  line-height: 1.18 !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .mascot {
  width: clamp(42px, 5.6dvh, 52px) !important;
  height: clamp(42px, 5.6dvh, 52px) !important;
  border-radius: 16px !important;
  font-size: clamp(25px, 3.6dvh, 32px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .stage {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  border-radius: 18px !important;
  overflow: hidden !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .scene {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  padding: 8px !important;
  place-items: center !important;
  align-content: center !important;
  overflow: hidden !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .canvas-wrap {
  width: min(100%, calc((100dvh - 238px) * 16 / 9), 1120px) !important;
  height: min(100%, calc(100dvh - 238px)) !important;
  aspect-ratio: 16 / 9 !important;
  margin: auto !important;
  border-radius: 18px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: auto !important;
  border-radius: 15px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .canvas-hud {
  top: 10px !important;
  left: 10px !important;
  gap: 8px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .pill {
  padding: 6px 10px !important;
  font-size: clamp(13px, 1.3vw, 16px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .footer {
  gap: 10px !important;
  padding: 7px 10px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .footer .feedback {
  min-height: 34px !important;
  font-size: clamp(14px, 1.45vw, 18px) !important;
  line-height: 1.2 !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .primary-button,
html[data-rg-device] body.task-mode[data-task-type="catch"] .secondary-button {
  min-height: 42px !important;
  padding: 0 clamp(12px, 1.8vw, 20px) !important;
  border-radius: 14px !important;
  font-size: clamp(16px, 1.7vw, 20px) !important;
}

@media (max-width: 720px) {
  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .app {
    padding: 7px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .shell {
    gap: 6px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .topbar {
    grid-template-columns: 40px minmax(0, 1fr) 44px !important;
    gap: 7px !important;
    padding: 6px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .home-link,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .audio-button {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    font-size: 18px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .chapter strong {
    font-size: 17px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .chapter span {
    font-size: 11px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .progress {
    display: none !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .prompt {
    padding: 5px 7px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .prompt-text {
    gap: 7px !important;
    font-size: 16px !important;
    line-height: 1.15 !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .mascot {
    width: 38px !important;
    height: 38px !important;
    font-size: 23px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .stage {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .scene {
    padding: 6px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .canvas-wrap {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: auto !important;
    border-width: 2px !important;
    border-radius: 16px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: auto !important;
    border-radius: 14px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .canvas-hud {
    top: 8px !important;
    left: 8px !important;
    gap: 5px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .pill {
    padding: 5px 7px !important;
    font-size: 12px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .footer {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
    padding: 6px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .footer .feedback {
    grid-column: 1 / -1 !important;
    order: -1 !important;
    min-height: 28px !important;
    font-size: 13px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .primary-button,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .secondary-button {
    min-height: 34px !important;
    padding: 0 8px !important;
    border-radius: 11px !important;
    font-size: 15px !important;
  }
}

/* Branch task three-device responsive layer */
html[data-rg-device="browser"] {
  --rg-branch-pad: 18px;
  --rg-branch-hit: 46px;
}

html[data-rg-device="browser"] .map-page .map-frame {
  width: min(100vw, calc(100dvh * 941 / 1672)) !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
}

html[data-rg-device="tablet"] {
  --rg-branch-pad: 12px;
  --rg-branch-hit: 48px;
}

html[data-rg-device="mobile"] {
  --rg-branch-pad: 8px;
  --rg-branch-hit: 48px;
}

html[data-rg-device] .gallery-map .hotspot,
html[data-rg-device] .map-frame .hotspot,
html[data-rg-device] .task-map-frame .task-hotspot,
html[data-rg-device] .practice-map .scene-object.is-interactive {
  min-width: var(--rg-branch-hit);
  min-height: var(--rg-branch-hit);
  -webkit-tap-highlight-color: transparent;
}

:where(
  html[data-rg-device] .sr-btn,
  html[data-rg-device] .sr-option,
  html[data-rg-device] .sr-token,
  html[data-rg-device] .sr-slot,
  html[data-rg-device] .primary-button,
  html[data-rg-device] .secondary-button,
  html[data-rg-device] .primary-play-btn,
  html[data-rg-device] .secondary-play-btn,
  html[data-rg-device] .choice-card,
  html[data-rg-device] .item-card,
  html[data-rg-device] .book-card,
  html[data-rg-device] .shelf-card,
  html[data-rg-device] .bus-card,
  html[data-rg-device] .option,
  html[data-rg-device] .slot,
  html[data-rg-device] .dropzone
) {
  min-height: var(--rg-branch-hit);
  touch-action: manipulation;
}

html[data-rg-device] .game .guide-dots button {
  width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
}

html[data-rg-device] .game .guide-dots button.on {
  width: 54px !important;
}

html[data-rg-device] .practice-player,
html[data-rg-device] .practice-player *,
html[data-rg-device] .task-layout,
html[data-rg-device] .task-layout * {
  box-sizing: border-box;
}

html[data-rg-device] body.task-mode {
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
}

html[data-rg-device] body.task-mode .app,
html[data-rg-device] body.task-mode .shell,
html[data-rg-device] body.task-mode .stage,
html[data-rg-device] body.task-mode .scene {
  min-height: 0 !important;
  overflow: hidden !important;
}

html[data-rg-device] body.task-mode .canvas-wrap {
  width: min(820px, 100%, clamp(260px, calc((100dvh - 455px) * 16 / 9), 820px)) !important;
}

html[data-rg-device="browser"] .gallery-map .guide-panel,
html[data-rg-device="tablet"] .gallery-map .guide-panel {
  left: 50% !important;
  bottom: 34% !important;
  width: min(360px, 32%) !important;
  transform: translateX(-50%) !important;
}

@media (min-width: 901px) and (max-width: 1180px) {
  html[data-rg-device="tablet"] .app:has(.gallery-map) .topbar {
    min-height: 62px !important;
    padding: 8px 14px !important;
  }

  html[data-rg-device="tablet"] #mapScreen.is-active {
    padding-top: 64px !important;
  }

  html[data-rg-device="tablet"] .gallery-map {
    width: min(calc(100vw - 16px), calc((100dvh - 64px) * 1672 / 941)) !important;
    max-height: calc(100dvh - 64px) !important;
  }

  html[data-rg-device="tablet"] .task-layout {
    width: calc(100vw - 20px) !important;
    height: calc(100dvh - 78px) !important;
    min-height: 0 !important;
    grid-template-columns: clamp(190px, 22vw, 250px) minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  html[data-rg-device="tablet"] .task-side,
  html[data-rg-device="tablet"] .task-main {
    padding: 14px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="tablet"] .option-grid,
  html[data-rg-device="tablet"] .option-grid.is-wide,
  html[data-rg-device="tablet"] .zone-grid {
    grid-template-columns: repeat(3, minmax(110px, 1fr)) !important;
  }

  html[data-rg-device="tablet"] .option-grid.is-compact {
    grid-template-columns: repeat(4, minmax(92px, 1fr)) !important;
  }

  html[data-rg-device="tablet"] body.map-mode .task-map-frame {
    width: min(calc(100vw - 16px), calc((100dvh - 16px) * 1024 / 1792)) !important;
    max-height: calc(100dvh - 16px) !important;
    border-radius: 12px !important;
  }

  html[data-rg-device="tablet"] body:not(.map-mode) .shell {
    width: min(100%, calc(100vw - 20px)) !important;
    gap: 10px !important;
  }

  html[data-rg-device="tablet"] body.task-mode .app {
    height: 100dvh !important;
    padding: 10px !important;
  }

  html[data-rg-device="tablet"] body.task-mode .shell {
    height: calc(100dvh - 20px) !important;
    min-height: 0 !important;
  }

  html[data-rg-device="tablet"] body:not(.map-mode) .stage {
    height: clamp(340px, calc(100dvh - 360px), 520px) !important;
  }

  html[data-rg-device="tablet"] .map-page .map-frame {
    width: min(calc(100vw - 20px), calc(100dvh * 941 / 1672)) !important;
    height: auto !important;
    min-height: 0 !important;
  }

  html[data-rg-device="tablet"] .sr-app {
    width: min(100%, calc(100vw - 20px)) !important;
    min-height: 100dvh !important;
    padding: 10px 0 !important;
  }

  html[data-rg-device="tablet"] .sr-topbar {
    grid-template-columns: minmax(220px, 1fr) minmax(180px, .8fr) auto !important;
    gap: 10px !important;
    padding: 12px !important;
  }

  html[data-rg-device="tablet"] .sr-stage {
    min-height: calc(100dvh - 250px) !important;
    padding: 16px !important;
  }

  html[data-rg-device="tablet"] .practice-player {
    width: 100vw !important;
    max-width: 100vw !important;
    padding: 10px !important;
    gap: 8px !important;
  }

  html[data-rg-device="tablet"] .practice-player .player-top {
    grid-template-columns: 52px minmax(0, 1fr) auto auto !important;
    gap: 8px !important;
  }

  html[data-rg-device="tablet"] .practice-player .task-stage {
    width: 100% !important;
    max-width: none !important;
  }

  html[data-rg-device="tablet"] .shopping-layout {
    grid-template-columns: minmax(180px, .72fr) minmax(0, 1fr) minmax(220px, .9fr) !important;
  }

  html[data-rg-device="tablet"] .class-layout,
  html[data-rg-device="tablet"] .bus-layout,
  html[data-rg-device="tablet"] .home-layout,
  html[data-rg-device="tablet"] .library-layout,
  html[data-rg-device="tablet"] .scenario-layout,
  html[data-rg-device="tablet"] .path-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html[data-rg-device="tablet"] .game .intro,
  html[data-rg-device="tablet"] .game .guide-screen {
    grid-template-columns: 1fr !important;
    gap: 18px !important;
    min-height: auto !important;
  }

  html[data-rg-device="tablet"] .game .hero-scene,
  html[data-rg-device="tablet"] .game .guide-stage {
    min-height: min(62dvh, 560px) !important;
  }

  html[data-rg-device="tablet"] .game .map-board {
    width: min(calc(100vw - 20px), calc((100dvh - 126px) * 16 / 9), 1180px) !important;
    min-height: auto !important;
  }
}

@media (max-width: 720px) {
  html[data-rg-device="mobile"] .app:has(.gallery-map) .topbar {
    grid-template-columns: 40px minmax(0, 1fr) minmax(72px, 94px) !important;
    min-height: 56px !important;
    padding: max(6px, env(safe-area-inset-top)) 8px 6px !important;
  }

  html[data-rg-device="mobile"] .app:has(.gallery-map) .titlebox h1 {
    font-size: clamp(15px, 4vw, 19px) !important;
    white-space: normal !important;
  }

  html[data-rg-device="mobile"] #mapScreen.is-active {
    padding-top: 54px !important;
  }

  html[data-rg-device="mobile"] .gallery-map {
    width: min(100vw, calc((100dvh - 54px) * 853 / 1844)) !important;
    max-height: calc(100dvh - 54px) !important;
  }

  html[data-rg-device="mobile"] .task-layout {
    width: calc(100vw - 12px) !important;
    height: calc(100dvh - 64px) !important;
    min-height: 0 !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
    gap: 8px !important;
  }

  html[data-rg-device="mobile"] .task-side {
    max-height: min(30dvh, 184px) !important;
    grid-template-rows: auto auto auto !important;
    gap: 7px !important;
    padding: 9px !important;
    overflow: auto !important;
  }

  html[data-rg-device="mobile"] .task-side h2 {
    font-size: 18px !important;
  }

  html[data-rg-device="mobile"] .task-instruction {
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  html[data-rg-device="mobile"] .side-actions {
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)) !important;
    gap: 7px !important;
  }

  html[data-rg-device="mobile"] .task-main {
    min-height: 0 !important;
    padding: 9px !important;
    overflow: auto !important;
  }

  html[data-rg-device="mobile"] .option-grid,
  html[data-rg-device="mobile"] .option-grid.is-compact,
  html[data-rg-device="mobile"] .option-grid.is-wide {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  html[data-rg-device="mobile"] .zone-grid,
  html[data-rg-device="mobile"] .zone-grid.is-two {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  html[data-rg-device="mobile"] .art-card,
  html[data-rg-device="mobile"] .choice-card,
  html[data-rg-device="mobile"] .drop-zone {
    min-height: 82px !important;
    padding: 8px !important;
  }

  html[data-rg-device="mobile"] .art-img,
  html[data-rg-device="mobile"] .art-img.is-icon {
    height: 70px !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .app {
    padding: 7px !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .shell {
    min-height: calc(100dvh - 14px) !important;
    gap: 7px !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .topbar {
    grid-template-columns: 42px minmax(0, 1fr) auto !important;
    gap: 7px !important;
    padding: 7px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .audio-button {
    min-width: 48px !important;
    width: 48px !important;
    padding: 0 !important;
    overflow: hidden !important;
    font-size: 20px !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .chapter strong {
    font-size: 18px !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .chapter span {
    font-size: 12px !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .prompt-text {
    font-size: 17px !important;
    gap: 8px !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .stage {
    height: auto !important;
    min-height: min(380px, calc(100dvh - 270px)) !important;
    border-radius: 8px !important;
    overflow: auto !important;
  }

  html[data-rg-device="mobile"] body:not(.map-mode) .grid-2,
  html[data-rg-device="mobile"] body:not(.map-mode) .grid-3,
  html[data-rg-device="mobile"] body:not(.map-mode) .grid-6,
  html[data-rg-device="mobile"] body:not(.map-mode) .target-layout {
    grid-template-columns: 1fr !important;
  }

  html[data-rg-device="mobile"] .map-page .map-frame {
    width: min(calc(100vw - 24px), calc(100dvh * 941 / 1672)) !important;
    height: auto !important;
    min-height: 0 !important;
  }

  html[data-rg-device="mobile"] .sr-app {
    width: 100% !important;
    min-height: 100dvh !important;
    padding: 8px !important;
  }

  html[data-rg-device="mobile"] .sr-shell {
    gap: 8px !important;
  }

  html[data-rg-device="mobile"] .sr-topbar,
  html[data-rg-device="mobile"] .sr-task,
  html[data-rg-device="mobile"] .sr-feedback {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 10px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="mobile"] .sr-brand-title {
    font-size: 18px !important;
  }

  html[data-rg-device="mobile"] .sr-task-text {
    font-size: 18px !important;
  }

  html[data-rg-device="mobile"] .sr-stage {
    min-height: 0 !important;
    padding: 10px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="mobile"] .sr-audio-strip .sr-audio-btn {
    height: 44px !important;
    min-height: 44px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="mobile"] .sr-grid,
  html[data-rg-device="mobile"] .sr-grid-three,
  html[data-rg-device="mobile"] .sr-q22-options,
  html[data-rg-device="mobile"] .sr-slots,
  html[data-rg-device="mobile"] .sr-tokens,
  html[data-rg-device="mobile"] .sr-story-frames {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  html[data-rg-device="mobile"] .sr-option,
  html[data-rg-device="mobile"] .sr-token,
  html[data-rg-device="mobile"] .sr-slot {
    min-height: 78px !important;
    padding: 10px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="mobile"] .practice-player {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow: auto !important;
    padding: max(6px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom)) !important;
    gap: 7px !important;
  }

  html[data-rg-device="mobile"] .practice-player .player-top {
    grid-template-columns: 42px minmax(0, 1fr) auto !important;
    gap: 7px !important;
  }

  html[data-rg-device="mobile"] .practice-player .replay-btn {
    grid-column: 1 / -1 !important;
  }

  html[data-rg-device="mobile"] .practice-player .task-stage {
    width: 100% !important;
    max-width: none !important;
    padding: 9px !important;
  }

  html[data-rg-device="mobile"] .practice-player .shopping-layout,
  html[data-rg-device="mobile"] .practice-player .class-layout,
  html[data-rg-device="mobile"] .practice-player .bus-layout,
  html[data-rg-device="mobile"] .practice-player .home-layout,
  html[data-rg-device="mobile"] .practice-player .library-layout,
  html[data-rg-device="mobile"] .practice-player .scenario-layout,
  html[data-rg-device="mobile"] .practice-player .path-layout {
    width: 100% !important;
    max-width: 100% !important;
  }

  html[data-rg-device="mobile"] .shopping-layout,
  html[data-rg-device="mobile"] .class-layout,
  html[data-rg-device="mobile"] .bus-layout,
  html[data-rg-device="mobile"] .home-layout,
  html[data-rg-device="mobile"] .library-layout,
  html[data-rg-device="mobile"] .scenario-layout,
  html[data-rg-device="mobile"] .path-layout,
  html[data-rg-device="mobile"] .shelf-grid,
  html[data-rg-device="mobile"] .class-items,
  html[data-rg-device="mobile"] .bus-grid,
  html[data-rg-device="mobile"] .choice-row,
  html[data-rg-device="mobile"] .scenario-options,
  html[data-rg-device="mobile"] .route-line,
  html[data-rg-device="mobile"] .home-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  html[data-rg-device="mobile"] .game {
    min-height: 100dvh !important;
    padding: 8px !important;
    overflow: auto !important;
  }

  html[data-rg-device="mobile"] .game .intro,
  html[data-rg-device="mobile"] .game .guide-screen {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    min-height: auto !important;
  }

  html[data-rg-device="mobile"] .game .hero-scene,
  html[data-rg-device="mobile"] .game .guide-stage {
    min-height: 360px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="mobile"] .game .topbar,
  html[data-rg-device="mobile"] .game .prompt {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    padding: 8px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="mobile"] .game .stage {
    min-height: 0 !important;
    padding: 10px !important;
    border-radius: 8px !important;
  }

  html[data-rg-device="mobile"] .game .map-board {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    min-height: 0 !important;
  }
}

/* Forest S1_Q04 catch game late overrides. Keep these after generic branch breakpoints. */
html[data-rg-device] body.task-mode[data-task-type="catch"] .shell {
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  min-height: 0 !important;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto !important;
  gap: clamp(6px, 1dvh, 10px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .topbar {
  padding: clamp(5px, .8vw, 9px) clamp(8px, 1vw, 12px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .progress {
  grid-template-columns: auto minmax(120px, 1fr) auto !important;
  padding: 5px 12px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .prompt {
  padding: 6px 10px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .prompt-text {
  font-size: clamp(18px, 1.8vw, 24px) !important;
  line-height: 1.18 !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .stage,
html[data-rg-device] body.task-mode[data-task-type="catch"] .scene {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: hidden !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .scene {
  padding: 8px !important;
  place-items: center !important;
  align-content: center !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .canvas-wrap {
  width: min(100%, calc((100dvh - 238px) * 16 / 9), 1120px) !important;
  height: min(100%, calc(100dvh - 238px)) !important;
  aspect-ratio: 16 / 9 !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  aspect-ratio: auto !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .footer {
  padding: 7px 10px !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .footer .feedback {
  min-height: 34px !important;
  font-size: clamp(14px, 1.45vw, 18px) !important;
}

html[data-rg-device] body.task-mode[data-task-type="catch"] .primary-button,
html[data-rg-device] body.task-mode[data-task-type="catch"] .secondary-button {
  min-height: 42px !important;
  font-size: clamp(16px, 1.7vw, 20px) !important;
}

@media (max-width: 720px) {
  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .shell {
    grid-template-rows: auto auto minmax(0, 1fr) auto !important;
    gap: 6px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .topbar {
    grid-template-columns: 40px minmax(0, 1fr) 44px !important;
    padding: 6px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .progress {
    display: none !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .prompt {
    padding: 5px 7px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .prompt-text {
    font-size: 16px !important;
    line-height: 1.15 !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .stage {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .scene {
    position: relative !important;
    display: block !important;
    padding: 0 !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .canvas-wrap,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .canvas-wrap canvas {
    aspect-ratio: auto !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .canvas-wrap {
    position: absolute !important;
    inset: 6px !important;
    width: auto !important;
    height: auto !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .footer {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
    padding: 6px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .footer .feedback {
    grid-column: 1 / -1 !important;
    order: -1 !important;
    min-height: 28px !important;
    font-size: 13px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .primary-button,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="catch"] .secondary-button {
    min-height: 34px !important;
    font-size: 15px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="match"] .stage,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="sequence"] .stage,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="lineup"] .stage {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="match"] .scene,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="sequence"] .scene,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="lineup"] .scene {
    gap: 7px !important;
    padding: 7px !important;
    align-content: center !important;
    overflow: hidden !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="match"] .target-layout {
    grid-template-columns: 1fr !important;
    gap: 7px !important;
    width: 100% !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="match"] .target-card {
    min-height: 88px !important;
    padding: 8px !important;
    font-size: 16px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="match"] .target-card .shoe-visual {
    width: 88px !important;
    height: 56px !important;
    margin-bottom: 2px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="match"] .grid-6 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
    width: 100% !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="match"] .grid-6 .option {
    min-height: 82px !important;
    padding: 6px !important;
    border-radius: 14px !important;
    font-size: 13px !important;
    gap: 3px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="match"] .grid-6 .shoe-visual {
    width: 66px !important;
    height: 43px !important;
    margin-bottom: 1px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="sequence"] .action-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    width: 100% !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="sequence"] .big-action {
    width: 100% !important;
    min-height: 98px !important;
    padding: 10px !important;
    border-radius: 16px !important;
    font-size: 18px !important;
    line-height: 1.1 !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="sequence"] .big-action .large-icon {
    margin-bottom: 6px !important;
    font-size: 54px !important;
    line-height: 1 !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="lineup"] .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
    width: 100% !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="lineup"] .grid-2 .slot,
  html[data-rg-device="mobile"] body.task-mode[data-task-type="lineup"] .grid-2 .slot[data-rank] {
    min-height: 66px !important;
    padding: 6px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="lineup"] .choice-tray {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
    width: 100% !important;
  }

  html[data-rg-device="mobile"] body.task-mode[data-task-type="lineup"] .draggable-choice {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 54px !important;
    padding: 5px !important;
    border-radius: 14px !important;
    font-size: 15px !important;
    line-height: 1.1 !important;
  }
}

/* Story Radio mobile late overrides. Keep these after generic branch breakpoints. */
@media (max-width: 720px) {
  html[data-rg-device="mobile"] .sr-app {
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    padding: max(6px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom)) !important;
  }

  html[data-rg-device="mobile"] .sr-shell {
    height: 100% !important;
    min-height: 0 !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
    gap: 6px !important;
  }

  html[data-rg-device="mobile"] .sr-stage {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    padding: 6px !important;
    border-radius: 14px !important;
  }

  html[data-rg-device="mobile"] .sr-audio-strip,
  html[data-rg-device="mobile"] .sr-audio-strip .sr-audio-btn {
    min-height: 40px !important;
    height: 40px !important;
  }

  html[data-rg-device="mobile"] .sr-feedback-compact {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    align-items: center !important;
    justify-items: stretch !important;
    gap: 6px !important;
    min-height: 48px !important;
    padding: 0 !important;
  }

  html[data-rg-device="mobile"] .sr-feedback-compact .sr-feedback-text {
    grid-column: 1 / -1 !important;
    min-height: 0 !important;
    font-size: 12px !important;
    line-height: 1.1 !important;
  }

  html[data-rg-device="mobile"] .sr-feedback-compact .sr-feedback-text:empty {
    display: none !important;
  }

  html[data-rg-device="mobile"] .sr-return-map-button,
  html[data-rg-device="mobile"] .sr-submit-btn {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 42px !important;
    height: 42px !important;
    padding: 0 10px 2px !important;
    border-radius: 14px !important;
    font-size: 18px !important;
    -webkit-text-stroke: 0 !important;
    text-shadow: none !important;
  }

  html[data-rg-device="mobile"] .sr-submit-btn {
    font-size: 30px !important;
    line-height: 1 !important;
  }

  html[data-rg-device="mobile"] .sr-grid,
  html[data-rg-device="mobile"] .sr-grid-three,
  html[data-rg-device="mobile"] .sr-q22-options {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
    height: 100% !important;
    align-content: center !important;
  }

  html[data-rg-device="mobile"] .sr-grid-three {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  html[data-rg-device="mobile"] .sr-option,
  html[data-rg-device="mobile"] .sr-token,
  html[data-rg-device="mobile"] .sr-slot {
    min-height: 0 !important;
    padding: 6px !important;
    border-radius: 13px !important;
  }

  html[data-rg-device="mobile"] .sr-visual {
    height: clamp(96px, 18dvh, 148px) !important;
    min-height: 0 !important;
    border-radius: 11px !important;
  }

  html[data-rg-device="mobile"] .sr-option-image-only .sr-visual {
    height: clamp(132px, 21dvh, 170px) !important;
  }

  html[data-rg-device="mobile"] .sr-option-image,
  html[data-rg-device="mobile"] .sr-option-image-only .sr-option-image {
    height: 100% !important;
    min-height: 0 !important;
  }

  html[data-rg-device="mobile"] .sr-option-label {
    margin-top: 4px !important;
    font-size: 13px !important;
    line-height: 1.12 !important;
  }

  html[data-rg-device="mobile"] .sr-q22-scene {
    margin-bottom: 6px !important;
  }

  html[data-rg-device="mobile"] .sr-q22-image,
  html[data-rg-device="mobile"] .sr-q22-image .sr-option-image {
    height: min(34dvh, 230px) !important;
    min-height: 0 !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-question-id="Q21"] .sr-grid,
  html[data-rg-device="mobile"] .sr-app[data-question-id="Q26"] .sr-grid,
  html[data-rg-device="mobile"] .sr-app[data-question-id="Q27"] .sr-grid,
  html[data-rg-device="mobile"] .sr-app[data-question-id="Q28"] .sr-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-question-id="Q21"] .sr-option-image-only {
    min-height: 0 !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-question-id="Q29"] .sr-stage {
    align-content: center !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-question-id="Q29"] .sr-story-frames {
    grid-template-columns: 1fr 22px 1fr !important;
    gap: 6px !important;
    margin-bottom: 6px !important;
    align-items: center !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-question-id="Q29"] .sr-arrow {
    transform: none !important;
    font-size: 20px !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-question-id="Q29"] .sr-scene {
    margin-bottom: 0 !important;
    padding: 5px !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-question-id="Q29"] .sr-story-frames .sr-visual {
    height: clamp(120px, 18dvh, 150px) !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-question-id="Q29"] .sr-grid-three {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    height: auto !important;
  }

  html[data-rg-device="mobile"] .sr-app[data-template="SortTemplate"] .sr-sort-wrap {
    height: 100% !important;
  }
}

/* 2026-06-10 fullscreen map cover fit
   Main map screens should cover the viewport by ratio, not fit inside it. */
.map-stage .campus-map {
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: fill !important;
}

.map-page {
  width: 100vw !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.map-page .map-frame,
html[data-rg-device="browser"] .map-page .map-frame,
html[data-rg-device="tablet"] .map-page .map-frame,
html[data-rg-device="mobile"] .map-page .map-frame {
  width: max(100.2vw, calc(100.2dvh * 941 / 1672)) !important;
  height: auto !important;
  min-height: 0 !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: 941 / 1672 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.practice-app {
  width: 100vw !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.practice-map,
html[data-rg-device="browser"] .practice-map,
html[data-rg-device="tablet"] .practice-map,
html[data-rg-device="mobile"] .practice-map {
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  width: max(100.2vw, calc(100.2dvh * 941 / 1672)) !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  aspect-ratio: 941 / 1672 !important;
  transform: translate(-50%, -50%) !important;
}

.app #mapScreen.screen.is-active,
html[data-rg-device="tablet"] .app #mapScreen.screen.is-active,
html[data-rg-device="mobile"] .app #mapScreen.screen.is-active {
  display: grid !important;
  place-items: center !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.app #mapScreen.screen.is-active .gallery-map,
html[data-rg-device="browser"] .app #mapScreen.screen.is-active .gallery-map,
html[data-rg-device="tablet"] .app #mapScreen.screen.is-active .gallery-map,
html[data-rg-device="mobile"] .app #mapScreen.screen.is-active .gallery-map {
  width: max(100.2vw, calc(100.2dvh * 1672 / 941)) !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  flex: none !important;
  aspect-ratio: 1672 / 941 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

@media (max-width: 900px) and (orientation: portrait) {
  .app #mapScreen.screen.is-active .gallery-map,
  html[data-rg-device="mobile"] .app #mapScreen.screen.is-active .gallery-map {
    width: max(100.2vw, calc(100.2dvh * 853 / 1844)) !important;
    aspect-ratio: 853 / 1844 !important;
  }
}

body.map-mode .task-map,
html[data-rg-device="tablet"] body.map-mode .task-map,
html[data-rg-device="mobile"] body.map-mode .task-map {
  width: 100vw !important;
  height: 100dvh !important;
  padding: 0 !important;
  overflow: hidden !important;
}

body.map-mode .task-map-frame,
html[data-rg-device="tablet"] body.map-mode .task-map-frame,
html[data-rg-device="mobile"] body.map-mode .task-map-frame {
  width: max(100.2vw, calc(100.2dvh * 1024 / 1792)) !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  aspect-ratio: 1024 / 1792 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* 2026-06-10 mobile task viewport fit: keep the action buttons tappable. */
@media (max-width: 520px) {
  body.task-mode,
  html[data-rg-device="mobile"] body.task-mode {
    height: 100svh !important;
    height: 100dvh !important;
    min-height: 100svh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  body.task-mode .app,
  html[data-rg-device="mobile"] body.task-mode .app {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100svh !important;
    height: 100dvh !important;
    min-height: 100svh !important;
    min-height: 100dvh !important;
    max-height: 100svh !important;
    max-height: 100dvh !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  body.task-mode .shell,
  html[data-rg-device="mobile"] body.task-mode .shell {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100svh !important;
    height: 100dvh !important;
    min-height: 0 !important;
    max-height: 100svh !important;
    max-height: 100dvh !important;
    grid-template-rows: auto auto minmax(0, 1fr) auto !important;
    gap: 6px !important;
    padding: 6px 6px max(6px, env(safe-area-inset-bottom)) !important;
    overflow: hidden !important;
  }

  body.task-mode .stage,
  html[data-rg-device="mobile"] body.task-mode .stage {
    height: 100% !important;
    min-height: 0 !important;
    max-height: 100% !important;
    align-self: stretch !important;
    overflow: hidden !important;
  }

  body.task-mode .scene,
  html[data-rg-device="mobile"] body.task-mode .scene {
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
}
