.battle-actions {
  display: flex;
  justify-self: end;
  gap: 8px;
}
.fullscreen-button,
.desktop-keys,
.install-label,
.upgrade-key,
#fullscreen-status { display: none; }

@media (min-width: 820px) and (orientation: landscape) {
  #game:has(#battle:not([hidden])) {
    width: 100%;
    margin: 0;
    box-shadow: none;
  }

  .menu {
    display: grid;
    align-items: safe center;
    padding: clamp(18px, 3.5dvh, 36px) clamp(18px, 4vw, 64px);
    background:
      linear-gradient(0deg, #0b1219 1%, #0c161bdf 53%, #101b22c9),
      url('./assets/world-map.webp') center 55% / cover;
  }
  .menu-shell {
    width: 100%;
    max-width: 1240px;
    grid-template-areas: "header header" "mission team" "mission nav" "mission guide";
    grid-template-columns: minmax(0, 2.16fr) minmax(250px, 1fr);
    grid-template-rows: auto auto auto 1fr;
    gap: 16px 20px;
  }
  .menu-header { grid-area: header; padding-bottom: 10px; border-bottom: 1px solid #99806967; }
  .menu-brand h1 span { font-size: clamp(2rem, 3.2vw, 3.2rem); }
  .menu-grid { display: contents; }
  .mission { grid-area: mission; align-self: start; }
  .mission-art { min-height: clamp(240px, 57dvh, 565px); }
  .mission-monster { right: 3%; width: min(72%, 560px); }
  .mission-intro { padding: clamp(16px, 3vw, 30px); }
  .mission-intro h2 { font-size: clamp(2.45rem, 4.7vw, 4.45rem); max-width: 16ch; }
  .mission-controls {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 9px;
    padding: 6px 13px 16px;
  }
  .mission-controls .challenge-link { grid-column: auto; }
  .mission-controls .menu-icon { --menu-icon-size: 28px; }
  .menu-team {
    grid-area: team;
    padding: 15px;
    border: 1px solid #82715b;
    border-radius: 15px;
    background: linear-gradient(130deg, #222b32, #151d25);
  }
  .team-title h2 { font-size: 1.25rem; }
  .menu-nav { grid-area: nav; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .menu-nav button { min-height: 62px; font-size: .82rem; }

  .menu-header #install { display: flex; gap: 9px; width: auto; padding: 0 12px; }
  .menu-header #install .install-label { display: block; font-size: .875rem; font-weight: 700; }
  .fullscreen-button { display: grid; place-items: center; }
  .fullscreen-icon {
    width: 17px;
    aspect-ratio: 1;
    background:
      linear-gradient(currentColor,currentColor) top left / 6px 2px,
      linear-gradient(currentColor,currentColor) top left / 2px 6px,
      linear-gradient(currentColor,currentColor) top right / 6px 2px,
      linear-gradient(currentColor,currentColor) top right / 2px 6px,
      linear-gradient(currentColor,currentColor) bottom left / 6px 2px,
      linear-gradient(currentColor,currentColor) bottom left / 2px 6px,
      linear-gradient(currentColor,currentColor) bottom right / 6px 2px,
      linear-gradient(currentColor,currentColor) bottom right / 2px 6px;
    background-repeat: no-repeat;
  }
  .fullscreen-button[aria-pressed="true"] { color: var(--gold); border-color: #dcb382; }
  .desktop-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    color: #dce4df;
    font-size: .875rem;
  }
  .desktop-keys span { display: inline-flex; align-items: center; gap: 5px; }
  kbd {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    padding: 1px 5px;
    border: 1px solid #778481;
    border-block-end: 2px solid #778481;
    border-radius: 4px;
    background: #1d2d35;
    color: #f8e4bf;
    font: 750 .78rem/1.3 system-ui, sans-serif;
    white-space: nowrap;
  }
  .menu-keys {
    grid-area: guide;
    align-self: start;
    padding: 12px;
    border: 1px solid #9c866755;
    border-radius: 10px;
    background: #101c25d9;
  }

  #battle {
    --hud-edge: clamp(16px, 2.35vw, 40px);
    --hud-width: clamp(226px, 24vw, 320px);
  }
  .hud { inset: 16px var(--hud-edge) auto; }
  .health-box { width: min(var(--hud-width), 275px); gap: 10px; padding: 7px 10px 7px 7px; }
  .health-box img { width: 45px; height: 45px; }
  .health-box > div { flex: 1; min-width: 0; }
  .health-box strong { font-size: .95rem; white-space: normal; }
  .health-box span { font-size: .8rem; }
  .health-track { width: 100%; height: 5px; }
  .run-box { min-width: 130px; padding: 5px 16px 7px; }
  .run-box strong { font-size: 1.45rem; line-height: 1.15; }
  .run-box span { font-size: .75rem; }
  .pause { width: 44px; height: 44px; }
  .pause:hover { border-color: #ffcb94; }
  .xp-hud, .quest-hud {
    left: var(--hud-edge);
    transform: none;
    width: min(var(--hud-width), 275px);
    padding: 6px 9px;
    font-size: .85rem;
  }
  .xp-hud { top: 89px; }
  .xp-track { flex: 1; }
  .quest-hud { top: 127px; }
  #quest-phase { font-size: .68rem; }
  #fullscreen-status:not(:empty) {
    display: block;
    position: absolute;
    right: clamp(16px, 2.35vw, 40px);
    top: 64px;
    z-index: 2;
    max-width: 26ch;
    margin: 0;
    padding: 9px 12px;
    border: 1px solid #c18d60;
    border-radius: 8px;
    background: #101820f5;
    font-size: .875rem;
  }
  .boss-hud { top: 79px; width: min(46vw, 420px); padding: 6px 10px; font-size: .85rem; }
  .rush { top: 79px; left: auto; right: var(--hud-edge); transform: none; max-width: 26vw; justify-content: end; }
  .boss-active .rush { top: 79px; }
  .horde-alert { top: 129px; }
  #toast { bottom: max(27%, 150px); }
  .combat-controls {
    inset: auto var(--hud-edge) 19px;
    align-items: end;
    justify-content: space-between;
  }
  .attack-belt { justify-items: end; margin-inline: auto 0; }
  .build-counts > span { padding: 3px 7px; font-size: .86rem; }
  .abilities { grid-template-columns: repeat(var(--learned, 1), 52px); }
  .ability { height: 52px; pointer-events: auto; }
  .ability small { font-size: .65rem; }
  .battle-keys {
    padding: 8px;
    border: 1px solid #abc1bc48;
    border-radius: 8px;
    background: #101820ed;
  }
  .battle-footer { bottom: 19px; padding: 5px 12px; font-size: .83rem; }

  #panel[data-kind="campaign"] { width: min(600px, calc(100% - 28px)); }
  #panel[data-kind="campaign"] .world-map {
    width: min(100%, 510px, 55dvh);
    margin-inline: auto;
  }
  #panel[data-kind="chapter"],
  #panel[data-kind="briefing"],
  #panel[data-kind="upgrade"] { width: min(950px, calc(100% - 32px)); }
  .chapter-route {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(270px, .7fr);
    align-items: center;
    gap: 16px;
  }
  .route-preview { min-height: clamp(248px, 45dvh, 480px); }
  .route-steps { margin: 0; row-gap: 13px; padding-block: 12px; }
  .route-step[data-link="down"]::after { height: calc(100% + 13px); }
  .route-step button { min-width: 48px; min-height: 48px; font-size: .95rem; }
  .chapter-hero { min-height: clamp(180px, 34dvh, 315px); }
  .upgrade-cards { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .upgrade-card { position: relative; align-items: start; min-height: 125px; padding: 14px 39px 14px 12px; }
  .upgrade-key { display: inline-grid; position: absolute; top: 10px; right: 9px; }
}
@media (min-width: 820px) and (orientation: landscape) and (any-pointer: coarse) {
  #stick { display: flex; }
  .battle-keys { display: none; }
}
@media (min-width: 820px) and (max-width: 1050px) and (orientation: landscape) {
  .mission-controls { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
  .mission-controls .challenge-link { grid-column: 1 / -1; }
}
