#gameViewport { position: relative; width: 100%; height: 100%; }
#viewportBounds { height: 100%; }
.admin-page :is(#viewportBounds, #gameViewport) { display: contents; }
.phone, .phone body { overflow: hidden; }
/* Kill the default translucent tap flash on buttons/links. */
.phone, .phone * { -webkit-tap-highlight-color: transparent; }
.phone #viewportBounds {
  display: block; position: fixed; container-type: size;
  left: calc(var(--visible-left) + env(safe-area-inset-left));
  top: calc(var(--visible-top) + env(safe-area-inset-top));
  width: calc(var(--visible-width) - env(safe-area-inset-left) - env(safe-area-inset-right));
  height: calc(var(--visible-height) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.phone #gameViewport {
  display: block; position: absolute; inset: 0 auto auto 0; overflow: hidden; container-type: size;
  box-sizing: border-box; transform: translate(0); transform-origin: top left;
  width: 100cqw; height: 100cqh; transition: none;
}
.phone.sideways #gameViewport {
  left: 100%; width: 100cqh; height: 100cqw; transform: rotate(90deg);
}
.phone .admin-page #gameViewport { overflow: auto; padding: 1rem; }
.phone #sceneSelect { container-name: mobile-menu; }
/* The navigation follows the height of its original artwork. Give the
   remaining width to the active panel so lists and the chapter rail can grow. */
.phone .menu-home {
  --nav-width: min(25%, 37.62cqh);
  width: 100%; height: 100%; aspect-ratio: auto; margin: 0;
  background: #172b24;
}
.phone .menu-nav {
  width: var(--nav-width);
  background: url(menu/home-back.jpg) left center / auto 100% no-repeat;
}
.phone .menu-nav img { object-fit: contain; }
.phone .content-panel { left: var(--nav-width); }
.phone :is(.menu-difficulty, .streamer-note, .scene-picker) {
  left: calc(var(--nav-width) + 1.8%);
}
/* 1287 × 145 header artwork: extend the line between the title and lamp. */
.phone .scene-heading {
  left: var(--nav-width);
  container-type: size;
}
.phone .scene-heading::before {
  content: ""; position: absolute; inset: 0;
  border-image: url(menu/heading.jpg) 0 180 0 320 fill / 0 124.14cqh 0 220.69cqh stretch;
}
.phone .scene-heading img { opacity: 0; }
.phone .room-heading img { object-fit: contain; }
/* Preview JPGs bake the scene name into the bottom edge; keep that edge visible. */
.phone #localPanel .scene-cards img {
  object-fit: cover;
  object-position: center bottom;
}
/* Extend the menu artwork behind cutouts while keeping controls in the safe area. */
.phone body:has(#sceneSelect) { background: #183325 url(chapter-map/club.jpg) center / cover; }
.phone .ss-tier span, .phone .table-tools, .phone .table-zoom { font-size: max(12px, 1.55cqw); }
.phone .menu-difficulty { min-height: 26px; }
.phone .menu-avatar-name { font-size: max(13px, 1.7cqw); }
.phone .menu-avatar small { font-size: max(11px, 1.25cqw); }
.phone #lobbyRoom #lobbyLeave { min-height: 30px; min-width: 50px; }
.phone .table-zoom button { min-width: 28px; min-height: 28px; }
.phone #tableZoom { height: 36px; }
.phone #profileNick, .phone #streamerHud input { font-size: 16px; }
.phone #tableNumber {
  font-size: max(12px, 1.55cqw);
  padding-left: 2em;
}
.phone .roster-page { overflow: auto; }
.phone .roster-left { justify-content: safe center; }
.phone .roster-title { padding-top: 5%; }
.phone .roster-link, .phone .roster-actions button { font-size: 13px; padding: 6px 10px; }
.phone .roster-actions { top: calc(100% + 3px); }
.phone #profileStatus { top: calc(100% + 32px); font-size: 12px; }
/* Keep the result below the two top-corner toolbars. */
.phone #resultBar { width: min(100%, 1024px); translate: 0 48px; }
.phone #resultText { width: 100%; }
/* 居中提示（规则消息）在手机上收小；位置在 hud.js resize() 里上移到中间偏上。 */
.phone #ruleText { font-size: 16px; }
.phone #ruleSub { font-size: 13px; }
.phone #streamerHud { top: 54px; bottom: auto; max-height: calc(100% - 68px); overflow: auto; box-sizing: border-box; }
.phone #linkDrop, .phone #matchSettle { max-height: calc(100% - 36px); box-sizing: border-box; overflow: auto; }
.phone #linkDrop { top: 12px; }
.phone #replayControls { max-width: calc(100% - 32px); }
.phone #replayControls .shot-menu { left: 0; max-height: min(200px, 45cqh); }
.phone #gameHudActions { left: 8px; top: 8px; gap: 4px; }
.phone #gameHudActions kbd { display: none; }
.phone :is(#ruleChoice, #matchExitDialog, #controlsGuide):modal {
  position: fixed; inset: var(--dialog-y) auto auto var(--dialog-x);
  margin: 0; transform: translate(-50%, -50%) rotate(var(--dialog-angle, 0deg));
  max-width: calc(var(--dialog-width) - 16px); max-height: calc(var(--dialog-height) - 16px);
  box-sizing: border-box; overflow: auto;
}
.phone #controlsGuide:modal { width: min(52rem, calc(var(--dialog-width) - 16px)); overflow: hidden; }
.phone.sideways { --dialog-angle: 90deg; --rail-touch-action: none; }
.phone #characterZoom { position: absolute; bottom: 8px; right: 12px; display: flex; gap: 8px; }
#characterZoom { display: none; }
#characterZoom button { font: 20px system-ui; width: 44px; height: 40px; }
.phone .character-page canvas { touch-action: none; }

.phone #watchControls { bottom: 66px; }
.phone body.watching-replay #watchControls {
  left: auto; right: 8px; top: 8px; bottom: auto;
}
.phone body.watching-replay #replayControls { bottom: 8px; }
.phone .roster-right:has(#recordList) { display: flex; flex-direction: column; }
.phone #recordList { min-height: 0; }
@container mobile-menu (max-height: 220px) {
  /* Keep the active form usable above a landscape software keyboard. */
  .phone .menu-home { min-height: 220px; }
}
.phone .character-page #hint span { display: none; }
