*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #c83217;
  --primary-hover: #b02d15;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #e8e8e8;
  --bg: #f5f5f5;
  --card: #fff;
  --radius: 12px;
  --font: 'PingFang SC', 'Microsoft YaHei', -apple-system, BlinkMacSystemFont, sans-serif;
  --page-pad-inline: max(16px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --page-pad-top: max(16px, env(safe-area-inset-top, 0px));
  --page-pad-bottom: max(20px, env(safe-area-inset-bottom, 0px));
  --card-pad-x: 20px;
  --shot-w: clamp(108px, 36vw, 140px);
  --shot-h: clamp(192px, 58vw, 248px);
  --touch-min: 44px;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  min-height: 100svh;
  overflow-x: hidden;
}

.page {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  padding: var(--page-pad-top) var(--page-pad-inline) var(--page-pad-bottom);
}

.card {
  width: 100%;
  max-width: 420px;
  min-width: 0;
  padding: clamp(24px, 6vw, 32px) var(--card-pad-x) clamp(20px, 5vw, 24px);
  background: var(--card);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.app-icon {
  width: clamp(72px, 20vw, 88px);
  height: clamp(72px, 20vw, 88px);
  border-radius: 18px;
  margin: 0 auto 16px;
}

.app-name {
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 600;
  line-height: 1.3;
}

.app-desc {
  margin-top: 8px;
  font-size: clamp(13px, 3.6vw, 15px);
  line-height: 1.5;
  color: var(--text-muted);
  padding: 0 4px;
}

.tip {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

.tip.info {
  background: #f0f4ff;
  color: #3b5bdb;
}

.tip.warn {
  background: #fff8e6;
  color: #9a6700;
}

.tip--ok {
  background: #edf7f0;
  color: #1e7b4c;
  text-align: center;
}

/* ── Screenshot slider（外层滚动，内层 max-content 才能横向滑） ── */
.screenshots {
  margin: 20px calc(-1 * var(--card-pad-x)) 4px;
  width: calc(100% + 2 * var(--card-pad-x));
  max-width: 100vw;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.screenshots::-webkit-scrollbar {
  display: none;
}

/* PC：显示滚动条 + 拖拽光标 */
@media (hover: hover) and (pointer: fine) {
  .screenshots {
    scrollbar-width: none;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
    cursor: grab;
  }

  .screenshots::-webkit-scrollbar {
    display: block;
    height: 6px;
  }

  .screenshots::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.22);
    border-radius: 3px;
  }

  .screenshots.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
    scroll-behavior: auto;
    user-select: none;
  }
}

.screenshot-track {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: clamp(8px, 2.5vw, 12px);
  width: max-content;
  min-width: 100%;
  padding: 0 var(--card-pad-x) 8px;
  box-sizing: border-box;
}

.screenshot {
  position: relative;
  flex: 0 0 var(--shot-w);
  width: var(--shot-w);
  min-width: var(--shot-w);
  height: var(--shot-h);
  border-radius: 10px;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  overflow: hidden;
  background: #eee;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  -webkit-user-drag: none;
  user-select: none;
}

.screenshot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.screenshot span {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  padding: 20px 6px 8px;
  font-size: 12px;
  color: #fff;
  text-align: center;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.5) 0%, transparent 100%);
  pointer-events: none;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--touch-min);
  margin-top: 20px;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  opacity: 0.92;
}

.btn-primary:disabled {
  background: #e0e0e0;
  color: #999;
  cursor: not-allowed;
}

.btn-primary.pulse:not(:disabled) {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 50, 23, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(200, 50, 23, 0); }
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-min);
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-muted);
  text-decoration: none;
}

.btn-link:active {
  opacity: 0.7;
}

/* ── PWA 安装指南 ── */
.pwa-guide {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: left;
}

.guide-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.guide-intro {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.guide-tabs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.guide-tab {
  flex: 1;
  min-height: var(--touch-min);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
  font-family: inherit;
  font-size: clamp(13px, 3.5vw, 14px);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.guide-tab.active {
  border-color: var(--primary);
  background: #fff5f3;
  color: var(--primary);
}

.guide-panel {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 8px;
}

.guide-panel[hidden] {
  display: none;
}

.guide-steps {
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-muted);
}

.guide-steps li + li {
  margin-top: 8px;
}

.guide-steps strong {
  color: var(--text);
  font-weight: 500;
}

.guide-note {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: #999;
}

.hidden {
  display: none !important;
}

/* ── 手机：去掉卡片边框/阴影，全屏铺平 ── */
@media (max-width: 480px) {
  :root {
    --bg: #fff;
    --card: #fff;
  }

  body {
    background: #fff;
  }

  .page {
    padding: var(--page-pad-top) 0 var(--page-pad-bottom);
  }

  .card {
    max-width: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    overflow: visible;
  }

  .guide-steps {
    font-size: clamp(12px, 3.4vw, 14px);
  }
}

/* ── 小屏手机：更大截图 ── */
@media (max-width: 380px) {
  :root {
    --card-pad-x: 16px;
    --shot-w: 40vw;
    --shot-h: 62vw;
  }
}

/* ── 横屏手机：压缩纵向空间 ── */
@media (max-height: 500px) and (orientation: landscape) {
  .page {
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  .card {
    padding-top: 16px;
    padding-bottom: 16px;
    border-radius: 0;
    box-shadow: none;
  }

  .app-icon {
    width: 56px;
    height: 56px;
    margin-bottom: 10px;
  }

  .screenshots {
    margin-top: 12px;
  }

  :root {
    --shot-h: 140px;
    --shot-w: 100px;
  }

  .btn-primary {
    margin-top: 12px;
  }

  .pwa-guide {
    margin-top: 12px;
    padding-top: 12px;
  }
}

/* ── 平板 / 桌面：居中卡片 ── */
@media (min-width: 481px) {
  .page {
    align-items: center;
    padding-top: max(32px, env(safe-area-inset-top, 0px));
  }

  .card {
    max-width: 400px;
    --card-pad-x: 28px;
    --shot-w: 132px;
    --shot-h: 234px;
  }
}

/* ── 大屏：限制最大宽度避免过宽 ── */
@media (min-width: 768px) {
  .card {
    max-width: 420px;
  }
}

/* ── 减少动效（系统偏好） ── */
@media (prefers-reduced-motion: reduce) {
  .btn-primary.pulse:not(:disabled) {
    animation: none;
  }

  .screenshots {
    scroll-behavior: auto;
  }
}
