@media (max-height: 760px) {
  .shell { padding: 8px; }
  .battle-screen { min-height: 0; height: calc(100dvh - 16px); padding: 10px; overflow: hidden; }
  .battle-status { margin: 2px 0; min-height: 20px; }
  .canvas-wrap { min-height: 0; padding: 4px; }
  .canvas-wrap canvas { width: auto; height: calc(100dvh - 230px); max-width: 100%; max-height: 100%; }
  .touch-controls { margin: 6px auto; }
  .control-hint { margin: 3px 0; font-size: .76rem; }
  .restart { min-height: 36px; }
  .battle-screen > #restartBtn { position: absolute; top: 10px; right: 10px; min-height: 36px; }
  .battle-head { padding-right: 150px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  /* Keep Main inside the landscape viewport; the portrait-sized poster used
     to force the whole shell past the bottom edge before Battle started. */
  .main-screen { min-height: 0; }
  .main-screen .topbar { padding-bottom: 8px; }
  .main-screen .main-grid { align-items: center; gap: 14px; padding: 12px; }
  .main-screen .poster { width: min(32vw, 270px); margin-inline: auto; }
  .main-screen .guide,
  .main-screen .main-howto { display: none; }
  body.wp-shell-main-active .wp-standard-main-composition {
    --wp-main-landscape-poster-size: clamp(200px, calc(100dvh - 130px), 270px) !important;
  }
  body.wp-shell-main-active .wp-standard-main-poster,
  body.wp-shell-main-active .wp-standard-main-poster-media,
  body.wp-shell-main-active .wp-standard-main-poster-media > img,
  body.wp-shell-main-active .wp-standard-main-poster > img {
    width: var(--wp-main-landscape-poster-size) !important;
    min-width: var(--wp-main-landscape-poster-size) !important;
    max-width: var(--wp-main-landscape-poster-size) !important;
    height: var(--wp-main-landscape-poster-size) !important;
    min-height: var(--wp-main-landscape-poster-size) !important;
    max-height: var(--wp-main-landscape-poster-size) !important;
  }
  body.wp-shell-main-active .wp-standard-main-copy { height: var(--wp-main-landscape-poster-size) !important; }
}

.twin-landscape-controls {
  display: none;
}

@media (max-height: 520px) and (orientation: landscape) {
  .battle-screen .touch-controls {
    display: none !important;
  }

  .twin-landscape-controls {
    position: fixed;
    z-index: 60;
    left: 50%;
    bottom: 8px;
    width: min(92vw, 560px);
    display: grid;
    grid-template-columns: 80px minmax(160px, 1fr) 80px;
    gap: 10px;
    margin: 0;
    transform: translateX(-50%);
  }

  .twin-landscape-controls[hidden] {
    display: none !important;
  }

  .twin-landscape-controls button {
    min-height: 52px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: var(--text);
    background: #ffffff0b;
    font-weight: 800;
  }

  .twin-landscape-controls button[data-twin-control="jump"] {
    background: linear-gradient(135deg, #78e2dc, #38a9bc);
    color: #06202b;
    border-color: #a4fff3;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .shell { padding: 4px; }
  .battle-screen { padding: 6px; }
  .battle-status, .control-hint { display: none; }
  .battle-screen .canvas-wrap { padding: 3px; display: grid; place-items: center; }
  .battle-screen .canvas-wrap canvas {
    width: auto !important;
    height: calc(100dvh - 195px) !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 195px) !important;
  }
  .touch-controls { margin: 4px auto; grid-template-columns: 60px minmax(140px,280px) 60px; }
  .restart { min-height: 34px; }
  .battle-screen .canvas-wrap canvas { height: calc(100dvh - 195px) !important; width: auto !important; max-width: 100% !important; max-height: calc(100dvh - 195px) !important; }
}
