/* patch_14 — mobile-first Safari layout repair.
   Width drives the game stage. Do not use dvh/svh for stage geometry:
   Safari browser chrome changes those values while scrolling and was moving
   controls / creating a large blank tail. */
@media (max-width:600px){
  html,body{min-height:0;background:var(--cream);}
  .app{
    width:100%;
    min-height:0;
    padding-bottom:calc(72px + env(safe-area-inset-bottom,0px));
  }
  header{height:106px;padding:18px 20px 8px;}
  .nav{
    height:calc(72px + env(safe-area-inset-bottom,0px));
    padding-bottom:env(safe-area-inset-bottom,0px);
  }

  /* Stable 430×645 design stage (2:3), scaled only by viewport width. */
  .game{
    width:100%;
    height:auto;
    min-height:0;
    aspect-ratio:2 / 3;
    overflow:hidden;
  }
  .art{
    inset:0;
    background-size:cover;
    background-position:center center;
  }

  /* Decorative floating seed/sprout removed by QA decision. */
  .seed,.sprout{display:none!important;}

  /* Growing controls: percentages are relative to the stable stage, so Safari
     address-bar expansion/collapse cannot move them independently. */
  .game:not(.result-mode) .status{
    top:79.0%!important;
    bottom:auto!important;
  }
  .game:not(.result-mode) .bar{
    top:82.6%!important;
    bottom:auto!important;
  }
  .game:not(.result-mode) .action{
    top:87.0%!important;
    bottom:auto!important;
    height:7.3%!important;
    min-height:0;
  }

  /* Result state is kept inside the same stable stage. */
  .game.result-mode .character-card{
    top:14.5%!important;
    width:min(300px,70vw);
    height:38.8%;
  }
  .game.result-mode .character{
    top:15.2%!important;
    height:36.9%;
    max-height:none;
  }
  .game.result-mode .result{
    top:55.5%!important;
    bottom:auto!important;
  }
  .game.result-mode .action,
  .game.result-mode .action:active{
    top:70.5%!important;
    bottom:auto!important;
    height:7.3%!important;
    min-height:0;
    transform:none!important;
  }
  .game.result-mode .action:active{transform:translateY(3px)!important;}
  .game.result-mode .result-tools{
    top:80.5%!important;
    bottom:auto!important;
    transform:none!important;
  }
}

/* Very narrow phones keep the same composition; touch targets must not collapse. */
@media (max-width:380px){
  .game:not(.result-mode) .action,
  .game.result-mode .action{min-height:44px;}
}
