/* v112 focused repair. Existing strong Singapore cards establish layout conventions.
   No changes to world map, physics, rewards, Guilin, or Sakura art/camera. */

/* The portrait follow canvas is the game; only the underlying 16:9 source is
   hidden once a complete portrait frame exists. No rotation message over play. */
@media (pointer:coarse) and (orientation:portrait) and (max-width:820px){
 body.amba-sakura-portrait-play #shell #ambaSakuraPortraitView{
  display:block!important;
  position:absolute!important;inset:0!important;
  width:100%!important;height:100%!important;
 }
 body.amba-sakura-portrait-play #shell .rotate-tip{display:none!important}
}

/* Singapore's approved retry card already separates art, copy and buttons.
   Reuse its structure for the problematic sprint and baton-completion cards. */
#singaporeRoot.sg-cinematic-active > :is(.sg-top,.sg-quest,.sg-mobile,.amba-mini-hud,.sg-hint){
 visibility:hidden!important;pointer-events:none!important;
}

/* The sprint painting is natively 1312:602. On portrait, match that stage ratio
   instead of fitting the painting into a tall purple letterbox. */
@media (orientation:portrait){
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-stage{
  height:auto!important;min-height:0!important;aspect-ratio:1312/602!important;
  background:#567394!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-stage .sg-scene-art{
  width:100%!important;height:100%!important;object-fit:cover!important;
  object-position:center!important;background:none!important;
 }
 /* The illustrated guardian greeting is also a wide painting, not a portrait.
    Let it fit naturally so Vibey and the Guardian are not cut off at the edges. */
 #singaporeRoot #sg-modal > .sg-modal-card.boss-intro .sg-stage{
  height:auto!important;min-height:0!important;aspect-ratio:1320/620!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.boss-intro .sg-stage .sg-scene-art{
  object-fit:contain!important;object-position:center!important;
 }
 /* Baton handover's full artwork is 1086px square. Keep the caption/CTA visible. */
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-stage{
  height:clamp(178px,31dvh,268px)!important;
  aspect-ratio:auto!important;min-height:0!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-v78-handover-panel{
  width:auto!important;height:95%!important;max-width:95%!important;
  object-fit:contain!important;left:50%!important;transform:translateX(-50%)!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-caption{
  padding:9px 13px 12px!important;
 }
}

@media (orientation:landscape){
 /* Singapore's landscape cards should follow the same side-by-side readability
    contract as the proven Guilin reward card: illustration at left, copy at
    right, with the CTA row still visible below. */
 #singaporeRoot #sg-modal > .sg-modal-card.country-start .sg-cinematic{
  display:grid!important;
  grid-template-columns:minmax(0,52%) minmax(0,48%)!important;
  align-items:stretch!important;
  height:auto!important;
  max-height:none!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.country-start .sg-stage{
  grid-column:1!important;grid-row:1!important;
  position:relative!important;height:clamp(134px,44dvh,220px)!important;
  min-height:0!important;aspect-ratio:auto!important;
  max-height:none!important;width:100%!important;
  overflow:hidden!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.country-start .sg-caption{
  grid-column:2!important;grid-row:1!important;
  display:flex!important;flex-direction:column!important;
  align-items:flex-start!important;justify-content:center!important;
  width:100%!important;min-width:0!important;
  padding:10px 12px!important;
  border-left:1px solid #d8af82!important;border-top:0!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.country-start .sg-name{
  width:max-content!important;max-width:100%!important;align-self:flex-start!important;
  flex:0 0 auto!important;font-size:clamp(13px,1.6vw,19px)!important;
  padding:4px 11px!important;margin-bottom:7px!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.country-start .sg-caption p{
  font-size:clamp(11px,1.2vw,15px)!important;
  line-height:1.27!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.country-start .sg-scene-art{
  width:100%!important;height:100%!important;
  object-fit:cover!important;object-position:center!important;background:none!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.country-start .sg-actions{
  margin:7px 2px 0!important;
 }

 /* Match the proven Marina Gate retry screen: art at left, dialogue at right.
    Narrow the sprint art column so its image fills the space without visible
    purple sidebands, and give the instruction panel that width instead. */
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-cinematic,
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-cinematic,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-cinematic{
  display:grid!important;
  align-items:stretch!important;
  height:auto!important;
  max-height:none!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-cinematic{
  grid-template-columns:minmax(0,44%) minmax(0,56%)!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-cinematic,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-cinematic{
  grid-template-columns:minmax(0,54%) minmax(0,46%)!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-stage,
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-stage,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-stage{
  grid-column:1!important;grid-row:1!important;
  position:relative!important;height:clamp(126px,46dvh,223px)!important;
  min-height:0!important;aspect-ratio:auto!important;
  max-height:none!important;width:100%!important;
  overflow:hidden!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-caption,
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-caption,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-caption{
  grid-column:2!important;grid-row:1!important;
  display:flex!important;flex-direction:column!important;
  align-items:flex-start!important;justify-content:center!important;
  width:100%!important;min-width:0!important;
  padding:10px 12px!important;
  border-left:1px solid #d8af82!important;border-top:0!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-caption p,
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-caption p,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-caption p{
  font-size:clamp(11px,1.2vw,15px)!important;
  line-height:1.27!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-name,
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-name,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-name{
  width:max-content!important;max-width:100%!important;align-self:flex-start!important;
  flex:0 0 auto!important;font-size:clamp(13px,1.6vw,19px)!important;
  padding:4px 11px!important;margin-bottom:7px!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-stage{
  background:none!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-scene-art{
  width:100%!important;height:100%!important;
  object-fit:cover!important;object-position:center!important;background:none!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-v78-handover-panel{
  width:auto!important;height:96%!important;max-width:96%!important;
  object-fit:contain!important;left:50%!important;transform:translateX(-50%)!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-scene-art{
  width:100%!important;height:100%!important;
  object-fit:contain!important;object-position:center!important;
  background:#5a4779!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-actions,
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-actions,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-actions{
  margin:7px 2px 0!important;
 }
}

@media (orientation:landscape) and (max-height:480px){
 #singaporeRoot #sg-modal > .sg-modal-card.country-start,
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro,
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card{
  max-height:calc(100dvh - 10px)!important;overflow:auto!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.country-start .sg-stage,
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-stage,
 #singaporeRoot #sg-modal > .sg-modal-card.baton-finish .sg-stage,
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-stage{
  height:clamp(122px,42dvh,176px)!important;
 }
}

/* Unlike the wide sprint painting, Courage Star art is 4:3. Its frame gets
   a proportionally narrower left column to avoid either cutting off heads
   or exposing large empty sidebands. */
@media (orientation:landscape){
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-cinematic{
  grid-template-columns:minmax(0,43%) minmax(0,57%)!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.victory-card .sg-scene-art{
  object-fit:cover!important;object-position:center 44%!important;
  background:none!important;
 }
}

/* v117: Marina Gate · Final Sprint, landscape only. The art fills the full
   height of the left column beside the instructions (no purple bands). */
@media (orientation:landscape){
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-cinematic{
  display:grid!important;
  grid-template-columns:minmax(0,48%) minmax(0,52%)!important;
  align-items:stretch!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-stage{
  grid-column:1!important;grid-row:1!important;
  position:relative!important;width:100%!important;height:auto!important;
  min-height:0!important;aspect-ratio:1312/602!important;align-self:stretch!important;
  background:none!important;overflow:hidden!important;
 }
 #singaporeRoot #sg-modal > .sg-modal-card.rush-intro .sg-stage .sg-scene-art{
  position:absolute!important;inset:0!important;
  width:100%!important;height:100%!important;
  object-fit:cover!important;object-position:center 50%!important;
  background:none!important;
 }
}
