/* Shared responsive foundation — mobile-first. */

html,
body {
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

button,
.btn,
.move-btn {
  min-height: max(44px, 2.75rem);
}

img,
svg,
video,
canvas {
  max-width: 100%;
}

.game-shell,
.game-shell__main,
.game-arena-panel,
.battle-arena,
.vip-live-arena {
  min-width: 0;
  max-width: 100%;
}

@media (min-width: 380px) {
  .choice-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 480px) {
  #app {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .choice-grid {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .header {
    padding-top: 0.5rem;
  }

  .header__title {
    font-size: 1.25rem;
  }

  .scoreboard__value {
    font-size: 1.5rem;
  }

  .choice-btn {
    min-height: 2.75rem;
  }

  .game-shell__main {
    padding-top: max(.35rem, var(--rps-safe-top));
    padding-bottom: max(.35rem, var(--rps-safe-bottom));
  }
}

@media (min-width: 768px) {
  #app {
    max-width: 520px;
  }
}

/* Prevent horizontal overflow in content blocks. */
pre, code {
  max-width: 100%;
  overflow-x: auto;
}

button, input {
  font-family: inherit;
}

@media (max-width: 520px) {
  #app {
    max-width: none;
    padding-inline: max(.65rem, var(--rps-safe-left)) max(.65rem, var(--rps-safe-right));
  }

  .game-shell__main {
    padding-inline: max(.55rem, var(--rps-safe-left)) max(.55rem, var(--rps-safe-right));
  }
}

@media (max-width: 360px) {
  #app {
    padding-inline: max(.45rem, var(--rps-safe-left)) max(.45rem, var(--rps-safe-right));
  }
}

/* Non-blocking portrait guidance. The game remains fully usable underneath. */
.orientation-recommendation {
  position: fixed;
  z-index: 1000;
  inset-inline: max(.65rem, var(--rps-safe-left)) max(.65rem, var(--rps-safe-right));
  bottom: max(.65rem, var(--rps-safe-bottom));
  width: min(30rem, calc(100vw - 1.3rem));
  margin-inline: auto;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--color-accent) 46%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--color-surface) 94%, transparent);
  box-shadow: 0 12px 34px rgb(0 0 0 / 38%);
  backdrop-filter: blur(14px);
}

.orientation-recommendation__title {
  display: block;
  color: var(--color-text);
  font-size: clamp(.82rem, 3.3vw, 1rem);
  line-height: 1.35;
}

.orientation-recommendation__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
  margin-top: .8rem;
}

.orientation-recommendation__actions .btn {
  min-width: 0;
  min-height: 44px;
  padding-inline: .65rem;
  font-size: clamp(.65rem, 2.8vw, .78rem);
  white-space: normal;
}

@media (max-width: 360px) {
  .orientation-recommendation__actions {
    grid-template-columns: 1fr;
  }
}

/* Keep live-match move controls usable on narrow screens without changing
   the protected live-layout stylesheet. */
@media (max-width: 720px) {
  .vip-live-match .battle-moves {
    max-width: calc(100% - 1rem);
    box-sizing: border-box;
  }

  .vip-live-match .move-btn {
    min-height: 48px;
  }
}

/* Stage D: shared battle geometry for portrait and short landscape. */
@media (max-width: 520px) and (orientation: portrait) {
  .battle-arena__top { gap: .25rem; }
  .battle-player__portrait { width: clamp(38px, 12vw, 48px); height: clamp(38px, 12vw, 48px); }
  .battle-player__name { font-size: clamp(.66rem, 2.8vw, .82rem); }
  .battle-action-stage { height: clamp(7rem, 24vh, 10.25rem); min-height: 7rem; max-height: 10.25rem; }
  .battle-timer { width: clamp(4.35rem, 18vw, 5.75rem); height: clamp(4.35rem, 18vw, 5.75rem); }
  .battle-moves { width: 100%; margin-top: .2rem; }
  .move-btn { min-height: 4.1rem; height: 4.1rem; padding-block: .45rem; }
  .move-btn__icon { width: 34px; height: 34px; }
  .battle-match-result { max-height: calc(var(--rps-viewport-height) - 1rem); overflow-y: auto; overscroll-behavior: contain; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .battle-arena__top { gap: .3rem; }
  .battle-player__portrait { width: 38px; height: 38px; }
  .battle-action-stage { height: clamp(4.5rem, 27vh, 7rem); min-height: 4.5rem; max-height: 7rem; }
  .battle-timer { width: 4.15rem; height: 4.15rem; font-size: 1.65rem; }
  .battle-moves__grid { gap: .35rem; }
  .move-btn { min-height: 3.35rem; height: 3.35rem; padding-block: .25rem; }
  .move-btn__icon { width: 28px; height: 28px; }
}
