#ui, #ui * { writing-mode: horizontal-tb; }
#hud .track { height: 5.6rem; }
#hud .track .bar { right: 1.8rem; }
#hud .track .goalFlag { right: 0; }
#hud .track .remain { top: 3.5rem; line-height: 1.3; }
#dlg .box { padding-bottom: 1.2rem; }
#dlg .nextHint { bottom: -.5rem; right: .4rem; }

/* ===== portrait (phone held upright) ===== */
@media (max-aspect-ratio: 1/1) {
  html { font-size: max(9px, min(calc(100vw / 30), calc(100vh / 52))); }
  #title .logoWrap { width: 92%; top: 10%; height: 28%; }
  #title .start { left: 5%; right: 5%; bottom: 10%; font-size: 1.8rem; }
  .subtitle { left: 5%; right: 5%; font-size: 1.5rem; }
  /* hud */
  #hud .rankBox { top: max(.8rem, env(safe-area-inset-top)); }
  #hud .rank { font-size: 3.6rem; }
  #hud .timeBox { top: 4.8rem; font-size: 1.5rem; }
  #hud .goldBox { top: 7rem; font-size: 1.4rem; }
  #hud .track { left: 5%; right: 5%; top: 10rem; }
  #hud .gauges { width: 88%; bottom: 13.5rem; }
  #hud .gLabel { min-width: 6rem; font-size: 1.3rem; }
  #hud .tut { top: 16rem; width: 90%; white-space: normal; font-size: 1.5rem; }
  #hud .count { font-size: 7rem; }
  .sbtn { width: 6.6rem; height: 6.6rem; }
  #goalBanner { font-size: 5rem; }
  /* stage card */
  #card .day { font-size: 1.9rem; }
  #card .name { font-size: 3.4rem; }
  #card .sub { font-size: 1.6rem; padding: 0 5%; }
  #card .tip { font-size: 1.35rem; padding: 0 6%; }
  /* dialogue: horizontal band at the bottom */
  #dlg .box { width: 96%; bottom: 2%; min-height: 0; gap: .8rem; align-items: flex-start; border-width: 1.6rem; border-image-width: 1.6rem; }
  #dlg .face { width: 5.2rem; height: 5.2rem; }
  #dlg .box > div:not(.face) { flex: 1; min-width: 0; }
  #dlg .who { font-size: 1.45rem; }
  #dlg .line { font-size: 1.5rem; }
  /* results */
  .resPanel { width: 96%; max-height: 96%; overflow-y: auto; border-width: 1.6rem; border-image-width: 1.6rem; }
  .resPanel h2 { font-size: 2.2rem; }
  .row { font-size: 1.45rem; gap: .5rem; padding: .3rem .4rem; }
  .row .pl { width: 2.4rem; font-size: 1.8rem; }
  .row .fc { width: 3rem; height: 3rem; }
  .row .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .row .tm, .row .pt { width: auto; }
  .btn { font-size: 1.45rem; padding: .5rem 1.6rem; }
  /* inn: standings on top, cards stacked in 3 rows */
  #inn .innWrap { inset: max(1%, env(safe-area-inset-top)) 3% 1%; flex-direction: column; overflow-y: auto; gap: .8rem; }
  #inn .colR { display: contents; }
  #inn .colR > * { order: 1; flex: none; }
  #inn .colR > .stPanel { order: -1; border-width: 1.2rem; border-image-width: 1.2rem; }
  #inn .stRow { white-space: nowrap; line-height: 1.2; }
  #title { background-image: url(assets/cover-bg.webp) !important; }
  #inn .stPanel h3 { grid-column: 1 / -1; font-size: 1.4rem; margin: 0; }
  #inn .colL { flex: none; order: 0; }
  #inn h2 { font-size: 2.2rem; }
  #inn .cards { flex-direction: column; gap: .5rem; }
  .tcard { display: grid; grid-template-columns: 5rem 1fr auto; grid-template-rows: auto auto; column-gap: .8rem; align-items: center; text-align: left; border-width: 1.2rem; border-image-width: 1.2rem; }
  .tcard img { grid-row: 1 / 3; width: 4.6rem; height: 4.6rem; }
  .tcard .tn { grid-column: 2; font-size: 1.6rem; }
  .tcard .td { grid-column: 2; min-height: 0; font-size: 1.25rem; }
  .tcard .tl { grid-column: 3; grid-row: 1 / 3; }
  #inn .stRow { font-size: 1.3rem; }
  #inn .stRow .fc { width: 2.2rem; height: 2.2rem; }
  /* ending */
  #ending .endTitle { font-size: 3.6rem; top: 6%; }
  #ending .endText { left: 4%; right: 4%; font-size: 1.45rem; padding: 1rem 1.2rem; }
}
