/* ===== 设计稿基准：402 × 874 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: #1E1627;
  color: rgba(255, 255, 255, 0.9);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: default;
}

a {
  text-decoration: none;
  color: inherit;
}

.page {
  /* 宽度铺满，按屏宽换算设计像素 */
  --u: calc(min(100vw, 430px) / 402);
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

.page__bg {
  position: fixed;
  inset: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: #1E1627 url("../img/bg.png") center top / cover no-repeat;
  z-index: 0;
  pointer-events: none;
}

/*
 * 整屏纵向均分：
 * 顶文案 / 中卡片（吃剩余高度） / 底按钮
 */
.content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  height: 100svh;
  padding:
    calc(env(safe-area-inset-top, 0px) + 24px)
    calc(16 * var(--u))
    calc(env(safe-area-inset-bottom, 0px) + 12px);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

body.is-ready .content {
  opacity: 1;
  transform: translateY(0);
}

/* ===== 顶部文案 ===== */
.hero {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.notice {
  width: 100%;
  border-radius: calc(12 * var(--u));
  background: rgba(151, 8, 246, 0.12);
  border: 1px solid rgba(151, 8, 246, 0.12);
  overflow: hidden;
}

.notice__inner {
  display: flex;
  align-items: center;
  gap: calc(4 * var(--u));
  padding: 10px calc(16 * var(--u));
}

.notice__icon,
.notice__tag {
  flex-shrink: 0;
}

.notice__track-wrap {
  flex: 1;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.notice__track {
  display: flex;
  width: max-content;
  animation: notice-scroll var(--notice-duration, 18s) linear infinite;
}

.notice__item {
  flex-shrink: 0;
  padding-right: calc(48 * var(--u));
  font-size: calc(12 * var(--u));
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.36);
  white-space: nowrap;
}

@keyframes notice-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.hero__title {
  margin-top: 16px;
  width: calc(306 * var(--u));
  max-width: 86%;
  height: auto;
}

.hero__subtitle {
  margin-top: 10px;
  width: 100%;
  font-size: calc(14 * var(--u));
  line-height: 1.4;
  text-align: center;
  color: rgba(255, 255, 255, 0.66);
}

/*
 * 中间卡片区：占据剩余高度，卡片始终 179:240 竖版比例
 * 高度随中间区域拉长，不再单独压扁
 */
.carousel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 12px 0 0;
  touch-action: pan-y;
}

.carousel__viewport {
  /*
   * 以高度定尺寸，锁定竖版 179:240
   * 中间剩余高度尽量给卡片，避免再被压成扁卡
   */
  --slide-h: clamp(
    168px,
    calc(100svh - 390px),
    calc(260 * var(--u))
  );
  --slide-w: calc(var(--slide-h) * 179 / 240);
  width: min(100%, calc(var(--slide-h) * 378 / 240));
  height: var(--slide-h);
  position: relative;
  overflow: visible;
  cursor: grab;
  margin: 0 auto;
}

.carousel__viewport.is-dragging {
  cursor: grabbing;
}

.carousel__track {
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel__slide {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--slide-w);
  height: var(--slide-h);
  border-radius: calc(var(--slide-h) * 24 / 240);
  overflow: hidden;
  background: #1E1627;
  transform: translate3d(-50%, -50%, 0);
  transform-origin: center center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  will-change: transform, opacity, filter;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  backface-visibility: hidden;
}

.carousel__slide.is-active {
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
}

.carousel__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.carousel__dots {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  margin-top: 10px;
}

.carousel__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  padding: 0;
  cursor: pointer;
  transition:
    width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
    background 0.3s ease,
    border-radius 0.3s ease;
}

.carousel__dot.is-active {
  width: 16px;
  border-radius: 3px;
  background: rgba(151, 8, 246, 0.75);
}

/* ===== 底部下载 ===== */
.download {
  flex: 0 0 auto;
  position: relative;
  width: calc(100% + 32 * var(--u));
  margin: 8px calc(-16 * var(--u)) 0;
  overflow: visible;
}

.download__bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  z-index: 0;
}

.download__actions {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 48px calc(16 * var(--u)) 4px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  border-radius: 12px;
  font-size: calc(16 * var(--u));
  line-height: 1;
  transition:
    transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.2s ease;
}

.btn img {
  width: 22px;
  height: 22px;
}

.btn--primary {
  background: rgba(222, 187, 246, 0.36);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
}

.btn--primary:active {
  transform: scale(0.975);
  background: rgba(222, 187, 246, 0.5);
}

.btn--disabled,
.btn--ghost {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.16);
}

.btn--disabled img,
.btn--ghost img {
  opacity: 0.3;
}

/* 较高屏幕：卡片可以更高，间距更舒展 */
@media (min-height: 780px) {
  .content {
    padding-top: calc(env(safe-area-inset-top, 0px) + 36px);
  }

  .hero__title {
    margin-top: 20px;
  }

  .carousel {
    margin-top: 20px;
  }

  .download__actions {
    padding-top: 56px;
    gap: 16px;
  }

  .btn {
    height: 56px;
  }
}

/* 较矮屏幕：压缩上下边距，把高度留给卡片 */
@media (max-height: 700px) {
  .content {
    padding-top: calc(env(safe-area-inset-top, 0px) + 16px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }

  .hero__title {
    margin-top: 12px;
  }

  .hero__subtitle {
    margin-top: 8px;
  }

  .carousel {
    margin-top: 8px;
  }

  .carousel__dots {
    margin-top: 8px;
  }

  .download {
    margin-top: 4px;
  }

  .download__actions {
    padding-top: 40px;
    gap: 10px;
  }

  .btn {
    height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .notice__track {
    animation: none;
  }

  .content {
    transition: none;
  }

  .btn {
    transition: none;
  }
}
