:root {
  --bg-top: #1b1033;
  --bg-mid: #2d1b4e;
  --bg-bot: #0f2a4a;
  --gold: #ffd166;
  --cyan: #5ec5ff;
  --ink: #f5f3ff;
  --muted: #b9aee0;
  --card: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-mid) 45%, var(--bg-bot) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
#app {
  max-width: 520px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  min-height: 100vh;
}
.zh { font-weight: 600; }
.en { color: var(--muted); font-weight: 400; }

.screen { display: none; animation: fade 0.35s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* buttons */
.btn {
  display: block; width: 100%;
  border: none; cursor: pointer;
  font-size: 17px; font-family: inherit;
  padding: 16px 0; border-radius: 999px;
  text-align: center; text-decoration: none;
  transition: transform .12s ease, opacity .18s ease;
}
.btn:active { transform: scale(0.985); opacity: .92; }
.btn-primary { background: linear-gradient(135deg, var(--gold), #ff9e6d); color: #2a1a0a; font-weight: 700; box-shadow: 0 10px 28px rgba(255,158,109,.32); }
.btn-cyan { background: rgba(94,197,255,.18); border: 1px solid rgba(94,197,255,.5); color: var(--ink); }
.btn-ghost { background: var(--card); border: 1px solid var(--card-border); color: var(--ink); }

/* ---- start screen ---- */
.hero { text-align: center; margin: 34px 0 40px; }
.badge {
  display: inline-block; letter-spacing: 9px; font-weight: 800; font-size: 14px;
  color: #2a1a0a; background: linear-gradient(135deg, var(--gold), #ff9e6d);
  padding: 6px 16px 6px 25px; border-radius: 999px; margin-bottom: 22px;
}
.title { font-size: 40px; line-height: 1.15; letter-spacing: 2px; margin: 0; }
.title-en { font-size: 15px; letter-spacing: 1px; margin-top: 6px; }
.lede { font-size: 16px; margin-top: 22px; }
.lede-en { font-size: 13px; margin-top: 4px; }

.axes-preview { background: var(--card); border: 1px solid var(--card-border); border-radius: 18px; padding: 4px 18px; margin-bottom: 36px; }
.axis-row { display: flex; align-items: center; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.axis-row:last-child { border-bottom: none; }
.pole { flex: 1; display: flex; flex-direction: column; }
.pole.right { align-items: flex-end; text-align: right; }
.pole-zh { font-size: 16px; font-weight: 600; }
.pole-en { font-size: 11px; color: var(--muted); margin-top: 2px; }
.vs { width: 44px; text-align: center; color: var(--cyan); font-size: 18px; }
.hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 18px; }
.hint.en { margin-top: 2px; font-size: 11px; }

/* ---- quiz screen ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.back-btn { background: none; border: none; color: var(--muted); font-size: 30px; cursor: pointer; width: 36px; line-height: 1; }
.counter { font-size: 14px; color: var(--muted); letter-spacing: 1px; }
.progress { height: 6px; background: rgba(255,255,255,.10); border-radius: 999px; overflow: hidden; margin-bottom: 40px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--gold)); border-radius: 999px; transition: width .25s ease; }
.q-zh { font-size: 25px; line-height: 1.4; }
.q-en { font-size: 14px; line-height: 1.4; margin-top: 8px; color: var(--muted); }
.options { display: flex; flex-direction: column; gap: 14px; margin-top: 36px; }
.opt { background: var(--card); border: 1px solid var(--card-border); border-radius: 16px; padding: 20px 18px; cursor: pointer; transition: transform .12s ease, background .18s ease, border-color .18s ease; }
.opt:hover { border-color: rgba(255,255,255,.28); }
.opt:active { transform: scale(.985); }
.opt.picked { background: rgba(255,209,102,.18); border-color: var(--gold); }
.opt-zh { font-size: 18px; line-height: 1.35; }
.opt-en { font-size: 13px; line-height: 1.35; margin-top: 6px; color: var(--muted); }

/* ---- result screen ---- */
.card { text-align: center; background: var(--card); border: 1px solid var(--card-border); border-radius: 22px; padding: 30px 22px 26px; margin-bottom: 20px; }
.r-emoji { font-size: 62px; line-height: 1; }
.r-code { margin-top: 8px; font-size: 22px; font-weight: 800; letter-spacing: 8px; color: var(--cyan); }
.r-name { font-size: 30px; margin-top: 8px; }
.r-name-en { font-size: 14px; margin-top: 2px; }
.r-tag { margin-top: 14px; font-size: 16px; color: var(--gold); line-height: 1.5; }
.r-tag-en { font-size: 12px; margin-top: 4px; font-style: italic; color: var(--muted); }

.axes-result { background: var(--card); border: 1px solid var(--card-border); border-radius: 18px; padding: 20px 20px 8px; margin-bottom: 20px; }
.axis { margin-bottom: 20px; }
.axis-labels { display: flex; justify-content: space-between; font-size: 15px; color: var(--muted); }
.axis-labels .win { color: var(--ink); font-weight: 700; }
.track { position: relative; height: 6px; border-radius: 999px; margin: 9px 0 7px; background: linear-gradient(90deg, rgba(94,197,255,.55), rgba(255,209,102,.55)); }
.dot { position: absolute; top: 50%; width: 15px; height: 15px; margin-left: -7px; transform: translateY(-50%); background: #fff; border-radius: 50%; box-shadow: 0 2px 7px rgba(0,0,0,.4); }
.axis-sub { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }
.win-pct { color: var(--gold); font-weight: 600; }

.section { background: var(--card); border: 1px solid var(--card-border); border-radius: 18px; padding: 20px; margin-bottom: 20px; }
.sec-title { font-size: 13px; color: var(--cyan); letter-spacing: 1px; margin-bottom: 10px; }
.desc { font-size: 16px; line-height: 1.7; }
.desc-en { font-size: 13px; line-height: 1.6; margin-top: 10px; }
.dual { display: flex; gap: 12px; margin-bottom: 20px; }
.mini { flex: 1; background: var(--card); border: 1px solid var(--card-border); border-radius: 16px; padding: 16px 14px; }
.mini-title { font-size: 13px; color: var(--gold); margin-bottom: 8px; }
.mini-zh { font-size: 14px; line-height: 1.5; }
.mini-en { font-size: 11px; line-height: 1.5; margin-top: 6px; color: var(--muted); }
.match-row { display: flex; align-items: center; gap: 14px; }
.match-emoji { font-size: 38px; }
.match-code { color: var(--cyan); font-weight: 700; font-size: 13px; letter-spacing: 2px; }
.match-name { font-size: 18px; }
.match-name-en { font-size: 12px; color: var(--muted); margin-top: 2px; }

.actions { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.act-row { display: flex; gap: 12px; }
.act-row .btn { flex: 1; }

/* ---- poster modal ---- */
.poster-mask { position: fixed; inset: 0; background: rgba(0,0,0,.8); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; overflow: auto; }
.poster-mask[hidden] { display: none; }
.poster-panel { display: flex; flex-direction: column; align-items: center; }
#poster { width: 300px; height: 506px; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.poster-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; justify-content: center; }
.poster-actions .btn { width: auto; padding: 12px 26px; font-size: 15px; }
.poster-hint { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* ===== multi-test home / intro / match ===== */
.back-link { background:none;border:none;color:var(--muted);font-size:14px;cursor:pointer;padding:6px 0;margin-bottom:6px; }
.back-link:active { opacity:.7; }

.test-cards { display:flex; flex-direction:column; gap:16px; margin-bottom:22px; }
.test-card {
  text-align:left; cursor:pointer; color:var(--ink);
  background:var(--card); border:1px solid var(--card-border); border-left:4px solid var(--accent,#5ec5ff);
  border-radius:18px; padding:18px 20px; transition:transform .12s ease, border-color .18s ease;
  font-family:inherit;
}
.test-card:hover { border-color:var(--accent,#5ec5ff); }
.test-card:active { transform:scale(.99); }
.tc-top { display:flex; align-items:center; justify-content:space-between; }
.tc-emoji { font-size:30px; }
.tc-code { font-size:13px; font-weight:800; letter-spacing:3px; color:var(--accent,#5ec5ff); }
.tc-name { font-size:22px; margin-top:6px; }
.tc-name-en { font-size:13px; color:var(--muted); font-weight:400; }
.tc-blurb { font-size:13px; color:var(--muted); margin-top:2px; }
.tc-axes { font-size:11px; color:var(--muted); margin-top:12px; line-height:1.9; }
.tc-axes i { color:var(--accent,#5ec5ff); font-style:normal; margin:0 6px; }
.tc-go { font-size:13px; color:var(--accent,#5ec5ff); font-weight:600; margin-top:12px; }
.match-cta { margin-top:4px; }

/* cross-test teaser on result */
.section.cross { border-color:rgba(124,255,178,.35); }
.cross-best { display:flex; align-items:center; gap:12px; }
.cross-tx { flex:1; }
.cross-tx .zh { font-size:18px; } .cross-tx .en { font-size:12px; color:var(--muted); }
.cross-pct { font-size:26px; font-weight:800; color:#7CFFB2; }
.cross-worst { font-size:12px; margin-top:8px; color:var(--muted); }
.match-code { color:var(--cyan); font-weight:700; font-size:13px; letter-spacing:2px; }

/* match screen */
.match-pickers { display:flex; gap:12px; margin-bottom:18px; }
.match-pickers .mp { flex:1; display:flex; flex-direction:column; gap:6px; }
.match-pickers label { font-size:12px; color:var(--muted); }
.match-sel {
  width:100%; appearance:none; -webkit-appearance:none;
  background:var(--card); color:var(--ink); border:1px solid var(--card-border);
  border-radius:12px; padding:12px 10px; font-size:14px; font-family:inherit;
}
.match-result { text-align:center; background:var(--card); border:1px solid var(--card-border); border-radius:20px; padding:26px 18px; margin-bottom:20px; }
.match-pct { font-size:64px; font-weight:800; color:#7CFFB2; line-height:1; }
.match-pct small { font-size:26px; }
.match-verdict { font-size:20px; color:var(--gold); margin-top:10px; }
.match-verdict-en { font-size:13px; margin-top:4px; }
.match-pair { display:flex; align-items:flex-start; justify-content:center; gap:10px; margin-top:22px; }
.match-pair .mpc { flex:1; max-width:130px; }
.mpc-emoji { font-size:40px; }
.match-pair .mpc .zh { font-size:15px; margin-top:4px; }
.match-pair .mpc .en { font-size:11px; color:var(--muted); margin-top:2px; }
.mpc-x { font-size:22px; color:var(--cyan); font-weight:800; align-self:center; }

/* ===== friend invite + compatibility ===== */
.btn-friend { background: linear-gradient(135deg, #ff8fcf, #c77dff); color: #2a0a22; font-weight: 700; box-shadow: 0 10px 28px rgba(199,125,255,.3); }
.iv-cap { font-size: 14px; color: var(--muted); margin-top: 14px; line-height: 1.5; }
.iv-pick { margin-top: 6px; }
.iv-or { text-align: center; font-size: 12px; margin: 14px 0 10px; }
.iv-pick .match-sel { margin-bottom: 0; }
.iv-pick .btn { margin-top: 10px; }
.cc-list { list-style: none; margin: 0; padding: 0; }
.cc-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.06); font-size: 15px; }
.cc-list li:last-child { border-bottom: none; }
.cc-list li .en { font-size: 12px; }

/* ===== polish: staggered reveal, depth, count-up ===== */
.screen.active > * { animation: rise .42s cubic-bezier(.2,.7,.3,1) both; }
.screen.active > *:nth-child(1){ animation-delay:.02s; }
.screen.active > *:nth-child(2){ animation-delay:.06s; }
.screen.active > *:nth-child(3){ animation-delay:.10s; }
.screen.active > *:nth-child(4){ animation-delay:.14s; }
.screen.active > *:nth-child(5){ animation-delay:.18s; }
.screen.active > *:nth-child(6){ animation-delay:.22s; }
.screen.active > *:nth-child(n+7){ animation-delay:.26s; }
@keyframes rise { from { opacity:0; transform: translateY(10px); } to { opacity:1; transform:none; } }
@media (prefers-reduced-motion: reduce) { .screen.active > * { animation: none; } }

.test-card { box-shadow: 0 2px 12px rgba(0,0,0,.18); }
.test-card:hover { box-shadow: 0 10px 34px rgba(0,0,0,.32); transform: translateY(-2px); }
.test-card:active { transform: scale(.99); }

.match-pct .pct-num { font-variant-numeric: tabular-nums; }
.home-foot { text-align:center; font-size:12px; color:var(--muted); margin-top:20px; }
