/* PWA 外壳补丁样式：只在网页版加载。 */

/* iOS 主屏沉浸式状态栏（build.mjs 里 black-translucent）：100% 高度会少一截状态栏高，
   底部露白。src/pwa.js 按屏幕实际高度写 --pwa-full-h 补齐。 */
html.pwa-ios-fill,
html.pwa-ios-fill body {
  height: var(--pwa-full-h, 100%);
  overflow: hidden;
}

/* 「安装到桌面」按钮（浏览器判定可安装时才出现，src/pwa.js） */
.pwa-install {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 50%;
  z-index: 8500;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 99px;
  transform: translateX(-50%);
  background: var(--accent, #6b6158);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  animation: pwa-dl-in 0.2s ease-out;
}
.pwa-install button {
  border: 0;
  background: transparent;
  color: var(--accent-ink, #fff);
  font: inherit;
  cursor: pointer;
}
.pwa-install-go {
  padding: 6px 6px 6px 14px;
  font-size: 13px;
  font-weight: 600;
}
.pwa-install-x {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  opacity: 0.8;
}

.pwa-install-status {
  gap: 8px;
  padding: 8px 16px 8px 12px;
  color: var(--accent-ink, #fff);
  font-size: 13px;
  font-weight: 600;
}
.pwa-install-spin {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: pwa-spin 0.8s linear infinite;
}
@keyframes pwa-spin {
  to { transform: rotate(360deg); }
}
.pwa-install-body {
  padding-left: 0;
}
.pwa-install-body p {
  margin: 0 0 6px;
}
.pwa-install-body ol {
  margin: 4px 0 0;
  padding-left: 18px;
}
.pwa-install-body li {
  margin-bottom: 6px;
}
.pwa-install-body b {
  color: var(--ink-strong, var(--ink, #2a2420));
}

/* 大应用首次下载确认（src/pwa.js）：颜色全走主题变量，深色主题自动跟随 */
.pwa-dl {
  position: absolute;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.38);
  animation: pwa-dl-in 0.18s ease-out;
}
.pwa-dl-card {
  width: 100%;
  max-width: 340px;
  padding: 22px 20px 16px;
  border-radius: 22px;
  background: var(--surface, #fbf8f3);
  color: var(--ink, #3b342e);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
  font-family: var(--app-font, inherit);
}
.pwa-dl-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-strong, var(--ink, #2a2420));
}
.pwa-dl-size {
  margin-top: 6px;
  font-size: 14px;
}
.pwa-dl-size b {
  color: var(--accent, #6b6158);
  font-size: 16px;
}
.pwa-dl-notes {
  margin: 12px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-mute, #8a8078);
}
.pwa-dl-notes b {
  color: var(--danger, #c4553f);
}
.pwa-dl-warn,
.pwa-dl-error {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--danger, #c4553f);
  background: color-mix(in srgb, var(--danger, #c4553f) 10%, transparent);
}
.pwa-dl-progress {
  margin-top: 14px;
}
.pwa-dl-bar {
  height: 8px;
  border-radius: 99px;
  overflow: hidden;
  background: var(--line, rgba(0, 0, 0, 0.08));
}
.pwa-dl-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #6b6158);
  transition: width 0.2s linear;
}
.pwa-dl-stat {
  margin-top: 6px;
  font-size: 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute, #8a8078);
}
.pwa-dl-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.pwa-dl-actions button {
  flex: 1;
  height: 42px;
  border: 1px solid var(--line, rgba(0, 0, 0, 0.1));
  border-radius: 12px;
  background: var(--card, transparent);
  color: var(--ink, #3b342e);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.pwa-dl-actions button.primary {
  border-color: transparent;
  background: var(--accent, #6b6158);
  color: var(--accent-ink, #fff);
  font-weight: 600;
}
.pwa-dl-actions button[hidden],
.pwa-dl [hidden] {
  display: none;
}
@keyframes pwa-dl-in {
  from { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .pwa-dl { animation: none; }
  .pwa-dl-bar i { transition: none; }
}

/* 横屏游戏竖着拿时的提示（src/pwa.js「横屏游戏」）：只在触屏 + 竖屏时出现，转过来自动消失 */
.pwa-rotate {
  display: none;
}
@media (orientation: portrait) and (pointer: coarse) {
  html.pwa-want-landscape .pwa-rotate:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 2147483646;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    background: rgba(12, 11, 16, 0.92);
    color: #fff;
    text-align: center;
    font-family: var(--app-font, inherit);
  }
}
.pwa-rotate-phone {
  width: 46px;
  height: 78px;
  margin-bottom: 14px;
  border: 3px solid currentColor;
  border-radius: 10px;
  animation: pwa-rotate 1.8s ease-in-out infinite;
}
.pwa-rotate-title {
  font-size: 18px;
  font-weight: 700;
}
.pwa-rotate-sub {
  font-size: 13px;
  opacity: 0.7;
}
.pwa-rotate button {
  margin-top: 18px;
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 99px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
@keyframes pwa-rotate {
  0%, 20% { transform: rotate(0); }
  50%, 80% { transform: rotate(-90deg); }
  100% { transform: rotate(0); }
}
@media (prefers-reduced-motion: reduce) {
  .pwa-rotate-phone { animation: none; transform: rotate(-90deg); }
}

/* 宽屏（电脑浏览器）：把小手机放进居中的手机框里，而不是拉满整个窗口。
   transform 让框成为 position:fixed 子元素的包含块，弹层 / 抽屉不会跑出框外。 */
@media (min-width: 700px) and (min-height: 560px) {
  html.pwa body {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      radial-gradient(80% 70% at 50% 0%, #3a3550 0%, transparent 70%),
      linear-gradient(160deg, #1e1c27 0%, #121118 100%);
  }

  html.pwa #screen.screen {
    flex: none;
    width: 412px;
    height: min(100% - 48px, 892px);
    border-radius: 40px;
    overflow: hidden;
    transform: translateZ(0);
    box-shadow:
      0 0 0 10px #0b0a0f,
      0 0 0 11px #2c2a35,
      0 30px 80px rgba(0, 0, 0, 0.55);
  }

  /* 横屏游戏：手机框跟着横过来 */
  html.pwa.pwa-want-landscape #screen.screen {
    width: min(100% - 48px, 892px);
    height: min(100% - 48px, 412px);
  }

  /* 手机上滚动条是悬浮的；电脑浏览器会占位露出一条，在手机框里隐藏 */
  html.pwa #screen,
  html.pwa #screen * {
    scrollbar-width: none;
  }
  html.pwa #screen ::-webkit-scrollbar {
    display: none;
  }
}
