:root {
  --primary: #4f46e5;
  --soft: #eef2ff;
  --text: #141b2d;
  --muted: #5a657d;
  --line: #e4eaf4;
  --surface: rgba(255, 255, 255, 0.88);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: #f6f7ff;
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  position: relative;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.nav {
  max-width: 1160px; margin: auto; padding: 10px 24px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
}
.logo { font-weight: 800; color: var(--primary); font-size: 1.18rem; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.nav-links { display: flex; gap: 4px 10px; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--muted); padding: 7px 11px; border-radius: 9px; font-size: .88rem; font-weight: 550; }
.nav-links a:hover, .nav-links a.active { color: var(--primary); background: var(--soft); font-weight: 700; }

/* Dopamine Aura Background */
.aura-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.aura {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.55;
}
.aura-1 { width: 420px; height: 420px; top: -100px; left: -80px; background: #ff9de2; }
.aura-2 { width: 460px; height: 460px; top: 15%; right: -120px; background: #7de2ff; }
.aura-3 { width: 440px; height: 440px; bottom: -140px; left: 32%; background: #c5ff95; }

/* Main Container */
.quiz-shell {
  max-width: 1040px; margin: 0 auto; padding: 34px 20px 44px;
}

.card-stage {
  max-width: 720px; margin: 0 auto;
  background: var(--surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  padding: 36px 34px;
  box-shadow: 0 20px 55px rgba(45, 58, 120, 0.09);
  animation: fadeUp .32s ease-out;
}

/* Intro */
.intro-stage { text-align: center; }
.pill-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  background: linear-gradient(135deg, #fff0f8, #eef4ff);
  border: 1px solid #e2d8ff;
  color: #5b3df5; font-size: .82rem; font-weight: 700;
}
.hero-title {
  margin-top: 18px;
  font-size: clamp(2.1rem, 5.5vw, 3.2rem);
  font-weight: 900; line-height: 1.18; letter-spacing: -0.02em;
}
.gradient-text {
  background: linear-gradient(120deg, #ff3d8b 0%, #7c3aed 52%, #00a8ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-desc {
  margin: 16px auto 0; max-width: 520px;
  color: var(--muted); font-size: .98rem; line-height: 1.75;
}

.preview-avatars {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin: 24px 0 24px;
}
.preview-avatars img {
  width: 68px; height: 68px; border-radius: 20px; object-fit: cover;
  border: 3px solid #fff; box-shadow: 0 8px 20px rgba(45, 58, 120, 0.14);
  transition: transform .18s ease;
}
.preview-avatars img:hover { transform: translateY(-4px) scale(1.06); }

.nickname-box {
  max-width: 380px; margin: 0 auto 22px; text-align: left;
}
.nickname-box label {
  display: block; font-size: .8rem; font-weight: 650; color: var(--muted); margin-bottom: 6px;
}
.nickname-box input {
  width: 100%; padding: 11px 14px; border-radius: 14px;
  border: 1.5px solid #d6dfef; background: #fff; color: var(--text);
  font-size: .92rem; transition: border-color .15s, box-shadow .15s;
}
.nickname-box input:focus {
  outline: none; border-color: #7c3aed; box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

.intro-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.btn-dopamine {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 28px; border: 0; border-radius: 999px;
  background: linear-gradient(125deg, #ff3d8b 0%, #7c3aed 55%, #2563eb 100%);
  color: #fff; font-size: 1rem; font-weight: 800;
  box-shadow: 0 12px 26px rgba(124, 58, 237, 0.28);
  transition: transform .16s ease, box-shadow .16s ease;
}
.btn-dopamine:hover { transform: translateY(-2px); box-shadow: 0 16px 32px rgba(124, 58, 237, 0.36); }
.btn-dopamine:active { transform: scale(0.98); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 22px; border-radius: 999px;
  border: 1.5px solid #d8e1f0; background: #fff; color: var(--text);
  font-size: .92rem; font-weight: 700; transition: all .15s;
}
.btn-ghost:hover { border-color: #7c3aed; color: #7c3aed; background: #f8f5ff; }

.meta-row {
  margin-top: 24px; padding-top: 18px; border-top: 1px dashed #dde5f2;
  display: flex; justify-content: center; flex-wrap: wrap; gap: 14px 24px;
  font-size: .82rem; color: var(--muted);
}

/* Quiz Stage */
.quiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.btn-back {
  border: 0; background: transparent; color: var(--muted);
  font-size: .88rem; font-weight: 650; padding: 6px 8px; border-radius: 8px;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-back:hover { background: #f1f4fb; color: var(--text); }
.quiz-counter { font-weight: 800; font-size: .92rem; color: #7c3aed; letter-spacing: 0.05em; }

.progress-bar {
  height: 9px; background: #eaeff8; border-radius: 999px; overflow: hidden; margin-bottom: 24px;
}
.progress-fill {
  height: 100%; width: 12.5%; border-radius: 999px;
  background: linear-gradient(90deg, #ff3d8b, #7c3aed, #00b4ff);
  transition: width .3s cubic-bezier(.22, 1, .36, 1);
}

.question-meta {
  display: inline-block; padding: 4px 11px; border-radius: 8px;
  background: #f3efff; color: #6d28d9; font-size: .78rem; font-weight: 750;
  margin-bottom: 10px;
}
.question-title {
  font-size: clamp(1.28rem, 3.2vw, 1.65rem);
  font-weight: 850; line-height: 1.4; margin-bottom: 22px;
}

.option-list { display: grid; gap: 11px; }
.option-btn {
  display: flex; align-items: flex-start; gap: 13px;
  width: 100%; padding: 15px 18px; text-align: left;
  border: 1.5px solid #e1e8f5; border-radius: 16px;
  background: #fff; color: var(--text);
  transition: transform .14s ease, border-color .14s ease, background .14s ease, box-shadow .14s ease;
}
.option-btn:hover {
  transform: translateY(-2px); border-color: #936eff;
  background: #faf8ff; box-shadow: 0 8px 20px rgba(124, 58, 237, 0.1);
}
.option-btn.selected {
  border-color: #7c3aed; background: linear-gradient(135deg, #f5f0ff, #eef6ff);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.16);
}
.opt-letter {
  flex: none; width: 30px; height: 30px; border-radius: 10px;
  display: grid; place-items: center;
  background: #f1f5fb; color: #5b6880; font-weight: 800; font-size: .84rem;
}
.option-btn:hover .opt-letter, .option-btn.selected .opt-letter {
  background: linear-gradient(135deg, #ff3d8b, #7c3aed); color: #fff;
}
.opt-text strong { display: block; font-size: .96rem; font-weight: 700; line-height: 1.45; }
.opt-text small { display: block; color: var(--muted); font-size: .82rem; margin-top: 2px; }

/* Loading */
.loading-stage { text-align: center; padding: 64px 28px; }
.spinner-orb {
  width: 78px; height: 78px; margin: 0 auto 20px; border-radius: 26px;
  display: grid; place-items: center; font-size: 2rem;
  background: linear-gradient(135deg, #ff3d8b, #7c3aed, #00b4ff);
  animation: spinPulse 1.1s ease-in-out infinite;
  box-shadow: 0 14px 32px rgba(124, 58, 237, 0.28);
}
.loading-stage h2 { font-size: 1.45rem; font-weight: 850; margin-bottom: 8px; }
.loading-stage p { color: var(--muted); font-size: .92rem; }

/* Result Stage */
.result-stage { animation: fadeUp .35s ease-out; }
.result-grid {
  display: grid; grid-template-columns: minmax(290px, 380px) minmax(0, 1fr);
  gap: 28px; align-items: start;
}
.poster-col { position: sticky; top: 82px; }
.poster-frame {
  border-radius: 24px; overflow: hidden;
  box-shadow: 0 22px 55px rgba(25, 35, 78, 0.18);
  background: #fff; border: 4px solid #fff;
}
.poster-frame img { display: block; width: 100%; height: auto; }
.poster-hint {
  margin-top: 10px; text-align: center; font-size: .8rem; color: var(--muted);
}

.info-col {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 26px; padding: 28px 30px;
  box-shadow: 0 18px 46px rgba(45, 58, 120, 0.08);
}
.result-badge-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.res-code {
  padding: 4px 12px; border-radius: 999px; font-weight: 900; font-size: .84rem;
  letter-spacing: 0.08em; color: #fff;
  background: linear-gradient(125deg, #ff3d8b, #7c3aed);
}
.res-rarity {
  padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: #f2f5fc; color: var(--muted);
}
.res-title { font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 900; line-height: 1.25; }
.res-quote {
  margin-top: 12px; padding: 12px 16px; border-radius: 14px;
  background: linear-gradient(135deg, #faf7ff, #f2f8ff);
  border-left: 4px solid #7c3aed;
  font-size: .95rem; font-weight: 650; color: #2d2654;
}
.res-desc { margin-top: 14px; color: var(--muted); font-size: .92rem; line-height: 1.75; }
.sync-note {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
  font-size: .8rem; font-weight: 700;
}

.stats-card, .match-card, .basis-card {
  margin-top: 20px; padding: 18px 20px; border-radius: 18px;
  background: #fff; border: 1px solid #e7edf7;
}
.stats-card h3, .basis-card h3 { font-size: .92rem; font-weight: 800; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stats-sub { font-size: .74rem; font-weight: 600; color: var(--muted); }
.basis-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.basis-list li { font-size: .85rem; color: #334155; display: flex; align-items: flex-start; gap: 8px; line-height: 1.55; }
.basis-list li::before { content: '•'; color: #7c3aed; font-weight: 900; }
.stat-bars { display: grid; gap: 11px; }
.stat-row { display: grid; gap: 5px; }
.stat-head { display: flex; justify-content: space-between; font-size: .82rem; font-weight: 650; }
.stat-head span:last-child { color: #7c3aed; font-weight: 800; }
.stat-track { height: 9px; border-radius: 999px; background: #eef2fa; overflow: hidden; }
.stat-fill { height: 100%; border-radius: 999px; transition: width .6s ease; }

.match-card { display: grid; gap: 14px; }
.match-label { display: block; font-size: .8rem; font-weight: 800; color: var(--muted); margin-bottom: 6px; }
.match-block p { font-size: .9rem; color: var(--text); line-height: 1.6; }
.matched-teams { display: grid; gap: 10px; }
.teams-loading { font-size: .84rem; color: var(--muted); }
.matched-team-item {
  display: grid; gap: 6px; padding: 12px 14px; border-radius: 14px;
  background: #f8faff; border: 1px solid #e2e9f7;
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.matched-team-item:hover { transform: translateY(-1px); border-color: #818cf8; box-shadow: 0 8px 20px rgba(79, 70, 229, 0.09); }
.matched-team-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.matched-team-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .88rem; }
.matched-contest { padding: 2px 8px; border-radius: 6px; background: #eef2ff; color: #4338ca; font-size: .74rem; font-weight: 750; }
.matched-persona-pill { padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; border: 1px solid transparent; }
.matched-fit-tag { padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 800; background: #fff0f5; color: #db2777; }
.matched-fit-tag.good { background: #eff6ff; color: #2563eb; }
.matched-team-reason { font-size: .8rem; color: #475569; }
.matched-team-note { font-size: .82rem; color: var(--text); line-height: 1.5; }
.matched-team-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.matched-team-cta { color: #4f46e5; font-weight: 800; font-size: .82rem; }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.result-actions .btn-dopamine { flex: 1; min-width: 210px; }
.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 12px 20px; border-radius: 999px;
  border: 2px solid #7c3aed; color: #7c3aed; background: #fff;
  font-size: .94rem; font-weight: 800; transition: all .15s;
}
.btn-outline:hover { background: #7c3aed; color: #fff; }
.result-sub-actions { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.btn-text {
  border: 0; background: transparent; color: var(--muted);
  font-size: .85rem; font-weight: 650; padding: 4px 2px;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-text:hover { color: #7c3aed; }

/* Gallery Dialog */
#gallery-dialog {
  width: min(820px, calc(100% - 24px));
  max-height: calc(100dvh - 36px);
  border: 0; border-radius: 24px; padding: 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}
#gallery-dialog::backdrop { background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px); }
.gallery-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.gallery-head h2 { font-size: 1.3rem; font-weight: 850; }
.gallery-head p { font-size: .84rem; color: var(--muted); margin-top: 3px; }
.btn-close-dialog {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; font-size: 1.3rem; line-height: 1; color: var(--muted);
}
.gallery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.gallery-item {
  border: 1.5px solid #e5ebf5; border-radius: 18px; padding: 12px;
  background: #fff; text-align: left; display: flex; align-items: center; gap: 12px;
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.gallery-item:hover { transform: translateY(-2px); border-color: #7c3aed; box-shadow: 0 10px 24px rgba(124, 58, 237, 0.12); }
.gallery-thumb {
  width: 72px; height: 72px; flex: none; border-radius: 16px; object-fit: cover;
  background: #f1f5f9;
}
.gallery-body { min-width: 0; flex: 1; display: grid; gap: 5px; }
.gallery-item-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.gallery-item strong { font-size: .96rem; }
.gallery-code { font-size: .7rem; font-weight: 800; padding: 2px 7px; border-radius: 999px; color: #fff; }
.gallery-item small { color: var(--muted); font-size: .78rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.site-footer { text-align: center; padding: 18px 20px 30px; color: var(--muted); font-size: .82rem; }
.site-footer a { text-decoration: underline; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spinPulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.08) rotate(12deg); }
}

@media (max-width: 820px) {
  .result-grid { grid-template-columns: 1fr; }
  .poster-col { position: static; max-width: 390px; margin: 0 auto; }
}
@media (max-width: 600px) {
  .nav { padding: 8px 14px; }
  .nav-links a { font-size: .79rem; padding: 5px 8px; }
  .quiz-shell { padding: 18px 12px 32px; }
  .card-stage { padding: 24px 18px; border-radius: 22px; }
  .info-col { padding: 20px 18px; }
  .gallery-grid { grid-template-columns: 1fr; }
}
