/* ==========================================================================
   jackane宇 · 移动端与微信/国内浏览器专项自适应层 (mobile-adapt.css)
   铁律：桌面端 (> 768px 键鼠环境) 100% 零改动，所有布局适配严格隔离在移动断点内
   ========================================================================== */

/* PC 桌面端默认彻底隐藏移动端专属「体感微闪」按钮，保证桌面检视坞像素级零变动 */
.mobile-only-gyro {
  display: none !important;
}

/* 弹窗底部低调非商业与版权合规声明条（不占用主舞台任何像素） */
.compliance-footnote {
  margin: 0;
  padding: 7px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(6, 9, 18, 0.55);
  color: rgba(148, 163, 184, 0.68);
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
  flex-shrink: 0;
}

.compliance-footnote.in-body {
  margin-top: 4px;
  border: 1px dashed rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
}

/* 晒卡战报长按保存图片容器（仅在移动端/微信生成时显式开启，允许系统原生保存菜单） */
.poster-mobile-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1.5px solid rgba(245, 200, 76, 0.45);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
  -webkit-touch-callout: default !important;
  -webkit-user-select: auto !important;
  user-select: auto !important;
  pointer-events: auto !important;
}

.poster-mobile-img[hidden] {
  display: none !important;
}

.poster-wechat-tip {
  margin: 0;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(245, 200, 76, 0.14);
  border: 1px solid rgba(245, 200, 76, 0.42);
  color: #fde68a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.poster-wechat-tip[hidden] {
  display: none !important;
}

/* 触屏与移动端：GPU 显存保护、禁用崩溃滤镜与启用体感微闪按钮（PC 桌面端 0 影响） */
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
  :root {
    --chrome-surface: rgba(12, 17, 29, 0.96);
  }

  html[data-studio-light="day"] {
    --chrome-surface: rgba(255, 255, 255, 0.96);
  }

  /* 1. 彻底关闭安卓微信 XWeb / 移动 GPU 必黑屏的 SVG 卷积锐化滤镜 (<feConvolveMatrix>) */
  .showcase-layer .card-full-art,
  .card.stack-top .card-full-art,
  .card.zoomed-focus .card-full-art,
  .card-full-art {
    filter: none !important;
    transform: none !important;
  }

  /* 2. 关闭全屏多通道高斯模糊 (backdrop-filter)，彻底根治移动端 512px 显存瓦片丢失导致的底栏截断/白块与点击闪屏 */
  .ledger-pill-btn,
  .trophy-hall-btn,
  .brand-stage-crest,
  .utility-cluster,
  .switcher-row,
  .variant-pills,
  .box-bar-compact,
  .box-drawer-panel,
  .pull-banner,
  .showcase-scrim,
  .card-inspect-pill,
  .showcase-bar,
  .showcase-nav-paddle,
  .agency-picker-bar,
  .console-dock,
  .binder-backdrop,
  .tear-label,
  .back-print-box {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* 2b. 安卓 Chromium / 微信 XWeb 防点击闪背景：锁死舞台背景单层不透明合成，禁用触屏按钮动态 filter/transform 升层 */
  button,
  a,
  label,
  [role="button"] {
    -webkit-tap-highlight-color: transparent !important;
  }

  .stage-backdrop {
    contain: strict;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  html[data-studio-light="dark"] .stage-backdrop-light,
  html[data-studio-light="day"] .stage-backdrop-dark {
    display: none !important;
  }

  html[data-studio-light="dark"] .stage-backdrop-dark,
  html[data-studio-light="day"] .stage-backdrop-light {
    opacity: 1 !important;
    transition: none !important;
  }

  .dock-btn:hover:not(:disabled),
  .dock-btn:active:not(:disabled),
  .dock-btn.is-pressed:not(:disabled),
  .fresh-box-btn:hover:not(:disabled),
  .fresh-box-btn:active:not(:disabled),
  .box-scale-trigger:hover:not(:disabled),
  .box-scale-trigger:active:not(:disabled),
  .ledger-pill-btn:active,
  .trophy-hall-btn:active,
  .brand-stage-crest:active,
  .box-selector-trigger:active,
  .flip-pack-btn:active,
  .showcase-nav-paddle:hover:not(:disabled),
  .showcase-nav-paddle:active:not(:disabled),
  .util-btn:active {
    filter: none !important;
    transform: none !important;
    translate: none !important;
  }

  .dock-btn:active:not(:disabled),
  .ledger-pill-btn:active,
  .brand-stage-crest:active,
  .box-selector-trigger:active,
  .flip-pack-btn:active {
    border-color: rgba(245, 200, 76, 0.72) !important;
  }

  .showcase-scrim {
    background: rgba(5, 8, 18, 0.9) !important;
  }

  html[data-studio-light="day"] .showcase-scrim {
    background: rgba(15, 23, 42, 0.72) !important;
  }

  .binder-backdrop {
    background: rgba(5, 8, 16, 0.88) !important;
  }

  /* 3. 移除全屏动态噪点层与大半径离屏高斯模糊，释放数十 MB 移动显存 */
  .stage-grain {
    display: none !important;
  }

  .pack-aura,
  .ground-shadow,
  .ground-shadow.fat-shadow,
  .anamorphic-halo {
    filter: none !important;
  }

  /* 4. 扁平化主舞台 (.scene) 卡牌 3D 层级，杜绝 20 张肥包并发 preserve-3d 爆显存 */
  .card-edge {
    display: none !important;
  }

  .scene .card {
    transform-style: flat !important;
    will-change: auto !important;
  }

  .scene .card-back {
    display: none !important;
  }

  .scene .card-face {
    transform: none !important;
    isolation: auto !important;
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
  }

  .scene .card-full-art {
    backface-visibility: visible !important;
    -webkit-backface-visibility: visible !important;
  }

  .showcase-layer .card {
    will-change: auto !important;
  }

  .showcase-layer .card-face {
    isolation: auto !important;
  }

  /* 进入 3D 检视台时彻底挂起底层舞台元素，保证 GPU 100% 算力供给当前单卡与卡砖 */
  .stage.showcase-mode .scene,
  .stage.showcase-mode .stage-playmat {
    visibility: hidden !important;
  }

  /* 平视静止态 (--tilt: 0) 不挂载全息遮罩与混合模式层；仅在手指倾斜单卡 (.is-tilting) 时按需点亮 */
  .card:not(.is-tilting) .card-face > .foil-holo,
  .card:not(.is-tilting) .card-face > .foil-texture,
  .card:not(.is-tilting) .card-face > .foil-glare {
    display: none !important;
  }

  /* 移动端简化双复合 SVG 噪点遮罩为轻量线性微闪，杜绝搓卡掉帧 */
  .card.is-tilting .card-face > .foil-texture {
    display: none !important;
  }

  .mobile-only-gyro:not([hidden]) {
    display: inline-flex !important;
  }

  .mobile-only-gyro.gyro-active {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.28), rgba(245, 200, 76, 0.24)) !important;
    border-color: rgba(245, 200, 76, 0.72) !important;
    color: #fde047 !important;
  }

  html[data-studio-light="day"] .mobile-only-gyro.gyro-active {
    color: #0369a1 !important;
    border-color: rgba(2, 132, 199, 0.58) !important;
  }
}

/* ==========================================================================
   手机端视口全面适配 (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {
  :root {
    --pack-h: min(368px, 45svh, 94vw);
    --card-w: min(318px, 75vw, calc((100svh - 236px) / 1.3967));
  }

  /* ---------- 1. 顶栏防撞收口（适配 360px~430px 手机屏与灵动岛） ---------- */
  .top-bar {
    top: max(10px, env(safe-area-inset-top));
    left: 8px;
    right: 8px;
    min-height: 36px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
  }

  .top-left-cluster {
    gap: 5px;
  }

  .ledger-pill-btn {
    height: 32px;
    padding: 0 9px;
    font-size: 12px;
    gap: 4px;
  }

  .trophy-hall-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
  }

  .trophy-hall-btn .bond-ready-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 7px;
    height: 7px;
  }

  .brand-stage-crest {
    padding: 4px 11px 4px 6px;
    gap: 6px;
    max-width: 100%;
  }

  .crest-ball {
    width: 22px;
    height: 22px;
  }

  .crest-owner {
    font-size: 12.5px;
    white-space: nowrap;
  }

  .crest-sub {
    display: none;
  }

  .utility-cluster {
    padding: 2px;
    gap: 2px;
  }

  .util-btn,
  .util-btn.mode-btn,
  .util-btn.foil-btn,
  .util-btn.mute-btn {
    width: 30px;
    height: 30px;
    padding: 0;
  }

  /* ---------- 2. 顶部选盒胶囊与下拉抽屉防裁切 ---------- */
  .series-switcher {
    top: calc(max(10px, env(safe-area-inset-top)) + 41px);
    max-width: calc(100vw - 14px);
    gap: 6px;
  }

  .box-bar-compact {
    max-width: 100%;
    padding: 3px 5px 3px 4px;
    gap: 4px;
  }

  .box-selector-trigger {
    height: 28px;
    padding: 0 8px 0 4px;
    gap: 6px;
    min-width: 0;
  }

  .box-trigger-title {
    font-size: 11.5px;
    max-width: 44vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .box-trigger-meta {
    font-size: 10px;
    padding: 1px 6px;
  }

  .flip-pack-btn {
    height: 28px;
    padding: 0 8px;
    font-size: 11px;
  }

  .box-drawer-panel {
    width: calc(100vw - 16px);
    max-height: calc(100svh - 110px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px;
    border-radius: 18px;
  }

  .box-drawer-panel .variant-pills {
    flex-wrap: wrap;
  }

  /* ---------- 3. 出货横幅与舞台中心高度平衡 ---------- */
  .pull-banner {
    top: calc(max(10px, env(safe-area-inset-top)) + 42px);
    width: max-content;
    max-width: calc(100vw - 20px);
    padding: 8px 14px 9px;
    border-radius: 18px;
    white-space: normal;
    text-align: center;
  }

  .banner-title {
    font-size: 12.5px;
    line-height: 1.35;
  }

  .pack,
  .card {
    top: 46.5%;
  }

  .ground-shadow,
  .pack-aura {
    top: 46.5%;
  }

  .showcase-layer {
    --card-w: min(326px, 78vw, calc((100svh - 228px) / 1.3967));
  }

  .showcase-layer.has-slab {
    --card-w: min(292px, 73vw, calc((100svh - 304px) / 1.3967));
  }

  .showcase-nav-paddle {
    width: 38px;
    height: 38px;
    top: 44%;
  }

  .showcase-nav-paddle.prev { left: 6px; }
  .showcase-nav-paddle.next { right: 6px; }

  /* 窄屏亚克力砖铭牌与微距标尺防溢出 */
  .bgs-sub-matrix {
    gap: 1px 4px;
    padding: 2px 4px;
    font-size: 7px;
  }

  .psa-barcode {
    width: 48px;
  }

  .caliper-readout-bar {
    gap: 4px;
    top: -34px;
  }

  .caliper-chip {
    padding: 2px 5px;
    font-size: 9.5px;
  }

  /* ---------- 4. 底部双层拇指控制台（主操作置顶放大 + 状态条紧凑归拢） ---------- */
  .bottom-chrome {
    bottom: max(10px, env(safe-area-inset-bottom, 10px));
    width: calc(100vw - 14px);
    max-width: 460px;
    gap: 6px;
  }

  .gesture-hint {
    white-space: normal;
    text-align: center;
    justify-content: center;
    max-width: calc(100vw - 24px);
    font-size: 11px;
    line-height: 1.35;
  }

  .gesture-hint::before,
  .gesture-hint::after {
    display: none;
  }

  .card-inspect-pill {
    max-width: 100%;
    padding: 5px 10px;
    gap: 4px 6px;
    font-size: 11px;
    border-radius: 16px;
    white-space: normal;
    flex-wrap: wrap;
    justify-content: center;
    overflow: visible;
  }

  .inspect-name {
    max-width: 128px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .inspect-quick-3d {
    padding: 2px 9px;
    font-size: 10.5px;
  }

  .console-dock {
    width: 100%;
    padding: 6px 7px;
    border-radius: 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 4px;
  }

  /* 第一排：大拇指高频主按钮区横跨整行 */
  .console-actions {
    order: -1;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0;
  }

  .console-actions .dock-btn {
    flex: 1 1 auto;
    height: 37px;
    padding: 0 10px;
    font-size: 12.5px;
  }

  .console-actions #prevCardBtn {
    flex: 0 0 auto;
    padding: 0 10px;
  }

  /* 第二排：图鉴 + 点数 + 盒况点阵 + 称重/换盒 稳居单排不折三层 */
  .console-item {
    height: 30px;
    padding: 0 5px;
    gap: 4px;
  }

  .console-item:not(.luck-switch) .console-kicker {
    display: none;
  }

  .console-val {
    font-size: 11px;
  }

  .binder-icon {
    width: 14px;
    height: 14px;
  }

  .points-gem {
    width: 15px;
    height: 15px;
    font-size: 9px;
  }

  #boxStatusKicker {
    display: none;
  }

  .box-meter-group {
    flex: 1 1 auto;
    justify-content: flex-end;
    min-height: 30px;
    height: auto;
    padding: 1px 0 1px 4px;
    gap: 4px;
  }

  .box-meta-with-matrix {
    gap: 2px;
    padding: 1px 2px;
    margin: 0;
  }

  #boxRemainText {
    font-size: 10px;
  }

  .box-matrix-track {
    gap: 1.5px;
  }

  .box-slot-cell {
    width: 3.8px;
    height: 5.5px;
  }

  .box-slot-cell.is-fat-slot {
    width: 7.5px;
  }

  .box-scale-trigger,
  .fresh-box-btn {
    height: 26px;
    padding: 0 7px;
    font-size: 10.5px;
    gap: 3px;
  }

  /* 3D 检视底部操作坞与双机构选送栏手机收口 */
  .showcase-bar {
    width: 100%;
    padding: 6px;
    border-radius: 18px;
    gap: 5px;
  }

  .showcase-sep {
    display: none !important;
  }

  .showcase-group {
    flex: 1 1 auto;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
  }

  .showcase-bar .dock-btn {
    flex: 1 1 auto;
    height: 34px;
    padding: 0 10px;
    font-size: 11.5px;
  }

  .agency-picker-bar {
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 18px;
    padding: 7px;
    gap: 6px;
  }

  .agency-choice-btn {
    flex: 1 1 140px;
    padding: 7px 10px;
  }

  /* ---------- 5. 六大弹窗全面升级为手机底部抽屉 (Bottom Sheet) ---------- */
  .binder-modal {
    padding: 0;
    align-items: end;
  }

  .binder-sheet {
    width: 100%;
    max-width: 100%;
    max-height: 91svh;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: none;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  .binder-sheet::before {
    content: "";
    display: block;
    width: 38px;
    height: 4px;
    margin: 8px auto 2px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.22);
    flex-shrink: 0;
  }

  @keyframes mobile-sheet-up {
    from {
      opacity: 0.4;
      translate: 0 28px;
    }
    to {
      opacity: 1;
      translate: 0 0;
    }
  }

  .binder-head {
    flex-wrap: wrap;
    padding: 8px 14px 10px;
    gap: 8px;
  }

  .binder-sub {
    font-size: 11px;
    line-height: 1.35;
  }

  .binder-title {
    font-size: 15.5px;
  }

  .binder-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }

  .binder-actions .dock-btn,
  .binder-reset,
  .binder-close {
    height: 31px;
    padding: 0 11px;
    font-size: 11.5px;
  }

  .binder-controls {
    padding: 8px 12px;
    gap: 7px;
  }

  .binder-tabs,
  .binder-rarity-pills {
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .binder-tabs::-webkit-scrollbar,
  .binder-rarity-pills::-webkit-scrollbar {
    display: none;
  }

  /* 关键：iOS Safari / 微信内置浏览器输入框字号 >= 16px，彻底杜绝聚焦强制放大页面 */
  .binder-search {
    flex: 1 1 160px;
    min-width: 0;
    height: 36px;
    font-size: 16px;
  }

  .binder-own-select {
    flex: 0 0 auto;
    height: 36px;
    font-size: 16px;
  }

  .binder-rarity-pills {
    order: 3;
    flex: 1 1 100%;
  }

  .price-edit-input {
    font-size: 16px;
  }

  /* 9宫格皮质活页卡册手机窄屏扩容优化 */
  .binder-leather-book {
    padding: 10px 10px 16px;
    -webkit-overflow-scrolling: touch;
  }

  .leather-page-wrap {
    padding: 10px 9px 10px 18px;
    border-radius: 14px;
  }

  .leather-page-wrap::after {
    inset: 4px;
    border-radius: 10px;
  }

  .binder-rings-spine {
    left: 4px;
    width: 9px;
  }

  .binder-rings-spine i {
    width: 9px;
    height: 16px;
  }

  .leather-9grid {
    gap: 6px;
  }

  .pocket-slot {
    padding: 4px;
    border-radius: 8px;
    gap: 3px;
  }

  .pocket-emboss-num {
    font-size: 14px;
  }

  .pocket-emboss-rarity {
    font-size: 9px;
  }

  .pocket-silhouette-veil {
    gap: 4px;
    padding: 4px;
  }

  .pocket-slot .binder-exchange-btn {
    padding: 4px 6px;
    font-size: 9.5px;
  }

  .pocket-caption {
    font-size: 9.5px;
  }

  .pocket-serial {
    display: none;
  }

  .binder-pager-bar {
    gap: 10px;
  }

  .binder-pager-bar .dock-btn {
    height: 33px;
    padding: 0 12px;
    font-size: 12px;
  }

  /* 原封盒挑包与电子秤弹窗：电子秤置顶紧凑横排，点包即看重、免上下翻找 */
  .picker-body {
    padding: 12px 12px 18px;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .digital-scale-panel {
    order: -1;
    padding: 11px 12px;
    gap: 8px;
    border-radius: 14px;
  }

  .scale-plate-preview {
    flex-direction: row;
    justify-content: center;
    padding: 6px 10px;
    gap: 10px;
  }

  .scale-plate-preview img {
    width: 36px;
    height: 60px;
  }

  .scale-lcd-box {
    padding: 7px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .scale-lcd-label {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .scale-lcd-digits {
    font-size: 22px;
  }

  .picker-box-tray {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
  }

  .picker-box-tray.tray-fat {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .picker-pack-img-wrap {
    width: 44px;
    height: 75px;
  }

  .tray-fat .picker-pack-img-wrap {
    width: 56px;
    height: 92px;
  }

  /* 展厅、账本与战报内边距手机优化 */
  .ten-pull-body,
  .ledger-body,
  .trophy-hall-body {
    padding: 12px 12px 18px;
    -webkit-overflow-scrolling: touch;
  }

  .trophy-hall-tabs {
    padding: 8px 12px 0;
  }

  .trophy-summary-banner,
  .bonds-equip-bar {
    padding: 10px 12px;
  }

  .trophy-summary-banner {
    order: -2;
  }

  .poster-preview-wrap {
    order: -1;
  }

  .trophy-summary-banner .dock-btn {
    width: 100%;
  }

  .equip-group {
    width: 100%;
    justify-content: space-between;
  }
}

/* 超窄屏手机 (<= 380px，如 iPhone SE / 小折叠外屏) 进一步微缩防换行 */
@media (max-width: 380px) {
  .points-gem {
    display: none;
  }

  .box-slot-cell {
    width: 3.8px;
  }

  .binder-actions .dock-btn,
  .binder-reset,
  .binder-close {
    padding: 0 8px;
    font-size: 11px;
  }
}
