/**
 * stages-30-ui.css — 6-Chapter & Difficulty Selector, Zero-Text 5-Star HUD,
 * Smooth STAGE Control-Mode Collapse Transitions, Floating Replay Cue, and Pause Jump Picker.
 *
 * Tuned for landscape phones (844x390, 932x430) and iPad tablets (1024x768+).
 * All interactive hit targets strictly >= 48x48 CSS px.
 */

/* ==========================================================================
   1. TITLE OVERLAY: 6-CHAPTER & DIFFICULTY SELECTOR (.sc30-title-selector)
   ========================================================================== */

.sc30-title-selector {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(11, 21, 40, 0.76) 0%, rgba(8, 16, 32, 0.84) 100%);
  border: 1px solid rgba(245, 196, 94, 0.34);
  box-shadow:
    0 6px 18px rgba(3, 8, 20, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  box-sizing: border-box;
}

.sc30-title-selector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}

.sc30-selector-heading {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fde68a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc30-total-badge {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fef3c7;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(245, 196, 94, 0.16);
  border: 1px solid rgba(245, 196, 94, 0.38);
}

/* Title card scroll container for elastic phone viewports */
.title-card-container:has(.sc30-title-selector) {
  max-height: calc(100vh - 12px);
  max-height: calc(var(--vvh, 100vh) - max(6px, var(--safe-t, 0px)) - max(6px, var(--safe-b, 0px)) - 4px);
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.title-card-container:has(.sc30-title-selector) .pill-select {
  min-height: 48px;
  padding: 0 12px;
  box-sizing: border-box;
}

.title-card-container:has(.sc30-title-selector) .pill-select select {
  min-height: 48px;
  min-width: 54px;
  padding: 0 4px;
  box-sizing: border-box;
}

.title-card-container:has(.sc30-title-selector) .btn-subtle-pill,
.title-card-container:has(.sc30-title-selector) .mode-chip,
.title-card-container:has(.sc30-title-selector) .bench-link,
.title-card-container:has(.sc30-title-selector) .btn-play-cta {
  min-height: 48px;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.sc30-title-selector-bar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sc30-chapter-group {
  flex: 1 1 460px;
  display: grid;
  grid-template-columns: repeat(6, minmax(64px, 1fr));
  gap: 6px;
  min-width: max-content;
}

.sc30-diff-group {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(76px, auto));
  gap: 6px;
  padding-left: 10px;
  border-left: 1px solid rgba(245, 196, 94, 0.24);
  min-width: max-content;
}

.sc30-chapter-btn,
.sc30-diff-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 5px 8px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 244, 214, 0.22);
  background: rgba(17, 30, 56, 0.78);
  color: #f8f1dc;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
  transition:
    transform 0.12s ease,
    border-color 0.16s ease,
    background-color 0.16s ease,
    box-shadow 0.16s ease;
}

.sc30-chapter-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  min-width: 54px;
}

.sc30-ch-top {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
}

.sc30-ch-code {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #fff7df;
  white-space: nowrap;
}

.sc30-ch-name {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(248, 241, 220, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 74px;
}

.sc30-ch-stars {
  font-size: 0.68rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fcd34d;
  line-height: 1.1;
  white-space: nowrap;
}

.sc30-chapter-btn.is-complete .sc30-ch-stars {
  color: #5eead4;
}

.sc30-chapter-btn:hover,
.sc30-diff-btn:hover {
  border-color: rgba(245, 196, 94, 0.62);
  background: rgba(26, 44, 78, 0.88);
}

.sc30-chapter-btn:active,
.sc30-diff-btn:active {
  transform: scale(0.96);
}

.sc30-chapter-btn.is-selected,
.sc30-chapter-btn[aria-pressed="true"] {
  border-color: #fbbf24;
  background: linear-gradient(180deg, rgba(245, 196, 94, 0.30) 0%, rgba(42, 62, 98, 0.88) 100%);
  box-shadow:
    0 0 0 2px rgba(251, 191, 36, 0.24),
    0 4px 14px rgba(245, 196, 94, 0.28);
}

.sc30-chapter-btn.is-target-chapter:not(.is-selected) {
  border-color: rgba(94, 234, 212, 0.72);
  box-shadow: 0 0 0 1.5px rgba(94, 234, 212, 0.22);
}

.sc30-diff-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.sc30-diff-easy {
  color: #bbf7d0;
  border-color: rgba(74, 222, 128, 0.34);
}

.sc30-diff-medium {
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.38);
}

.sc30-diff-hard {
  color: #fecdd3;
  border-color: rgba(251, 113, 133, 0.38);
}

.sc30-diff-btn.is-selected,
.sc30-diff-btn[aria-pressed="true"] {
  color: #1c1304;
  border-color: #fff3c4;
  background: linear-gradient(180deg, #ffe38f 0%, #f4b63f 100%);
  box-shadow: 0 4px 14px rgba(245, 196, 94, 0.42);
}

.sc30-chapter-btn:focus-visible,
.sc30-diff-btn:focus-visible,
.sc30-stage-replay-cue:focus-visible,
.sc30-pause-diff-btn:focus-visible,
.sc30-pause-chapter-btn:focus-visible,
.sc30-pause-stage-btn:focus-visible {
  outline: 2.5px solid #fde68a;
  outline-offset: 2px;
}

/* ==========================================================================
   1b. KID TITLE: 4 hero cards + one big play disc + corner parent gear.
   Language, mother tongue, chapter, difficulty, 1P/co-op and "back to hub" live in
   the parent drawer (#parent-settings-panel inside #pause-helper-dialog).
   ========================================================================== */
.btn-title-parent {
  position: absolute;
  top: max(8px, var(--safe-t, 0px), env(safe-area-inset-top, 0px));
  right: max(10px, var(--safe-r, 0px), env(safe-area-inset-right, 0px));
  z-index: 3;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 242, 198, 0.5);
  background: rgba(12, 22, 40, 0.72);
  color: #fde68a;
  opacity: 0.72;
  cursor: pointer;
}
.btn-title-parent:hover,
.btn-title-parent:focus-visible { opacity: 1; }

.title-overlay .title-card-container {
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3dvh, 24px);
}
.title-overlay .title-header {
  justify-content: center;
  flex-wrap: nowrap;
}
.title-overlay .title-headings { flex: 0 1 auto; text-align: center; }
.title-overlay .hero-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  gap: clamp(8px, 1.6cqi, 16px);
  overflow: visible;
}
.title-overlay .hero-grid .hero-card {
  flex-direction: column;
  min-width: 108px;
  min-height: 124px;
  max-height: none;
  padding: 8px 6px;
  border-width: 3px;
}
.title-overlay .hero-grid .hero-card.is-selected,
.title-overlay .hero-grid .hero-card[aria-checked="true"] {
  border-color: var(--gold-bright);
  transform: scale(1.04);
}
.title-overlay .hero-grid .hero-avatar {
  width: clamp(52px, 17dvh, 84px);
  height: clamp(52px, 17dvh, 84px);
}
.title-overlay .hero-grid .hero-avatar img { width: 100%; height: 100%; }
.title-overlay .title-footer { justify-content: center; }
.title-overlay .btn-play-cta {
  min-width: 200px;
  min-height: 64px;
  padding: 6px 28px;
}
.title-overlay .btn-play-cta .play-triangle { font-size: 28px; line-height: 1; }
.title-overlay .btn-play-cta #play-cta-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (orientation: landscape) and (max-height: 335px) {
  .title-overlay .title-card-container { gap: 6px; padding: 6px 18px; }
  .title-overlay .compass-emblem { width: 30px; height: 30px; font-size: 1rem; }
  .title-overlay .title-headings h1 { margin: 0; font-size: 1.05rem; }
  .title-overlay .hero-grid { grid-template-columns: repeat(5, minmax(96px, 1fr)); gap: 8px; }
  .title-overlay .hero-grid .hero-card { min-width: 96px; min-height: 104px; padding: 4px 4px; gap: 2px; }
  .title-overlay .hero-grid .hero-avatar { width: 52px; height: 52px; }
  .title-overlay .btn-play-cta { min-width: 176px; min-height: 54px; padding: 4px 22px; }
}

.parent-settings-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 6px 2px 10px;
}
.parent-settings-panel .pill-select select { min-height: 44px; }
.parent-settings-panel .mode-bar { display: contents; }
.parent-settings-panel .room-code-wrap input { min-height: 44px; }
.btn-parent-close {
  display: none;
  width: 48px;
  height: 48px;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 242, 198, 0.5);
  background: rgba(12, 22, 40, 0.85);
  color: #fde68a;
  font-size: 1.2rem;
  font-weight: 800;
  cursor: pointer;
}
dialog#pause-helper-dialog[data-origin="title"] .btn-parent-close { display: grid; }
dialog#pause-helper-dialog[data-origin="title"] :is(#btn-resume-game, #btn-back-to-title, #btn-parent-read-aloud) { display: none !important; }

/* ==========================================================================
   2. IN-GAME HUD: ZERO-TEXT 5-STAR STRIP & FLOATING STAGE REPLAY HELPER
   ========================================================================== */

/* Prevent top-right 76x76 STAGE replay ear button from clipping at negative y */
#hud-touch-layer:has(.sc30-hud-stars) .jumi-touch-hud,
.hud-touch-layer:has(.sc30-hud-stars) .jumi-touch-hud {
  align-items: flex-start;
}

.sc30-hud-stars {
  position: absolute;
  top: max(10px, calc(env(safe-area-inset-top, 0px) + 6px));
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  z-index: 11;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(12, 22, 42, 0.64);
  border: 1px solid rgba(245, 196, 94, 0.32);
  box-shadow: 0 4px 12px rgba(3, 9, 22, 0.3);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  transition: left 0.22s ease, right 0.22s ease, transform 0.22s ease;
}

/* Shift beside Pause button when 2-3P Co-op room pill occupies top-center in TRAVEL */
#hud-touch-layer:has(.jumi-room-pill:not([hidden])) .sc30-hud-stars,
.hud-touch-layer:has(.jumi-room-pill:not([hidden])) .sc30-hud-stars {
  left: calc(max(14px, env(safe-area-inset-left, 0px)) + 58px);
  right: auto;
  transform: none;
}

/* Dock 5-star chapter pill to the clear sky left of hud-ear during STAGE mode so it never
   occludes multi-select progress stars, clocks, coin panels, or top option circles */
#hud-touch-layer[data-control-mode="STAGE"] .sc30-hud-stars,
.hud-touch-layer[data-control-mode="STAGE"] .sc30-hud-stars,
.sc30-hud-stars[data-control-mode="STAGE"] {
  left: auto;
  right: calc(max(14px, env(safe-area-inset-right, 0px)) + 86px);
  transform: none;
}

/* Dock #bilingual-toast to the empty bottom-center bridge wall during stages30 STAGE mode
   so it never occludes equations (STG-02), analog clocks (STG-19), or option pads */
#hud-touch-layer[data-control-mode="STAGE"]:has(.sc30-hud-stars) + #bilingual-toast,
#hud-touch-layer[data-control-mode="STAGE"]:has(.sc30-hud-stars) ~ .bilingual-toast {
  top: auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  max-width: min(360px, 44vw);
  z-index: 15;
}

#hud-touch-layer:has(.sc30-hud-stars) + #bilingual-toast,
#hud-touch-layer:has(.sc30-hud-stars) ~ .bilingual-toast {
  top: auto !important;
  bottom: calc(max(var(--safe-b, 0px), env(safe-area-inset-bottom, 0px)) + 12px) !important;
  left: 50% !important;
  right: auto !important;
  transform: translateX(-50%) !important;
  max-width: min(360px, 44vw);
  z-index: 15;
}

.sc30-hud-star {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.sc30-hud-star svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: rgba(255, 248, 225, 0.06);
  stroke: rgba(148, 163, 184, 0.45);
  stroke-width: 1.45;
  stroke-linejoin: round;
  transition: fill 0.22s ease, stroke 0.22s ease, filter 0.22s ease;
}

.sc30-hud-star.is-completed svg,
.sc30-hud-star[data-completed="true"] svg {
  fill: #fbbf24;
  stroke: #fef08a;
  filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.58));
}

.sc30-hud-star.is-current,
.sc30-hud-star[data-current="true"] {
  transform: scale(1.18);
  animation: sc30HudStarPulse 1.9s ease-in-out infinite;
}

.sc30-hud-star.is-current svg,
.sc30-hud-star[data-current="true"] svg {
  fill: rgba(253, 230, 138, 0.55);
  stroke: #ffffff;
  stroke-width: 2;
  filter: drop-shadow(0 0 7px rgba(253, 230, 138, 0.92));
}

.sc30-hud-star.is-completed.is-current svg,
.sc30-hud-star[data-completed="true"][data-current="true"] svg {
  fill: #fde047;
  stroke: #ffffff;
}

@keyframes sc30HudStarPulse {
  0%, 100% { transform: scale(1.12); }
  50% { transform: scale(1.26); }
}

/* Warm floating helper cue ("點我重聽主人題目 🔊") during STAGE mode */
.sc30-stage-replay-cue {
  --sc30-replay-shadow-a:
    0 8px 22px rgba(4, 10, 24, 0.46),
    0 0 0 3px rgba(251, 191, 36, 0.18),
    0 0 16px rgba(245, 196, 94, 0.38);
  --sc30-replay-shadow-b:
    0 8px 24px rgba(4, 10, 24, 0.5),
    0 0 0 4px rgba(251, 191, 36, 0.34),
    0 0 26px rgba(251, 191, 36, 0.68);
  position: absolute;
  left: max(14px, var(--safe-l, 0px), env(safe-area-inset-left, 0px));
  bottom: calc(max(var(--safe-b, 0px), env(safe-area-inset-bottom, 0px)) + 12px);
  z-index: 14;
  min-width: 48px;
  min-height: 48px;
  max-width: min(330px, 46vw);
  padding: 8px 18px 8px 14px;
  border-radius: 999px;
  border: 1.75px solid rgba(255, 232, 163, 0.92);
  background: linear-gradient(135deg, rgba(133, 77, 14, 0.92) 0%, rgba(30, 41, 75, 0.92) 100%);
  color: #fffbeb;
  box-shadow: var(--sc30-replay-shadow-a);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: clamp(0.8rem, 0.72rem + 0.28vw, 0.94rem);
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;

  /* Retracted default state (TRAVEL mode) */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 16px, 0) scale(0.92);
  transition:
    opacity 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0.26s,
    box-shadow 0.2s ease;
}

.sc30-stage-replay-cue.is-visible,
.sc30-stage-replay-cue[data-visible="true"],
#hud-touch-layer[data-control-mode="STAGE"] .sc30-stage-replay-cue,
.hud-touch-layer[data-control-mode="STAGE"] .sc30-stage-replay-cue {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(1);
  transition:
    opacity 0.26s cubic-bezier(0.22, 1, 0.36, 1) 0.04s,
    transform 0.28s cubic-bezier(0.22, 1, 0.36, 1) 0.04s,
    visibility 0s linear 0s,
    box-shadow 0.2s ease;
  animation: sc30ReplayGlow 2.4s ease-in-out infinite;
}

.sc30-stage-replay-cue:active,
.sc30-stage-replay-cue.is-rippling {
  transform: translate3d(0, 1px, 0) scale(0.96);
  box-shadow:
    0 0 0 5px rgba(253, 230, 138, 0.42),
    0 0 28px rgba(251, 191, 36, 0.85);
}

.sc30-replay-icon {
  flex: 0 0 auto;
  font-size: 1.18rem;
  line-height: 1;
}

.sc30-replay-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes sc30ReplayGlow {
  0%, 100% {
    box-shadow: var(--sc30-replay-shadow-a);
  }
  50% {
    box-shadow: var(--sc30-replay-shadow-b);
  }
}

/* ==========================================================================
   3. SMOOTH PAD COLLAPSE / EXPAND FOR hud-touch-layer[data-control-mode="STAGE"]
   ========================================================================== */

#hud-touch-layer:not([hidden]) .jumi-left-pad,
.hud-touch-layer:not([hidden]) .jumi-left-pad {
  display: flex;
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: left bottom;
  transition:
    opacity 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

#hud-touch-layer:not([hidden]) .jumi-right-pad,
.hud-touch-layer:not([hidden]) .jumi-right-pad {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, 0, 0) scale(1);
  transform-origin: right bottom;
  transition:
    opacity 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.26s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

/* ==========================================================================
   4. PAUSE DRAWER CHAPTER / STAGE JUMP PICKER & PARENT HELPER CARD
   ========================================================================== */

.sc30-parent-guide-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(15, 27, 50, 0.72);
  border: 1px solid rgba(245, 196, 94, 0.3);
  margin-bottom: 12px;
}

.sc30-parent-chapter {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 700;
  color: #5eead4;
}

.sc30-parent-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  color: #fef3c7;
}

.sc30-parent-host {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: #fde68a;
}

.sc30-parent-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sc30-parent-section-label {
  font-size: 0.78rem;
  color: #fcd34d;
}

.sc30-parent-section-body {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.48;
  color: #f8f1dc;
  overflow-wrap: anywhere;
}

.sc30-inline-code {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  border-radius: 6px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.34);
  color: #fde68a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  font-weight: 700;
  line-height: 1.25;
}

#pause-helper-dialog:has(.sc30-pause-picker) .pause-locale-select {
  min-height: 48px;
  min-width: 48px;
  padding: 6px 14px;
  box-sizing: border-box;
}

#pause-helper-dialog:has(.sc30-pause-picker) button,
#pause-helper-dialog:has(.sc30-pause-picker) select,
#pause-helper-dialog:has(.sc30-pause-picker) a {
  touch-action: pan-y manipulation;
}

.sc30-pause-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(10, 19, 37, 0.82);
  border: 1px solid rgba(245, 196, 94, 0.36);
  box-sizing: border-box;
}

.sc30-pause-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sc30-pause-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  color: #fde68a;
}

.sc30-pause-total-badge {
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fef3c7;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(245, 196, 94, 0.18);
  border: 1px solid rgba(245, 196, 94, 0.4);
}

.sc30-pause-hint {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(248, 241, 220, 0.82);
}

.sc30-pause-diff-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sc30-pause-diff-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sc30-pause-diff-btn {
  flex: 1 1 130px;
  min-width: 88px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1.5px solid rgba(245, 196, 94, 0.36);
  background: rgba(19, 34, 62, 0.86);
  color: #fff8eb;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
  box-sizing: border-box;
}

.sc30-pause-diff-count {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.88;
}

.sc30-pause-chapters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sc30-pause-chapter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(17, 30, 56, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.sc30-pause-chapter-row.is-active-chapter {
  border-color: rgba(251, 191, 36, 0.58);
  background: rgba(30, 48, 82, 0.78);
}

.sc30-pause-chapter-btn {
  flex: 1 1 168px;
  min-width: 120px;
  min-height: 48px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1.5px solid rgba(245, 196, 94, 0.32);
  background: rgba(12, 23, 44, 0.86);
  color: #fef3c7;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  box-sizing: border-box;
}

.sc30-pause-chapter-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sc30-pause-chapter-stars {
  flex: 0 0 auto;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  color: #fcd34d;
}

.sc30-pause-stage-list {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sc30-pause-stage-btn {
  min-width: 48px;
  min-height: 48px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1.5px solid rgba(255, 244, 214, 0.24);
  background: rgba(18, 33, 60, 0.9);
  color: #fff8eb;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  box-sizing: border-box;
}

.sc30-pause-stage-num {
  font-size: 0.84rem;
  font-weight: 900;
  line-height: 1.05;
}

.sc30-pause-stage-tier {
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  color: #fcd34d;
}

.sc30-pause-stage-btn.sc30-stage-diff-easy .sc30-pause-stage-tier { color: #86efac; }
.sc30-pause-stage-btn.sc30-stage-diff-medium .sc30-pause-stage-tier { color: #fde047; }
.sc30-pause-stage-btn.sc30-stage-diff-hard .sc30-pause-stage-tier { color: #fda4af; }

.sc30-pause-stage-btn.is-completed {
  border-color: rgba(94, 234, 212, 0.64);
  background: rgba(20, 56, 66, 0.78);
}

.sc30-pause-stage-btn.is-current {
  border-color: #fde047;
  background: linear-gradient(180deg, rgba(245, 196, 94, 0.36) 0%, rgba(36, 56, 92, 0.94) 100%);
  box-shadow: 0 0 0 2px rgba(253, 224, 71, 0.3);
}

.sc30-pause-diff-btn:active,
.sc30-pause-chapter-btn:active,
.sc30-pause-stage-btn:active {
  transform: scale(0.96);
}

/* ==========================================================================
   5. LANDSCAPE PHONE (844x390, 932x430) & TABLET RESPONSIVE TUNING
   ========================================================================== */

/* Landscape phones & compact widths (e.g. 844x390, 932x430, 667x320):
   Preserve full #hero-grid breathing room, enforce >= 48x48px targets, and guarantee
   non-overlapping horizontal swipe scrolling on .sc30-title-selector-bar. */
@media (max-width: 899px), (orientation: landscape) and (max-height: 499px) {
  .title-card-container:has(.sc30-title-selector) {
    padding: 8px 14px;
    gap: 5px;
  }

  .title-card-container:has(.sc30-title-selector) .title-header {
    gap: 8px;
  }

  .title-card-container:has(.sc30-title-selector) .title-headings h1 {
    font-size: clamp(1.02rem, 0.8rem + 1.1vw, 1.38rem);
    margin: 0;
  }

  .title-card-container:has(.sc30-title-selector) .title-subtitle {
    font-size: 0.74rem;
    margin: 0;
  }

  .title-card-container:has(.sc30-title-selector) .hero-card {
    padding: 6px 8px;
    gap: 3px;
  }

  .title-card-container:has(.sc30-title-selector) .hero-avatar {
    width: clamp(44px, 12dvh, 64px);
    height: clamp(44px, 12dvh, 64px);
  }

  .sc30-title-selector {
    padding: 4px 8px 5px;
    gap: 3px;
    border-radius: 13px;
  }

  .sc30-selector-heading {
    font-size: 0.68rem;
  }

  .sc30-total-badge {
    font-size: 0.66rem;
    padding: 1px 7px;
  }

  .sc30-title-selector-bar {
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .sc30-title-selector-bar::-webkit-scrollbar {
    display: none;
  }

  .sc30-chapter-group {
    flex: 1 0 max-content;
    min-width: max-content;
    display: inline-grid;
    grid-template-columns: repeat(6, minmax(52px, 1fr));
    gap: 4px;
  }

  .sc30-ch-name {
    display: none;
  }

  .sc30-chapter-btn {
    min-width: 52px;
    min-height: 48px;
    padding: 4px 5px;
    touch-action: pan-x manipulation;
  }

  .sc30-diff-group {
    flex: 0 0 max-content;
    min-width: max-content;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding-left: 6px;
  }

  .sc30-diff-btn {
    min-width: 62px;
    min-height: 48px;
    padding: 4px 9px;
    font-size: 0.71rem;
    touch-action: pan-x manipulation;
  }

  .sc30-hud-stars {
    top: max(6px, calc(env(safe-area-inset-top, 0px) + 4px));
    height: 26px;
    padding: 0 10px;
    gap: 5px;
  }

  .sc30-stage-replay-cue {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
    padding: 6px 14px 6px 12px;
    font-size: 0.8rem;
  }

  #hud-touch-layer[data-control-mode="STAGE"]:has(.sc30-hud-stars) + #bilingual-toast,
  #hud-touch-layer[data-control-mode="STAGE"]:has(.sc30-hud-stars) ~ .bilingual-toast {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
    padding: 5px 14px;
    font-size: 0.8rem;
  }
}

/* Ultra-short & narrow viewports (e.g. 667x320 Safari bar-open) */
@media (max-width: 740px), (orientation: landscape) and (max-height: 380px) {
  .title-card-container:has(.sc30-title-selector) {
    padding: 4px 10px;
    gap: 4px;
  }

  .title-card-container:has(.sc30-title-selector) .eyebrow-tag,
  .title-card-container:has(.sc30-title-selector) .title-subtitle {
    display: none;
  }

  .title-card-container:has(.sc30-title-selector) .hero-card {
    min-height: 62px;
    padding: 3px 4px;
    gap: 1px;
  }

  .title-card-container:has(.sc30-title-selector) .hero-avatar,
  .title-card-container:has(.sc30-title-selector) .hero-grid .hero-avatar img {
    width: 38px;
    height: 38px;
  }

  .sc30-title-selector-head {
    display: none;
  }

  .sc30-title-selector {
    padding: 3px 6px;
  }

  .sc30-chapter-group {
    grid-template-columns: repeat(6, minmax(50px, 1fr));
    gap: 4px;
  }

  .sc30-chapter-btn {
    min-width: 50px;
    padding: 3px 4px;
  }

  .sc30-diff-btn {
    min-width: 58px;
    padding: 4px 8px;
    font-size: 0.69rem;
  }

  #hud-touch-layer[data-control-mode="STAGE"] .sc30-hud-stars,
  .hud-touch-layer[data-control-mode="STAGE"] .sc30-hud-stars,
  .sc30-hud-stars[data-control-mode="STAGE"] {
    right: calc(max(12px, env(safe-area-inset-right, 0px)) + 82px);
    height: 22px;
    padding: 0 7px;
    gap: 3px;
  }

  #hud-touch-layer[data-control-mode="STAGE"] .sc30-hud-star,
  .hud-touch-layer[data-control-mode="STAGE"] .sc30-hud-star {
    width: 14px;
    height: 14px;
  }

  #hud-touch-layer[data-control-mode="STAGE"] .sc30-hud-star svg,
  .hud-touch-layer[data-control-mode="STAGE"] .sc30-hud-star svg {
    width: 13px;
    height: 13px;
  }

  .sc30-stage-replay-cue {
    max-width: min(200px, 31vw);
    padding: 6px 12px 6px 10px;
    font-size: 0.74rem;
    gap: 6px;
  }

  #hud-touch-layer[data-control-mode="STAGE"]:has(.sc30-hud-stars) + #bilingual-toast,
  #hud-touch-layer[data-control-mode="STAGE"]:has(.sc30-hud-stars) ~ .bilingual-toast {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 6px);
    padding: 4px 11px;
    font-size: 0.74rem;
    max-width: min(260px, 40vw);
  }

  /* Unified full-height sheet scrolling for Pause Drawer + 30-Stage Picker on ultra-short screens */
  #pause-helper-dialog:has(.sc30-pause-picker)[open] {
    display: block;
    overflow-y: auto;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  #pause-helper-dialog:has(.sc30-pause-picker)[open] .parent-helper-body {
    overflow-y: visible;
    max-height: none;
  }
}

html[data-vh-tier="ultra-short"] .sc30-title-selector-head {
  display: none;
}

/* iPad & Desktop spacious landscape (1024x768+): 2-line chapter chip prevents 1-char truncation */
@media (min-width: 900px) and (min-height: 500px) {
  .sc30-title-selector {
    padding: 10px 14px;
    gap: 7px;
  }

  .sc30-chapter-group {
    flex: 1 1 100%;
  }

  .sc30-diff-group {
    padding-left: 0;
    border-left: none;
  }

  .sc30-chapter-btn {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: center;
    column-gap: 5px;
    row-gap: 2px;
    min-height: 50px;
    padding: 4px 6px;
  }

  .sc30-ch-top {
    display: contents;
  }

  .sc30-ch-code {
    grid-row: 1;
    grid-column: 1;
    font-size: 0.72rem;
  }

  .sc30-ch-stars {
    grid-row: 1;
    grid-column: 2;
    font-size: 0.67rem;
  }

  .sc30-ch-name {
    display: block;
    grid-row: 2;
    grid-column: 1 / -1;
    max-width: 100%;
    font-size: 0.7rem;
  }

  .sc30-diff-btn {
    min-height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc30-hud-star,
  .sc30-stage-replay-cue,
  #hud-touch-layer .jumi-left-pad,
  #hud-touch-layer .jumi-right-pad,
  .hud-touch-layer .jumi-left-pad,
  .hud-touch-layer .jumi-right-pad {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* Round 3 stage controls occupy the side gutters of the fixed camera. */
#hud-touch-layer[data-stage-experience="r3"] .sc30-stage-replay-cue,
#hud-touch-layer[data-stage-experience="r3"] .sc30-stage-replay-cue:is(:active, .is-rippling) {
  --sc30-replay-shadow-a: none;
  --sc30-replay-shadow-b: none;
  animation: none !important;
  -webkit-animation: none !important;
  transition: none !important;
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: transparent !important;
}
#hud-touch-layer[data-stage-experience="r3"] .sc30-stage-replay-cue :is(.sc30-replay-icon, .sc30-replay-label) {
  opacity: 0 !important;
}
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] {
  --sc30-left: max(12px, var(--safe-l, 0px), env(safe-area-inset-left, 0px));
  --sc30-right: max(12px, var(--safe-r, 0px), env(safe-area-inset-right, 0px));
  --sc30-bottom: calc(max(var(--safe-b, 0px), env(safe-area-inset-bottom, 0px)) + 8px);
  --sc30-top: calc(max(var(--safe-t, 0px), env(safe-area-inset-top, 0px)) + 12px);
}
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) {
  position: absolute; display: flex !important; flex-direction: row; align-items: center;
  gap: 8px; width: 148px !important; height: 62px !important; padding: 0; border: 0;
  bottom: calc(var(--sc30-bottom) + 8px); opacity: 1 !important; visibility: visible !important;
  pointer-events: auto !important; transform: none; box-sizing: border-box;
}
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-right-pad { width: 132px !important; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-left-pad { left: calc(var(--sc30-left) + 8px); right: auto; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-right-pad { right: calc(var(--sc30-right) + 8px); left: auto; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) :is([data-input-control], [data-action], .jumi-game-button) {
  position: static !important; flex: 0 0 62px !important; width: 62px !important; min-width: 62px !important; height: 62px !important; min-height: 62px !important;
  margin: 0 !important; inset: auto !important; transform: none !important; box-sizing: border-box !important; pointer-events: auto !important;
  transition: width .18s ease-out, height .18s ease-out, background .1s ease, border-color .1s ease, box-shadow .12s ease !important;
}
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-left-pad [data-input-control="left"] { flex-basis: 64px !important; width: 64px !important; min-width: 64px !important; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-left-pad [data-input-control="right"] { flex-basis: 76px !important; width: 76px !important; min-width: 76px !important; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) :is(svg, .jumi-hud-label) { pointer-events: none !important; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.hud-ear, [data-testid="hud-ear"], [data-testid="hud-highfive"], [data-action="high-five"], [data-action="glide"], .jumi-room-pill) { display: none !important; pointer-events: none !important; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .sc30-stage-replay-cue {
  --sc30-replay-shadow-a: none;
  --sc30-replay-shadow-b: none;
  position: absolute; left: calc(var(--sc30-left) + 8px); top: calc(var(--sc30-top) + 76px); right: auto; bottom: auto;
  width: 128px; min-width: 128px; max-width: 128px; height: 48px; min-height: 48px; padding: 0 10px;
  margin: 0; transform: none; box-sizing: border-box; overflow: hidden;
  animation: none !important; -webkit-animation: none !important; transition: none !important;
  background: transparent !important; border-color: transparent !important; box-shadow: none !important; color: transparent !important;
}
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .sc30-stage-replay-cue:is(:active, .is-rippling) {
  background: transparent !important; border-color: transparent !important; box-shadow: none !important;
}
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .sc30-stage-replay-cue:focus-visible {
  outline: 2px solid #ffe49e; outline-offset: 2px;
}
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .sc30-stage-replay-cue :is(.sc30-replay-icon, .sc30-replay-label) { opacity: 0 !important; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.sc30-hud-stars, .sc30-stage-progress) {
  position: absolute; right: calc(var(--sc30-right) + 60px); top: calc(var(--sc30-top) + 8px); left: auto; bottom: auto;
  width: 132px; height: 24px; padding: 0 8px; margin: 0; transform: none; box-sizing: border-box;
}
#hud-touch-layer[data-stage-experience="r3"][data-control-mode="STAGE"]:has(.sc30-hud-stars) + #bilingual-toast,
#hud-touch-layer[data-stage-experience="r3"][data-control-mode="STAGE"]:has(.sc30-hud-stars) ~ .bilingual-toast {
  top: auto;
  bottom: calc(max(var(--safe-b, 0px), env(safe-area-inset-bottom, 0px)) + 6px);
  left: calc(50% + (max(12px, var(--safe-l, 0px)) - max(12px, var(--safe-r, 0px))) * 0.5);
  right: auto;
  transform: translateX(-50%);
  max-width: min(300px, calc(100vw - max(12px, var(--safe-l, 0px)) - max(12px, var(--safe-r, 0px)) - 244px));
  padding: 3px 12px;
  font-size: 0.78rem;
  z-index: 15;
}
@media (max-width: 700px), (max-height: 315px) {
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] {
    --sc30-bottom: calc(max(var(--safe-b, 0px), env(safe-area-inset-bottom, 0px)) + 4px);
    --sc30-top: calc(max(var(--safe-t, 0px), env(safe-area-inset-top, 0px)) + 6px);
  }
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) {
    bottom: calc(var(--sc30-bottom) + 4px);
  }
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .sc30-stage-replay-cue {
    top: calc(var(--sc30-top) + 66px);
    width: 88px; min-width: 88px; max-width: 88px;
    height: 48px; min-height: 48px;
  }
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.sc30-hud-stars, .sc30-stage-progress) {
    right: calc(var(--sc30-right) + 12px);
    top: calc(var(--sc30-top) + 4px);
    width: 112px; height: 22px; padding: 0 6px;
  }
}

@media (max-width: 700px) {
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) { width: 128px !important; height: 60px !important; }
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-left-pad { left: calc(var(--sc30-left) + 4px); }
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-right-pad { right: calc(var(--sc30-right) + 4px); }
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) :is([data-input-control], [data-action], .jumi-game-button),
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-left-pad :is([data-input-control="left"], [data-input-control="right"]) {
    flex: 0 0 60px !important; width: 60px !important; min-width: 60px !important; height: 60px !important; min-height: 60px !important;
  }
}

/* The hero and host stand behind the pads in a stage: keep the buttons full size but see-through */
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] .jumi-left-pad { background-color: transparent !important; }
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) .jumi-game-button:not(:active):not([data-pressed="true"]) {
  background: rgba(14, 24, 44, .2) !important;
  box-shadow: inset 0 0 0 1.5px rgba(8, 14, 26, .46), 0 0 0 1px rgba(255, 255, 255, .28) !important;
}
#hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) .jumi-game-button svg {
  filter: drop-shadow(0 1px 1.5px rgba(8, 14, 26, .8)) drop-shadow(0 0 1px rgba(8, 14, 26, .6));
}
@media (orientation: landscape) and (max-height: 335px) {
  #hud-touch-layer:not([hidden])[data-stage-experience="r3"][data-control-mode="STAGE"] :is(.jumi-left-pad, .jumi-right-pad) { bottom: 2px; }
}

/* Ultra-short old iPhone SE1 / 5s (568x268) & in-app webview (<315px tall): above-the-fold Title Card with >=48px touch targets */
@media (max-height: 315px) {
  .title-card-container:has(.sc30-title-selector) {
    padding: 3px 8px;
    gap: 3px;
  }
  .title-card-container:has(.sc30-title-selector) .title-header {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .title-card-container:has(.sc30-title-selector) .title-headings {
    flex: 1 1 110px;
    min-width: 92px;
  }
  .title-card-container:has(.sc30-title-selector) .top-lang-controls {
    flex: 0 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .title-card-container:has(.sc30-title-selector) .pill-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .title-card-container:has(.sc30-title-selector) .btn-back-to-hub {
    display: inline-block;
    line-height: 45px;
    text-align: left;
    max-width: 108px;
    padding: 0 8px;
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .title-card-container:has(.sc30-title-selector) .pill-select {
    min-height: 48px;
    padding: 0 6px;
    gap: 2px;
    font-size: 0.7rem;
  }
  .title-card-container:has(.sc30-title-selector) .pill-select select {
    min-height: 48px;
    min-width: 48px;
    max-width: 96px;
    padding: 0 2px;
    font-size: 0.72rem;
  }
  .title-card-container:has(.sc30-title-selector) .hero-card {
    flex-direction: row;
    min-height: 48px;
    padding: 2px 6px;
    gap: 5px;
    border-radius: 10px;
  }
  .title-card-container:has(.sc30-title-selector) .hero-avatar,
  .title-card-container:has(.sc30-title-selector) .hero-grid .hero-avatar img {
    width: 30px;
    height: 30px;
  }
  .title-card-container:has(.sc30-title-selector) .sc30-title-selector {
    padding: 3px 6px;
    gap: 2px;
  }
  .title-card-container:has(.sc30-title-selector) .sc30-title-selector-head {
    display: none;
  }
  .title-card-container:has(.sc30-title-selector) .sc30-chapter-btn,
  .title-card-container:has(.sc30-title-selector) .sc30-diff-btn {
    min-height: 48px;
    padding: 2px 5px;
  }
  .title-card-container:has(.sc30-title-selector) .title-footer {
    flex-wrap: nowrap;
    gap: 5px;
  }
  .title-card-container:has(.sc30-title-selector) .mode-bar {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .title-card-container:has(.sc30-title-selector) .btn-subtle-pill,
  .title-card-container:has(.sc30-title-selector) .mode-chip,
  .title-card-container:has(.sc30-title-selector) .bench-link,
  .title-card-container:has(.sc30-title-selector) .btn-play-cta {
    min-height: 48px;
    padding: 2px 8px;
  }
  .title-card-container:has(.sc30-title-selector) .mode-chip,
  .title-card-container:has(.sc30-title-selector) .bench-link {
    min-width: 0;
    font-size: 0.68rem;
    line-height: 1.15;
  }
  .title-card-container:has(.sc30-title-selector) .btn-play-cta {
    flex: 0 0 auto;
    min-width: 112px;
    padding: 2px 12px;
    font-size: 0.82rem;
  }
}

.sc30-hud-star.is-completed.is-assisted svg {
  fill: rgba(15, 23, 42, 0.85);
  stroke: #fde047;
  stroke-width: 2.35;
  filter: drop-shadow(0 0 5px rgba(253, 224, 71, 0.65));
}
.sc30-hud-star-glyph::before { content: '☆'; color: #fbbf24; }
.sc30-hud-star.is-completed:not(.is-assisted) .sc30-hud-star-glyph::before { content: '★'; }
.sc30-pause-stage-tier.is-assisted { color: #fbbf24; }
@keyframes sc30-softgate-pulse { 50% { transform: scale(1.08); opacity: .8; } }
.jumi-action-button.is-softgate-hint { animation: sc30-softgate-pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .jumi-action-button.is-softgate-hint { animation: none; } }

.corridor-quest { position: fixed; top: max(50px, calc(env(safe-area-inset-top) + 44px)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; pointer-events: none; z-index: 12; }
.corridor-quest[hidden] { display: none; }
.corridor-quest { transition: opacity 0.18s ease; }
.corridor-quest.is-yielding { opacity: 0; }
.cq-tasks, .cq-progress { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 26px; background: rgba(20, 30, 54, 0.62); }
.cq-tasks { min-width: 224px; justify-content: center; }
.cq-tasks.is-empty { background: transparent; }
.cq-slot { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.16); border: 2px dashed rgba(255, 255, 255, 0.45); }
.cq-slot[hidden] { display: none; }
.cq-slot img { width: 30px; height: 30px; object-fit: contain; opacity: 0.5; }
.cq-slot svg { fill: rgba(255, 255, 255, 0.6); stroke: rgba(255, 255, 255, 0.6); }
.cq-slot.is-done { background: #F5C45E; border: 2px solid #FFF1B3; }
.cq-slot.is-done img { opacity: 1; }
.cq-slot.is-done svg { fill: #7A4A12; stroke: #7A4A12; }
.corridor-quest.is-complete .cq-progress { animation: cq-celebrate 0.45s ease-in-out 4; }
@keyframes cq-celebrate { 50% { transform: scale(1.16); } }
.cq-verbs { display: flex; gap: 3px; }
.cq-verb { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, 0.16); border: 1.5px dashed rgba(255, 255, 255, 0.45); }
.cq-verb[hidden] { display: none; }
.cq-verb svg { width: 15px; height: 15px; fill: none; stroke: rgba(255, 255, 255, 0.72); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.cq-verb.is-done { background: #F5C45E; border: 1.5px solid #FFF1B3; }
.cq-verb.is-done svg { stroke: #7A4A12; }
.cq-motes { display: flex; align-items: center; justify-content: center; gap: 3px; width: 108px; height: 28px; }
.cq-pip { width: 15px; height: 15px; flex: none; background: rgba(255, 255, 255, 0.26); clip-path: polygon(50% 0, 62% 36%, 100% 38%, 70% 60%, 81% 100%, 50% 76%, 19% 100%, 30% 60%, 0 38%, 38% 36%); transition: background 0.2s, transform 0.2s; }
.cq-pip[hidden] { display: none; }
.cq-pip.is-on { background: #FFD36B; transform: scale(1.12); }
.cq-motes.is-full .cq-pip.is-on { background: #FFF1B3; }
.cq-badge { position: relative; width: 40px; height: 40px; flex: none; display: grid; place-items: center; }
.cq-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.cq-ring circle { fill: none; stroke-width: 3.600; }
.cq-ring-track { stroke: rgba(255, 255, 255, 0.28); }
.cq-ring-fill { stroke: #FFD36B; stroke-linecap: butt; stroke-dasharray: 100 100; stroke-dashoffset: 100; transition: stroke-dashoffset 0.5s ease-out; }
.cq-badge.is-earned .cq-ring-fill { stroke: #FFF1B3; filter: drop-shadow(0 0 3px rgba(255, 224, 138, 0.95)); }
.cq-badge-art { position: relative; width: 26px; height: 26px; display: block; }

.badge-emblem { position: relative; display: block; width: 100%; height: 100%; }
.badge-svg { width: 100%; height: 100%; overflow: visible; }
.badge-ribbon { fill: var(--b2); }
.badge-disc { fill: var(--b2); stroke: #FFF1B3; stroke-width: 2; }
.badge-rim { fill: var(--b1); }
.badge-glyph { fill: none; stroke: #FFFFFF; stroke-width: 1.900; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 0.5px rgba(0, 0, 0, 0.5)); }
.badge-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: none; }
.badge-emblem.has-art .badge-img { display: block; }
.badge-emblem.has-art .badge-svg { display: none; }
.badge-emblem.is-locked .badge-ribbon { fill: none; }
.badge-emblem.is-locked .badge-disc { fill: rgba(255, 255, 255, 0.08); stroke: rgba(255, 255, 255, 0.5); stroke-dasharray: 3 2.500; }
.badge-emblem.is-locked .badge-rim { fill: none; }
.badge-emblem.is-locked .badge-glyph { stroke: rgba(255, 255, 255, 0.4); }
.badge-emblem.is-locked .badge-img { filter: grayscale(1) brightness(0.45) contrast(0.8); opacity: 0.55; }

.badge-celebration { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; animation: bc-fade 3.2s ease-in-out forwards; }
.badge-celebration[hidden] { display: none; }
.bc-rays { position: absolute; width: min(70vh, 420px); height: min(70vh, 420px); border-radius: 50%; background: repeating-conic-gradient(from 0deg, rgba(255, 224, 138, 0.5) 0deg 10deg, rgba(255, 224, 138, 0) 10deg 24deg); -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 68%); mask-image: radial-gradient(circle, #000 20%, transparent 68%); animation: bc-spin 6s linear infinite; }
.bc-medal { position: relative; width: min(42vh, 200px); height: min(42vh, 200px); filter: drop-shadow(0 0 16px rgba(255, 224, 138, 0.9)); animation: bc-pop 0.9s cubic-bezier(0.2, 1.5, 0.4, 1) both; }
@keyframes bc-pop { 0% { transform: scale(0.1) rotate(-25deg); } 60% { transform: scale(1.18) rotate(6deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes bc-spin { to { transform: rotate(360deg); } }
@keyframes bc-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .bc-rays { animation: none; } .bc-medal { animation: none; } }

.btn-title-badges { position: absolute; top: max(8px, var(--safe-t, 0px), env(safe-area-inset-top, 0px)); left: max(10px, var(--safe-l, 0px), env(safe-area-inset-left, 0px)); z-index: 3; width: 52px; height: 52px; display: grid; place-items: center; padding: 0 0 8px; border-radius: 50%; border: 2px solid rgba(255, 242, 198, 0.75); background: rgba(12, 22, 40, 0.78); color: #FFD36B; cursor: pointer; }
.btn-title-badges:focus-visible { outline: 3px solid #fde68a; outline-offset: 2px; }
.tb-dots { position: absolute; bottom: 6px; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; }
.tb-dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, 0.3); }
.tb-dots i.is-on { background: #FFD36B; }

.badge-book { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: rgba(8, 14, 28, 0.78); }
.badge-book[hidden] { display: none; }
.bb-card { position: relative; padding: 18px clamp(10px, 2.4cqi, 22px) 14px; border-radius: 22px; background: rgba(20, 30, 54, 0.95); border: 2px solid rgba(255, 224, 138, 0.7); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5); --bb: clamp(52px, calc((100cqi - 120px) / 6), 104px); }
.bb-close { position: absolute; top: -14px; right: -14px; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 242, 198, 0.75); background: rgba(12, 22, 40, 0.95); color: #fde68a; cursor: pointer; }
.bb-slots { display: grid; grid-template-columns: repeat(6, var(--bb)); gap: clamp(4px, 1.2cqi, 12px); }
.bb-slot { position: relative; width: var(--bb); height: var(--bb); display: grid; place-items: center; }
.bb-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.bb-ring circle { fill: none; stroke-width: 3; }
.bb-ring .cq-ring-track { stroke: rgba(255, 255, 255, 0.22); }
.bb-ring .cq-ring-fill { stroke: #FFD36B; stroke-linecap: butt; stroke-dasharray: 100 100; }
.bb-slot.is-earned .cq-ring-fill { stroke: #FFF1B3; }
.bb-slot.is-next { animation: bb-next 1.6s ease-in-out infinite; }
@keyframes bb-next { 50% { transform: scale(1.07); } }
@media (prefers-reduced-motion: reduce) { .bb-slot.is-next { animation: none; } }
.bb-art { position: relative; width: 68%; height: 68%; display: block; }

/* The word toast must sit under the quest HUD, not on top of it (667x320 put both at y~50). */
body:has(#corridor-quest:not([hidden])) #bilingual-toast {
  top: calc(max(50px, calc(env(safe-area-inset-top) + 44px)) + 52px);
  z-index: 11;
}
