/* =========================================================
   V148-A · STABILITY PASS
   Purpose: unblock play, stop cross-layout collisions, keep phone and desktop
   as distinct compositions. No new narrative content in this layer.
   ========================================================= */

:root{--v148-safe-top:max(10px,env(safe-area-inset-top));--v148-safe-bottom:max(10px,env(safe-area-inset-bottom))}

/* Defensive interaction floor. */
.chapter-day1 button,.chapter-day2 button,.chapter-day3 button,.chapter-day4 button,.v104-d3-scene button{
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
.chapter-day1 button:disabled,.chapter-day2 button:disabled,.chapter-day3 button:disabled,.chapter-day4 button:disabled,.v104-d3-scene button:disabled{
  cursor:not-allowed;
}

/* DAY 1 · only one layer of dinner UI at a time. */
.chapter-day1 .dish-tip{z-index:46!important}
.chapter-day1 .meal-farewell-choice{z-index:45!important}
.chapter-day1 .meal-breath{z-index:45!important}

/* DAY 1 · garden source is an optional sheet, never a second card over narration. */
.chapter-day1 .garden-source{z-index:48!important}
.chapter-day1 .garden-source[open]{box-shadow:0 18px 56px rgba(0,0,0,.34)!important}
.chapter-day1 .garden-scene:has(.garden-source[open]) .garden-whisper,
.chapter-day1 .garden-scene:has(.garden-source[open]) .garden-fact{
  opacity:.08!important;pointer-events:none!important;
}

/* DAY 1 · taxi receipts must never animate from outside the viewport. */
.chapter-day1 .v123-taxi-receipt{
  left:50%!important;right:auto!important;transform:translateX(-50%)!important;
  box-sizing:border-box!important;
}

/* DAY 2 · shrine: the action that advances the ritual must always be reachable. */
.chapter-day2.d2-prayer .d2-prayer-panel{
  display:flex!important;flex-direction:column!important;
}
.chapter-day2.d2-prayer .d2-prayer-action,
.chapter-day2.d2-prayer .d2-prayer-exit-stable{
  flex:0 0 auto!important;
}
.chapter-day2.d2-prayer .d2-prayer-exit-stable{
  position:sticky!important;bottom:0!important;z-index:8!important;
  margin-top:10px!important;background:#f4eddf!important;color:#15313a!important;
  box-shadow:0 -12px 24px rgba(4,22,29,.22)!important;
}
/* Historical delayed animations could leave the shrine action untappable after a state jump. */
.chapter-day2.d2-prayer .d2-prayer-action{
  opacity:1!important;pointer-events:auto!important;animation:none!important;
}

/* DAY 3 · a photo is a physical event. */
.v104-d3-scene .v104-photo-flash{animation-duration:.22s!important}

/* -------- PHONE COMPOSITION -------- */
@media(max-width:760px){
  /* Optional information opens as a lower sheet; it never lives across the top narration. */
  .chapter-day1 .garden-source{
    top:auto!important;right:10px!important;bottom:max(74px,calc(var(--v148-safe-bottom) + 62px))!important;left:10px!important;
    width:auto!important;max-height:42svh!important;overflow:auto!important;padding:11px 12px!important;
    border-radius:14px!important;background:rgba(5,28,39,.93)!important;
  }
  .chapter-day1 .garden-source:not([open]){left:auto!important;width:auto!important;bottom:max(72px,calc(var(--v148-safe-bottom) + 60px))!important;padding:7px 10px!important}

  /* Dinner detail stays above the safe edge and cannot coexist visually with the farewell layer. */
  .chapter-day1 .dish-tip{bottom:max(12px,var(--v148-safe-bottom))!important;max-height:44svh!important}
  .chapter-day1 .meal-farewell-choice,.chapter-day1 .meal-breath{bottom:max(12px,var(--v148-safe-bottom))!important}

  /* Printed taxi paper: no transitional transform/clip on phone. */
  .chapter-day1 .v123-taxi-receipt{
    top:auto!important;bottom:max(84px,calc(var(--v148-safe-bottom) + 72px))!important;
    width:calc(100vw - 28px)!important;max-width:360px!important;max-height:44svh!important;overflow:auto!important;
    animation:v148ReceiptAppear .18s ease-out both!important;clip-path:none!important;
  }
  @keyframes v148ReceiptAppear{from{opacity:0;transform:translate(-50%,8px)}to{opacity:1;transform:translate(-50%,0)}}

  /* Shrine completion: panel scrolls internally, exit remains on screen. */
  .chapter-day2.d2-prayer .d2-prayer-panel{
    top:auto!important;bottom:max(10px,var(--v148-safe-bottom))!important;
    max-height:50svh!important;overflow:auto!important;overscroll-behavior:contain!important;
  }
  .chapter-day2.d2-prayer .d2-prayer-action{min-height:58px!important}
  .chapter-day2.d2-prayer .d2-prayer-exit-stable{min-height:52px!important;width:100%!important}

  /* General modal containment for the scenes repeatedly seen clipped on phones. */
  .chapter-day1 :is(.afterbath-card,.afterbath-culture,.taxi-address-panel,.taxi-greeting-v38,.taxi-ride-control),
  .chapter-day2 :is(.v86-shrine-discovery,.v79-tanaka-dialogue,.v78-return-panel),
  .v104-d3-scene :is(.v104-menu-object,.v104-bill-flow,.v104-cruise-ticket){
    max-width:calc(100vw - 20px)!important;box-sizing:border-box!important;
  }

  /* Prevent source/culture accordions from opening underneath fixed HUD elements. */
  .chapter-day1 details[open],.chapter-day2 details[open],.chapter-day3 details[open],.v104-d3-scene details[open]{scroll-margin-top:110px}
}

/* Very small Android widths. */
@media(max-width:380px){
  .chapter-day1 .v123-taxi-receipt{width:calc(100vw - 20px)!important}
  .chapter-day2.d2-prayer .d2-prayer-panel{left:8px!important;right:8px!important}
}

/* -------- DESKTOP COMPOSITION --------
   Desktop is not a stretched phone: information panels stay to one side and
   leave the world visible. */
@media(min-width:761px){
  .chapter-day1 .garden-source{
    top:clamp(120px,17vh,180px)!important;right:clamp(24px,4vw,70px)!important;left:auto!important;
    width:min(330px,26vw)!important;max-height:52vh!important;overflow:auto!important;
  }
  .chapter-day1 .garden-whisper{left:clamp(28px,5vw,78px)!important;right:auto!important;width:min(540px,42vw)!important}

  .chapter-day1 .dish-tip,.chapter-day1 .meal-farewell-choice,.chapter-day1 .meal-breath{
    right:clamp(28px,5vw,78px)!important;left:auto!important;width:min(480px,36vw)!important;
  }
  .chapter-day1 .v123-taxi-receipt{width:min(330px,26vw)!important}

  .chapter-day2.d2-prayer .d2-prayer-panel{
    left:clamp(28px,5vw,78px)!important;right:auto!important;bottom:clamp(28px,6vh,70px)!important;
    width:min(440px,34vw)!important;max-height:64vh!important;overflow:auto!important;
  }
  .chapter-day2.d2-prayer .d2-prayer-exit-stable{position:sticky!important}

  /* Day 3 keeps text off the center of the photography on desktop. */
  .v104-d3-scene .v104-whisper,.v104-d3-scene>.v104-dialogue,.v104-d3-scene .v104-dialogue-stack{
    max-width:min(500px,38vw)!important;
  }
  .v104-d3-scene .v104-menu-object{width:min(860px,68vw)!important;left:50%!important;right:auto!important;transform:translateX(-50%)!important}
  .v104-d3-scene .v104-bill-flow{width:min(760px,62vw)!important}
}
