:root {
  --bg: #0b1017;
  --panel: rgba(13, 19, 28, 0.82);
  --panel-strong: rgba(12, 18, 28, 0.94);
  --line: rgba(236, 224, 184, 0.22);
  --text: #f8f1dc;
  --muted: #c9bfa5;
  --gold: #d8b35a;
  --ember: #b85532;
  --jade: #5cbb9d;
  --ink: #080b10;
  --hero-image: none;
  --quiz-hero-image: url("./assets/quiz-immortal-path-wide.jpg");
  --intro-heading-font: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  --intro-heading-size: 42px;
  --intro-heading-width: 11em;
  --intro-lead-font: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  --intro-lead-size: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
}

button {
  font: inherit;
}

.app {
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  transition: background 180ms ease;
  background:
    linear-gradient(180deg, rgba(8, 11, 16, 0.02), rgba(8, 11, 16, 0.62)),
    var(--hero-image) center 18% / cover no-repeat;
}

.app.is-loading {
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 179, 90, 0.12), transparent 24rem),
    linear-gradient(180deg, #10130f 0%, #080d15 48%, #050911 100%);
}

.app.is-quiz-mode,
.app.is-result-mode {
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 179, 90, 0.12), transparent 22rem),
    linear-gradient(180deg, #10130f 0%, #080d15 34%, #050911 100%);
}

.app::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 0%, rgba(216, 179, 90, 0.18), transparent 34rem),
    linear-gradient(90deg, rgba(8, 11, 16, 0.28), rgba(8, 11, 16, 0.03), rgba(8, 11, 16, 0.28));
}

.app.is-loading::before {
  background: linear-gradient(90deg, rgba(8, 11, 16, 0.16), transparent 34%, transparent 66%, rgba(8, 11, 16, 0.16));
}

.app.is-quiz-mode::before,
.app.is-result-mode::before {
  background:
    linear-gradient(90deg, rgba(8, 11, 16, 0.16), transparent 34%, transparent 66%, rgba(8, 11, 16, 0.16));
}

.screen {
  display: none;
  min-height: 100vh;
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 24px 18px;
}

.version-badge {
  position: fixed;
  right: 12px;
  bottom: 10px;
  z-index: 5;
  color: rgba(248, 241, 220, 0.56);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}

.audio-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 8;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(236, 224, 184, 0.34);
  border-radius: 50%;
  color: var(--gold);
  background: rgba(8, 11, 16, 0.58);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.audio-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 179, 90, 0.76);
  background: rgba(16, 21, 31, 0.82);
}

.audio-toggle:focus-visible {
  outline: 2px solid rgba(216, 179, 90, 0.8);
  outline-offset: 3px;
}

.audio-icon {
  display: none;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.audio-toggle.is-on .audio-icon-on,
.audio-toggle:not(.is-on) .audio-icon-off {
  display: block;
}

.audio-toggle:not(.is-on) {
  color: rgba(248, 241, 220, 0.7);
}

.audio-toggle.is-blocked {
  border-color: rgba(216, 179, 90, 0.48);
  background: rgba(8, 11, 16, 0.72);
}

.language-toggle {
  position: fixed;
  top: 14px;
  right: 64px;
  z-index: 8;
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  height: 42px;
  border: 1px solid rgba(236, 224, 184, 0.34);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--gold);
  background: rgba(8, 11, 16, 0.58);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.language-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(216, 179, 90, 0.76);
  background: rgba(16, 21, 31, 0.82);
}

.language-toggle:focus-visible {
  outline: 2px solid rgba(216, 179, 90, 0.8);
  outline-offset: 3px;
}

.screen.is-active {
  display: flex;
}

.intro {
  align-items: flex-end;
  padding-bottom: 40px;
}

.hero-art {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.intro-content {
  width: 100%;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15, 22, 33, 0.78), rgba(10, 14, 21, 0.92));
  backdrop-filter: blur(10px);
  padding: 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  max-width: min(100%, var(--intro-heading-width));
  font-family: var(--intro-heading-font);
  font-size: var(--intro-heading-size);
  line-height: 1.08;
}

.lead {
  margin: 14px 0 24px;
  color: var(--muted);
  font-family: var(--intro-lead-font);
  font-size: var(--intro-lead-size);
  line-height: 1.6;
}

.primary-btn,
.ghost-btn {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 18px;
  cursor: pointer;
}

.primary-btn {
  color: var(--ink);
  background: linear-gradient(180deg, #f1d889, var(--gold));
  font-weight: 700;
}

.ghost-btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.quiz {
  flex-direction: column;
  gap: 16px;
  justify-content: flex-start;
  padding-top: 10px;
}

.quiz-hero {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(236, 224, 184, 0.22);
  border-radius: 2px;
  background: rgba(8, 11, 16, 0.3) var(--quiz-hero-image) center center / contain no-repeat;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

.quiz-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(3, 6, 10, 0.03));
}

.quiz-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
}

.quiz-header h2 {
  font-size: 24px;
  line-height: 1.28;
}

#phaseLabel {
  display: none;
}

.progress-badge {
  flex: 0 0 auto;
  min-width: 58px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--gold);
  text-align: center;
  background: rgba(0, 0, 0, 0.28);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--jade), var(--gold), var(--ember));
  transition: width 220ms ease;
}

.options {
  display: grid;
  gap: 10px;
}

.option-btn {
  width: 100%;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  background: var(--panel-strong);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.option-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(216, 179, 90, 0.72);
  background: rgba(25, 33, 46, 0.94);
}

.option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-right: 8px;
  border-radius: 50%;
  color: var(--ink);
  background: var(--gold);
  font-weight: 800;
}

.option-text {
  line-height: 1.55;
}

.result {
  align-items: center;
  justify-content: center;
  width: min(100%, 720px);
  padding: 16px 10px;
  background: #080d15;
}

.result-art {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #080d15;
}

.result-card {
  position: relative;
  width: min(100%, 640px);
  min-height: min(92vh, 760px);
  overflow: hidden;
  border: 2px solid rgba(238, 213, 142, 0.78);
  border-radius: 14px;
  background: #070b12;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.56);
  isolation: isolate;
}

.result-full-image {
  display: none;
  width: 100%;
  max-height: calc(100vh - 110px);
  object-fit: contain;
  background: #050812;
}

.result-card.is-image-result {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 76px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.result-card.is-image-result .result-full-image {
  display: block;
}

.result-card.is-image-result::before,
.result-card.is-image-result::after {
  display: none;
}

.result-card.is-image-result .poster-bg,
.result-card.is-image-result .poster-character,
.result-card.is-image-result .poster-top,
.result-card.is-image-result .poster-main,
.result-card.is-image-result .poster-quote,
.result-card.is-image-result .poster-footer {
  display: none;
}

.result-card::before,
.result-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: 3;
  border: 1px solid rgba(238, 213, 142, 0.38);
  border-radius: 10px;
  pointer-events: none;
}

.result-card::after {
  inset: 16px 22px auto;
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, rgba(238, 213, 142, 0.45), transparent);
}

.poster-bg {
  position: absolute;
  inset: 0;
  z-index: -3;
  background: #08101a center / cover no-repeat;
  filter: saturate(0.9) contrast(1.03);
}

.poster-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 70% 15%, rgba(238, 213, 142, 0.22), transparent 28%),
    linear-gradient(90deg, rgba(5, 8, 14, 0.96) 0%, rgba(5, 8, 14, 0.78) 50%, rgba(5, 8, 14, 0.42) 100%),
    linear-gradient(180deg, rgba(5, 8, 14, 0.18), rgba(5, 8, 14, 0.9) 72%, #050812 100%);
}

.poster-character {
  position: absolute;
  right: -7%;
  bottom: 9%;
  z-index: -1;
  width: 58%;
  height: 78%;
  object-fit: cover;
  object-position: center bottom;
  opacity: 0.9;
  filter: drop-shadow(-18px 22px 32px rgba(0, 0, 0, 0.55));
}

.poster-character[src=""],
.poster-emblem[src=""],
.poster-qr[src=""] {
  display: none;
}

.poster-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 24px 0;
}

.poster-brand {
  margin: 0;
  color: rgba(248, 241, 220, 0.9);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  letter-spacing: 2px;
}

.poster-main {
  position: relative;
  z-index: 2;
  width: 66%;
  padding: 10px 0 0 28px;
}

.poster-emblem {
  width: 72px;
  height: 54px;
  object-fit: contain;
  margin-bottom: 4px;
}

.poster-cn {
  margin: 0;
  color: var(--gold);
  font-size: 20px;
  font-weight: 700;
}

.poster-subtitle {
  margin: 2px 0 8px;
  color: rgba(248, 241, 220, 0.88);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.result-card h2 {
  margin-top: 4px;
  color: #fff6dc;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 7vw, 54px);
  line-height: 0.92;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.faction {
  display: inline-flex;
  margin: 12px 0 0;
  border: 1px solid rgba(238, 213, 142, 0.45);
  border-radius: 999px;
  padding: 5px 12px;
  color: var(--gold);
  background: rgba(5, 8, 14, 0.62);
  font-size: 12px;
}

.poster-desc {
  max-width: 220px;
  margin: 18px 0 0;
  color: rgba(248, 241, 220, 0.9);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-line;
}

.poster-traits-title {
  margin: 22px 0 8px;
  color: rgba(238, 213, 142, 0.92);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 11px;
  letter-spacing: 2px;
}

.poster-traits {
  display: flex;
  gap: 14px;
}

.poster-trait {
  display: grid;
  justify-items: center;
  gap: 5px;
  width: 54px;
  color: rgba(248, 241, 220, 0.9);
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
}

.poster-trait img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.trait-fallback {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: #10131a;
  border-radius: 50%;
  background: linear-gradient(180deg, #f3deb0, #b89445);
  font-size: 15px;
  font-weight: 700;
}

.poster-quote {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 148px;
  z-index: 2;
  margin: 0;
  color: #f8f1dc;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 3.5vw, 24px);
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}

.poster-quote::before,
.poster-quote::after {
  color: rgba(248, 241, 220, 0.58);
  font-size: 30px;
}

.poster-quote::before {
  content: "“";
  margin-right: 10px;
}

.poster-quote::after {
  content: "”";
  margin-left: 10px;
}

.poster-footer {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 82px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(238, 213, 142, 0.28);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(5, 8, 14, 0.66);
}

.poster-qr-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(248, 241, 220, 0.86);
  font-size: 8px;
  letter-spacing: 0.5px;
}

.poster-qr {
  width: 38px;
  height: 38px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.92);
}

.poster-tags {
  margin: 0;
  color: var(--gold);
  font-size: 9px;
  line-height: 1.35;
  text-align: right;
  white-space: pre-line;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.result-actions {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  z-index: 8;
}

@media (min-width: 720px) {
  :root {
    --intro-heading-size: 56px;
  }

  .screen {
    width: min(100%, 680px);
    padding: 40px 24px;
  }

  h1 {
    font-size: var(--intro-heading-size);
  }

  .intro-content {
    max-width: 520px;
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 36px;
  }

  .quiz-header h2 {
    font-size: 21px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .poster-main {
    width: 72%;
    padding-left: 22px;
  }

  .poster-character {
    width: 64%;
  }

  .poster-desc {
    max-width: 180px;
  }

  .poster-traits {
    gap: 8px;
  }
}
