/* ==========================================================================
   [CSS-2] 布局与背景
   渐变背景、漂浮金色光晕层、三阶段容器切换布局、响应式框架
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--c-text);
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(120vmax 90vmax at 85% -10%, rgba(250, 237, 196, 0.9), transparent 60%),
    radial-gradient(100vmax 80vmax at 0% 100%, rgba(243, 226, 181, 0.65), transparent 55%),
    linear-gradient(165deg, #FDF6E0 0%, #FFFEF8 46%, #FBF0D2 100%);
  background-attachment: fixed;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   背景氛围层：缓慢漂浮的金色光晕
   ========================================================================== */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(64px);
  will-change: transform;
}

.orb-a {
  width: 58vmax;
  height: 58vmax;
  top: -20vmax;
  left: -14vmax;
  background: radial-gradient(circle, rgba(240, 212, 124, 0.5), transparent 66%);
  animation: orb-float-a 26s var(--ease-apple) infinite alternate;
}

.orb-b {
  width: 46vmax;
  height: 46vmax;
  right: -16vmax;
  top: 24vh;
  background: radial-gradient(circle, rgba(250, 237, 196, 0.75), transparent 66%);
  animation: orb-float-b 32s var(--ease-apple) infinite alternate;
}

.orb-c {
  width: 40vmax;
  height: 40vmax;
  left: 16vw;
  bottom: -22vmax;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.28), transparent 66%);
  animation: orb-float-c 38s var(--ease-apple) infinite alternate;
}

/* ==========================================================================
   阶段容器：三个 stage 绝对叠放，is-active 丝滑淡入
   ========================================================================== */
.app {
  position: relative;
  z-index: var(--z-stage);
  height: 100dvh;
}

.stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(14px, 3.2vh, 28px);
  padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  text-align: center;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(26px) scale(0.985);
  transition:
    opacity var(--dur-stage) var(--ease-apple),
    transform var(--dur-stage) var(--ease-apple),
    visibility 0s linear var(--dur-stage);
}

/* 安全垂直居中：内容放得下时居中展示；超出视口时可完整滚动查看
   （auto margin 技巧，避免 flex 居中 + overflow 裁切内容） */
.stage > * {
  flex-shrink: 0;
}

.stage > :first-child {
  margin-top: auto;
}

.stage > :last-child {
  margin-bottom: auto;
}

.stage.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

/* ==========================================================================
   欢迎页
   ========================================================================== */
.welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 640px;
}

.welcome-emblem {
  font-size: clamp(20px, 4vw, 30px);
  color: var(--c-gold);
  margin-bottom: clamp(8px, 1.8vh, 16px);
  text-shadow: 0 0 18px rgba(212, 175, 55, 0.65), 0 0 42px rgba(212, 175, 55, 0.35);
  animation: emblem-glow 3.2s ease-in-out infinite;
}

.welcome-eyebrow {
  font-size: clamp(12px, 2.6vw, 15px);
  letter-spacing: 0.6em;
  text-indent: 0.6em;
  color: var(--c-text-soft);
  margin-bottom: clamp(10px, 2.4vh, 20px);
}

.welcome-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(32px, 8.4vw, 60px);
  line-height: 1.22;
  letter-spacing: 0.06em;
  background: var(--grad-gold-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--c-gold);
  filter: drop-shadow(0 2px 14px rgba(212, 175, 55, 0.28));
  margin-bottom: clamp(12px, 2.6vh, 22px);
}

.welcome-sub {
  font-size: clamp(13px, 3vw, 16px);
  line-height: 1.9;
  letter-spacing: 0.22em;
  color: var(--c-text-soft);
  margin-bottom: clamp(26px, 5.4vh, 46px);
}

/* 欢迎页元素依次入场（stagger，由 --d 控制延迟） */
.welcome-inner > * {
  opacity: 0;
  animation: fade-rise 0.9s var(--ease-spring) forwards;
  animation-delay: var(--d, 0s);
}

.welcome-inner > *:nth-child(1) { --d: 0.08s; }
.welcome-inner > *:nth-child(2) { --d: 0.22s; }
.welcome-inner > *:nth-child(3) { --d: 0.38s; }
.welcome-inner > *:nth-child(4) { --d: 0.56s; }
.welcome-inner > *:nth-child(5) { --d: 0.78s; }

/* 修复：开始按钮的呼吸光晕动画优先级更高，曾覆盖入场动画导致按钮
   永久停留在 opacity:0 —— 改为双动画叠加（先入场，后呼吸） */
.welcome-inner > .btn-primary:not(:disabled) {
  animation:
    fade-rise 0.9s var(--ease-spring) var(--d, 0s) forwards,
    btn-breath 2.8s ease-in-out 1.8s infinite;
}

/* Rev.7：金渐变标题统一流光（background-size 拉开后位移扫过）
   ⚠️ .welcome-title 是 .welcome-inner 子元素：入场靠 fade-rise 把 opacity
   从 0 拉回 1，shimmer 必须与 fade-rise 双动画叠加（同按钮的既有修复），
   单写 animation 会顶掉入场动画导致标题永久透明。 */
.round-title,
.finale-title {
  background-size: 200% auto;
  animation: text-shimmer 5.5s linear infinite;
}

.welcome-inner > .welcome-title {
  background-size: 200% auto;
  animation:
    fade-rise 0.9s var(--ease-spring) var(--d, 0s) forwards,
    text-shimmer 5.5s linear infinite;
}

/* ==========================================================================
   抽卡舞台（三轮复用）
   ========================================================================== */
.round-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.round-eyebrow {
  font-size: clamp(11px, 2.4vw, 14px);
  letter-spacing: 0.55em;
  text-indent: 0.55em;
  color: var(--c-text-soft);
}

.round-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(22px, 5.2vw, 34px);
  letter-spacing: 0.12em;
  background: var(--grad-gold-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--c-gold);
}

.round-actions {
  display: flex;
  justify-content: center;
  min-height: 52px;
  margin-top: clamp(4px, 1vh, 10px);
}

/* ==========================================================================
   结算页
   ========================================================================== */
.finale-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 640px;
}

.finale-eyebrow {
  font-size: clamp(11px, 2.4vw, 14px);
  letter-spacing: 0.6em;
  text-indent: 0.6em;
  color: var(--c-text-soft);
  margin-bottom: clamp(14px, 3vh, 24px);
}

.finale-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.6vw, 18px);
  margin-bottom: clamp(16px, 3.4vh, 28px);
}

.finale-star {
  width: clamp(34px, 8.6vw, 56px);
  height: clamp(34px, 8.6vw, 56px);
  display: block;
}

.finale-star svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: #E4CE8F;
  opacity: 0.16;
  transform: scale(0.72) rotate(-12deg);
  transition: opacity 0.55s var(--ease-apple), transform 0.55s var(--ease-spring), filter 0.55s var(--ease-apple);
}

.finale-star.is-lit svg {
  fill: #F0D47C;
  opacity: 1;
  transform: scale(1) rotate(0deg);
  filter: drop-shadow(0 0 10px rgba(240, 212, 124, 0.95)) drop-shadow(0 0 26px rgba(212, 175, 55, 0.55));
  animation: star-pop 0.7s var(--ease-spring);
}

.finale-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(26px, 6.6vw, 44px);
  letter-spacing: 0.1em;
  background: var(--grad-gold-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--c-gold);
  margin-bottom: clamp(10px, 2.2vh, 18px);
}

.finale-sub {
  font-size: clamp(12px, 2.8vw, 15px);
  letter-spacing: 0.24em;
  line-height: 2;
  color: var(--c-text-soft);
  margin-bottom: clamp(26px, 5.2vh, 44px);
}

/* ==========================================================================
   按钮
   ========================================================================== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.35s var(--ease-spring),
    box-shadow 0.35s var(--ease-apple),
    opacity 0.3s var(--ease-apple);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:not(:disabled):active {
  transform: scale(0.96);
}

.btn-primary {
  padding: 0.92em 2.5em;
  font-size: clamp(15px, 3.4vw, 17px);
  color: #FFF9E3;
  background: var(--grad-gold-btn);
  box-shadow:
    0 12px 32px rgba(196, 154, 49, 0.38),
    0 2px 6px rgba(168, 132, 43, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  text-shadow: 0 1px 2px rgba(122, 91, 20, 0.45);
  overflow: hidden; /* Rev.7：约束流光扫过层 */
}

/* Rev.7：按钮流光扫过（高光带周期性掠过，抽卡按钮的"祈愿感"） */
.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(105deg,
    transparent 32%,
    rgba(255, 252, 235, 0.55) 50%,
    transparent 68%);
  background-size: 260% 100%;
  background-position: 130% 0;
  pointer-events: none;
  animation: btn-shine 3.4s ease-in-out infinite;
}

.btn-primary:disabled::after {
  animation: none;
  opacity: 0;
}

.btn-hero {
  padding: 1.05em 3.1em;
  font-size: clamp(16px, 3.8vw, 19px);
}

.btn-quiet {
  padding: 0.72em 2em;
  font-size: clamp(12px, 2.8vw, 14px);
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--c-text-soft);
  border: 1px solid rgba(160, 138, 92, 0.45);
  background: rgba(255, 253, 244, 0.6);
  border-radius: 999px;
}

.btn-quiet:hover {
  color: var(--c-text-strong);
  border-color: rgba(160, 138, 92, 0.8);
}

/* ==========================================================================
   线索图片放大镜（lightbox）：全屏深色遮罩 + 图片居中，
   遮罩淡入 + 图片轻缩放入场；点击遮罩任意处 / 按 Esc 关闭。
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-lightbox);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 48px);
  background: rgba(46, 38, 22, 0.88);
  opacity: 0;
  pointer-events: none;
  cursor: zoom-out;
  transition: opacity 0.3s var(--ease-apple);
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  transform: scale(0.92);
  transition: transform 0.32s var(--ease-apple);
}

.lightbox.is-open img {
  transform: scale(1);
}

/* ==========================================================================
   响应式：移动端竖屏（375px 基准）→ 桌面端（≥768px）
   ========================================================================== */
@media (min-width: 768px) {
  .app {
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
  }
}
