:root {
  --bg-top: #07131f;
  --bg-bottom: #02060d;
  --panel: rgba(7, 18, 30, 0.78);
  --panel-strong: rgba(7, 16, 26, 0.92);
  --border: rgba(146, 197, 255, 0.2);
  --text-main: #f3e6c2;
  --text-subtle: rgba(230, 238, 255, 0.76);
  --accent-gold: #f0c36d;
  --accent-cyan: #69d7f4;
  --accent-ember: #ff8c61;
  --result-primary: #f0c36d;
  --result-secondary: #69d7f4;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top, rgba(60, 131, 183, 0.22), transparent 36%),
    radial-gradient(circle at 80% 20%, rgba(240, 195, 109, 0.12), transparent 24%),
    radial-gradient(circle at 10% 80%, rgba(83, 159, 185, 0.16), transparent 28%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 42vmax;
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(14px);
  opacity: 0.28;
}

body::before {
  top: -18vmax;
  right: -10vmax;
  background: radial-gradient(circle, rgba(105, 215, 244, 0.28), transparent 68%);
}

body::after {
  bottom: -18vmax;
  left: -14vmax;
  background: radial-gradient(circle, rgba(255, 140, 97, 0.24), transparent 70%);
}

.page-veil {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 90px 90px;
  mask-image: radial-gradient(circle at center, black 48%, transparent 95%);
  opacity: 0.16;
}

.page-ornament {
  position: fixed;
  width: 20rem;
  height: 20rem;
  border-radius: 50%;
  border: 1px solid rgba(240, 195, 109, 0.12);
  pointer-events: none;
}

.ornament-left {
  left: -7rem;
  top: 22%;
  box-shadow:
    inset 0 0 0 1px rgba(105, 215, 244, 0.08),
    0 0 0 2.5rem rgba(255, 255, 255, 0.015);
}

.ornament-right {
  right: -5rem;
  bottom: 12%;
  box-shadow:
    inset 0 0 0 1px rgba(255, 140, 97, 0.08),
    0 0 0 3rem rgba(255, 255, 255, 0.012);
}

.app-shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0 4rem;
  position: relative;
  z-index: 1;
}

.hero-panel,
.test-panel {
  background: linear-gradient(180deg, rgba(9, 21, 35, 0.8), rgba(5, 12, 20, 0.92));
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.85fr);
  gap: 1.5rem;
  padding: clamp(1.5rem, 3vw, 2.6rem);
  position: relative;
  overflow: hidden;
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 0%, rgba(240, 195, 109, 0.12), transparent 24%),
    radial-gradient(circle at 100% 50%, rgba(105, 215, 244, 0.16), transparent 32%);
  pointer-events: none;
}

.hero-copy,
.hero-sigil,
.test-panel {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--accent-cyan);
  font-size: 0.92rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1,
h2,
.spirit-name,
.power-figure {
  font-family: "STKaiti", "KaiTi", "Baskerville", serif;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 5vw, 4.2rem);
  line-height: 1.02;
  letter-spacing: 0.04em;
}

.hero-text {
  margin: 1.1rem 0 0;
  max-width: 44rem;
  color: var(--text-subtle);
  font-size: 1.05rem;
  line-height: 1.8;
}

.hero-sigil {
  display: grid;
  justify-items: center;
  gap: 1.2rem;
  padding: 1.2rem;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(11, 24, 38, 0.94), rgba(7, 17, 28, 0.8));
  border: 1px solid rgba(240, 195, 109, 0.14);
}

.sigil-ring {
  position: relative;
  width: min(100%, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle, rgba(240, 195, 109, 0.14) 0%, transparent 58%),
    conic-gradient(from 90deg, rgba(240, 195, 109, 0.2), transparent 20%, rgba(105, 215, 244, 0.45), transparent 52%, rgba(255, 140, 97, 0.25), transparent 78%, rgba(240, 195, 109, 0.18));
}

.sigil-ring::before,
.sigil-ring::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  inset: 10%;
  border: 1px solid rgba(240, 195, 109, 0.18);
}

.sigil-ring::after {
  inset: 22%;
  border-color: rgba(105, 215, 244, 0.24);
}

.sigil-core {
  width: 24%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6de 0%, rgba(240, 195, 109, 0.86) 32%, rgba(240, 195, 109, 0.08) 72%, transparent 100%);
  box-shadow:
    0 0 28px rgba(240, 195, 109, 0.46),
    0 0 56px rgba(105, 215, 244, 0.16);
}

.sigil-details {
  width: 100%;
  display: grid;
  gap: 0.45rem;
  text-align: center;
}

.sigil-details p {
  margin: 0;
  color: rgba(206, 219, 239, 0.66);
  letter-spacing: 0.12em;
  font-size: 0.85rem;
  text-transform: uppercase;
}

.sigil-details strong {
  color: var(--text-main);
  font-weight: 600;
  line-height: 1.7;
}

.test-panel {
  margin-top: 1.4rem;
  padding: clamp(1.35rem, 3vw, 2.3rem);
}

.mode-switch {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  margin-bottom: 1.35rem;
  padding: 1rem;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(10, 24, 38, 0.88), rgba(7, 17, 28, 0.8));
  border: 1px solid rgba(105, 215, 244, 0.12);
}

.mode-switch-label {
  margin: 0;
  color: rgba(201, 216, 240, 0.74);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

.mode-switch-group {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 0.45rem;
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(240, 195, 109, 0.12);
}

.mode-switch-button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.78rem 1.25rem;
  background: transparent;
  color: rgba(227, 236, 251, 0.76);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition:
    transform 180ms ease,
    filter 180ms ease,
    background 180ms ease,
    color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.mode-switch-button:hover {
  transform: translateY(-1px);
  color: rgba(255, 247, 226, 0.95);
}

.mode-switch-button.is-active {
  color: #08111b;
  background: linear-gradient(135deg, rgba(240, 195, 109, 0.98), rgba(255, 224, 160, 0.98) 40%, rgba(105, 215, 244, 0.96));
  box-shadow:
    0 8px 18px rgba(240, 195, 109, 0.16),
    0 8px 22px rgba(105, 215, 244, 0.12);
}

.mode-switch-button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.mode-switch-note {
  margin: 0;
  max-width: 42rem;
  color: rgba(214, 225, 242, 0.72);
  text-align: center;
  line-height: 1.7;
}

.start-area,
.action-row {
  display: grid;
  justify-items: center;
}

.primary-button,
.secondary-button {
  border: none;
  border-radius: 999px;
  padding: 1rem 2.3rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease,
    background 180ms ease;
}

.primary-button {
  color: #08111b;
  background: linear-gradient(135deg, var(--accent-gold), #ffe0a0 48%, var(--accent-cyan));
  box-shadow:
    0 14px 28px rgba(105, 215, 244, 0.2),
    0 10px 28px rgba(240, 195, 109, 0.22);
}

.secondary-button {
  color: var(--text-main);
  background: linear-gradient(135deg, rgba(10, 22, 36, 0.95), rgba(14, 34, 56, 0.92));
  border: 1px solid rgba(240, 195, 109, 0.24);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.06);
}

.primary-button:active,
.secondary-button:active {
  transform: scale(0.98);
}

.hint-text {
  margin: 0.9rem 0 0;
  color: rgba(214, 225, 242, 0.68);
  text-align: center;
}

.loading-panel {
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 0.4rem 0 1rem;
  animation: fade-up 520ms ease both;
}

.loading-core {
  position: relative;
  width: min(68vw, 300px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.orbit {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0.95;
}

.orbit::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, transparent 0 12%, rgba(240, 195, 109, 0.92) 18%, transparent 26%, rgba(105, 215, 244, 0.84) 42%, transparent 58%, rgba(255, 140, 97, 0.8) 74%, transparent 88%, rgba(240, 195, 109, 0.75));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}

.orbit-a {
  animation: spin 6s linear infinite;
}

.orbit-b {
  inset: 12%;
  animation: spin-reverse 5.2s linear infinite;
}

.orbit-c {
  inset: 24%;
  animation: pulse-ring 3.6s ease-in-out infinite;
}

.pulse-center {
  position: absolute;
  inset: 36%;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 247, 226, 0.98) 0 20%, rgba(240, 195, 109, 0.88) 34%, rgba(105, 215, 244, 0.34) 58%, transparent 78%);
  box-shadow:
    0 0 38px rgba(240, 195, 109, 0.58),
    0 0 80px rgba(105, 215, 244, 0.24);
  animation: core-breathe 2s ease-in-out infinite;
}

.particle-cloud {
  position: absolute;
  inset: 0;
}

.particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 20%, rgba(105, 215, 244, 0.72) 40%, rgba(240, 195, 109, 0.15) 82%, transparent 100%);
  box-shadow: 0 0 18px rgba(105, 215, 244, 0.22);
  animation: drift var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
}

.loading-title {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.loading-text {
  margin: 0;
  color: var(--text-subtle);
  text-align: center;
}

.result-panel {
  margin-top: 0.8rem;
  animation: reveal-results 700ms cubic-bezier(0.18, 0.86, 0.28, 1) both;
}

.section-heading {
  margin-bottom: 1.3rem;
}

h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  letter-spacing: 0.04em;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.result-grid.is-twin {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.spirit-cards-container {
  display: contents;
}

.result-card {
  min-height: 100%;
  padding: 1.25rem;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(9, 21, 35, 0.92), rgba(6, 14, 24, 0.92)),
    linear-gradient(135deg, rgba(240, 195, 109, 0.08), transparent 42%);
  border: 1px solid rgba(240, 195, 109, 0.16);
  position: relative;
  overflow: hidden;
}

.result-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(105, 215, 244, 0.12), transparent 34%);
  pointer-events: none;
}

.card-label {
  margin: 0 0 0.85rem;
  color: rgba(201, 216, 240, 0.72);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.84rem;
}

.spirit-name {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.85rem);
  line-height: 1.08;
  color: var(--result-primary);
  text-shadow: 0 0 24px rgba(240, 195, 109, 0.24);
}

.spirit-card.is-fused {
  border-color: rgba(240, 195, 109, 0.28);
  box-shadow: inset 0 0 0 1px rgba(240, 195, 109, 0.08);
}

.spirit-card-subtitle {
  margin: 0.55rem 0 0;
  color: rgba(214, 225, 242, 0.72);
  line-height: 1.6;
  font-size: 0.94rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(105, 215, 244, 0.1);
  border: 1px solid rgba(105, 215, 244, 0.22);
  color: rgba(230, 241, 255, 0.92);
  font-size: 0.88rem;
}

.card-copy,
.verdict-copy {
  margin: 1rem 0 0;
  color: var(--text-subtle);
  line-height: 1.9;
}

.power-card {
  display: grid;
  align-content: start;
  justify-items: center;
  text-align: center;
}

.power-figure {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  gap: 0.2rem;
  margin-top: 0.2rem;
  padding: 1.3rem 1.6rem;
  color: var(--result-primary);
  font-size: clamp(3.2rem, 8vw, 4.6rem);
  line-height: 0.9;
}

.power-figure::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(240, 195, 109, 0.18), transparent 62%),
    conic-gradient(from 180deg, rgba(240, 195, 109, 0.38), transparent 35%, rgba(105, 215, 244, 0.28), transparent 70%, rgba(255, 140, 97, 0.18));
  filter: blur(1px);
  z-index: -1;
}

.power-figure small {
  font-size: 1.05rem;
  color: var(--text-subtle);
  transform: translateY(0.6rem);
}

.power-title {
  margin: 0.35rem 0 0;
  font-size: 1.15rem;
  color: var(--result-secondary);
  letter-spacing: 0.08em;
}

.verdict-card {
  border-color: rgba(105, 215, 244, 0.16);
}

.result-grid.is-twin .verdict-card {
  grid-column: auto;
}

.action-row {
  margin-top: 1.25rem;
}

.is-hidden {
  display: none !important;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes spin-reverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

@keyframes pulse-ring {
  0%,
  100% {
    transform: scale(0.96);
    opacity: 0.75;
  }
  50% {
    transform: scale(1.04);
    opacity: 1;
  }
}

@keyframes core-breathe {
  0%,
  100% {
    transform: scale(0.94);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(0.85);
    opacity: 0.32;
  }
  50% {
    transform: translate3d(var(--drift-x), var(--drift-y), 0) scale(1.15);
    opacity: 1;
  }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reveal-results {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .verdict-card {
    grid-column: 1 / -1;
  }

  .result-grid.is-twin .verdict-card {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 1rem, 1120px);
    padding: 1rem 0 2.5rem;
  }

  .hero-panel,
  .test-panel {
    border-radius: 22px;
  }

  .hero-text,
  .card-copy,
  .verdict-copy {
    line-height: 1.7;
  }

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

  .mode-switch-group {
    width: 100%;
    grid-auto-flow: initial;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-switch-button {
    width: 100%;
  }

  .spirit-name {
    font-size: 2rem;
  }

  .power-figure {
    font-size: 3.5rem;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .loading-core {
    width: min(78vw, 260px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
