/* Phone play in both orientations, including notches and home indicators. */
#app{min-height:0}
/* Four raised dots keep the pad recognisable even before it is touched. */
#app #stick::before{content:"";position:absolute;inset:5px;border-radius:50%;pointer-events:none;background:radial-gradient(circle at 50% 9%,#fff6d9 0 3px,#082e3d 3.5px 5px,transparent 5.5px),radial-gradient(circle at 91% 50%,#fff6d9 0 3px,#082e3d 3.5px 5px,transparent 5.5px),radial-gradient(circle at 50% 91%,#fff6d9 0 3px,#082e3d 3.5px 5px,transparent 5.5px),radial-gradient(circle at 9% 50%,#fff6d9 0 3px,#082e3d 3.5px 5px,transparent 5.5px);opacity:.95}
#app #stick-zone[data-active="true"] #stick::before{opacity:1}
/* Keep setup navigation outside the scrolling choices in every viewport. */
#app :is(#character-screen,#opponent-screen,#difficulty-screen,#arena-screen,#length-screen).setup-screen{
  grid-template-rows:auto minmax(0,1fr) auto;
  overflow:hidden;
  padding-bottom:max(12px,env(safe-area-inset-bottom));
}
#app :is(#character-screen,#opponent-screen,#difficulty-screen,#arena-screen,#length-screen) .setup-content{
  min-height:0;
  align-self:stretch;
  overflow:auto;
  overscroll-behavior:contain;
  justify-content:safe center;
  align-content:safe center;
  padding:8px;
  scroll-padding:8px;
}
#app .setup-screen .setup-content>*{flex-shrink:0}
#app #difficulty-screen .setup-content{padding-inline:32px;scroll-padding-inline:32px}
#app .setup-screen .setup-footer{align-self:end}
/* Fade only the unfinished scroll edge; the final choice stays fully visible. */
#app .setup-screen .setup-content[data-scroll-more="true"]{
  mask-image:linear-gradient(to bottom,#000 calc(100% - 36px),transparent);
}
/* Desktop setup uses the width of the window instead of tall phone cards. */
@media(min-width:901px) and (min-height:541px){
  #app :is(#character-screen,#opponent-screen,#difficulty-screen,#arena-screen,#length-screen).setup-screen{
    padding-top:max(20px,env(safe-area-inset-top));gap:12px;
  }
  #app .setup-screen .setup-head{gap:4px;padding-inline:80px}
  #app .setup-screen .setup-head h2{font-size:30px}
  #app .setup-screen .setup-footer{width:min(560px,100%);gap:18px}
  #app :is(#character-screen,#opponent-screen,#difficulty-screen,#arena-screen,#length-screen) .setup-footer :is(.text-button,.primary){
    height:76px;min-height:76px;padding:21px 22px 21px;font-size:16px;
  }
  #app #character-screen .character-options{grid-template-columns:repeat(5,minmax(0,1fr));width:min(1200px,100%);gap:12px}
  #app #character-screen .character-option{
    height:clamp(235px,calc(100dvh - 260px),310px);min-height:0;
    --figure-height:clamp(94px,16dvh,132px);padding:28px 12px 34px;gap:8px;
  }
  #app #character-screen .fighter-stage{height:clamp(110px,19dvh,150px);min-height:0}
  #app #character-screen .character-option strong{font-size:clamp(17px,1.7vw,24px)}
  #app #difficulty-screen .difficulty.setup-choices{grid-template-columns:repeat(3,minmax(0,1fr));width:100%;margin:0;gap:26px}
  #app #difficulty-screen .diff-card{
    height:clamp(320px,calc(100dvh - 280px),380px);min-height:0;
    padding:32px 36px 38px;gap:16px;
  }
  #app #difficulty-screen .diff-face{width:clamp(64px,11dvh,84px);height:clamp(64px,11dvh,84px)}
  #app #difficulty-screen .diff-copy{gap:10px;width:min(100%,200px)}
  #app #difficulty-screen .diff-text{font-size:13px;line-height:1.5;margin-top:4px}
  /* Preserve the portrait collectible: name and artwork above the dossier. */
  #app #opponent-screen .rival-collectible{
    width:min(480px,calc(100% - 184px));min-height:min-content;
    grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(160px,1fr) auto;
  }
  #app #opponent-screen .rival-traits li{font-size:14px;line-height:1.4}
  #app #arena-screen .arena-options{
    grid-template-columns:minmax(0,1.3fr) minmax(340px,1fr);grid-template-areas:"stage side";gap:24px;
  }
  #app #arena-screen .arena-stage{width:100%;max-height:100%;aspect-ratio:16/10}
  #app #arena-screen .arena-side{gap:8px}
  #app #arena-screen .arena-choice-section{gap:8px}
  #app #arena-screen .arena-side .time-mode button{min-height:52px;padding-block:6px}
  #app #length-screen .length-options .setup-choices{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:759px) and (orientation:portrait){
  #app #opponent-screen .rival-collectible{--rival-art-height:clamp(240px,38dvh,340px)}
}
@media(max-width:720px),(max-height:540px){
  #app .setup-screen .setup-footer{grid-template-columns:minmax(0,1fr) minmax(0,1.4fr);gap:12px}
  #app :is(#character-screen,#opponent-screen,#difficulty-screen,#arena-screen,#length-screen) .setup-footer :is(.text-button,.primary){
    height:64px;min-height:64px;padding:17px 12px 17px;font-size:14px;gap:8px;
  }
}
.home-screen .install-game{min-height:44px;font-size:13px;flex-shrink:0}
#app .install-help{width:100%;height:100dvh;overflow:auto;padding:max(24px,env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left))}
#app .install-help form{width:min(520px,100%)}
#app .install-help form>header{margin-bottom:24px}
#app .install-help h2{font-size:26px;line-height:1.2}
#app .install-help p{font-size:15px;line-height:1.6;margin:16px 0;color:var(--brand-cream)}
#app .install-help ol{padding-left:24px;margin:0;line-height:1.6}
#app .install-help li{padding-left:6px;margin-bottom:14px}
#app .install-help .install-note,#app .install-help #install-tip{font-size:13px;color:var(--brand-cream);opacity:.85}
.install-device-buttons{display:grid;gap:12px;margin:24px 0}
#app .install-help .install-device-buttons .menu-button{width:100%;min-height:76px;justify-content:center;gap:12px}
#app .install-help #install-change-device{display:block;margin:16px auto;min-height:62px;font-size:14px}
#app .install-help .primary{display:block;width:min(360px,100%);margin:20px auto 0}
#install-status:empty{display:none}
@media(max-width:720px),(max-height:540px) and (orientation:landscape){
  .topbar{height:calc(82px + env(safe-area-inset-top));padding-top:calc(10px + env(safe-area-inset-top))}
  #app .header-actions .icon-button,#app .header-actions #pause{width:72px;height:72px;min-width:72px;min-height:72px;max-width:72px;padding:20px;flex-shrink:0}
  .scoreboard{top:calc(10px + env(safe-area-inset-top))}
  #app[data-touch="true"] .scoreboard{width:min(180px,calc(100vw - 184px - env(safe-area-inset-left) - env(safe-area-inset-right)))}
  #app[data-touch="true"] .scoreboard[data-mode="set"]{width:min(202px,calc(100vw - 184px - env(safe-area-inset-left) - env(safe-area-inset-right)))}
  .callout,.rally-label{margin-top:env(safe-area-inset-top)}
}
@media(max-width:720px) and (orientation:portrait){
  [data-touch="true"] .touch-controls{bottom:calc(24px + env(safe-area-inset-bottom));left:max(16px,env(safe-area-inset-left));right:max(16px,env(safe-area-inset-right))}
  [data-touch="true"] #stick{width:112px;height:112px}
  [data-touch="true"] .touch-actions{grid-template-columns:64px 64px;grid-template-rows:64px;gap:8px}
  [data-touch="true"] .touch-actions button{width:64px;height:64px;font-size:12px}
  [data-touch="true"] .touch-actions #touch-serve{width:136px;height:80px;font-size:16px}
  [data-touch="true"] [data-serving="true"] .touch-actions{grid-template-columns:1fr;grid-template-rows:auto}
  [data-touch="true"] .contact-hint{bottom:calc(170px + env(safe-area-inset-bottom));max-width:calc(100vw - 32px);white-space:normal;text-align:center;gap:6px}
  [data-touch="true"] .serve-meter{bottom:calc(210px + env(safe-area-inset-bottom));width:min(310px,calc(100vw - 32px))}
  [data-touch="true"] .coach{left:50%;top:calc(70px + env(safe-area-inset-top));width:calc(100vw - 32px);max-width:480px}
  [data-touch="true"] .coach-text strong{font-size:22px}
  [data-touch="true"] .coach-demo{min-width:56px}
}

/* Leave room for the entire comic frame and its shadow inside the scroll area. */
#app #opponent-screen .opponent-content{height:auto;padding:16px 88px 24px;scroll-padding:16px 88px 24px;gap:0}
#app #opponent-screen .opponent-content[data-scroll-more="true"]{mask-image:none}
#app #opponent-screen .rival-collectible{width:min(480px,100%);height:auto;min-height:0;max-height:none;grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto;gap:10px;padding:14px;--rival-art-height:clamp(144px,22dvh,180px)}
#app #opponent-screen .fighter{height:auto;min-height:0;grid-template-rows:auto auto;gap:8px}
#app #opponent-screen .rival-card-header{min-height:38px;padding:0 2px 4px}
#app #opponent-screen .fighter-name{font-size:30px;line-height:1.1}
#app #opponent-screen .fighter-stage{height:var(--rival-art-height);min-height:0}
#app #opponent-screen .rival-dossier{align-self:stretch;padding:0;gap:10px}
#app #opponent-screen .rival-intro .rival-quote{font-size:13px;line-height:1.4;padding:6px 9px}
#app #opponent-screen .trait-columns{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
#app #opponent-screen .rival-traits{padding:8px;gap:6px}
#app #opponent-screen .rival-traits h4{font-size:10px;padding:4px 6px}
#app #opponent-screen .rival-traits ul{gap:6px}
#app #opponent-screen .rival-traits li{font-size:13px;line-height:1.4}
#app #opponent-screen .rival-arrow{width:64px;height:64px;min-width:64px;min-height:64px;padding:16px;top:calc(65px + var(--rival-art-height)/2)}
#app #opponent-screen .rival-arrow.previous{left:-80px}
#app #opponent-screen .rival-arrow.next{right:-80px}
@media(max-width:759px){
  #app #opponent-screen .opponent-content{padding:16px 12px 24px;scroll-padding:16px 12px 24px}
  #app #opponent-screen .rival-collectible{padding:12px;--rival-art-height:clamp(160px,23dvh,210px)}
  #app #opponent-screen .fighter-name{font-size:26px}
  #app #opponent-screen .rival-traits li{font-size:12px}
  #app #opponent-screen .rival-arrow{width:44px;height:44px;min-width:44px;min-height:44px;padding:10px}
  #app #opponent-screen .rival-arrow.previous{left:8px}
  #app #opponent-screen .rival-arrow.next{right:8px}
}
