@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@500;700&display=swap");

:root {
  --paper: #f6f1e7;
  --paper-raised: #fffcf6;
  --ink: #24211c;
  --ink-soft: #6b6459;
  --seal: #a6323f;
  --seal-soft: #a6323f1a;
  --jade: #4b6358;
  --line: #ded5c2;

  --font-display: "Noto Serif SC", "Songti SC", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100svh;
  display: flex;
  justify-content: center;
  padding: 32px 16px;
}

.app {
  width: 100%;
  max-width: 440px;
}

.brand {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-bottom: 28px;
}

.brand__mark {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand__mark span {
  color: var(--seal);
}

.screen {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 36px 28px;
}

.screen[hidden] {
  display: none;
}

/* ---------- Gate screen ---------- */

.gate__title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 10px;
  text-align: center;
}

.gate__subtitle {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
  margin: 0 0 32px;
}

.code-input {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
}

.code-input input {
  width: 44px;
  height: 54px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 22px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}

.code-input input:focus {
  border-color: var(--seal);
}

.gate__error {
  color: var(--seal);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
  margin: -12px 0 16px;
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 3px;
  padding: 15px 20px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn:active {
  opacity: 0.8;
}

.btn--primary {
  background: var(--ink);
  color: var(--paper-raised);
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

/* ---------- Quiz screen ---------- */

.quiz__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.quiz__track {
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 32px;
}

.quiz__fill {
  height: 100%;
  background: var(--seal);
  width: 0%;
  transition: width 0.35s ease;
}

.quiz__question {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.55;
  margin: 0 0 24px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--paper-raised);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option:hover {
  border-color: var(--ink-soft);
}

.option.is-selected {
  border-color: var(--seal);
  background: var(--seal-soft);
}

.option__marker {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-soft);
  position: relative;
}

.option.is-selected .option__marker {
  border-color: var(--seal);
}

.option.is-selected .option__marker::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--seal);
}

/* ---------- Loading screen ---------- */

.loading {
  text-align: center;
  padding: 60px 20px;
}

.loading__text {
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--ink-soft);
}

.loading__seal {
  width: 56px;
  height: 56px;
  margin: 0 auto 24px;
  border: 2px solid var(--seal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.95); }
  50% { opacity: 1; transform: scale(1); }
}

/* ---------- Result screen ---------- */

.result__label {
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}

.seal-stamp {
  width: 96px;
  height: 96px;
  margin: 0 auto 20px;
  border: 2.5px solid var(--seal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--seal);
  position: relative;
}

.result__percent {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 700;
  text-align: center;
  color: var(--seal);
  line-height: 1;
  margin-bottom: 6px;
}

.result__name {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 4px;
}

.result__era {
  text-align: center;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

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

.tag {
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 5px 14px;
  color: var(--ink-soft);
}

.quote-block {
  border-left: 2px solid var(--seal);
  padding: 4px 0 4px 16px;
  margin: 0 0 28px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 14px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.portrait {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
  margin: 0 0 4px;
}

.bar-row {
  display: grid;
  grid-template-columns: 40px 1fr 30px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 9px;
}

.bar-row__label {
  color: var(--ink-soft);
}

.bar-row__track {
  height: 5px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.bar-row__fill {
  display: block; /* 关键修复：span默认是inline，inline元素的width会被浏览器直接忽略 */
  width: 0;
  height: 100%;
  background: var(--jade);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.bar-row__value {
  text-align: right;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.insight-list {
  list-style: none;
  margin: 0 0 8px;
  padding: 0;
}

.insight-list li {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
  padding-left: 16px;
  position: relative;
  margin-bottom: 12px;
}

.insight-list li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--seal);
  font-weight: 700;
}

.result__actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.result__actions .btn {
  flex: 1;
}

.footnote {
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 20px;
  opacity: 0.7;
}
