/* ============================================================
 * Universal Mobile & WeChat WebView Adaptation Layer
 * Applies cleanly across all 14 portrait 5-minute mini games
 * ============================================================ */

:root {
  --app-vh: 1vh;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

html,
body {
  overscroll-behavior: none;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  width: 100%;
  height: calc(var(--app-vh) * 100);
  height: 100dvh;
}

/* Eliminate 300ms double-tap delay without breaking touch-action:none draggable slots/buttons */
a,
.mode-btn,
.choice-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* Explicitly preserve touch-action:none on all draggable game items & hold-buttons */
.bp-slot,
.shop-card,
.ctrl-btn,
.action-btn {
  touch-action: none;
}

/* Prevent page drag/scroll on all interactive game canvases */
canvas {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Mobile / Coarse Pointer: Full-bleed native WeChat Mini Game feel */
@media (max-width: 540px), (hover: none) and (pointer: coarse) {
  body {
    padding: 0 !important;
    margin: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
  }

  .app-backdrop {
    padding: 0 !important;
    width: 100% !important;
    height: calc(var(--app-vh) * 100) !important;
  }

  .wx-shell,
  .phone-shell,
  #app-shell,
  .game-shell,
  .wechat-shell {
    width: 100% !important;
    max-width: 100% !important;
    height: calc(var(--app-vh) * 100) !important;
    max-height: calc(var(--app-vh) * 100) !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding-bottom: var(--sab);
    padding-left: var(--sal);
    padding-right: var(--sar);
  }

  /* Safe-area aware top bar */
  .wx-topbar,
  #wx-header,
  .wx-bar {
    padding-top: max(6px, var(--sat)) !important;
    height: auto !important;
    min-height: calc(44px + var(--sat)) !important;
    flex-shrink: 0 !important;
  }

  .wx-title {
    font-size: 14px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .wx-back,
  .wx-back-btn {
    min-height: 30px;
    display: inline-flex !important;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* Smooth scrolling inside Start / End / Modal overlays on short mobile viewports */
[id*="startScreen"],
[id*="start-screen"],
[id*="screen-start"],
[id*="endScreen"],
[id*="end-screen"],
[id*="screen-end"],
[id*="overlay-start"],
[id*="overlay-end"],
.start-screen,
.end-screen,
.screen-overlay,
.modal-body,
.modal-card,
.modal-sheet,
.modal-panel,
.dex-list,
.rules-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Compact adjustments for short mobile viewports (e.g. WeChat iOS WebView ~580-670px) */
@media (max-height: 690px) {
  .wx-topbar,
  #wx-header,
  .wx-bar {
    min-height: calc(38px + var(--sat)) !important;
    padding-bottom: 4px !important;
  }

  .wx-title {
    font-size: 13px !important;
  }
}

/* Subtle non-blocking hint if phone is rotated to narrow landscape */
#mobile-landscape-hint {
  display: none;
  position: fixed;
  left: 50%;
  bottom: max(12px, var(--sab));
  transform: translateX(-50%);
  z-index: 99999;
  background: rgba(15, 23, 42, 0.88);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

@media (max-height: 460px) and (orientation: landscape) and (pointer: coarse) {
  #mobile-landscape-hint {
    display: block;
  }
}
