:root {
  --bg: #f0ebfa;
  --bg-2: #e8e0f5;
  --card: #ffffff;
  --ink: #1e1840;
  --muted: #7a7194;
  --line: #e6dff3;
  --accent: #6c4fe0;
  --accent-2: #8b6cf5;
  --accent-soft: #f0ebff;
  --danger: #e24c4c;
  --radius: 20px;
  --shadow: 0 8px 28px rgba(78, 48, 150, 0.08);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 480px at 50% -8%, #dccfff 0%, transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--ink);
}

body { display: flex; justify-content: center; }

#app {
  width: min(420px, 100%);
  min-height: 100vh;
  padding: 14px 16px 40px;
}

.screen { display: none; animation: fadeIn 0.25s ease; }
.screen.active { display: block; }

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

.topbar {
  text-align: center;
  margin-bottom: 18px;
  padding-top: 4px;
}
.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.gate-brand { text-align: center; margin-bottom: 18px; }

.hero-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 32px;
  background: linear-gradient(145deg, #7b5cf2, #5a3fd4);
  box-shadow: 0 12px 24px rgba(90, 63, 208, 0.32);
}
.hero-icon-pin { font-size: 30px; }

.hero-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.35;
  color: #2a1f5c;
}
.gate-brand .hero-title { font-size: 24px; }

.hero-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 12px;
}

.gate-card { padding: 18px 16px 14px; }
.gate-card.has-error {
  box-shadow: 0 0 0 1px rgba(226, 76, 76, 0.12), var(--shadow);
}

.note-card {
  padding: 14px 16px;
}
.note-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}
.note-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
}

.field-label {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 12px;
}

.code-boxes {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fbfaff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.code-boxes.has-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(226, 76, 76, 0.1);
  background: #fff8f8;
}
.code-boxes input {
  width: 44px;
  height: 48px;
  border: none;
  border-radius: 8px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  line-height: 48px;
  padding: 0;
  margin: 0;
  color: var(--accent);
  outline: none;
  background: transparent;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  letter-spacing: 0;
  caret-color: var(--accent);
  /* 不用 -webkit-text-security：iOS 下易导致数字垂直偏移、被裁切 */
}
.code-boxes input:focus { background: rgba(108, 79, 224, 0.06); }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 0;
}
.demo-hint {
  text-align: center;
  color: #a59bb8;
  font-size: 12px;
  margin: 10px 0 0;
}
.error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
  margin: 2px 0 4px;
  font-weight: 600;
}

.btn {
  border: none;
  border-radius: 16px;
  padding: 15px 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  width: 100%;
  margin-top: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 10px 22px rgba(108, 79, 224, 0.28);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--line);
  width: 100%;
}
.btn-sm { padding: 10px 14px; font-size: 13px; width: auto; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-row .btn { flex: 1; }
.sticky-actions {
  position: sticky;
  bottom: 8px;
  margin-top: 16px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(240, 235, 250, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 -4px 20px rgba(78, 48, 150, 0.06);
}
.sticky-actions .btn { margin-top: 0; width: auto; }

.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0 14px;
}
.feature-item {
  background: linear-gradient(180deg, #fcfbff, #f6f2ff);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
}
.feature-item .fi { font-size: 22px; margin-bottom: 4px; }
.feature-item .ft { font-weight: 800; color: var(--accent); font-size: 16px; }
.feature-item .fd { font-size: 12px; color: var(--muted); margin-top: 2px; }

.note {
  background: #f7f4fd;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 12px;
}
.note strong { color: var(--ink); display: block; margin-bottom: 6px; }
.note p { margin: 0; }

.dim-list { display: grid; gap: 8px; margin-bottom: 14px; }
.dim-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.dim-item .di { font-size: 18px; line-height: 1.2; }
.dim-item .dn { font-size: 13px; font-weight: 700; color: var(--accent); }
.dim-item .dd { font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.4; }

.demo-tools {
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed #cfc0ef;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  color: var(--muted);
}
.demo-tools button { margin-top: 8px; }
.demo-tools[hidden],
.demo-hint[hidden] {
  display: none !important;
}

.progress-wrap { margin-bottom: 12px; }
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.progress-meta .pct { color: var(--accent); font-weight: 700; }
.bar { height: 8px; background: #e8e0f5; border-radius: 999px; overflow: hidden; }
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.25s ease;
}

.quiz-card { padding: 20px 16px; }
.cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 14px;
}
.q-text {
  margin: 0 0 18px;
  font-size: 19px;
  line-height: 1.4;
  font-weight: 800;
}
.options { display: grid; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.option:active { transform: scale(0.99); }
.option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.radio {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid #c5bdd8;
  flex-shrink: 0;
  position: relative;
}
.option.selected .radio { border-color: var(--accent); }
.option.selected .radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent);
}
.quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  gap: 10px;
}
.quiz-footer .tip { color: var(--muted); font-size: 12px; }

.loading-visual {
  width: 140px;
  height: 140px;
  margin: 56px auto 18px;
  border-radius: 50%;
  border: 4px solid #e0d6f5;
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
  display: grid;
  place-items: center;
  font-size: 40px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { text-align: center; font-size: 20px; font-weight: 800; margin: 0; }
.loading-sub { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

.result-pin {
  width: 48px;
  height: 48px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #ffe8e8;
  display: grid;
  place-items: center;
  font-size: 24px;
}
.result-lead { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.result-percent {
  text-align: center;
  font-size: 56px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  margin: 4px 0;
}
.result-city {
  text-align: center;
  font-size: 34px;
  font-weight: 900;
  margin: 4px 0 0;
  color: var(--accent);
}
.result-province { text-align: center; color: var(--muted); margin: 4px 0 6px; font-size: 14px; }
.result-slogan { text-align: center; color: var(--muted); margin: 0 0 12px; font-size: 13px; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 14px;
}
.tag {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.reason { background: #f7f4fd; border-radius: 14px; padding: 14px; }
.reason h3 { margin: 0 0 8px; font-size: 14px; }
.reason p { margin: 0; font-size: 13px; line-height: 1.75; color: #3f3654; }

.section-card { padding-top: 16px; }
.section-title { margin: 0 0 12px; font-size: 16px; font-weight: 800; }
.section-head { font-size: 16px; font-weight: 800; margin: 6px 4px 10px; }

.portrait { display: grid; gap: 10px; }
.portrait-row {
  display: grid;
  grid-template-columns: 88px 1fr 36px;
  gap: 8px;
  align-items: center;
}
.portrait-row .pn { font-size: 12px; color: var(--muted); }
.portrait-row .pb {
  height: 8px;
  background: #ece6f7;
  border-radius: 999px;
  overflow: hidden;
}
.portrait-row .pb > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}
.portrait-row .ps {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  text-align: right;
}

.city-card { padding: 16px; }
.city-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.city-card-head .name { font-size: 16px; font-weight: 800; }
.city-card-head .name span { color: var(--muted); font-weight: 500; font-size: 13px; }
.city-card-head .pct { font-size: 22px; font-weight: 900; color: var(--accent); }
.city-card .tags { justify-content: flex-start; }
.city-card .desc { margin: 0; font-size: 13px; line-height: 1.75; color: #3f3654; }
