/* =========================================================
   寻武魂·抗天命 — 古早页游玄幻视觉
   可替换背景图：修改下方 --bg-image 的 url(...)
   ========================================================= */

:root {
  --ink: #07060c;
  --ink-deep: #0c0a14;
  --blood: #b91c1c;
  --crimson: #e11d2e;
  --gold: #e8c547;
  --gold-bright: #ffe28a;
  --gold-dim: #a8842a;
  --mist: rgba(180, 160, 120, 0.12);
  --text: #f3e6c4;
  --text-dim: #c4b18a;
  --frame: #8b6914;

  /* 【替换背景图】将图片放到 /public/assets/ 后改此处路径 */
  --bg-image: url("/assets/bg-home.png");

  --font-title: "ZCOOL KuHei", "Noto Serif SC", "STXingkai", "楷体", serif;
  --font-body: "Noto Serif SC", "Songti SC", "SimSun", serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--ink);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
}

/* ---------- 背景层 ---------- */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* 底图：优先 --bg-image；图片缺失时下方渐变仍作氛围兜底 */
.bg-image {
  position: absolute;
  inset: 0;
  background-color: #0a0812;
  background-image:
    var(--bg-image),
    radial-gradient(ellipse 80% 55% at 50% 20%, rgba(140, 30, 40, 0.35), transparent 60%),
    radial-gradient(ellipse 70% 50% at 50% 90%, rgba(40, 20, 80, 0.4), transparent 55%),
    linear-gradient(180deg, #1a0f18 0%, #0a0812 45%, #05040a 100%);
  background-size: cover, auto, auto, auto;
  background-position: center, center, center, center;
  background-repeat: no-repeat;
  filter: saturate(1.1) contrast(1.05);
  transform: scale(1.04);
  animation: bg-breathe 12s ease-in-out infinite alternate;
}

/* 首页：暗调异界 + 法阵底图（可见、偏暗、仅明暗闪） */
.page-home .bg-void {
  position: absolute;
  inset: 0;
  background: #05040a;
}

.page-home .bg-ground {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 60%;
  opacity: 0.7;
  filter: saturate(1.15) contrast(1.05) brightness(0.9);
  animation: ground-flicker 2.4s ease-in-out infinite;
}

/* 适中压暗：背景可见，文字更易读 */
.page-home .bg-dim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 55% at 50% 40%, rgba(8, 6, 14, 0.32) 0%, rgba(5, 4, 10, 0.22) 55%, rgba(5, 4, 10, 0.42) 100%),
    linear-gradient(180deg, rgba(5, 4, 10, 0.25) 0%, rgba(5, 4, 10, 0.12) 45%, rgba(5, 4, 10, 0.36) 100%);
}

.page-home .bg-mist {
  background:
    radial-gradient(ellipse 50% 35% at 30% 75%, rgba(180, 40, 50, 0.16), transparent 70%),
    radial-gradient(ellipse 45% 30% at 70% 70%, rgba(80, 100, 180, 0.12), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(40, 20, 60, 0.28), transparent 65%);
}

.page-home .bg-vignette {
  background:
    radial-gradient(ellipse 85% 75% at 50% 45%, transparent 45%, rgba(0, 0, 0, 0.32) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.18) 0%, transparent 30%, transparent 78%, rgba(0, 0, 0, 0.3) 100%);
}

.page-home .bg-runes,
.page-home .bg-runes::before,
.page-home .bg-runes::after {
  display: none;
}

.bg-mist {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(ellipse 45% 30% at 20% 70%, rgba(200, 180, 120, 0.14), transparent 70%),
    radial-gradient(ellipse 50% 35% at 80% 60%, rgba(160, 120, 80, 0.12), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(90, 40, 50, 0.25), transparent 65%);
  animation: mist-drift 18s ease-in-out infinite alternate;
}

.bg-runes {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    radial-gradient(circle at 15% 25%, transparent 0 38px, rgba(232, 197, 71, 0.35) 39px 41px, transparent 42px),
    radial-gradient(circle at 85% 30%, transparent 0 28px, rgba(232, 197, 71, 0.28) 29px 31px, transparent 32px),
    radial-gradient(circle at 70% 75%, transparent 0 48px, rgba(185, 28, 28, 0.3) 49px 51px, transparent 52px),
    radial-gradient(circle at 25% 80%, transparent 0 22px, rgba(232, 197, 71, 0.22) 23px 25px, transparent 26px);
  animation: rune-pulse 6s ease-in-out infinite;
}

.bg-runes::before,
.bg-runes::after {
  content: "魂";
  position: absolute;
  font-family: var(--font-title);
  font-size: clamp(6rem, 18vw, 14rem);
  color: rgba(232, 197, 71, 0.06);
  letter-spacing: 0.2em;
  user-select: none;
}

.bg-runes::before {
  top: 8%;
  left: 4%;
  transform: rotate(-12deg);
}

.bg-runes::after {
  content: "命";
  bottom: 6%;
  right: 6%;
  transform: rotate(8deg);
  color: rgba(185, 28, 28, 0.08);
}

.bg-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, transparent 30%, rgba(0, 0, 0, 0.55) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, transparent 25%, transparent 70%, rgba(0, 0, 0, 0.55) 100%);
}

@keyframes bg-breathe {
  from { transform: scale(1.02); }
  to { transform: scale(1.06); }
}

/* 背景仅明暗闪烁（不位移、不缩放） */
@keyframes ground-flicker {
  0%, 100% {
    filter: saturate(1.1) contrast(1.05) brightness(0.85);
    opacity: 0.64;
  }
  50% {
    filter: saturate(1.2) contrast(1.1) brightness(0.98);
    opacity: 0.78;
  }
}

@keyframes mist-drift {
  from { transform: translateX(-2%) translateY(1%); }
  to { transform: translateX(3%) translateY(-2%); }
}

@keyframes rune-pulse {
  0%, 100% { opacity: 0.14; }
  50% { opacity: 0.28; }
}

/* 闪烁光效 + 轻微跳动（标题 / 关键词 / 按钮字） */
@keyframes spark-bounce {
  0%, 100% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
    text-shadow:
      0 0 4px rgba(255, 200, 80, 0.55),
      0 0 12px rgba(255, 80, 40, 0.35),
      0 1px 2px rgba(0, 0, 0, 0.8);
  }
  50% {
    transform: translateY(-3px) scale(1.04);
    filter: brightness(1.35);
    text-shadow:
      0 0 8px rgba(255, 240, 160, 1),
      0 0 18px rgba(255, 180, 60, 0.9),
      0 0 32px rgba(255, 60, 40, 0.7),
      0 0 48px rgba(200, 40, 40, 0.45),
      0 1px 2px rgba(0, 0, 0, 0.8);
  }
}

.fx-spark {
  display: inline-block;
  animation: spark-bounce 1.35s ease-in-out infinite;
  color: var(--gold-bright);
}

/* 正文关键词：轻微明暗闪光，不跳动 */
.hero-intro .fx-spark {
  animation: intro-flicker 2.2s ease-in-out infinite;
  color: #ffd978;
  font-weight: 700;
}

@keyframes intro-flicker {
  0%, 100% {
    filter: brightness(1);
    text-shadow:
      0 0 6px rgba(255, 200, 80, 0.4),
      0 1px 2px rgba(0, 0, 0, 0.85);
  }
  50% {
    filter: brightness(1.2);
    text-shadow:
      0 0 10px rgba(255, 220, 120, 0.7),
      0 0 18px rgba(255, 120, 50, 0.35),
      0 1px 2px rgba(0, 0, 0, 0.85);
  }
}

/* ---------- 首页 ---------- */
.page-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.home-stage {
  position: relative;
  z-index: 1;
  width: min(860px, 92vw);
  margin: 0 auto;
  padding: clamp(2.5rem, 8vh, 5rem) 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.4rem, 3.5vh, 2.2rem);
}

/* 古早页游发光外描边主标题 */
.hero-title,
.worlds-title {
  position: relative;
  margin: 0;
  font-family: var(--font-title);
  font-weight: 400;
  font-size: clamp(2.8rem, 9vw, 5.6rem);
  letter-spacing: 0.18em;
  line-height: 1.15;
  color: var(--gold-bright);
  text-indent: 0.18em;
  text-shadow:
    0 0 2px #3a1800,
    0 0 1px #000,
    1px 1px 0 #5c2000,
    -1px -1px 0 #5c2000,
    1px -1px 0 #5c2000,
    -1px 1px 0 #5c2000,
    2px 2px 0 #2a0c00,
    0 0 12px rgba(255, 200, 60, 0.85),
    0 0 28px rgba(255, 80, 40, 0.55),
    0 0 48px rgba(200, 40, 40, 0.4),
    0 4px 0 rgba(0, 0, 0, 0.65);
}

.hero-title.fx-spark {
  animation: title-spark-bounce 1.35s ease-in-out infinite;
}

.worlds-title {
  animation: title-flare 2.8s ease-in-out infinite;
}

.hero-title::before,
.worlds-title::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-text-stroke: 3px rgba(120, 40, 10, 0.85);
  text-shadow: none;
  z-index: -1;
  filter: blur(0.3px);
}

@keyframes title-spark-bounce {
  0%, 100% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
    text-shadow:
      0 0 2px #3a1800,
      0 0 1px #000,
      1px 1px 0 #5c2000,
      -1px -1px 0 #5c2000,
      1px -1px 0 #5c2000,
      -1px 1px 0 #5c2000,
      2px 2px 0 #2a0c00,
      0 0 12px rgba(255, 200, 60, 0.85),
      0 0 28px rgba(255, 80, 40, 0.55),
      0 0 48px rgba(200, 40, 40, 0.4),
      0 4px 0 rgba(0, 0, 0, 0.65);
  }
  50% {
    transform: translateY(-5px) scale(1.035);
    filter: brightness(1.3);
    text-shadow:
      0 0 2px #3a1800,
      0 0 1px #000,
      1px 1px 0 #5c2000,
      -1px -1px 0 #5c2000,
      1px -1px 0 #5c2000,
      -1px 1px 0 #5c2000,
      2px 2px 0 #2a0c00,
      0 0 20px rgba(255, 240, 150, 1),
      0 0 40px rgba(255, 120, 50, 0.9),
      0 0 70px rgba(220, 40, 40, 0.65),
      0 4px 0 rgba(0, 0, 0, 0.65);
  }
}

@keyframes title-flare {
  0%, 100% {
    text-shadow:
      0 0 2px #3a1800,
      0 0 1px #000,
      1px 1px 0 #5c2000,
      -1px -1px 0 #5c2000,
      1px -1px 0 #5c2000,
      -1px 1px 0 #5c2000,
      2px 2px 0 #2a0c00,
      0 0 12px rgba(255, 200, 60, 0.85),
      0 0 28px rgba(255, 80, 40, 0.55),
      0 0 48px rgba(200, 40, 40, 0.4),
      0 4px 0 rgba(0, 0, 0, 0.65);
  }
  50% {
    text-shadow:
      0 0 2px #3a1800,
      0 0 1px #000,
      1px 1px 0 #5c2000,
      -1px -1px 0 #5c2000,
      1px -1px 0 #5c2000,
      -1px 1px 0 #5c2000,
      2px 2px 0 #2a0c00,
      0 0 18px rgba(255, 230, 120, 1),
      0 0 36px rgba(255, 100, 50, 0.75),
      0 0 64px rgba(220, 40, 40, 0.55),
      0 4px 0 rgba(0, 0, 0, 0.65);
  }
}

.hero-intro {
  margin: 0;
  max-width: 38em;
  font-size: clamp(0.95rem, 2.1vw, 1.12rem);
  line-height: 1.95;
  color: var(--text-dim);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.04em;
}

/* CTA 按钮 */
.cta-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.4rem;
  padding: 0.95rem 2.8rem;
  text-decoration: none;
  font-family: var(--font-title);
  font-size: clamp(1.25rem, 3vw, 1.55rem);
  letter-spacing: 0.22em;
  color: #fff6d4;
  background:
    linear-gradient(180deg, #8b1a1a 0%, #5c0e12 48%, #3a080c 100%);
  border: 2px solid var(--gold);
  box-shadow:
    0 0 0 1px #2a1000 inset,
    0 0 18px rgba(232, 197, 71, 0.35),
    0 6px 0 #1a0608,
    0 10px 24px rgba(0, 0, 0, 0.55);
  text-shadow: 0 0 8px rgba(255, 180, 60, 0.7), 0 2px 0 #2a0808;
  transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
  overflow: hidden;
  cursor: pointer;
}

.cta-btn__text {
  position: relative;
  z-index: 1;
  text-indent: 0.22em;
}

.cta-btn__text.fx-spark {
  animation: spark-bounce 1.35s ease-in-out infinite;
}

.cta-btn__glow {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(255, 230, 140, 0.35) 48%,
    transparent 66%
  );
  transform: translateX(-120%);
  animation: none;
}

.cta-btn:hover {
  transform: translateY(-6px);
  filter: brightness(1.12);
  box-shadow:
    0 0 0 1px #2a1000 inset,
    0 0 28px rgba(255, 210, 80, 0.7),
    0 0 48px rgba(255, 60, 40, 0.45),
    0 10px 0 #1a0608,
    0 16px 32px rgba(0, 0, 0, 0.55);
}

.cta-btn:hover .cta-btn__glow {
  animation: cta-shine 1.1s ease-in-out infinite;
}

.cta-btn:active {
  transform: translateY(-2px);
}

@keyframes cta-shine {
  0% { transform: translateX(-120%); opacity: 0.4; }
  50% { opacity: 1; }
  100% { transform: translateX(120%); opacity: 0.4; }
}

/* ---------- 世界选择页 ---------- */
.page-worlds {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.worlds-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 1.5rem 1rem 0.5rem;
}

.back-btn {
  position: absolute;
  left: clamp(0.8rem, 3vw, 2rem);
  top: 1.6rem;
  display: inline-block;
  padding: 0.45rem 0.9rem;
  font-family: var(--font-title);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-decoration: none;
  border: 1px solid var(--gold-dim);
  background: rgba(20, 10, 8, 0.65);
  box-shadow: 0 0 12px rgba(232, 197, 71, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.back-btn:hover {
  transform: translateY(-2px);
  color: var(--gold-bright);
  box-shadow: 0 0 18px rgba(232, 197, 71, 0.45);
}

.worlds-title {
  font-size: clamp(1.9rem, 5.5vw, 3.2rem);
  margin-top: 2.2rem;
}

.worlds-sub {
  margin: 0.8rem 0 0;
  color: var(--text-dim);
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  letter-spacing: 0.12em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.worlds-stage {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(1.4rem, 4vw, 2.8rem);
  padding: 2rem 1.2rem 4rem;
  width: min(960px, 100%);
  margin: 0 auto;
}

/* 古早游戏边框卡片 — 横 4 : 竖 3 */
.world-card {
  position: relative;
  width: min(400px, 90vw);
  aspect-ratio: 4 / 3;
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: transform 0.28s ease;
}

.world-card__frame {
  position: absolute;
  inset: 0;
  border: 3px solid var(--gold);
  background:
    linear-gradient(165deg, rgba(80, 20, 24, 0.92) 0%, rgba(18, 12, 22, 0.95) 55%, rgba(10, 8, 16, 0.98) 100%);
  box-shadow:
    0 0 0 1px #3a2208,
    0 0 0 6px rgba(40, 22, 8, 0.85),
    0 0 0 7px var(--gold-dim),
    inset 0 0 40px rgba(232, 197, 71, 0.08),
    0 12px 28px rgba(0, 0, 0, 0.55);
  clip-path: polygon(
    12px 0,
    calc(100% - 12px) 0,
    100% 12px,
    100% calc(100% - 12px),
    calc(100% - 12px) 100%,
    12px 100%,
    0 calc(100% - 12px),
    0 12px
  );
  transition: box-shadow 0.28s ease, border-color 0.28s ease;
}

/* 卡片背景图：约 50% 透明度 + 压暗 */
.world-card__bg {
  position: absolute;
  inset: 3px;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.5;
  filter: brightness(0.55);
  clip-path: polygon(
    12px 0,
    calc(100% - 12px) 0,
    100% 12px,
    100% calc(100% - 12px),
    calc(100% - 12px) 100%,
    12px 100%,
    0 calc(100% - 12px),
    0 12px
  );
  pointer-events: none;
}

.world-card--marvel .world-card__bg {
  background-image: url("/assets/world-marvel.png");
  /* 尽量完整放入六宫格，不裁切 */
  background-size: contain;
  background-position: center;
  background-color: #0a0812;
  opacity: 1;
  filter: brightness(1.15);
}

.world-card--kings .world-card__bg {
  background-image: url("/assets/world-kings.png");
  /* 尽量完整放入拼图，不裁切 */
  background-size: contain;
  background-position: center;
  background-color: #0a0812;
  opacity: 0.75;
  filter: brightness(0.82);
}

.world-card__frame::before,
.world-card__frame::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid var(--gold-bright);
  opacity: 0.7;
}

.world-card__frame::before {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
}

.world-card__frame::after {
  bottom: 8px;
  right: 8px;
  border-left: none;
  border-top: none;
}

.world-card__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  height: 100%;
  min-height: 0;
  padding: 1.5rem 1.5rem;
  text-align: center;
}

.world-card__badge {
  font-size: 0.8rem;
  letter-spacing: 0.28em;
  color: var(--gold-dim);
  text-indent: 0.28em;
}

.world-card__name {
  font-family: var(--font-title);
  font-size: clamp(1.7rem, 4vw, 2.15rem);
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  color: var(--gold-bright);
  text-shadow:
    0 0 10px rgba(255, 180, 60, 0.6),
    0 0 22px rgba(200, 40, 40, 0.35),
    0 2px 0 #2a1000;
}

.world-card__desc {
  max-width: 16em;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-dim);
  letter-spacing: 0.06em;
}

.world-card:hover {
  transform: scale(1.05);
}

.world-card:hover .world-card__frame {
  border-color: var(--gold-bright);
  box-shadow:
    0 0 0 1px #3a2208,
    0 0 0 6px rgba(40, 22, 8, 0.85),
    0 0 0 7px var(--gold),
    inset 0 0 50px rgba(232, 197, 71, 0.16),
    0 0 36px rgba(255, 200, 80, 0.45),
    0 0 60px rgba(200, 40, 40, 0.3),
    0 16px 36px rgba(0, 0, 0, 0.6);
}

.world-card:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 6px;
}

/* Toast 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 12%;
  z-index: 20;
  transform: translateX(-50%) translateY(12px);
  padding: 0.85rem 1.6rem;
  font-family: var(--font-title);
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: var(--gold-bright);
  background: rgba(18, 10, 12, 0.92);
  border: 1px solid var(--gold);
  box-shadow: 0 0 24px rgba(232, 197, 71, 0.35), 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.demo-note {
  position: relative;
  z-index: 1;
  margin: 0;
  padding: 0.6rem 1rem 1.2rem;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: rgba(196, 177, 138, 0.45);
}

/* ---------- 自适应 ---------- */
@media (max-width: 640px) {
  .back-btn {
    position: static;
    margin-bottom: 0.8rem;
  }

  .worlds-title {
    margin-top: 0.4rem;
  }

  .hero-intro {
    line-height: 1.8;
  }

  .cta-btn {
    padding: 0.85rem 1.8rem;
    letter-spacing: 0.14em;
  }
}
