/* Scrollable game panels can pan. Specific battle controls still own their pointers. */
:where([data-game-viewport], [data-game-viewport] *) {
  touch-action: pan-x pan-y;
}

.handset {
  --screen-height: min(860px, calc(100dvh - 106px), calc((100vw - 44px) * 19.5 / 9));
  --rim: 9px;
  --safe-top: clamp(25px, 4dvh, 38px);
  --safe-bottom: 18px;
  --safe-left: 0px;
  --safe-right: 0px;
  --nav-height: 44px;
  --chrome-height: calc(var(--safe-top) + var(--nav-height));
  flex: none;
  position: relative;
  width: calc(var(--screen-height) * 9 / 19.5 + 2 * var(--rim));
  padding: var(--rim);
  border-radius: clamp(27px, 5dvh, 54px);
  background: linear-gradient(120deg, #adafa5, #393c39 12%, #121414 50%, #777b75 88%, #272a29);
  box-shadow: 0 0 0 1px #1b1c1a, inset 0 0 0 2px #ffffff35, inset 0 0 0 5px #141615, 0 12px 42px #07120e99;
}
.handset::before, .handset::after {
  content: ''; position: absolute; width: 3px; background: #686d66; border-radius: 2px;
  pointer-events: none;
}
.handset::before { left: -3px; top: 19%; height: 4%; box-shadow: 0 38px #686d66; }
.handset::after { right: -3px; top: 28%; height: 8%; }
.screen {
  height: var(--screen-height);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: calc(clamp(27px, 5dvh, 54px) - var(--rim));
  background: #1b3028;
  container-type: inline-size;
}
.screen::before, .screen::after {
  content: ''; position: absolute; z-index: 8; left: 50%; transform: translateX(-50%);
  border-radius: 30px; pointer-events: none;
}
.screen::before { width: 23%; height: calc(var(--safe-top) * .62); top: 6px; background: #090b0a; }
.screen::after { width: 32%; height: 4px; bottom: 6px; background: #efece0; }
.wx-nav {
  position: absolute; z-index: 4; top: 0; inset-inline: 0; height: var(--chrome-height);
  padding: var(--safe-top) calc(10px + var(--safe-right)) 0 calc(10px + var(--safe-left));
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(#10231ede, #10231eb8);
}
.wx-nav button {
  display: grid; place-items: center; padding: 0; color: #fff;
  background: transparent; border: none; min-height: 32px;
}
.wx-nav button:focus-visible { outline-offset: -3px; }
#wx-back, .wx-capsule {
  border: 1px solid #ffffff65; border-radius: 20px; background: #10221abf;
}
#wx-back { width: 42px; }
.wx-nav svg { width: 20px; height: 20px; }
#wx-back path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back-icon, .playing .home-icon { display: none; }
.playing .back-icon { display: inline; }
.wx-capsule { display: flex; align-items: center; }
.wx-capsule button { width: 43px; }
.wx-capsule::before { content: ''; width: 1px; height: 15px; background: #ffffff52; order: 1; }
#wx-exit { order: 2; }
#wx-menu {
  position: absolute; z-index: 7; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; color: var(--paper); background: #0b1914a8;
}
#wx-menu[open] { display: flex; align-items: flex-end; }
.wx-sheet {
  width: 100%; padding: 18px 14px calc(14px + var(--safe-bottom));
  background: #21352e; border-radius: 18px 18px 0 0; display: grid; gap: 7px;
}
.wx-sheet h2 { margin: 0 0 5px; font-size: 16px; }
.wx-sheet button { min-height: 40px; border-radius: 8px; }
@media (max-width: 700px) {
  .handset { --screen-height: min(860px, calc(100dvh - 44px), calc((100vw - 44px) * 19.5 / 9)); }
}
@media (max-width: 700px) and (orientation: portrait) and (pointer: coarse) {
  .handset {
    --screen-height: 100dvh; --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px);
    width: min(100%, calc(100dvh * 9 / 16)); padding: 0; border-radius: 0; background: none; box-shadow: none;
  }
  .screen { border-radius: 0; }
  .handset::before, .handset::after, .screen::before, .screen::after { display: none; }
}
@media (max-height: 550px) and (orientation: landscape) {
  .handset { --screen-height: calc(100dvh - 16px); --rim: 6px; --safe-top: 17px; --safe-bottom: 8px; --nav-height: 34px; }
}
