/* 理财人格 16 型 · 样式。手机优先；屏幕宽的时候居中显示，最宽 480px。 */
:root {
  --bg: #FFF8F0;
  --surface: #FFFFFF;
  --ink: #2B2118;
  --ink-2: #6E6157;
  --ink-3: #85786D;
  --line: #EFE3D3;
  --track: #F2E9DF;
  --primary: #E4572E;
  --primary-soft: #FDE7DC;
  --shadow: 0 6px 24px rgba(91, 58, 26, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Helvetica Neue", Arial, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  /* 结果页和类型卡片会按类型所在的分组改写这三个颜色 */
  --theme: var(--primary);
  --theme-deep: #B9431F;
  --theme-soft: var(--primary-soft);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
body.lock { overflow: hidden; }
[hidden] { display: none !important; }
#app { flex: 1; width: 100%; max-width: 480px; margin: 0 auto; padding: 0 16px; }
.screen { padding: 24px 0 8px; animation: fade .25s ease; }
.emoji { font-family: var(--emoji); line-height: 1; font-style: normal; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid #2C5E9E; outline-offset: 2px; }

.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  transition: transform .1s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #FFFFFF; box-shadow: 0 6px 16px rgba(228, 87, 46, .25); }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.btn + .btn { margin-top: 12px; }
.title { font-size: 30px; font-weight: 800; letter-spacing: .02em; line-height: 1.3; }
.hint { font-size: 13px; color: var(--ink-2); margin-top: 10px; }

/* 兑换码 */
.gate { padding-top: 12vh; text-align: center; }
.gate-icon { font-size: 56px; margin-bottom: 14px; }
.gate-tip { color: var(--ink-2); margin: 10px 0 24px; }
#gate-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 20px;
  letter-spacing: .15em;
  text-align: center;
  text-transform: uppercase;
}
#gate-input:focus { border-color: var(--primary); outline: none; }
#gate-input::placeholder { color: var(--ink-3); font-family: var(--font); font-size: 16px; letter-spacing: normal; }
.err { min-height: 1.6em; margin: 8px 0 12px; color: #C0392B; font-size: 14px; }
.gate-buy { margin-top: 20px; font-size: 14px; color: var(--ink-2); }

/* 封面 */
.cover { padding-top: 3vh; text-align: center; }
.cover-art {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 280px;
  margin: 0 auto 28px;
}
.cover-art span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 62px;
  border-radius: 16px;
  background: var(--theme-soft);
  font-size: 34px;
}
.subtitle { margin-top: 8px; color: var(--ink-2); font-size: 17px; }
.meta { margin: 18px 0 28px; color: var(--ink-3); font-size: 14px; }

/* 答题 */
.quiz-top { display: flex; align-items: center; justify-content: space-between; height: 40px; }
.back { padding: 8px 12px 8px 0; color: var(--ink-2); font-size: 15px; }
.count { color: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.progress { height: 8px; margin: 4px 0 28px; overflow: hidden; border-radius: 99px; background: var(--track); }
.progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width .3s ease; }
.q-text { min-height: 3.1em; margin-bottom: 22px; font-size: 20px; font-weight: 700; line-height: 1.55; }
.opt {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  padding: 15px 18px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(91, 58, 26, .04);
  font-size: 16px;
  line-height: 1.5;
  text-align: left;
  transition: border-color .15s ease, background-color .15s ease, transform .1s ease;
}
.opt:active { transform: scale(.985); }
.opt.on { border-color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.q-body.enter { animation: slide .28s ease; }

/* 交卷后的等待 */
.loading { padding-top: 26vh; text-align: center; color: var(--ink-2); }
.hop { display: flex; justify-content: center; gap: 12px; margin-bottom: 22px; font-size: 40px; }
.hop span { animation: hop .9s ease-in-out infinite; }
.hop span:nth-child(2) { animation-delay: .15s; }
.hop span:nth-child(3) { animation-delay: .3s; }
.hop span:nth-child(4) { animation-delay: .45s; }

/* 结果 */
.hero {
  padding: 26px 20px 24px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--theme-soft), var(--surface) 78%);
  box-shadow: var(--shadow);
  text-align: center;
}
.hero-label { color: var(--theme-deep); font-size: 14px; font-weight: 600; letter-spacing: .1em; }
.hero-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 148px;
  height: 148px;
  margin: 16px auto 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .06);
  font-size: 84px;
}
.hero-code { color: var(--theme-deep); font-size: 15px; font-weight: 700; letter-spacing: .4em; text-indent: .4em; }
.hero-name { margin: 2px 0 6px; font-size: 34px; font-weight: 800; line-height: 1.3; }
.hero-motto { margin-bottom: 22px; color: var(--ink-2); text-wrap: balance; }
.result .btn-primary { background: var(--theme-deep); box-shadow: none; }

.block { margin-top: 16px; padding: 22px 20px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.block h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 18px; font-weight: 800; }
.block h2::before { content: ""; width: 6px; height: 18px; border-radius: 3px; background: var(--theme); }
.block ul { list-style: none; }
.block li { position: relative; margin-top: 8px; padding-left: 18px; }
.block li:first-child { margin-top: 0; }
.block li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 7px; height: 7px; border-radius: 50%; background: var(--theme); }
.pits li::before { background: #E0A030; }

.dim + .dim { margin-top: 18px; }
.dim-name { margin-bottom: 4px; color: var(--ink-3); font-size: 13px; }
.dim-row { display: flex; align-items: center; gap: 10px; font-size: 15px; font-variant-numeric: tabular-nums; }
.dim-row b { flex: none; width: 62px; }
.dim-row b.r { text-align: right; }
.win { color: var(--theme-deep); font-weight: 800; }
.lose { color: var(--ink-3); font-weight: 400; }
.bar { display: flex; flex: 1; height: 10px; overflow: hidden; border-radius: 99px; background: var(--track); }
.bar i { display: block; height: 100%; }
.bar i.on { background: var(--theme); }
.dim-desc { margin-top: 6px; color: var(--ink-2); font-size: 13px; }

.rel {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--theme-soft);
  text-align: left;
}
.rel:first-of-type { margin-top: 0; }
.rel-art { display: flex; flex: none; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: var(--surface); font-size: 30px; }
.rel-main { display: block; min-width: 0; }
.rel-tag { display: block; color: var(--theme-deep); font-size: 12px; font-weight: 700; }
.rel-name { display: block; font-size: 17px; font-weight: 800; }
.rel-name small { margin-left: 6px; color: var(--ink-3); font-size: 12px; font-weight: 400; }
.rel-text { display: block; margin-top: 4px; color: var(--ink-2); font-size: 14px; line-height: 1.55; }

.gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.tile { position: relative; padding: 10px 0 8px; border-radius: 14px; background: var(--theme-soft); text-align: center; }
.tile .emoji { display: block; margin-bottom: 6px; font-size: 30px; }
/* 11px 是为了让六个字的"淡定卡皮巴拉"在 360px 宽的手机上也排得下一行 */
.tile .nm { display: block; font-size: 11px; line-height: 1.3; text-wrap: balance; }
.tile.me { box-shadow: inset 0 0 0 2px var(--theme-deep); }
.tile.me::after {
  content: "你";
  position: absolute;
  top: -6px;
  right: -4px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--theme-deep);
  color: #FFFFFF;
  font-size: 11px;
  line-height: 18px;
}
.actions { margin-top: 24px; }

/* 类型简介弹层 */
.sheet {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(30, 20, 10, .45);
  animation: fade .2s ease;
}
.sheet-body {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  text-align: center;
  animation: up .25s ease;
}
.sheet-art { display: flex; align-items: center; justify-content: center; width: 96px; height: 96px; margin: 0 auto 12px; border-radius: 50%; background: var(--theme-soft); font-size: 54px; }
.sheet-tag { display: inline-block; margin-bottom: 8px; padding: 2px 10px; border-radius: 99px; background: var(--theme-soft); color: var(--theme-deep); font-size: 12px; font-weight: 700; }
.sheet-code { color: var(--theme-deep); font-size: 14px; font-weight: 700; letter-spacing: .3em; text-indent: .3em; }
.sheet-name { margin: 2px 0 6px; font-size: 26px; font-weight: 800; }
.sheet-motto { color: var(--ink-2); text-wrap: balance; }
.sheet-intro { margin: 14px 0 22px; text-align: left; }

/* 结果卡片 */
.overlay {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: rgba(20, 14, 8, .85);
  animation: fade .2s ease;
}
.overlay img { display: block; max-width: 100%; max-height: 72vh; border-radius: 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); -webkit-touch-callout: default; }
.overlay-tip { margin: 16px 0 12px; color: #FFFFFF; font-size: 15px; }
.overlay .btn { max-width: 200px; background: rgba(255, 255, 255, .18); color: #FFFFFF; }

.disclaimer { padding: 24px 16px calc(20px + env(safe-area-inset-bottom)); color: var(--ink-2); font-size: 12px; text-align: center; }
.load-error { padding: 40px 16px; text-align: center; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes up { from { transform: translateY(40px); } to { transform: none; } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px); } }

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