/* Mobile menus share a single navigation row and keep the comic palette. */
@media(max-width:760px),(orientation:landscape) and (max-height:540px){
  html,body{overflow:hidden}
  #app,#app .screen *,#app dialog,#app dialog *{scrollbar-width:none}
  #app *::-webkit-scrollbar{display:none;width:0;height:0}
  #app .header-actions,#app[data-touch="true"] .header-actions{
    position:fixed;top:calc(8px + env(safe-area-inset-top));right:calc(12px + env(safe-area-inset-right));
    display:flex;flex-direction:row;align-items:center;gap:6px;margin:0;
  }
  #app .header-actions :is(.icon-button,#pause){
    width:44px;height:44px;min-width:44px;max-width:44px;min-height:44px;padding:11px;
  }
  #app .header-actions svg{width:22px;height:22px}
  #app:has(.screen:not([hidden])) .topbar{z-index:70}
  #app:has(.screen:not([hidden])) .scoreboard{display:none}
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen).setup-screen{
    padding:calc(60px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
    display:grid;grid-template-rows:auto minmax(0,1fr) auto;gap:8px;overflow:hidden;
  }
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-head{
    width:100%;padding:0;gap:0;min-width:0;
  }
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-head h2{
    font-size:clamp(20px,5.8vw,25px);line-height:1.2;letter-spacing:-.4px;text-align:center;text-wrap:balance;
  }
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-steps{
    position:fixed;z-index:7;top:calc(8px + env(safe-area-inset-top));left:calc(12px + env(safe-area-inset-left));
    display:flex;align-items:center;justify-content:flex-start;gap:0;width:calc(100% - 128px - env(safe-area-inset-left) - env(safe-area-inset-right));max-width:180px;height:44px;
  }
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-step{
    flex:1;min-width:0;width:auto;max-width:36px;height:44px;min-height:44px;padding:0;
  }
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-step::before{width:17px;height:10px}
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-step[data-state="current"]::before{width:27px}
  #app .setup-chips{display:none}
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-content{
    align-self:stretch;min-width:0;min-height:0;width:100%;margin:0;padding:6px 4px 8px;scroll-padding:8px;scrollbar-width:none;
  }
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-footer{
    width:min(520px,100%);grid-template-columns:minmax(0,1fr) minmax(0,1.4fr);gap:10px;padding:0;
  }
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-footer :is(.text-button,.primary){
    width:100%;height:56px;min-height:56px;min-width:0;padding:14px 12px;font-size:14px;line-height:1.2;gap:7px;white-space:normal;text-align:center;
  }

  /* Existing collectible and equipment art can shrink within their layout. */
  #app #character-screen[data-equipment-scenes] .equipment-content:not(:has(.equipment-picker:not([hidden]))) .equipment-summary{
    min-height:0;flex:1;grid-template-rows:repeat(2,minmax(0,1fr));
  }
  #app #character-screen[data-equipment-scenes] .equipment-content:not(:has(.equipment-picker:not([hidden]))) .equipment-summary .equipment-card{
    height:100%;max-height:none;aspect-ratio:auto;
  }
  #app #character-screen .equipment-content:has(.equipment-picker:not([hidden])) .return-animation-picker{display:none}
  #app #character-screen[data-equipment-scenes] .equipment-content .equipment-picker button strong{
    white-space:normal;overflow-wrap:anywhere;text-wrap:balance;font-size:16px;
  }
  #app #opponent-screen .opponent-content{overflow:hidden;max-width:none;padding:16px 32px 30px}
  #app #opponent-screen .rival-collectible{flex:1;min-height:0;height:100%;max-height:100%;width:100%}
  #app #opponent-screen .rival-sheet{min-height:0;height:100%;grid-template-rows:minmax(0,1fr) auto}
  #app #opponent-screen .fighter{min-height:0;grid-template-rows:auto minmax(0,1fr)}
  #app #opponent-screen .fighter-stage{min-height:0}
  #app #opponent-screen .rival-swipe-hint,#app[data-touch="true"] #opponent-screen .rival-swipe-hint{display:none}
  #app #length-screen .length-options{overflow:hidden;padding-bottom:6px}
  #app #equipment-detail{scrollbar-width:none}
  #app #equipment-detail h2{white-space:normal;overflow-wrap:anywhere}

  #app #welcome{padding:calc(60px + env(safe-area-inset-top)) 16px calc(10px + env(safe-area-inset-bottom));gap:8px;overflow:hidden;justify-content:center}
  #app #welcome .screen-head{order:0;margin:0}
  #app #welcome .screen-head .game-logo{width:clamp(60px,12dvh,100px)}
  #app #welcome .home-links{order:1;flex:1;min-height:0;max-height:400px;width:min(440px,100%);grid-template-columns:1fr;grid-template-rows:repeat(4,minmax(0,1fr));gap:8px}
  #app #welcome .home-links button{height:100%;min-height:0;max-height:none;padding:8px 15%;font-size:15px;gap:8px;flex-direction:row;justify-content:space-between;text-align:left}
  #app #welcome .home-button-copy{gap:3px;min-width:0;line-height:1.2}
  #app #welcome .home-button-copy small{font-size:11px;line-height:1.25}
  #app #welcome .home-links button>svg{width:22px;height:22px;flex-shrink:0}
  #app #welcome .home-progress-row{order:2;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;width:min(440px,100%)}
  #app #welcome :is(#player-progress,.account-entry){grid-template-columns:28px minmax(0,1fr) 10px;gap:5px;min-height:62px;padding:8px;border-width:2px}
  #app #welcome :is(.xp-home-copy strong,.account-entry strong){font-size:13px;line-height:1.2}
  #app #welcome :is(.xp-home-copy small,.account-entry small){display:none}
  #app #welcome .account-entry>svg,#app #welcome .xp-badge{width:28px;height:28px}
  #app #welcome .account-entry-arrow{font-size:18px}
  #app #welcome .install-game{order:3}
  #app #welcome .presented{order:4;gap:2px;margin:0;font-size:9px;min-height:0}
  #app #welcome .presented img{width:90px}
  #app #welcome .game-website{display:none}

  #app #learning-choice{display:grid;grid-template-columns:minmax(0,1fr);grid-template-areas:none;grid-template-rows:auto auto minmax(0,1fr) auto;gap:8px;padding:calc(60px + env(safe-area-inset-top)) 16px calc(10px + env(safe-area-inset-bottom));overflow:hidden}
  #app #learning-choice h2{grid-column:1;grid-row:1;font-size:23px;line-height:1.2;margin:0;text-wrap:balance}
  #app #learning-choice .learning-choice-intro{grid-column:1;grid-row:2;font-size:12px;line-height:1.3}
  #app #learning-choice .learning-choice-options{grid-column:1;grid-row:3;width:min(460px,100%);height:100%;min-height:0;align-self:stretch;grid-template-columns:1fr;grid-template-rows:repeat(3,minmax(0,1fr));gap:10px;margin:0 auto}
  #app #learning-choice .learning-choice-card{position:relative;isolation:isolate;min-height:0;height:100%;grid-template-columns:60px minmax(0,1fr);grid-template-rows:minmax(0,1fr);gap:6px;padding:20px 20px 16px;background:transparent url('./comic-controls-neutral/phone-cards-1.webp') center/100% 100% no-repeat;align-items:center}
  #app #learning-choice .learning-choice-art{height:66px;width:66px}
  #app #learning-choice .learning-choice-copy{min-height:0;padding:0;background:none;gap:4px}
  #app #learning-choice .learning-choice-copy strong{font-size:17px;line-height:1.2}
  #app #learning-choice .learning-choice-copy small{font-size:11px;line-height:1.3}
  #app #learning-choice .learning-choice-copy b{display:none}
  #app #learning-choice .howto-actions{grid-column:1;grid-row:4;padding:0;margin:0 auto;width:min(300px,100%)}
  #app #learning-choice .howto-actions button{height:52px;min-height:52px;padding:12px 28px;font-size:14px}
}
@media(orientation:landscape) and (max-height:540px){
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen).setup-screen{padding-top:calc(56px + env(safe-area-inset-top));gap:5px;padding-bottom:6px}
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-head h2{font-size:20px}
  #app :is(#length-screen,#character-screen,#opponent-screen,#difficulty-screen,#arena-screen) .setup-footer :is(.text-button,.primary){height:48px;min-height:48px;padding:10px 12px;font-size:13px}

  #app #character-screen[data-equipment-scenes] .equipment-content:not(:has(.equipment-picker:not([hidden]))) .equipment-summary{
    grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:minmax(0,1fr);
  }
  #app #character-screen[data-equipment-scenes] .equipment-content:has(.equipment-picker:not([hidden])){overflow:hidden;gap:6px;padding-block:0}
  #app #character-screen[data-equipment-scenes] .equipment-content:has(.equipment-picker:not([hidden])) .equipment-summary{flex:0 0 52px;gap:10px;grid-template-rows:52px}
  #app #character-screen[data-equipment-scenes] .equipment-content:has(.equipment-picker:not([hidden])) .equipment-summary .equipment-card{height:52px}
  #app #character-screen[data-equipment-scenes] .equipment-content:has(.equipment-picker:not([hidden])) .equipment-card h3{top:5px;left:8px;font-size:8px;padding:2px 5px}
  #app #character-screen[data-equipment-scenes] .equipment-content:has(.equipment-picker:not([hidden])) .equipment-card>strong{bottom:5px;left:9px;font-size:14px}
  #app #character-screen[data-equipment-scenes] .equipment-content .equipment-picker:not([hidden]){display:flex;flex-direction:column;flex:1;min-height:0;padding:0;gap:4px}
  #app #character-screen[data-equipment-scenes] .equipment-picker>h3{font-size:16px;line-height:1.2;margin:0}
  #app #character-screen[data-equipment-scenes] .equipment-content .equipment-picker :is(.character-options,.racket-options){flex:1;min-height:0;overflow:auto;grid-template-columns:repeat(3,minmax(0,1fr));grid-auto-rows:100%;gap:10px;padding:0 2px 4px}
  #app #character-screen[data-equipment-scenes] .equipment-picker :is(.character-option,.racket-option){height:100%;min-height:0;aspect-ratio:auto}
  #app #character-screen[data-equipment-scenes] .equipment-content .equipment-picker .equipment-model-stage{height:100%}
  #app #character-screen[data-equipment-scenes] .equipment-content .equipment-picker button strong{font-size:14px;line-height:1.2;padding:16px 3px 6px}
  #app #character-screen[data-equipment-scenes] .equipment-picker .skin-level-lock{font-size:9px;padding:3px;left:3px;top:4px;gap:3px}
  #app #character-screen[data-equipment-scenes] .equipment-picker .skin-lock-icon{width:14px;height:14px}

  #app #welcome{display:grid;grid-template-columns:minmax(140px,.6fr) minmax(0,1.4fr);grid-template-rows:minmax(0,1fr) auto auto;gap:6px 14px;padding-top:56px;align-items:center}
  #app #welcome .screen-head{grid-column:1;grid-row:1}
  #app #welcome .screen-head .game-logo{width:70px}
  #app #welcome .home-links{grid-column:2;grid-row:1 / 3;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:repeat(2,minmax(0,1fr));height:100%;max-height:none;gap:8px}
  #app #welcome .home-links button{padding-inline:14%;font-size:14px}
  #app #welcome .home-progress-row{grid-column:1;grid-row:2;grid-template-columns:1fr;gap:6px}
  #app #welcome :is(#player-progress,.account-entry){min-height:44px;padding:5px 7px}
  #app #welcome :is(.xp-home-copy strong,.account-entry strong){font-size:12px}
  #app #welcome .presented{grid-column:2;grid-row:3;justify-self:center}
  #app #welcome .game-website{grid-column:1;grid-row:3;justify-self:center}
  #app #learning-choice{padding-top:56px;grid-template-rows:auto minmax(0,1fr) auto;gap:6px}
  #app #learning-choice h2{font-size:20px}
  #app #learning-choice .learning-choice-intro{display:none}
  #app #learning-choice .learning-choice-options{grid-row:2;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:minmax(0,1fr);max-width:none;width:100%;gap:10px}
  #app #learning-choice .learning-choice-card{display:flex;flex-direction:column;justify-content:center;padding:18px 18px;gap:5px}
  #app #learning-choice .learning-choice-art{width:44px;height:44px}
  #app #learning-choice .learning-choice-copy{text-align:center;gap:4px}
  #app #learning-choice .learning-choice-copy strong{font-size:16px}
  #app #learning-choice .learning-choice-copy small{font-size:11px}
  #app #learning-choice .howto-actions{grid-row:3}
  #app #learning-choice .howto-actions button{height:48px;min-height:48px;padding:10px 28px;font-size:13px}
  #app #opponent-screen .opponent-content{padding:16px 58px 40px}
  #app #opponent-screen .rival-pile{height:100%}
  #app #opponent-screen .rival-sheet{grid-template-rows:minmax(0,1fr);gap:10px;padding:10px}
  #app #opponent-screen .fighter{height:100%;gap:5px}
  #app #opponent-screen .fighter-stage{height:100%}
  #app #opponent-screen .fighter-name{font-size:22px}
  #app #opponent-screen .rival-card-header{min-height:26px;gap:5px;padding:0}
  #app #opponent-screen .rival-sheet .rival-emblem{width:26px;height:26px}
  #app #opponent-screen .rival-sheet .rival-emblem img{width:25px;height:25px}
  #app #opponent-screen .rival-dossier{padding:0;gap:8px;background:none;border:0;box-shadow:none;min-height:0}
  #app #opponent-screen .rival-intro .rival-quote{font-size:12px;line-height:1.25;padding:5px 8px;margin:0 0 5px}
  #app #opponent-screen .rival-traits{padding:5px;gap:4px}
  #app #opponent-screen .rival-traits h4{font-size:10px;padding:3px;letter-spacing:0}
  #app #opponent-screen .rival-traits ul{gap:4px}
  #app #opponent-screen .rival-traits li{font-size:11px;line-height:1.25;padding-left:14px}
  #app #opponent-screen .rival-traits li::before{width:11px;height:11px;font-size:10px}
  #app #opponent-screen .rival-arrow{top:50%;translate:0 -50%;width:44px;height:44px}
  #app #opponent-screen .rival-arrow.previous{left:-50px}
  #app #opponent-screen .rival-arrow.next{right:-50px}

  #app #arena-screen .arena-options{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.15fr);grid-template-rows:minmax(0,1fr);grid-template-areas:'stage side';gap:14px;overflow:hidden;align-items:stretch}
  #app #arena-screen .arena-stage{width:100%;height:100%;min-height:0;aspect-ratio:auto}
  #app #arena-screen .arena-side{gap:8px;justify-content:center;min-height:0}
  #app #arena-screen .arena-section-title{font-size:10px;margin:0 0 4px}
  #app #arena-screen .arena-choices{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  #app #arena-screen .arena-choices .arena-option{grid-column:auto;min-height:44px;height:44px;padding:4px;gap:0;justify-content:center}
  #app #arena-screen .court-thumb,#app #arena-screen .arena-name small{display:none}
  #app #arena-screen .arena-name{align-items:center;text-align:center}
  #app #arena-screen .arena-name strong{font-size:12px}
  #app #arena-screen .arena-side .time-mode{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
  #app #arena-screen .arena-side .time-mode button{min-height:44px;height:44px;padding:5px 18px 5px 6px;gap:6px}
  #app #arena-screen .time-mode button svg{flex-basis:18px;width:18px;height:18px}
  #app #arena-screen .time-copy strong{font-size:12px}
  #app #arena-screen .time-copy small{display:none}
  #app #arena-screen .match-summary{display:none}
  #app #arena-screen .arena-caption{inset:auto 10px 10px}
  #app #arena-screen .arena-caption strong{font-size:18px}
  #app #arena-screen .arena-caption>span{font-size:10px}

  #app #length-screen .length-options{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.1fr);grid-template-rows:auto minmax(0,1fr) auto;gap:6px 16px;align-content:stretch;justify-content:stretch}
  #app #length-screen .length-options .event-options{grid-column:1;grid-row:1 / 4;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:0;align-items:stretch;max-width:none;width:100%}
  #app #length-screen .length-options .event-options .event-card{min-height:0;height:100%;padding:12px 7px 26px;gap:5px;justify-content:center;border-width:3px}
  #app #length-screen .event-art{height:clamp(35px,14dvh,70px);margin:12px 0 0}
  #app #length-screen .event-kicker,#app #length-screen .length-options .event-options .event-card small{display:none}
  #app #length-screen .event-stamp{top:7px;font-size:8px;padding:2px 5px}
  #app #length-screen .length-options .event-options .event-card strong{font-size:16px;letter-spacing:-.3px;line-height:1.2}
  #app #length-screen .event-check{width:18px;height:18px;right:9px;bottom:7px;font-size:12px}
  #app #length-screen .duration-head{grid-column:2;grid-row:1}
  #app #length-screen .duration-head h3{font-size:16px;line-height:1.2;margin:0;text-wrap:balance}
  #app #length-screen .duration-head p{display:none}
  #app #length-screen .length-options .format-options{grid-column:2;grid-row:2;grid-template-columns:1fr;grid-template-rows:repeat(3,minmax(44px,1fr));gap:4px;padding:0;min-height:0;width:100%;max-width:none}
  #app #length-screen .length-options .format-options button{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto;height:100%;min-height:44px;padding:10px 32px 11px;gap:8px;align-content:center;text-align:left}
  #app #length-screen .format-kicker,#app #length-screen .format-scope{display:none}
  #app #length-screen .length-options .format-options button strong{grid-column:1;grid-row:1;font-size:16px;line-height:1.2;justify-self:start;white-space:normal}
  #app #length-screen .length-options .format-options button small{grid-column:2;grid-row:1;font-size:12px;line-height:1.2;text-align:right}
  #app #length-screen .length-options .format-options button .selection-mark{width:16px;height:16px;top:50%;translate:0 -50%;right:4%;font-size:11px;border-width:1px}
  #app #length-screen .match-estimate{grid-column:2;grid-row:3;font-size:10px;line-height:1.2;margin:0}
  #app #length-screen .tournament-preview{grid-column:1 / -1;padding:3px;font-size:11px}
  #app #length-screen .tournament-preview p{display:none}
}
@media(max-height:620px) and (orientation:portrait){
  #app #length-screen .length-options:has(#tournament-preview:not([hidden])) .format-options button{height:56px;min-height:56px;padding-block:17px 12px}
  #app #length-screen .length-options:has(#tournament-preview:not([hidden])) #match-estimate{display:none}
  #app #length-screen .tournament-preview{padding:4px 6px}
  #app #length-screen .tournament-preview strong{font-size:10px;line-height:1.2}
  #app #character-screen[data-equipment-scenes] .equipment-content:not(:has(.equipment-picker:not([hidden]))) .equipment-summary{
    grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:minmax(0,1fr);
  }
  #app #character-screen[data-equipment-scenes] .equipment-content .equipment-summary .equipment-card .text-button{
    left:6px;right:6px;bottom:10px;width:calc(100% - 12px);font-size:11px;
  }
  #app #character-screen[data-equipment-scenes] .equipment-content .equipment-summary .equipment-card>strong{font-size:18px;max-width:calc(100% - 32px)}
}
@media(max-height:350px) and (orientation:landscape){
  #app #learning-choice .learning-choice-art{width:28px;height:28px}
  #app #learning-choice .learning-choice-card{padding:14px 16px;gap:4px}
  #app #learning-choice .learning-choice-copy strong{font-size:15px}
  #app #learning-choice .learning-choice-copy small{font-size:10px;line-height:1.2}
  #app #opponent-screen .rival-intro{display:none}
  #app #opponent-screen .opponent-content{padding-block:10px 22px}
  #app #opponent-screen .rival-sheet{grid-template-columns:minmax(0,.75fr) minmax(0,1.25fr);padding:8px;gap:7px}
  #app #opponent-screen .fighter-name{font-size:17px}
  #app #opponent-screen .trait-columns{gap:4px}
  #app #opponent-screen .rival-traits{padding:4px}
  #app #length-screen .length-options{gap:4px 10px;grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr)}
  #app #length-screen .duration-head h3{font-size:14px}
  #app #length-screen .length-options .format-options button{padding:7px 24px 9px;gap:5px}
  #app #length-screen .length-options .format-options button strong{font-size:14px}
  #app #length-screen .length-options .format-options button small{font-size:11px}
  #app #length-screen .match-estimate{display:none}
}

/* Pop-ups (Marcel 27.10.): on iPhones the status-bar strip swallows taps (the account × sat there).
   Card pop-ups centre between notch and home bar; full-screen ones start below the notch. */
html body :is(#game-account-dialog,#player-progress-dialog,#thennos-card,#rank-gallery-dialog,#equipment-detail,#result-details-dialog,#result-share-dialog)[open]{
  inset-block:env(safe-area-inset-top) env(safe-area-inset-bottom);max-height:calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))}
@media(max-width:700px) and (orientation:portrait){html body #xp-reward-dialog[open]{padding-top:max(12px,env(safe-area-inset-top));padding-bottom:max(12px,env(safe-area-inset-bottom))}}
html body .racket-workshop .ws-room{padding-top:max(6px,env(safe-area-inset-top))}
