/* ── 基础（深色） ─────────────────────────────────────── */
:root {
  color-scheme: dark;

  --bg: #0e1014;
  --bg-soft: #12151b;
  --card: #171a21;
  --card-2: #1d212a;
  --ink: #e9ebf2;
  --ink-2: #b7bcc9;
  --muted: #868d9d;
  --line: #262b36;
  --line-2: #1f242e;
  --accent: #7b8cff;
  --accent-soft: rgba(123, 140, 255, .14);
  --accent-ink: #a5b2ff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  /* 深色下给一点极淡的顶部光晕，避免大块纯黑显得廉价 */
  background-image: radial-gradient(120% 60% at 50% -10%, rgba(123, 140, 255, .07), transparent 60%);
  background-repeat: no-repeat;
}

.screen[hidden] { display: none !important; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: fade .32s ease both;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ── 首页 ─────────────────────────────────────── */
.intro {
  margin: auto;
  width: 100%;
  max-width: 560px;
  padding: 48px 24px calc(48px + env(safe-area-inset-bottom));
  text-align: center;
}

.mark {
  font-size: 44px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 22px;
  text-shadow: 0 0 32px rgba(123, 140, 255, .45);
}

.intro h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.25;
  color: #f2f4fa;
}

.sub {
  margin: 0 auto 26px;
  max-width: 30em;
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.75;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 34px;
}

.chip {
  display: inline-block;
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: .01em;
}

.btn-primary {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 100%;
  max-width: 320px;
  padding: 17px 24px;
  border-radius: 14px;
  background: linear-gradient(180deg, #8493ff, #6a7bff);
  color: #0b0d12;
  font-family: inherit;
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: .02em;
  transition: transform .12s ease, filter .18s ease, box-shadow .18s ease;
  box-shadow: 0 8px 26px rgba(106, 123, 255, .32);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(.985); }

.tiny {
  margin: 30px auto 0;
  max-width: 34em;
  color: #5f6675;
  font-size: 12px;
  line-height: 1.7;
}

/* ── 答题 ─────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 16px 10px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.icon-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s, color .15s, opacity .15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .06); color: var(--ink); }
.icon-btn:disabled { opacity: 0; pointer-events: none; }

.counter {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.counter-ghost { width: 38px; }

.progress {
  height: 3px;
  background: var(--line-2);
  max-width: 720px;
  width: calc(100% - 32px);
  margin: 0 auto;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8493ff, #6a7bff);
  border-radius: 999px;
  transition: width .38s cubic-bezier(.4, 0, .2, 1);
  box-shadow: 0 0 12px rgba(123, 140, 255, .5);
}

.qwrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 20px 0;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.qcard {
  width: 100%;
  padding: 4px 0 0;
}
.qcard.enter { animation: qin .3s cubic-bezier(.2, .7, .3, 1) both; }
@keyframes qin {
  from { opacity: 0; transform: translateX(14px); }
  to   { opacity: 1; transform: none; }
}

/* 未作答却想翻页时，轻微提示 */
.qcard.nudge { animation: nudge .34s ease; }
@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.qindex {
  margin: 0 0 14px;
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .1em;
}

.qtext {
  margin: 0 0 30px;
  font-size: clamp(21px, 5.2vw, 28px);
  font-weight: 620;
  line-height: 1.5;
  letter-spacing: -.01em;
  color: #f0f2f8;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option {
  appearance: none;
  text-align: left;
  cursor: pointer;
  width: 100%;
  min-height: 68px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 15.5px;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
  transition: border-color .16s ease, background .16s ease, transform .1s ease, box-shadow .16s ease;
}
.option:hover {
  border-color: #39415a;
  background: var(--card-2);
  box-shadow: var(--shadow);
}
.option:active { transform: scale(.994); }

.option .key {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: all .16s ease;
}

.option.chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.option.chosen .key {
  border-color: var(--accent);
  background: var(--accent);
  color: #0b0d12;
}

.hint {
  text-align: center;
  color: #565d6b;
  font-size: 12px;
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
  margin: 0;
}
kbd {
  font-family: inherit;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 11px;
  color: var(--muted);
  background: var(--card);
}

/* 只在触屏设备显示滑动提示 */
.touch-only { display: none; }
@media (hover: none) {
  .touch-only { display: inline; }
  .kb-only { display: none; }
}

/* ── 结果 ─────────────────────────────────────── */
.result {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: max(48px, env(safe-area-inset-top)) 24px calc(56px + env(safe-area-inset-bottom));
}

.rlabel {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .12em;
}

.typecode {
  font-size: clamp(52px, 15vw, 78px);
  font-weight: 700;
  letter-spacing: .06em;
  line-height: 1.05;
  color: var(--accent-ink);
  text-shadow: 0 0 40px rgba(123, 140, 255, .3);
}

.typelabels {
  margin: 12px 0 10px;
  color: var(--ink-2);
  font-size: 15px;
  letter-spacing: .02em;
}
.typelabels span + span::before {
  content: "·";
  margin: 0 9px;
  color: #414857;
}

/* 类型名，如「调停者」 */
.typename {
  margin: 0 0 36px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--accent-ink);
}
.typename:empty { display: none; }

.bars {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 26px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  margin-bottom: 14px;
}

.bar-row .bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 9px;
}
.bar-head .side { color: var(--muted); }
.bar-head .side.win { color: var(--ink); font-weight: 600; }

.bar-track {
  position: relative;
  height: 7px;
  background: var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8493ff, #6a7bff);
  transition: width .8s cubic-bezier(.2, .8, .2, 1);
}
.bar-row:nth-child(2) .bar-fill { background: linear-gradient(90deg, #5ecfb8, #35a894); }
.bar-row:nth-child(3) .bar-fill { background: linear-gradient(90deg, #f0a468, #d8813c); }
.bar-row:nth-child(4) .bar-fill { background: linear-gradient(90deg, #b592f0, #8f66d6); }

.dims { display: flex; flex-direction: column; gap: 12px; }

.dim-block {
  padding: 22px 22px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.dim-block h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.005em;
  color: #eef0f6;
}
.dim-block h3 em {
  font-style: normal;
  color: var(--accent-ink);
  margin-left: 7px;
  font-weight: 600;
}
.dim-block p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.85;
}

.ractions {
  display: flex;
  justify-content: center;
  margin-top: 34px;
}

.btn-ghost {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  padding: 11px 26px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  transition: border-color .16s, color .16s, background .16s;
}
.btn-ghost:hover { border-color: #39415a; color: var(--ink); background: var(--card-2); }

/* 结果页依次浮现 */
.result > * { animation: rise .5s ease both; }
#r-panel > * { animation: rise .5s ease both; }
#r-panel > *:nth-child(1) { animation-delay: .02s; }
#r-panel > *:nth-child(2) { animation-delay: .08s; }
#r-panel > *:nth-child(3) { animation-delay: .14s; }
#r-panel > *:nth-child(4) { animation-delay: .2s; }
#r-panel > *:nth-child(5) { animation-delay: .26s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* 提交失败 */
#r-fail { text-align: center; padding-top: 40px; }
#r-wait { text-align: center; padding-top: 72px; }
.rfail-title {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.01em;
  color: #f0f2f8;
}
.rfail-msg {
  margin: 0 auto 26px;
  max-width: 30em;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.8;
}
#btn-retry { max-width: 260px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
