/* Fateweld desktop app shell.
   Mobile remains document-scroll-first; desktop keeps navigation persistent and
   gives the active game surface the viewport's remaining space. */
@media (min-width: 960px) and (min-height: 600px) {
  html:has(body:not(.public-landing-active):not(.public-landing-pending)) {
    height: 100%;
    overflow: hidden;
  }

  body:not(.public-landing-active):not(.public-landing-pending) {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body:not(.public-landing-active):not(.public-landing-pending) > .app {
    width: min(var(--app-width), calc(100vw - 24px));
    height: 100dvh;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 10px 0 12px;
  }

  body:not(.public-landing-active):not(.public-landing-pending) > .app > header {
    min-width: 0;
    min-height: 44px;
    align-items: center;
    flex-wrap: nowrap;
    margin-bottom: 8px;
  }

  body:not(.public-landing-active):not(.public-landing-pending) > .app > header h1 {
    flex: 0 0 auto;
    font-size: 21px;
  }

  body:not(.public-landing-active):not(.public-landing-pending) .screen-tabs {
    order: initial;
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }

  body:not(.public-landing-active):not(.public-landing-pending) .screen-tab {
    min-height: 36px;
    flex: 0 0 auto;
    padding-inline: 12px;
  }

  body:not(.public-landing-active):not(.public-landing-pending) .display-panel {
    flex: 0 0 auto;
    margin-left: 0;
  }

  body:not(.public-landing-active):not(.public-landing-pending) #sandboxScreen,
  body:not(.public-landing-active):not(.public-landing-pending) #battleScreen {
    min-height: 0;
    height: 100%;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    align-content: start;
    padding: 0 2px 2px;
  }

  body[data-game-screen="overview"]:not(.public-landing-active):not(.public-landing-pending) #sandboxScreen {
    display: block;
    overflow: hidden;
  }

  body[data-game-screen="overview"] #overviewHeroPanel {
    height: 100%;
    min-height: 0;
  }

  body[data-game-screen="overview"] .home-identity-content {
    min-height: 0;
    gap: 10px;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: clamp(14px, 1.7vw, 24px);
  }

  body[data-game-screen="overview"] .home-identity-heading h2 {
    font-size: clamp(27px, 3vw, 42px);
  }

  body[data-game-screen="overview"] .home-vital-card {
    padding: 9px 10px;
  }

  body[data-game-screen="overview"] .home-resource {
    padding: 8px 9px;
  }

  body[data-game-screen="overview"] .home-combat-record,
  body[data-game-screen="overview"] .home-chat-discovery {
    padding: 9px 10px;
  }

  body[data-game-screen="overview"] .team-combat-entry {
    margin-top: 0;
    padding: 10px;
  }

  body[data-game-screen="overview"] .team-combat-mode-entry {
    padding: .5rem;
  }

  body[data-game-screen="overview"] .home-character-stage {
    min-height: 0;
    height: 100%;
  }

  .actor-3x3-dialog[open] {
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    overflow: hidden;
  }

  .actor-3x3-dialog .team-combat-shell {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 12px 14px;
  }

  .actor-3x3-dialog .team-combat-live {
    margin: 6px 0;
  }

  .actor-3x3-dialog .team-combat-content {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .actor-3x3-dialog .actor-3x3-human-loop,
  .actor-3x3-dialog .actor-3x3-human-loop.has-context {
    grid-template-columns: minmax(500px, 1.65fr) minmax(280px, .75fr);
    align-items: start;
  }

  .actor-3x3-dialog .actor-3x3-human-loop .actor-3x3-field[data-projection="landscape"] {
    --actor-hex-width: var(--actor-desktop-context-hex-width, var(--actor-desktop-hex-width, 50px));
  }

  .actor-3x3-dialog .actor-3x3-contextual-combat {
    top: 0;
  }

  .actor-3x3-dialog .actor-3x3-flow-disclosure[open] {
    max-height: min(42dvh, 430px);
    overflow: auto;
    overscroll-behavior: contain;
  }

  .actor-3x3-dialog .actor-3x3-flow-disclosure[open] > summary {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgb(13 15 14 / 96%);
  }
}

@media (min-width: 960px) and (min-height: 600px) and (max-height: 820px) {
  body:not(.public-landing-active):not(.public-landing-pending) > .app {
    padding-top: 6px;
    padding-bottom: 7px;
  }

  body:not(.public-landing-active):not(.public-landing-pending) > .app > header {
    min-height: 38px;
    margin-bottom: 5px;
  }

  body[data-game-screen="overview"] .home-identity-content {
    gap: 7px;
    padding: 11px 14px;
  }

  body[data-game-screen="overview"] .home-character-line {
    margin-top: 7px;
  }

  body[data-game-screen="overview"] .home-vital-top {
    margin-bottom: 6px;
  }

  body[data-game-screen="overview"] .home-route-grid button {
    padding: 8px 9px;
  }

  .actor-3x3-dialog .team-combat-header h2 {
    font-size: 1.1rem;
  }

  .actor-3x3-dialog .clone-trial-summary > div {
    padding: .42rem .5rem;
  }

  .actor-3x3-dialog .clone-trial-field-note {
    margin: .1rem 0;
    font-size: .75rem;
  }

  .actor-3x3-dialog .actor-3x3-human-loop {
    gap: .45rem;
    padding: .45rem;
  }
}
