
/* Phone-only layout. Keep the authored 960x540 world and its hit-testing intact.
 * Separate art and controls rather than covering a tall stage with a wide canvas.
 * Dedicated puzzle and landscape layouts retain their existing contracts. */
@media (orientation:portrait) and (max-width:700px) {
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden]):not(.rw-chase-mode):not(.rw-dedicated-puzzle) {
  --rw-phone-inset:8px;
  display:grid!important;grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:auto auto minmax(0,1fr)!important;
  gap:8px!important;
  padding:max(8px,env(safe-area-inset-top,0px)) var(--rw-phone-inset) max(8px,env(safe-area-inset-bottom,0px))!important;
  box-sizing:border-box!important;overflow:hidden!important;
  background:linear-gradient(180deg,#efe2c7,#faf3e6 50%,#efe4cf)!important;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden])>.rw-head {
  grid-area:1/1!important;position:relative!important;inset:auto!important;
  width:auto!important;min-width:0!important;margin:0!important;
  padding:0 78px 0 0!important;box-sizing:border-box!important;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-head .rw-brand{
  max-width:100%!important;width:auto!important;padding:4px 8px!important;
  background:transparent!important;box-shadow:none!important;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-head>button[data-next-scene]{
  max-width:100%!important;width:100%!important;margin:4px 0 0!important;
  min-height:44px!important;font-size:15px!important;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden])>.rw-shell{
  grid-area:2/1!important;position:relative!important;inset:auto!important;
  width:100%!important;height:min(56.25vw,38dvh)!important;
  min-width:0!important;min-height:0!important;margin:0!important;
  align-self:start!important;justify-self:stretch!important;
  background:#e2d2b8!important;border-radius:9px!important;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden])>.rw-shell>.rw-surface,
 #stage .rw-world.rw-chase-mode:not([hidden])>.rw-shell>.rw-surface{
  position:absolute!important;inset:auto!important;top:50%!important;left:50%!important;
  transform:translate(-50%,-50%)!important;
  width:min(100cqw,calc(100cqh * 1.77777778))!important;
  height:auto!important;max-width:100%!important;max-height:100%!important;
  aspect-ratio:16/9!important;touch-action:none;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden])>.rw-fit-rail:not([hidden]){
  grid-area:3/1!important;position:relative!important;inset:auto!important;
  display:block!important;width:100%!important;height:100%!important;
  min-height:0!important;min-width:0!important;max-width:none!important;max-height:none!important;
  padding:8px!important;margin:0!important;box-sizing:border-box!important;
  overflow:auto!important;overscroll-behavior:contain;touch-action:pan-y;
  border:1px solid #d4c2a3!important;background:#fff9ee!important;box-shadow:none!important;
 }
 #stage .rw-world.rw-atlas-mode>.rw-atlas-rail .rw-atlas-menu{
  position:static!important;width:100%!important;max-height:none!important;margin:0!important;
  padding:0!important;border:0!important;box-shadow:none!important;background:transparent!important;
 }
 #stage .rw-world.rw-atlas-mode>.rw-atlas-rail .rw-atlas-menu>summary{
  display:list-item!important;min-height:44px;box-sizing:border-box;
  position:sticky;top:0;background:#fff9ee!important;padding:10px 8px;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-fit-rail :is(.rw-controls,.rw-system-nav,.rw-regions,.rw-optional-grid){
  display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:6px!important;min-width:0;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-fit-rail .rw-controls.rw-camera-controls:not([hidden]){
  display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-fit-rail .rw-button{
  min-width:0!important;min-height:44px!important;white-space:normal!important;overflow-wrap:anywhere;
  font-size:14px!important;line-height:1.3!important;touch-action:manipulation;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-fit-rail .rw-objective{
  padding:6px 4px!important;box-shadow:none!important;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-fit-rail .rw-world-actions [data-quest-primary]{
  font-size:15px!important;
 }
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-fit-rail .rw-action-heading,
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-fit-rail .rw-optional-actions{grid-column:1/-1;}
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-floating-notice{
  position:absolute!important;left:50%!important;right:auto!important;top:var(--rw-notice-top,100px)!important;
  bottom:auto!important;max-width:calc(100% - 24px)!important;
  z-index:6;pointer-events:none;
 }
 /* Chapter art is preserved as a whole; no slow zoom that clips the painting. */
 #stage .res-host[data-scene="harbor:H-04"]::before,
 #stage .res-host[data-scene="harbor:H-05"]::before{
  background-size:contain!important;background-position:center 20%!important;animation:none!important;
 }
 #stage .res-host.res-library-reveal .library-reveal-painting{
  object-fit:contain!important;object-position:center 20%!important;transform:none!important;animation:none!important;
 }
 #stage .res-host:not(.res-library-reveal) .res-dialogue:has(.res-portrait:not([hidden])){
  grid-template-columns:minmax(0,1fr)!important;align-content:end!important;gap:6px!important;
 }
 #stage .res-host:not(.res-library-reveal) .res-dialogue .res-portrait:not([hidden]){
  width:auto!important;height:clamp(96px,24dvh,220px)!important;max-width:100%!important;
  max-height:24dvh!important;justify-self:center;object-fit:contain!important;object-position:bottom;
 }
 #stage .res-host .res-dialogue .res-body{max-width:100%;box-sizing:border-box}
 #stage .res-host .res-dialogue .res-line{font-size:16px!important;line-height:1.55!important}
 #stage .res-host .res-dialogue .res-choices button{min-height:44px!important;white-space:normal;overflow-wrap:anywhere}
}

/* Both orientations use the approved, spoiler-free title painting.
   Portrait focuses on the two original cover cats, not the story leads. */
#stage #intro .cb-title-cover{display:none!important}
/* Portrait title and combat: keep the actual painting sharp, provide a stable
   bottom skill dock and reserve the same clearance in the combat simulation. */
@media (orientation:portrait) and (max-width:700px){
 #stage #intro.cb-rpg-intro:not(.hide){
  background:#f3e1c1!important;
  grid-template-rows:minmax(0,1fr) auto!important;
  padding:calc(44px + env(safe-area-inset-top,0px)) max(12px,env(safe-area-inset-right,0px)) max(12px,env(safe-area-inset-bottom,0px)) max(12px,env(safe-area-inset-left,0px))!important;
  gap:0!important;
 }
 #stage #intro .cb-title-landscape{
  inset:0!important;
  background:linear-gradient(180deg,#f3e1c1 0%,#ecd7b5 42%,#343139 75%,#24242b 100%)!important;
  animation:none!important;filter:none!important;
 }
 #stage #intro .cb-title-cover{
  grid-area:1/1!important;position:relative;z-index:2;
  display:grid!important;place-items:center;align-self:stretch;justify-self:stretch;
  width:100%;height:100%;min-height:0;min-width:0;
  container-type:size;overflow:hidden;pointer-events:none;
 }
 #stage #intro .cb-title-cover .cb-title-cover-art{
  display:block;width:min(100cqw,100cqh);height:min(100cqw,100cqh);
  min-width:0;min-height:0;max-width:100%;max-height:100%;
  object-fit:cover;object-position:76% center;
  border-radius:10px;
 }
 #stage #intro .cb-title-content{
  grid-area:2/1!important;align-self:end!important;justify-self:center!important;
  width:min(100%,420px)!important;padding:8px 2px 0!important;box-sizing:border-box!important;
  margin:0!important;max-height:none!important;overflow:visible;gap:8px!important;
 }
 #stage #intro .cb-intro-titleblock{gap:5px!important}
 #stage #intro .cb-intro-actions{margin:4px 0 0!important}
 #stage #intro .cb-intro-actions button:is(#intro-start,#intro-continue){min-height:48px!important}
 #stage #intro #cb-title-name{line-height:1.08!important}
 #stage:has(#intro:not(.hide)) #cb-system-toggle{min-height:44px!important}
 #stage #battle-ui.on .move-bar{
  left:8px!important;right:8px!important;bottom:max(8px,env(safe-area-inset-bottom,0px))!important;
  transform:none!important;width:auto!important;max-width:none!important;
  display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;
  gap:5px!important;justify-content:stretch!important;align-items:stretch!important;
  box-sizing:border-box!important;
 }
 #stage #battle-ui.on .move-bar .move{
  width:100%!important;min-width:0!important;max-width:none!important;
  height:54px!important;min-height:48px!important;
  padding:3px 4px!important;box-sizing:border-box!important;
  overflow:hidden;touch-action:manipulation;
 }
 #stage #battle-ui.on .move-bar .mv-name{
  font-size:11px!important;white-space:normal!important;line-height:1.15!important;
  overflow-wrap:anywhere;max-width:100%;text-align:center;
 }
 #stage #battle-ui.on .move-bar .mv-icon{font-size:19px!important}
 #stage #battle-ui.on .move-bar .mv-k{font-size:9px!important;line-height:1!important}
 #stage #battle-ui.on .battle-tools .tiny-btn{min-height:44px!important;min-width:44px!important}
 #stage #battle-ui.on #duo-burst{
  top:calc(env(safe-area-inset-top,0px) + 148px)!important;
  min-height:44px!important;
 }
 #stage #battle-ui.on #battle-squad-rail #bench-slots.is-open{
  max-height:100px;overflow:auto;overscroll-behavior:contain;
 }
 #stage #battle-ui.on #battle-squad-rail .team-slot{min-height:44px;min-width:44px}
 #stage #battle-ui.on #battle-squad-rail #bench-slots button{min-height:44px}
 #stage #battle-ui.on .battle-hint{max-width:calc(100% - 16px)!important;white-space:normal!important}
 #stage #battle-ui.on .cb-region-combat{max-width:calc(100% - 20px)!important}
 #stage #battle-ui.on .cb-region-combat button{min-height:44px!important}
}

#stage{--cb-portrait-safe-top:env(safe-area-inset-top,0px);--cb-portrait-safe-bottom:env(safe-area-inset-bottom,0px)}

/* Finale on a phone: a persistent goal in the unused strip left of the Menu.
 * Details remain accessible on demand, while the default field stays clear. */
#stage #battle-ui .cb-finale-compact{display:none!important}
@media (orientation:portrait) and (max-width:700px){
 #stage #battle-ui.on .cb-finale-compact{
  position:absolute;z-index:11;top:calc(env(safe-area-inset-top,0px) + 2px);left:max(7px,env(safe-area-inset-left,0px));right:calc(88px + env(safe-area-inset-right,0px));
  height:44px;min-height:44px;width:auto;display:grid!important;grid-template-columns:minmax(0,1fr) auto auto;
  align-items:center;gap:4px;padding:4px 7px;box-sizing:border-box;border:1px solid #bfa77a;border-radius:9px;
  background:#f6e9cdee;color:#493e2b;font:700 12px/1.2 var(--cb-font-body);text-align:left;pointer-events:auto;touch-action:manipulation;
 }
 #stage #battle-ui.on .cb-finale-compact [data-compact-goal]{min-width:0;overflow-wrap:anywhere}
 #stage #battle-ui.on .cb-finale-compact [data-compact-count]{font-size:11px;white-space:nowrap;font-variant-numeric:tabular-nums}
 #stage #battle-ui.on .cb-finale-compact .cb-finale-chevron{font-size:12px}
 #stage #battle-ui.on .cb-finale-compact[data-cinematic="true"]{visibility:hidden!important;pointer-events:none!important}
 #stage #battle-ui.on .cb-finale-hud:not(.cb-finale-details-open){display:none!important}
 #stage #battle-ui.on .cb-finale-hud.cb-finale-details-open{pointer-events:auto;max-height:calc(100% - var(--cb-rpg-hud-top,200px) - 140px - env(safe-area-inset-bottom,0px));overflow:auto}
 #stage #battle-ui.on .cb-finale-hud [data-finale-focus] button{min-height:44px}
 /* The primary action already names the current objective; do not repeat the
    identical status in the heading directly above it. */
 #stage .rw-world.rw-region-compact>.rw-head:has(>[data-next-scene]) .rw-fit-summary{display:none!important}
}

/* Native portrait cover and chase; desktop artwork and input are untouched. */
@media (orientation:portrait) and (max-width:700px){
 #stage #intro.cb-rpg-intro:not(.hide){display:block!important;padding:0!important;background:#f3e1c1!important}
 #stage #intro .cb-title-cover{position:absolute!important;inset:0!important;display:block!important;z-index:1!important;width:100%!important;height:100%!important}
 #stage #intro .cb-title-cover picture{display:block;width:100%;height:100%}
 #stage #intro .cb-title-cover .cb-title-cover-art{width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;object-fit:cover!important;object-position:center!important;border-radius:0!important}
 #stage #intro .cb-title-content{position:absolute!important;inset:0!important;width:100%!important;max-width:none!important;padding:0!important;margin:0!important;display:block!important;pointer-events:none!important;background:transparent!important;box-shadow:none!important;z-index:3!important}
 #stage #intro .cb-intro-brand{position:absolute;top:max(4.5%,env(safe-area-inset-top));left:0;right:0;text-align:center;color:#815d35!important;text-shadow:none!important;font-size:11px!important}
 #stage #intro .cb-intro-titleblock{position:absolute!important;top:8%;left:7%;right:7%;text-align:center}
 #stage #intro .game-logo{color:#58442d!important;text-shadow:0 1px 2px #fff6e1!important;font-size:clamp(27px,9vw,45px)!important}
 #stage #intro .cb-intro-tagline{color:#634e37!important;text-shadow:0 1px 2px #fff5d8!important;font-size:clamp(11px,3.2vw,15px)!important}
 #stage #intro .cb-intro-titleblock::before{display:none!important}
 #stage #intro .cb-intro-actions{position:absolute!important;bottom:max(6%,calc(env(safe-area-inset-bottom) + 10px));left:6%;right:6%;margin:0!important;pointer-events:auto!important}
 #stage #intro .cb-intro-actions button{min-height:48px!important}
 #stage .rw-world.rw-chase-mode:not([hidden])>.rw-shell{inset:0!important;width:100%!important;height:100%!important;background:#e6d7ba!important;border-radius:0!important}
 #stage .rw-world.rw-chase-mode:not([hidden])>.rw-shell>.rw-surface{inset:0!important;top:0!important;left:0!important;transform:none!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;aspect-ratio:auto!important}
 #stage .rw-world.rw-chase-mode>.rw-chase-bar{top:auto!important;bottom:max(10px,env(safe-area-inset-bottom))!important;left:8px!important;right:8px!important;transform:none!important;width:auto!important;max-width:none!important;display:grid!important;grid-template-columns:1fr 1fr;gap:6px!important;padding:9px!important}
 #stage .rw-world.rw-chase-mode .rw-chase-status{grid-column:1/-1;text-align:center;font-size:13px;line-height:1.35}
 #stage .rw-world.rw-chase-mode .rw-chase-bar button{min-height:44px!important;white-space:normal!important}
 #stage .rw-world.rw-chase-mode>.rw-chase-stick,#stage .rw-world.rw-chase-mode>.rw-chase-jump{display:none!important}
}

/* Tall world paintings fill the viewport; map pan/zoom and touch share the native art coordinates. */
@media (orientation:portrait) and (max-width:700px){
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden]):not(.rw-chase-mode):not(.rw-dedicated-puzzle){display:block!important;padding:0!important;background:#efe1c7!important}
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden])>.rw-shell{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;border-radius:0!important;container-type:size}
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden])>.rw-shell>.rw-surface{position:absolute!important;top:50%!important;left:50%!important;transform:translate(-50%,-50%)!important;width:max(100cqw,calc(100cqh * var(--rw-map-width-ratio,.5625)))!important;height:auto!important;aspect-ratio:var(--rw-map-ratio,9/16)!important;max-width:none!important;max-height:none!important}
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden])>.rw-head{position:absolute!important;top:max(8px,env(safe-area-inset-top))!important;left:8px!important;right:8px!important;z-index:5!important;width:auto!important;padding:0 76px 0 0!important;pointer-events:none}
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-head .rw-brand{background:#fff6e4eb!important;box-shadow:0 2px 10px #54412633!important;border-radius:10px;pointer-events:auto}
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact)>.rw-head>button{pointer-events:auto}
 #stage .rw-world:is(.rw-atlas-mode,.rw-region-compact):not([hidden])>.rw-fit-rail:not([hidden]){position:absolute!important;top:auto!important;bottom:max(8px,env(safe-area-inset-bottom))!important;left:8px!important;right:8px!important;width:auto!important;height:auto!important;max-height:29dvh!important;z-index:5!important;border-radius:12px!important;background:#fff9eeeb!important;box-shadow:0 2px 10px #54412633!important}
}

@media (orientation:portrait) and (max-width:700px){
 #stage .rw-world.rw-atlas-mode>.rw-atlas-rail:has(.rw-atlas-menu:not([open])){display:block!important}
 #stage .rw-world.rw-atlas-mode>.rw-atlas-rail .rw-atlas-menu>summary{display:block!important;min-height:44px;cursor:pointer}
 #stage .library-reveal-stage[data-native-portrait="true"] .library-reveal-painting{object-fit:cover!important;object-position:center!important;transform:none!important}
 #stage .cbcp-stage[data-native-portrait="true"] .cbcp-art-stack{inset:0!important}
 #stage .cbcp-stage[data-native-portrait="true"] .cbcp-art{object-fit:cover!important;object-position:center!important;transform:none!important}
 #stage .cbcp-stage[data-native-portrait="true"]::before{display:none!important}
}

/* Native scene board fills its playfield; the control drawer remains outside the hit area. */
@media (orientation:portrait) and (max-width:700px){
 #stage .rw-world.rw-native-puzzle:not([hidden]){background:var(--rw-puzzle-art) center/cover no-repeat!important;--rw-game-controls:38%}
 #stage .rw-world.rw-native-puzzle:not([hidden])>.rw-shell{background:transparent!important;border-radius:0!important}
 #stage .rw-world.rw-native-puzzle:not([hidden])>.rw-shell>.rw-surface{inset:0!important;top:0!important;left:0!important;transform:none!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;aspect-ratio:auto!important}
 #stage .rw-world.rw-native-puzzle>.rw-dedicated-rail{background:#fff6e9f5!important}
}

@media (orientation:portrait) and (max-width:700px){
 #stage .rw-world[data-ceremony="harbor"]:not([hidden])>.rw-shell{inset:0!important;width:100%!important;height:100%!important;background:transparent!important}
 #stage .rw-world[data-ceremony="harbor"]:not([hidden])>.rw-shell>.rw-surface{inset:0!important;top:0!important;left:0!important;transform:none!important;width:100%!important;height:100%!important;aspect-ratio:auto!important;max-width:none!important;max-height:none!important}
 #stage .rw-world[data-ceremony="harbor"]>.rw-fit-rail{display:none!important}
 #stage #cb-player-first-intro{background:#fff8eb!important;color:#352b20!important;padding:10px!important;width:min(94%,440px)!important;bottom:max(12px,env(safe-area-inset-bottom))!important;box-shadow:0 4px 18px #523a2833!important}
 #stage #cb-player-first-intro>div{margin:0!important;background:transparent!important;border:0!important;padding:0!important;gap:8px!important;box-shadow:none!important}
 #stage #cb-player-first-intro h2{font-size:clamp(18px,5vw,22px)!important}
 #stage #cb-player-first-intro p{font-size:14px!important;line-height:1.35!important;color:#352b20!important} #stage #cb-player-first-intro button{min-height:44px!important;font-size:14px!important} #stage #cb-player-first-intro button img{width:26px!important;height:28px!important}
 #stage .res-ending-title>img{inset:0!important;width:100%!important;height:100%!important;object-fit:cover!important;object-position:center!important}
}

/* The native portrait painting is the containing block, not the old grid row. */
@media (orientation:portrait) and (max-width:700px){
 #stage #intro.cb-rpg-intro:not(.hide){position:absolute!important;inset:0!important;width:100%!important;height:100%!important;box-sizing:border-box!important;overflow:hidden!important;display:block!important;padding:0!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;min-height:0!important;max-height:none!important;max-width:none!important;margin:0!important;padding:0!important;transform:none!important;display:block!important;box-sizing:border-box!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-brand{position:absolute!important;inset:max(3%,env(safe-area-inset-top,0px)) 0 auto!important;margin:0!important;transform:none!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-titleblock{position:absolute!important;inset:max(8%,calc(env(safe-area-inset-top,0px) + 24px)) 6% auto!important;width:auto!important;height:auto!important;min-height:0!important;max-height:none!important;margin:0!important;padding:0!important;transform:none!important;display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:flex-start!important;gap:6px!important;text-align:center!important}
 #stage #intro.cb-rpg-intro:not(.hide) .cb-intro-titleblock>#cb-title-name,#stage #intro.cb-rpg-intro:not(.hide) .cb-intro-titleblock>.cb-intro-tagline{position:static!important;inset:auto!important;transform:none!important;margin:0!important;max-width:100%!important;width:auto!important;height:auto!important;text-align:center!important}
 #stage #intro.cb-rpg-intro:not(.hide) .cb-intro-titleblock>#cb-title-name{font-size:clamp(26px,8.3vw,44px)!important;line-height:1.1!important;white-space:normal!important;text-wrap:balance}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-actions{position:absolute!important;inset:auto 6% max(3%,calc(env(safe-area-inset-bottom,0px) + 12px))!important;transform:none!important;margin:0!important;width:auto!important;max-width:none!important;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-actions>button{width:100%!important;max-width:none!important;margin:0!important;min-height:48px!important;min-width:0!important;white-space:normal!important;overflow-wrap:anywhere!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-actions>button[hidden]{display:none!important}
}


@media(orientation:portrait) and (max-width:700px){#stage #intro.cb-rpg-intro:not(.hide) .cb-intro-titleblock>#cb-title-name{display:block!important;visibility:visible!important;opacity:1!important;color:#58442d!important} #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-actions>button{box-sizing:border-box!important;min-width:0!important}}

#stage .rw-world.rw-festival-story:not([hidden]){display:block!important;padding:0!important;background:#402e27!important;overflow:hidden!important}
#stage .rw-world.rw-festival-story>.rw-shell{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;min-height:0!important;max-height:none!important;border-radius:0!important;container-type:size}
#stage .rw-world.rw-festival-story>.rw-shell>.rw-surface{position:absolute!important;inset:auto!important;top:50%!important;left:50%!important;transform:translate(-50%,-50%)!important;width:min(100cqw,calc(100cqh * 1.77777778))!important;height:auto!important;max-width:100%!important;max-height:100%!important;aspect-ratio:16/9!important;touch-action:none}
#stage .rw-world.rw-festival-story>.rw-head{position:absolute!important;top:4px!important;left:8px!important;right:auto!important;z-index:4!important;max-width:55%!important;pointer-events:none}
#stage .rw-world.rw-festival-story>.rw-head button{display:none!important}
#stage .rw-world .rw-festival-card{position:absolute;z-index:6;bottom:max(10px,env(safe-area-inset-bottom,0px));left:50%;transform:translateX(-50%);width:min(94%,620px);box-sizing:border-box;padding:10px 14px;border:1px solid #d4b480;border-radius:14px;background:#fff5e6f5;color:#604a37;box-shadow:0 3px 18px #39291d55;text-align:center}
#stage .rw-world .rw-festival-title{display:block;font-size:clamp(15px,2vw,20px);line-height:1.25}
#stage .rw-world .rw-festival-line{margin:5px 0;font-size:clamp(13px,1.5vw,16px);line-height:1.35}
#stage .rw-world .rw-festival-hint{margin:3px 0 7px;font-size:12px;line-height:1.25;color:#715b46}
#stage .rw-world .rw-festival-card>.rw-puzzle-controls{position:static!important;display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr));width:auto!important;height:auto!important;max-height:none!important;overflow:visible!important;gap:5px!important;margin:0!important;padding:0!important;background:transparent!important}
#stage .rw-world .rw-festival-card button{min-height:44px!important;white-space:normal!important;margin:0!important}
#stage .rw-world .rw-festival-card button[aria-pressed=true]{background:#f0d3a0!important;border:2px solid #9e6c36!important}
#stage .rw-world .rw-festival-card .rw-festival-finish{grid-column:1/-1;background:#916039!important;color:#fff8e9!important;font-weight:800!important}
@media (orientation:portrait) and (max-width:700px){
 #stage .rw-world.rw-festival-story>.rw-shell>.rw-surface{inset:0!important;width:100%!important;height:100%!important;aspect-ratio:auto!important;transform:none!important}
 #stage .rw-world .rw-next-cue{bottom:max(66px,env(safe-area-inset-bottom,0px))!important}
}
@media (orientation:landscape) and (max-height:480px){
 #stage .rw-world .rw-festival-card{width:min(60%,540px);left:auto;right:8px;transform:none;bottom:8px;padding:7px 10px}
 #stage .rw-world .rw-festival-hint{margin:2px 0}
}

/* Reachable bridge landings are obvious; wrong choices remain harmless and explain why. */
#stage .rw-world .rw-puzzle-controls button[data-path-available=true]{background:#e7f1d8!important;border:2px solid #759467!important;color:#365b36!important;font-weight:800!important}
#stage .rw-world .rw-puzzle-controls button[data-path-available=false]{opacity:.54!important}

#stage .rw-world .rw-next-reason{display:block;font-size:clamp(11px,1.4vw,14px);font-weight:500;line-height:1.25;margin-bottom:3px;color:#705a40}
#stage .rw-world .rw-scene-motive{font-size:12px;line-height:1.3;color:#735537;margin:3px 0}
@media (orientation:landscape) and (max-height:480px){#stage .rw-world .rw-scene-motive{font-size:11px;margin:2px 0}#stage .rw-world .rw-next-cue{max-width:65%}}

/* Restoration is a payoff scene, not a second task screen. */
#stage .rw-world.rw-story-ceremony:not([hidden]){display:block!important;padding:0!important;overflow:hidden!important;background:#342e2b!important}
#stage .rw-world.rw-story-ceremony>.rw-shell{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;border-radius:0!important;container-type:size}
#stage .rw-world.rw-story-ceremony>.rw-shell>.rw-surface{position:absolute!important;inset:auto!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;width:min(100cqw,calc(100cqh * 1.77777778))!important;height:auto!important;max-width:100%!important;max-height:100%!important;aspect-ratio:16/9!important}
#stage .rw-world .rw-ceremony-caption{position:absolute;z-index:6;left:50%;bottom:max(12px,env(safe-area-inset-bottom,0px));transform:translateX(-50%);max-width:90%;width:max-content;box-sizing:border-box;border-radius:12px;padding:9px 18px;background:#30251dd9;color:#fff3d7;text-align:center;pointer-events:none;box-shadow:0 3px 16px #20160e44}
#stage .rw-world .rw-ceremony-caption strong,#stage .rw-world .rw-ceremony-caption span{display:block;line-height:1.35}
#stage .rw-world .rw-ceremony-caption strong{font-size:clamp(15px,2vw,20px)}
#stage .rw-world .rw-ceremony-caption span{font-size:clamp(12px,1.5vw,15px)}
@media(orientation:portrait) and (max-width:700px){#stage .rw-world.rw-story-ceremony[data-ceremony="harbor"]>.rw-shell>.rw-surface{inset:0!important;transform:none!important;width:100%!important;height:100%!important;aspect-ratio:auto!important}}

/* Story beats use a single painting layer, not a second copy of either actor. */
#stage .res-host .res-emotional-beat{font-size:clamp(11px,1.25vw,14px);line-height:1.35;color:#d7bc86;margin:0 0 7px}
#stage .res-host.res-emotional-art{isolation:isolate;overflow:hidden;background:#382e36!important}
#stage .res-host.res-emotional-art::before,#stage .res-host.res-emotional-art::after{display:none!important}
#stage .res-host .res-emotional-painting{position:absolute;inset:0;width:100%;height:calc(100% - 100px);object-fit:contain;object-position:center;z-index:-1;pointer-events:none}
#stage .res-host.res-emotional-art .res-dialogue{position:relative;z-index:1;grid-template-columns:1fr!important;width:min(930px,100%);max-height:48%;overflow:auto}
#stage .res-host.res-emotional-art .res-portrait{display:none!important}
@media(orientation:portrait) and (max-width:700px){#stage .res-host.res-emotional-art .res-emotional-painting{height:66%;top:4%}#stage .res-host.res-emotional-art .res-dialogue{max-height:48%}}

/* A pause is part of the performance, not a new click gate. */
#stage .res-host .res-dialogue[data-story-mood="quiet"] .res-body{border-color:#9e91af;box-shadow:0 10px 32px #1b142955;transition:box-shadow .35s,border-color .35s}
#stage .res-host .res-dialogue[data-story-mood="warm"] .res-body{border-color:#d8b784}
#stage .res-host .res-dialogue[data-story-mood="bright"] .res-body{border-color:#e0c68d}
@media(prefers-reduced-motion:reduce){#stage .res-host .res-body{transition:none!important}}

/* The native portrait painting is the containing block, not the old grid row. */
@media (orientation:portrait) and (max-width:700px){
 #stage #intro.cb-rpg-intro:not(.hide){position:absolute!important;inset:0!important;width:100%!important;height:100%!important;box-sizing:border-box!important;overflow:hidden!important;display:block!important;padding:0!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;min-height:0!important;max-height:none!important;max-width:none!important;margin:0!important;padding:0!important;transform:none!important;display:block!important;box-sizing:border-box!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-brand{position:absolute!important;inset:max(3%,env(safe-area-inset-top,0px)) 0 auto!important;margin:0!important;transform:none!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-titleblock{position:absolute!important;inset:max(8%,calc(env(safe-area-inset-top,0px) + 24px)) 6% auto!important;width:auto!important;height:auto!important;min-height:0!important;max-height:none!important;margin:0!important;padding:0!important;transform:none!important;display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:flex-start!important;gap:6px!important;text-align:center!important}
 #stage #intro.cb-rpg-intro:not(.hide) .cb-intro-titleblock>#cb-title-name,#stage #intro.cb-rpg-intro:not(.hide) .cb-intro-titleblock>.cb-intro-tagline{position:static!important;inset:auto!important;transform:none!important;margin:0!important;max-width:100%!important;width:auto!important;height:auto!important;text-align:center!important}
 #stage #intro.cb-rpg-intro:not(.hide) .cb-intro-titleblock>#cb-title-name{font-size:clamp(26px,8.3vw,44px)!important;line-height:1.1!important;white-space:normal!important;text-wrap:balance}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-actions{position:absolute!important;inset:auto 6% max(3%,calc(env(safe-area-inset-bottom,0px) + 12px))!important;transform:none!important;margin:0!important;width:auto!important;max-width:none!important;display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:8px!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-actions>button{width:100%!important;max-width:none!important;margin:0!important;min-height:48px!important}
 #stage #intro.cb-rpg-intro:not(.hide)>.cb-title-content>.cb-intro-actions>button[hidden]{display:none!important}
}


/* Native portrait story plates: keep post-combat/ceremony dialogue full bleed without altering desktop compositions. */
@media (orientation:portrait) and (max-width:700px){
 #stage .res-host:is([data-scene="harbor:H-04"],[data-scene="harbor:H-05"])::before{background-size:cover!important;background-position:center!important;background-repeat:no-repeat!important}
 #stage .res-host .res-skip-top{right:max(12px,env(safe-area-inset-right,0px))!important}
}


/* Shared portrait minigame layout: content-sized controls, reserved interactive area.
   Do not let legacy landscape grid, fixed-height rails or floating cards cover it. */
@media (orientation:portrait) and (max-width:700px){
 #stage .rw-world:is(.rw-dedicated-puzzle,.rw-festival-story,.rw-chase-mode):not([hidden]){
  display:grid!important;grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:56px minmax(0,1fr) auto!important;gap:0!important;
  background:var(--rw-puzzle-art,none) center/cover no-repeat!important;
  padding:0 0 env(safe-area-inset-bottom,0px)!important;box-sizing:border-box!important;
 }
 #stage .rw-world:is(.rw-dedicated-puzzle,.rw-festival-story,.rw-chase-mode):not([hidden])>.rw-shell{
  grid-area:2/1/3/2!important;position:relative!important;inset:auto!important;
  width:100%!important;height:100%!important;min-width:0!important;min-height:0!important;
  margin:0!important;background:transparent!important;border-radius:0!important;
 }
 #stage .rw-world:is(.rw-native-puzzle,.rw-chase-mode):is(.rw-dedicated-puzzle,.rw-festival-story,.rw-chase-mode):not([hidden])>.rw-shell>.rw-surface{
  inset:0!important;top:0!important;left:0!important;transform:none!important;width:100%!important;height:100%!important;
  max-width:none!important;max-height:none!important;aspect-ratio:auto!important;
 }
 #stage .rw-world.rw-dedicated-puzzle:not([hidden])>.rw-fit-rail.rw-dedicated-rail,
 #stage .rw-world.rw-festival-story:not([hidden])>.rw-festival-card,
 #stage .rw-world.rw-chase-mode:not([hidden])>.rw-chase-bar{
  grid-area:3/1/4/2!important;position:relative!important;inset:auto!important;transform:none!important;
  width:auto!important;height:auto!important;min-height:0!important;max-width:none!important;
  max-height:42dvh!important;margin:4px 6px 6px!important;padding:0!important;
  gap:4px!important;overflow:auto!important;box-sizing:border-box!important;
  background:transparent!important;border:0!important;box-shadow:none!important;
 }
 #stage .rw-world.rw-dedicated-puzzle .rw-minigame-goal{
  display:grid!important;grid-template-columns:minmax(0,1fr) auto;gap:3px 5px!important;align-items:center!important;
  padding:4px 7px!important;border-radius:9px;background:#fff7e8ed;color:#493e2b
 }
 #stage .rw-world.rw-dedicated-puzzle .rw-minigame-title{font-size:13px!important;line-height:1.2!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-minigame-goal>:not(.rw-minigame-title):not(.rw-minigame-leave){grid-column:1/-1}
 #stage .rw-world.rw-dedicated-puzzle :is(.rw-minigame-hint,.rw-minigame-progress,.rw-notice){font-size:12px!important;line-height:1.3!important;margin:0!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-minigame-goal>.rw-minigame-leave{grid-column:2;grid-row:1;min-height:44px!important;padding:2px 6px!important;font-size:11px!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-minigame-goal>.rw-scene-motive{display:none!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-dedicated-rail .rw-puzzle-controls{
  display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:4px!important;
  width:100%!important;align-content:start!important
 }
 #stage .rw-world.rw-dedicated-puzzle .rw-puzzle-controls>button{min-height:44px!important;width:100%!important;margin:0!important;padding:4px!important;box-shadow:none!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-puzzle-controls> :not(button):not(.rw-quality-cards){
  grid-column:1/-1!important;background:#fff7e8ed;color:#493e2b!important;padding:4px 7px!important;
  border-radius:8px;font-size:12px!important;line-height:1.25!important;margin:0!important;min-height:0!important;overflow-wrap:anywhere
 }
 #stage .rw-world.rw-dedicated-puzzle .rw-quality-cards{gap:4px!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-quality-card{min-height:44px!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-quality-prop{height:clamp(30px,6dvh,52px)!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-active-flight>button[data-sky-land]{grid-column:1/-1!important}
 #stage .rw-world.rw-dedicated-puzzle .rw-puzzle-controls>button:only-of-type{grid-column:1/-1}
 #stage .rw-world.rw-festival-story:not([hidden])>.rw-festival-card{padding:6px!important;background:#fff7e8ed!important}
 #stage .rw-world.rw-festival-story .rw-festival-title{font-size:13px!important}
 #stage .rw-world.rw-festival-story .rw-festival-line{font-size:13px!important;margin:3px 0!important}
 #stage .rw-world.rw-festival-story .rw-festival-hint{font-size:12px!important;margin:3px 0!important}
 #stage .rw-world.rw-chase-mode:not([hidden])>.rw-chase-bar{display:grid!important;grid-template-columns:1fr 1fr;gap:4px!important}
 #stage .rw-world.rw-chase-mode .rw-chase-status{background:#fff7e8ed;border-radius:8px;padding:4px;font-size:12px!important}
}

/* Story ceremonies are independent of the preceding puzzle rail. */
#stage .rw-world.rw-story-ceremony:not([hidden])>.rw-ceremony-caption{display:block!important;visibility:visible!important;opacity:1!important;position:absolute!important;z-index:9!important;left:50%!important;bottom:max(12px,env(safe-area-inset-bottom,0px))!important;top:auto!important;transform:translateX(-50%)!important;max-width:90%!important;color:#fff3d7!important;background:#30251ded!important}

/* Native mobile story and sanctuary compositions: never reuse a 16:9 plate after combat. */
@media (orientation:portrait) and (max-width:700px){
 #stage .res-host:is([data-scene^="finale:"],[data-scene^="epilogue:"]):not(.res-library-reveal):not(.res-emotional-art){isolation:isolate;background:#192e36;inset:0!important;width:100%!important;height:100%!important;box-sizing:border-box}
 #stage .res-host:is([data-scene^="finale:"],[data-scene^="epilogue:"]):not(.res-library-reveal):not(.res-emotional-art)::before{content:"";position:absolute;inset:0;z-index:-2;pointer-events:none;background-position:center!important;background-size:cover!important;background-repeat:no-repeat!important}
 #stage .res-host[data-scene^="finale:"]::before{background-image:url("../assets/mobile-portrait/battle-finale.webp")!important}
 #stage .res-host[data-scene="finale:B-04"]::before{background-image:url("../assets/mobile-portrait/story-b04-reunion.webp")!important}
 #stage .res-host[data-scene^="epilogue:"]::before{background-image:url("../assets/mobile-portrait/story-e03-garden.webp")!important}
 #stage .rw-world.rw-story-ceremony:not([hidden])>.rw-shell>.rw-surface{inset:0!important;top:0!important;left:0!important;transform:none!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;aspect-ratio:auto!important}
}

/* Rotation-safe minigame geometry. Reserve a real playfield even during the
   frame in which the runtime replaces its landscape/native canvas. */
@media (orientation:portrait) and (max-width:700px){
 #stage .rw-world.rw-dedicated-puzzle:not([hidden]){
  display:grid!important;grid-template-columns:minmax(0,1fr)!important;
  grid-template-rows:56px minmax(0,1fr) minmax(0,auto)!important;
  padding:0 0 env(safe-area-inset-bottom,0px)!important;gap:0!important;
 }
 #stage .rw-world.rw-dedicated-puzzle:not([hidden])>.rw-shell{
  grid-area:2/1/3/2!important;position:relative!important;inset:auto!important;
  width:100%!important;height:100%!important;min-width:0!important;min-height:0!important;
  max-width:none!important;max-height:none!important;margin:0!important;
 }
 #stage .rw-world.rw-dedicated-puzzle:not([hidden])>.rw-shell>.rw-surface{
  position:absolute!important;inset:0!important;transform:none!important;
  width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;aspect-ratio:auto!important;
 }
 #stage .rw-world.rw-dedicated-puzzle:not([hidden])>.rw-fit-rail.rw-dedicated-rail{
  grid-area:3/1/4/2!important;position:relative!important;inset:auto!important;
  width:auto!important;height:auto!important;min-height:0!important;
  max-height:40dvh!important;margin:4px 6px 6px!important;overflow:auto!important;
 }
}

/* Starbell manual combat: stable left thumb movement, independent right thumb actions.
   The full-width portrait grid remains available in automatic mode only. */
#stage #battle-ui.on.touch-manual .move-bar{
 position:absolute!important;left:auto!important;right:max(8px,env(safe-area-inset-right,0px))!important;
 bottom:max(12px,env(safe-area-inset-bottom,0px))!important;top:auto!important;transform:none!important;
 width:auto!important;max-width:58%!important;display:grid!important;
 grid-template-columns:repeat(3,clamp(44px,14vw,58px))!important;
 grid-template-rows:repeat(2,clamp(44px,14vw,58px))!important;
 gap:5px!important;justify-content:end!important;align-items:stretch!important;padding:0!important;
 pointer-events:auto!important;z-index:24;
}
#stage #battle-ui.on.touch-manual .move-bar .move{
 width:100%!important;height:100%!important;min-width:0!important;min-height:44px!important;
 padding:3px!important;box-sizing:border-box!important;touch-action:manipulation;
 border-radius:16px!important;overflow:hidden;
}
#stage #battle-ui.on.touch-manual #mv-q{grid-area:1/1}
#stage #battle-ui.on.touch-manual #mv-e{grid-area:1/2}
#stage #battle-ui.on.touch-manual #mv-basic{grid-area:1/3}
#stage #battle-ui.on.touch-manual #mv-lock{grid-area:2/1}
#stage #battle-ui.on.touch-manual #mv-dodge{grid-area:2/2}
#stage #battle-ui.on.touch-manual #ult-btn{grid-area:2/3}
#stage #battle-ui.on.touch-manual #battle-touch-joystick{
 position:absolute!important;display:grid!important;place-items:center!important;
 left:max(12px,env(safe-area-inset-left,0px))!important;right:auto!important;top:auto!important;
 bottom:max(22px,calc(env(safe-area-inset-bottom,0px) + 12px))!important;
 width:clamp(82px,27vw,114px)!important;height:clamp(82px,27vw,114px)!important;
 transform:none!important;pointer-events:none!important;z-index:23;
}
#stage #battle-ui.on.touch-manual #duo-burst:not([hidden]){
 top:auto!important;left:auto!important;right:max(8px,env(safe-area-inset-right,0px))!important;
 bottom:calc(clamp(44px,14vw,58px)*2 + 24px + env(safe-area-inset-bottom,0px))!important;
 transform:none!important;max-width:56%!important;min-height:44px!important;
}
@media(orientation:landscape) and (max-height:500px){
 #stage #battle-ui.on.touch-manual .move-bar{grid-template-columns:repeat(3,48px)!important;grid-template-rows:repeat(2,48px)!important}
 #stage #battle-ui.on.touch-manual #battle-touch-joystick{width:88px!important;height:88px!important}
 #stage #battle-ui.on.touch-manual #duo-burst:not([hidden]){bottom:calc(120px + env(safe-area-inset-bottom,0px))!important}
}

/* Regional dialogue shares the actual exploration camera at every aspect ratio.
   Dedicated library/illustrated story scenes and finale/ending art stay separate. */
#stage .res-host:is([data-scene^="harbor:"],[data-scene^="forest:"],[data-scene^="forge:"],[data-scene^="sky:"],[data-scene^="library:"],[data-scene^="starfall:"]):not(.res-library-reveal):not(.res-emotional-art){background:linear-gradient(0deg,#49362220,transparent 42%)!important;backdrop-filter:none!important;}
#stage .res-host:is([data-scene^="harbor:"],[data-scene^="forest:"],[data-scene^="forge:"],[data-scene^="sky:"],[data-scene^="library:"],[data-scene^="starfall:"]):not(.res-library-reveal):not(.res-emotional-art)::before,#stage .res-host:is([data-scene^="harbor:"],[data-scene^="forest:"],[data-scene^="forge:"],[data-scene^="sky:"],[data-scene^="library:"],[data-scene^="starfall:"]):not(.res-library-reveal):not(.res-emotional-art)::after{content:none!important;display:none!important;background:none!important;animation:none!important;}

/* One map actor layer; speaker art remains compact, never a second full-size cat. */
#stage:has(.res-dialogue[aria-modal=true]) :is(.sg-discovery,.sg-prologue-guide,.rw-fit-rail,.rw-controls,.rw-heading){visibility:hidden!important;pointer-events:none!important}
@media (orientation:portrait) and (max-width:700px){
 #stage .res-host:not(.res-library-reveal):not(.res-emotional-art) .res-dialogue .res-portrait:not([hidden]){height:clamp(65px,12dvh,100px)!important;max-height:12dvh!important;width:auto!important;object-fit:contain!important}
}
/* Touch actions stay on the right even with smart battle enabled. */
#stage #battle-ui.on.touch-battle .move-bar{left:auto!important;right:max(8px,env(safe-area-inset-right,0px))!important;bottom:max(12px,env(safe-area-inset-bottom,0px))!important;transform:none!important;width:auto!important;max-width:58%!important;display:grid!important;grid-template-columns:repeat(3,clamp(44px,14vw,58px))!important;grid-template-rows:repeat(2,clamp(44px,14vw,58px))!important;gap:5px!important;padding:0!important;justify-content:end!important}
#stage #battle-ui.on.touch-battle .move-bar .move{width:100%!important;height:100%!important;min-width:0!important;min-height:44px!important;padding:3px!important}
#stage #battle-ui.on.touch-battle #mv-q{grid-area:1/1}#stage #battle-ui.on.touch-battle #mv-e{grid-area:1/2}#stage #battle-ui.on.touch-battle #mv-basic{grid-area:1/3}#stage #battle-ui.on.touch-battle #mv-lock{grid-area:2/1}#stage #battle-ui.on.touch-battle #mv-dodge{grid-area:2/2}#stage #battle-ui.on.touch-battle #ult-btn{grid-area:2/3}
#stage #battle-ui.on.touch-battle #duo-burst:not([hidden]){top:auto!important;left:auto!important;right:8px!important;bottom:calc(clamp(44px,14vw,58px)*2 + 24px + env(safe-area-inset-bottom,0px))!important;transform:none!important;max-width:56%!important}
#stage #battle-ui #btn-debug[hidden]{display:none!important}
@media(orientation:landscape) and (max-height:500px){#stage #battle-ui.on.touch-battle .move-bar{grid-template-columns:repeat(3,48px)!important;grid-template-rows:repeat(2,48px)!important}#stage #battle-ui.on.touch-battle #duo-burst:not([hidden]){bottom:calc(120px + env(safe-area-inset-bottom,0px))!important}}

/* Landscape shadow theater: the stage is not underneath a giant dialogue card. */
@media(orientation:landscape){
 #stage .rw-world.rw-festival-story:not([hidden]){--rw-story-panel:clamp(220px,26%,320px);background:#f7ecdd!important}
 #stage .rw-world.rw-festival-story:not([hidden])>.rw-shell{inset:52px calc(var(--rw-story-panel) + 16px) 8px 8px!important;width:auto!important;height:auto!important;border-radius:14px!important;background:var(--rw-puzzle-art,none) center/cover no-repeat!important;overflow:hidden!important}
 #stage .rw-world.rw-festival-story:not([hidden])>.rw-shell>.rw-surface{inset:auto!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;width:min(100cqw,calc(100cqh * var(--rw-map-width-ratio,1.77777778)))!important;height:auto!important;aspect-ratio:var(--rw-map-ratio,16/9)!important}
 #stage .rw-world.rw-festival-story:not([hidden])>.rw-festival-card{top:52px!important;bottom:auto!important;right:8px!important;left:auto!important;transform:none!important;width:var(--rw-story-panel)!important;max-height:calc(100% - 60px);overflow:auto;text-align:left;box-shadow:none!important}
 #stage .rw-world.rw-festival-story .rw-festival-card>.rw-puzzle-controls{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}

#stage .res-ending-film [hidden]{display:none!important}#stage .res-ending-film .res-ending-skip{position:absolute;right:12px;top:12px;z-index:4;min-height:44px;padding:8px 14px;border:1px solid #b7986b;background:#fff5e9ed;color:#604a37;border-radius:10px}#stage .res-ending-film .res-ending-caption{position:absolute;bottom:max(18px,env(safe-area-inset-bottom,0px));left:50%;transform:translateX(-50%);width:max-content;max-width:88%;padding:10px 18px;border-radius:12px;color:#fff9e9;background:#332b28db;text-align:center;font-size:clamp(16px,2.8vmin,23px);z-index:3}
#stage #battle-ui.on.touch-battle .move-bar .move{touch-action:none!important}#stage #battle-ui.on.touch-battle .move-bar .mv-k{font-size:10px!important}#stage #battle-ui.on.touch-battle #duo-burst{touch-action:none!important}#stage #battle-ui.on.touch-battle .cb-region-combat button{touch-action:none!important}#stage .cb-save-picker [data-slot-language],#stage .cb-save-picker .cb-picker-language{display:none!important}


/* Single main quest entry, above the exploration viewport. */
#stage .rw-world>.rw-head>button[data-next-scene]{font-size:clamp(14px,2.1vmin,19px)!important;min-height:44px!important;line-height:1.25!important;text-align:left!important;max-width:min(72vw,440px)!important;padding:7px 11px!important}
#stage .rw-world>.rw-head>button[data-next-scene]::after{content:" ›";font-weight:800;color:#8b6734}
#stage .rw-world>.rw-head>button[data-walking=true]::after{content:""}

/* One small gold quest button, no duplicated objective or bottom overlay. */
#stage .rw-world>.rw-head>button[data-next-scene]{display:block!important;box-sizing:border-box!important;width:max-content!important;max-width:min(68vw,340px)!important;min-height:44px!important;max-height:58px!important;overflow:hidden!important;margin:4px 0 0!important;padding:7px 11px!important;border:1px solid #8a6633!important;border-left:4px solid #b78335!important;border-radius:9px!important;background:#fff0cdeF!important;color:#64421e!important;font-size:clamp(14px,1.85vmin,17px)!important;line-height:1.25!important;font-weight:750!important;box-shadow:0 2px 8px #392a2040!important;pointer-events:auto!important;text-align:left!important}
#stage .rw-world>.rw-head:has(>button[data-next-scene]) .rw-fit-summary{display:none!important}
#stage .rw-world>.rw-head:has(>button[data-next-scene]) .rw-brand{width:max-content!important;max-width:min(60vw,300px)!important;padding:4px 8px!important}
#stage .rw-world>.rw-head>button[data-next-scene][data-walking=true]{opacity:.83!important}
@media(orientation:landscape) and (max-height:500px){#stage .rw-world>.rw-head>button[data-next-scene]{max-width:min(48vw,320px)!important;min-height:44px!important;font-size:14px!important}}

#stage #cb-region-combat[data-phase=warning]{border-color:#b46f48!important}#stage #cb-region-combat[data-phase=warning]>span{color:#8b3e2b!important;font-weight:750!important}#stage #cb-region-combat[data-phase=opening]>span{color:#3d6a4e!important;font-weight:750!important}

/* A dialogue portrait is a speaker illustration, not a cat standing on the world painting. */
#stage:has(.res-host.is-visible:not([style*="display: none"]) .res-dialogue:not([hidden])) :is(.rw-head,.rw-fit-rail,.rw-floating-notice,.rw-region-toggle){visibility:hidden!important;pointer-events:none!important}
@media(orientation:portrait) and (max-width:700px){
 #stage .res-host:not(.res-library-reveal):not(.res-emotional-art):not(.res-homecoming):not(.rw-lookout-full) .res-dialogue:has(.res-portrait:not([hidden])):not(:has(.sky-lookout-view)){display:grid!important;grid-template-columns:68px minmax(0,1fr)!important;align-items:center!important;gap:8px!important;padding:8px!important;background:#fff8ebf7;border:1px solid #cbb38a;border-radius:14px;box-shadow:0 4px 16px #49362226;overflow:visible!important}
 #stage .res-host:not(.res-library-reveal):not(.res-emotional-art):not(.res-homecoming):not(.rw-lookout-full) .res-dialogue:not(:has(.sky-lookout-view)) .res-portrait:not([hidden]){width:68px!important;height:78px!important;max-height:none!important;background:#f5e8d5;border:1px solid #d8bf97;border-radius:10px;box-sizing:border-box;filter:none!important;animation:none!important;object-fit:contain!important;object-position:bottom center;justify-self:center}
 #stage .res-host:not(.res-library-reveal):not(.res-emotional-art):not(.res-homecoming):not(.rw-lookout-full) .res-dialogue:has(.res-portrait:not([hidden])):not(:has(.sky-lookout-view)) .res-body{padding:5px!important;background:transparent!important;border:0!important;box-shadow:none!important}
 #stage .res-host:not(.res-library-reveal):not(.res-emotional-art) .res-dialogue:has(.sky-lookout-view[data-pose="sit"]) {display:grid!important;grid-template-columns:minmax(0,1fr)!important}
}
#stage .res-ending-film>img{object-fit:contain!important;object-position:center!important}
#stage .res-ending-film>div:not([hidden]){min-width:min(88%,320px);box-shadow:0 6px 28px #49362226}
#stage .res-ending-film>div:not([hidden])>h2{margin:8px 0 6px!important;color:#60452e!important;letter-spacing:.035em!important;line-height:1.12!important;font-size:clamp(23px,5vw,40px)!important}
#stage .res-ending-film>div:not([hidden])>button{min-height:44px!important;padding:8px 18px!important;border:1px solid #9f8257!important;border-radius:10px!important;color:#4c3824!important;background:#f1dfb5!important;font:600 15px var(--cb-font-body,system-ui)!important;cursor:pointer}

/* Keep authored revelation art legible, and use a single compact speaker portrait. */
@media (orientation:portrait) and (max-width:700px){
 #stage .res-library-reveal .library-reveal-painting{filter:none!important}
 #stage .res-library-reveal .library-reveal-shade{background:linear-gradient(0deg,#182a3466 0%,transparent 25%)!important}
 #stage .res-host.res-library-reveal .res-dialogue:has(.res-portrait:not([hidden])){display:grid!important;grid-template-columns:68px minmax(0,1fr)!important;align-items:center!important;gap:8px!important;background:#fff8ebf7;border:1px solid #cbb38a;border-radius:14px;padding:8px!important;box-shadow:0 4px 16px #49362226}
 #stage .res-host.res-library-reveal .res-dialogue .res-portrait:not([hidden]){display:block!important;width:68px!important;height:78px!important;max-height:none!important;object-fit:contain!important;background:#f5e8d5;border:1px solid #d8bf97;border-radius:10px;filter:none!important;animation:none!important}
 #stage .res-host.res-library-reveal .res-dialogue:has(.res-portrait:not([hidden])) .res-body{padding:5px!important;background:transparent!important;border:0!important;box-shadow:none!important}
}

#stage .rw-world>.rw-head>button[data-next-scene]{max-height:none!important;overflow:visible!important;font-size:16px!important;line-height:1.4!important;white-space:normal!important}

/* Mirror gallery: the scene itself is the control surface. Assistance is optional. */
#stage .rw-world.rw-dedicated-puzzle.rw-mirror-direct:not([hidden]){--rw-game-controls:116px;display:grid!important;grid-template-rows:var(--rw-game-top) minmax(0,1fr) auto!important;grid-template-columns:minmax(0,1fr)!important;}
#stage .rw-world.rw-dedicated-puzzle.rw-mirror-direct:not([hidden])>.rw-shell{grid-area:2/1/3/2!important;position:relative!important;inset:auto!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;margin:0!important;min-height:0!important;}
#stage .rw-world.rw-dedicated-puzzle.rw-mirror-direct:not([hidden])>.rw-shell>.rw-surface{position:absolute!important;inset:0!important;transform:none!important;width:100%!important;height:100%!important;max-width:none!important;max-height:none!important;aspect-ratio:auto!important;}
#stage .rw-world.rw-dedicated-puzzle.rw-mirror-direct:not([hidden])>.rw-dedicated-rail{grid-area:3/1/4/2!important;position:relative!important;inset:auto!important;display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;align-items:start!important;width:auto!important;height:auto!important;max-height:32dvh!important;margin:4px 8px 8px!important;padding:6px 9px!important;overflow:auto!important;background:#fff7e9!important;gap:8px!important;}
#stage .rw-mirror-direct .rw-minigame-goal{padding:0!important;}#stage .rw-mirror-direct .rw-minigame-hint{display:none!important;}#stage .rw-mirror-direct .rw-mirror-assist summary{cursor:pointer;font-size:13px;min-height:36px;display:flex;align-items:center;}#stage .rw-mirror-direct .rw-mirror-assist[open]{min-width:min(260px,38vw);}#stage .rw-mirror-direct .rw-mirror-assist:not([open])>.rw-puzzle-controls{display:none!important;}
@media(orientation:portrait){#stage .rw-world.rw-dedicated-puzzle.rw-mirror-direct:not([hidden])>.rw-dedicated-rail{grid-template-columns:minmax(0,1fr)!important;}#stage .rw-mirror-direct .rw-mirror-assist[open]{min-width:0;}}

/* Full-stage lookout: the existing approved painting owns the scene. */
#stage .res-host.rw-lookout-full .res-dialogue{z-index:2!important;position:absolute!important;bottom:0!important;top:auto!important;left:0!important;right:0!important;max-height:45%!important;background:#202a39dc!important;border-radius:12px 12px 0 0!important;overflow:auto!important;}
#stage .res-host.rw-lookout-full .sky-lookout-view{position:absolute!important;inset:0!important;z-index:0!important;}#stage .res-host.rw-lookout-full .sky-lookout-painting{object-fit:cover!important;}
#stage .res-dialogue .res-controls:has(.res-visible-next){display:flex!important;justify-content:flex-end!important;}
#stage .res-dialogue .res-visible-next:not([hidden]){display:inline-flex!important;min-height:44px!important;padding:5px 18px!important;border:1px solid #e7c58c!important;background:#fff0d0!important;color:#453c38!important;border-radius:9px!important;align-items:center!important;}

@media(orientation:landscape){#stage .rw-world.rw-dedicated-puzzle.rw-mirror-direct:not([hidden])>.rw-shell>.rw-surface{inset:auto!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;width:min(100cqw,calc(100cqh * 1.77777778))!important;height:auto!important;aspect-ratio:16/9!important;max-width:100%!important;max-height:100%!important;}}

/* The direct minigame canvas is centered within the available viewport, never clipped by the obsolete side rail. */
#stage .rw-world.rw-dedicated-puzzle.rw-mirror-direct:not([hidden])>.rw-shell{container-type:size;overflow:hidden!important;box-sizing:border-box!important;}
@media(orientation:landscape){#stage .rw-world.rw-dedicated-puzzle.rw-mirror-direct:not([hidden])>.rw-shell>.rw-surface{inset:auto!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;width:min(100cqw,calc(100cqh * var(--rw-map-width-ratio,1.77777778)))!important;height:auto!important;aspect-ratio:var(--rw-map-ratio,16/9)!important;max-width:100%!important;max-height:100%!important;}}

/* Shared portrait card for all ordinary dialogue, including garden visits. */
@media(orientation:portrait) and (max-width:700px){
 #stage .res-host:not(.res-library-reveal):not(.res-emotional-art):not(.res-homecoming):not(.rw-lookout-full) .res-dialogue:has(.res-portrait:not([hidden])):not(:has(.sky-lookout-view)){box-sizing:border-box;max-height:56dvh!important;overflow:auto!important}
 #stage .res-host:not(.res-library-reveal):not(.res-emotional-art):not(.res-homecoming):not(.rw-lookout-full) .res-dialogue:not(:has(.sky-lookout-view)) .res-portrait:not([hidden]){display:block!important;flex:none!important;align-self:center!important}
 #stage #cb-traveler-encounter .cb-encounter-controls{justify-content:flex-end!important;flex-wrap:wrap!important}
 #stage #cb-traveler-encounter .cb-encounter-controls .cb-encounter-next{flex:0 0 auto!important;background:#fff0d0!important;border-color:#e7c58c!important;font-weight:600!important}
}

/* Tea illustration fills the stage; dialogue is a compact overlay. */
#stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]){
 display:grid!important;grid-template-rows:minmax(0,1fr) auto!important;grid-template-columns:minmax(0,1fr)!important;
 align-items:stretch!important;justify-items:stretch!important;gap:0!important;padding:0!important;overflow:hidden!important;background:#293144!important;
}
#stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]) .sky-lookout-view{
 position:relative!important;inset:auto!important;width:100%!important;height:100%!important;min-height:0!important;grid-row:1;grid-column:1;overflow:hidden!important;
}
#stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]) .res-dialogue{
 position:relative!important;inset:auto!important;width:100%!important;max-height:none!important;min-width:0!important;grid-row:2;grid-column:1;
 display:grid!important;grid-template-columns:minmax(0,1fr)!important;gap:0!important;padding:0!important;margin:0!important;border:0!important;
 border-radius:0!important;background:#fff7e8!important;overflow:visible!important;box-sizing:border-box!important;
}
#stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]) .res-dialogue .res-body{
 grid-column:1/-1;min-width:0!important;border:0!important;border-radius:0!important;box-shadow:none!important;padding:8px 14px!important;background:#fff7e8!important;
}
#stage .res-host.rw-lookout-full .res-controls:has(.res-visible-next:not([hidden])){margin-top:6px!important;justify-content:flex-end!important;}
#stage .res-host.rw-lookout-full .res-visible-next:not([hidden]){min-width:108px!important;font-size:15px!important;font-weight:700!important;justify-content:center!important;}
#stage .res-host.rw-lookout-full .res-choices:has(button){margin:6px 0 0!important;}
#stage .res-host.rw-lookout-full .res-choices button{min-height:44px!important;}
@media(orientation:landscape) and (max-height:520px){
 #stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]){grid-template-rows:minmax(0,1fr)!important;grid-template-columns:minmax(0,1.6fr) minmax(0,1fr)!important;}
 #stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]) .res-dialogue{grid-row:1;grid-column:2;align-self:end!important;max-height:100%!important;overflow:auto!important;}
}

/* Full-bleed authored art; transparent dialogue chrome does not resize the painting. */
#stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]){display:flex!important;position:absolute!important;inset:0!important;align-items:flex-end!important;justify-content:flex-end!important;background:transparent!important;padding:8px!important;}
#stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]) .sky-lookout-view{position:absolute!important;inset:0!important;width:100%!important;height:100%!important;}
#stage .res-host.rw-lookout-full:has(.sky-lookout-view[data-painting-ready="true"]) .res-dialogue{position:relative!important;z-index:3!important;width:min(100%,760px)!important;max-height:35%!important;overflow:auto!important;border-radius:12px!important;align-self:flex-end!important;}
#stage .res-host.rw-lookout-full .sky-lookout-painting,#stage .res-ending-film>img,#stage .res-host.res-library-reveal .library-reveal-painting,#stage .res-host .res-emotional-painting{object-fit:cover!important;object-position:center!important;}
#stage .res-host .res-emotional-painting{height:100%!important;}

/* The mural remains full bleed; its dialogue uses the same left portrait as all six regions. */
#stage .res-host[data-scene^="library:"] .res-dialogue:has(.res-portrait:not([hidden])) .res-body{grid-column:2!important;grid-row:1!important;min-width:0!important}
#stage .res-host[data-scene^="library:"] .res-dialogue:has(.res-portrait:not([hidden])) .res-portrait{grid-column:1!important;grid-row:1!important}

/* Compact visible actions on touch devices, retaining the left movement zone. */
#stage #battle-ui.on.touch-battle .move-bar{--sb-action-size:clamp(44px,14vw,58px);grid-template-columns:repeat(3,var(--sb-action-size))!important;grid-template-rows:repeat(2,var(--sb-action-size))!important;align-content:end!important;align-items:stretch!important}
#stage #battle-ui.on.touch-battle:not(.touch-manual) .move-bar:has(#mv-e[hidden]){grid-template-columns:repeat(2,var(--sb-action-size))!important}
#stage #battle-ui.on.touch-battle:not(.touch-manual) .move-bar:has(#mv-e[hidden]) #mv-q{grid-area:1/1!important}
#stage #battle-ui.on.touch-battle:not(.touch-manual) .move-bar:has(#mv-e[hidden]) #mv-basic{grid-area:1/2!important}
#stage #battle-ui.on.touch-battle:not(.touch-manual) .move-bar:has(#mv-e[hidden]) #mv-dodge{grid-area:2/1!important}
#stage #battle-ui.on.touch-battle:not(.touch-manual) .move-bar:has(#mv-e[hidden]) #ult-btn{grid-area:2/2!important}
#stage #battle-ui.on.touch-battle.touch-manual .move-bar:has(#mv-e[hidden]) #mv-q{grid-area:1/2!important}
#stage #battle-ui.on.touch-battle:not(.touch-manual) .move-bar #mv-lock,
#stage #battle-ui.on.touch-battle .move-bar .move[hidden]{display:none!important}
@media(orientation:landscape) and (max-height:500px){#stage #battle-ui.on.touch-battle .move-bar{--sb-action-size:48px}}
#stage .rw-world .rw-puzzle-controls[data-spatial=bridge] button[data-bridge-primary=true]{background:#ffdf94!important;border:2px solid #9a641f!important;color:#573509!important;font-weight:900!important;box-shadow:0 0 0 2px #fff2c9,0 3px 12px #6d461f55!important;min-height:44px!important}
#stage .rw-world .rw-puzzle-controls[data-spatial=bridge] button[data-bridge-primary=true]:not(:disabled){animation:sb-bridge-cue 1.8s ease-in-out infinite}
@keyframes sb-bridge-cue{50%{box-shadow:0 0 0 4px #ffd56a99,0 3px 12px #6d461f55}}
@media(prefers-reduced-motion:reduce){#stage .rw-world .rw-puzzle-controls[data-spatial=bridge] button[data-bridge-primary=true]{animation:none!important}}

/* Luna's duel uses the same enemy health meter as regional battles; the gold line marks the nonlethal win threshold. */
#stage #battle-ui .battle-enemy-track.sb-duel-health:not([hidden]){display:block!important;position:relative;height:10px!important;min-height:10px!important}
#stage #battle-ui .battle-enemy-track.sb-duel-health::after{content:none}

/* Portrait skill reference lives in the paused Controls dialog, not over combat.
   Suppress hover tooltips even on desktop browsers using a narrow viewport. */
@media(orientation:portrait) and (max-width:700px){
 #stage #battle-ui.on #battle-skill-tooltip{display:none!important}
 #stage #battle-ui.on .cb-finale-hud.cb-finale-details-open{
  max-height:calc(100% - var(--cb-rpg-hud-top,200px) - 194px - env(safe-area-inset-bottom,0px))!important;
 }
}

/* Native puzzle artwork must share the canvas crop across the header and controls. */
@media(orientation:portrait){#stage .rw-world.rw-native-puzzle.rw-dedicated-puzzle:not([hidden]){background-size:var(--rw-native-art-size,cover)!important;background-position:var(--rw-native-art-position,center)!important;}}
