/* ========== 页面切换动画 ========== */
.screen {
  animation: none;
}
.screen.active {
  animation: screenIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes screenIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========== 开始页面 ========== */
.start-badge {
  animation: badgeFade 1s ease 0.3s both;
}
.game-title .title-line:first-child {
  animation: titleSlide 0.9s cubic-bezier(0.4, 0, 0.2, 1) 0.4s both;
}
.game-title .title-accent {
  animation: titleSlide 0.9s cubic-bezier(0.4, 0, 0.2, 1) 0.6s both;
}
.title-divider {
  animation: dividerExpand 0.7s ease 0.9s both;
}
.game-subtitle {
  animation: fadeUp 0.7s ease 1.1s both;
}
.game-desc {
  animation: fadeUp 0.7s ease 1.3s both;
}
.start-buttons {
  animation: fadeUp 0.7s ease 1.5s both;
}
.version-info {
  animation: badgeFade 0.6s ease 2s both;
}

@keyframes badgeFade {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes titleSlide {
  from { opacity: 0; transform: translateY(28px); letter-spacing: 0.35em; }
  to { opacity: 1; transform: translateY(0); letter-spacing: 0.15em; }
}

@keyframes dividerExpand {
  from { opacity: 0; width: 0; }
  to { opacity: 1; width: 80px; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 场景标题进入 ========== */
.scene-title {
  animation: sceneTitleIn 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes sceneTitleIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
    letter-spacing: 0.15em;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    letter-spacing: 0.08em;
  }
}

/* ========== 选项淡入 ========== */
.choice-btn {
  opacity: 0;
  animation: choiceSlideIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.choice-btn:nth-child(2) { animation-delay: 0.08s; }
.choice-btn:nth-child(3) { animation-delay: 0.16s; }
.choice-btn:nth-child(4) { animation-delay: 0.24s; }
.choice-btn:nth-child(5) { animation-delay: 0.32s; }

@keyframes choiceSlideIn {
  from {
    opacity: 0;
    transform: translateX(-16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* ========== 自定义选项淡入 ========== */
.custom-choice-wrap {
  opacity: 0;
  animation: choiceSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.4s forwards;
}

/* ========== 结果区域展开 ========== */
.result-area:not(.hidden) {
  animation: resultExpand 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes resultExpand {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== 属性变化动画 ========== */
.effect-tag {
  animation: tagAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes tagAppear {
  0% {
    opacity: 0;
    transform: scale(0.6) translateY(8px);
  }
  60% {
    transform: scale(1.05) translateY(-2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ========== 面板滑入 ========== */
.status-panel:not(.hidden),
.save-panel:not(.hidden),
.ai-settings-panel:not(.hidden) {
  transform: translateX(0);
  animation: panelSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes panelSlideIn {
  from { transform: translateX(100%); opacity: 0.5; }
  to { transform: translateX(0); opacity: 1; }
}

/* ========== 叙事段落淡入 ========== */
.narrative-paragraph {
  animation: paragraphReveal 0.5s ease forwards;
}
@keyframes paragraphReveal {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 时间线条目 ========== */
.timeline-item {
  opacity: 0;
  animation: timelineReveal 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes timelineReveal {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========== 结局页面动画 ========== */
.ending-title {
  animation: endingTitleReveal 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes endingTitleReveal {
  from {
    opacity: 0;
    transform: translateY(35px) scale(0.9);
    letter-spacing: 0.2em;
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    letter-spacing: 0.05em;
  }
}

.ending-quote {
  opacity: 0;
  animation: endingQuoteReveal 1.2s ease 0.8s forwards;
}
@keyframes endingQuoteReveal {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 角色创建段落淡入 ========== */
.create-section {
  opacity: 0;
  animation: createSectionIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.create-section:nth-child(1) { animation-delay: 0.1s; }
.create-section:nth-child(2) { animation-delay: 0.18s; }
.create-section:nth-child(3) { animation-delay: 0.26s; }
.create-section:nth-child(4) { animation-delay: 0.34s; }
.create-section:nth-child(5) { animation-delay: 0.42s; }
.create-section:nth-child(6) { animation-delay: 0.5s; }
.create-section:nth-child(7) { animation-delay: 0.58s; }
.create-section:nth-child(8) { animation-delay: 0.66s; }

@keyframes createSectionIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== 阶段过渡动画 ========== */
.stage-transition-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  animation: stageTransition 3s ease forwards;
  pointer-events: none;
}
.stage-transition-overlay .stage-transition-text {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.2em;
  animation: stageTextPulse 3s ease forwards;
}
.stage-transition-overlay .stage-transition-line {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

@keyframes stageTransition {
  0% { opacity: 0; }
  15% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes stageTextPulse {
  0% { opacity: 0; transform: scale(0.95); letter-spacing: 0.3em; }
  20% { opacity: 1; transform: scale(1); letter-spacing: 0.2em; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.02); }
}
