/* SBTI Pro — based on original SBTI design by 蛆肉儿串儿
   Adapted with stats dashboard, i18n, and compare features */

:root {
  --bg: #f6faf6;
  --panel: #ffffff;
  --text: #1e2a22;
  --muted: #6a786f;
  --line: #dbe8dd;
  --soft: #edf6ef;
  --accent: #6c8d71;
  --accent-strong: #4d6a53;
  --shadow: 0 16px 40px rgba(47, 73, 55, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at top left, #f8fff8 0, #f6faf6 36%, #f2f7f3 100%);
  color: var(--text);
  min-height: 100vh;
}

.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

h1, h2, h3, p { margin: 0; }

/* ===== Cards ===== */
.card, .glass {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ===== Screens ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== Hero / Intro ===== */
.hero {
  padding: 28px;
  margin-top: 20px;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(127, 165, 134, 0.18), rgba(127, 165, 134, 0.02));
  pointer-events: none;
}

.hero-minimal {
  min-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 42px 20px;
}

.hero-minimal::after { display: none; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 999px;
  padding: 8px 12px;
  margin-bottom: 16px;
}

.hero h1 {
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  max-width: 680px;
}

.hero-sub {
  margin-top: 14px;
  font-size: clamp(20px, 3.5vw, 36px);
  font-weight: 800;
  color: var(--accent-strong);
}

.hero-desc {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.hero-stats {
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted);
}

.hero-stats .num {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent-strong);
  display: block;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
  justify-content: center;
}

/* ===== Buttons ===== */
button {
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
  font: inherit;
}

button:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

.btn-primary, .btn {
  background: var(--accent-strong);
  color: #fff;
  padding: 14px 20px;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(77, 106, 83, 0.18);
  font-weight: 700;
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}

.btn-secondary, .btn-ghost {
  background: #fff;
  color: var(--accent-strong);
  padding: 14px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  font-weight: 700;
  cursor: pointer;
  transition: transform .16s ease;
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  padding: 14px 20px;
  border-radius: 14px;
  font-weight: 700;
  border: 0;
  cursor: pointer;
}

.btn-pink {
  background: #8b6c5e;
  color: #fff;
  padding: 14px 20px;
  border-radius: 14px;
  font-weight: 700;
  border: 0;
  cursor: pointer;
}

/* ===== Lang Toggle ===== */
.lang-toggle {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 20px;
}

.lang-btn {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all .16s ease;
}

.lang-btn.active {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
}

/* ===== Test ===== */
.test-wrap {
  margin-top: 22px;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.progress {
  flex: 1;
  min-width: 240px;
  height: 10px;
  background: #edf3ee;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress span, .progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #97b59c, #5b7a62);
  border-radius: inherit;
  transition: width .22s ease;
}

.progress-text {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.question-list { display: grid; gap: 16px; }

.question {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
  transition: border-color .16s ease;
}

.question.answered { border-color: var(--accent); }

.question-error {
  border-color: #ef4444 !important;
  background: linear-gradient(180deg, #fff5f5, #fff0f0) !important;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.question-num, .question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.question-text, .question-title {
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  transition: border-color .16s ease, background .16s ease;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.option-btn:hover {
  border-color: #bcd0c1;
  background: #f8fcf9;
}

.option-btn.selected {
  border-color: var(--accent-strong);
  background: var(--soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.actions-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 6px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

/* ===== Result ===== */
.result-wrap {
  margin-top: 22px;
  padding: 22px;
}

.result-layout { display: grid; gap: 18px; }

.result-top {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
  align-items: stretch;
}

.poster-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
}

.poster-image {
  width: 100%;
  max-width: 260px;
  border-radius: 16px;
}

.poster-box {
  position: relative;
}

.poster-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: linear-gradient(transparent, rgba(255,255,255,0.95));
  border-radius: 0 0 18px 18px;
  text-align: center;
}

.poster-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.poster-code {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent-strong);
}

.poster-cn {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.type-box, .analysis-box, .dim-box, .note-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
}

.type-kicker {
  font-size: 12px;
  color: var(--accent-strong);
  margin-bottom: 8px;
  letter-spacing: .06em;
}

.type-name {
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.type-name .code { color: var(--accent-strong); }
.type-name .cn {
  display: block;
  font-size: 0.5em;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 600;
}

.match-badge, .match {
  margin-top: 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 14px;
}

.type-sub { margin-top: 10px; color: var(--muted); font-size: 14px; line-height: 1.8; }

.analysis-box h3, .dim-box h3, .note-box h3 {
  font-size: 16px;
  margin-bottom: 12px;
}

.analysis-box p {
  margin: 0;
  color: #304034;
  font-size: 15px;
  line-height: 1.9;
}

.dim-list { display: grid; gap: 12px; }

.dim-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.dim-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.dim-item-name { font-size: 14px; font-weight: 700; color: var(--text); }
.dim-item-score { color: var(--accent-strong); font-weight: 800; font-size: 14px; white-space: nowrap; }
.dim-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }

.note-box p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.8; }

.author-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
  overflow: hidden;
}

.author-box summary {
  list-style: none;
  cursor: pointer;
  padding: 18px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.author-box summary::-webkit-details-marker { display: none; }

.author-box summary::after {
  content: '展开';
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  background: var(--soft);
  padding: 6px 10px;
  border-radius: 999px;
}

.author-box[open] summary::after { content: '收起'; }

.author-content { border-top: 1px solid var(--line); padding: 0 18px 18px; }
.author-content p { margin: 14px 0 0; color: #304034; font-size: 14px; line-height: 1.9; }

.result-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

/* ===== Stats ===== */
.stats-wrap { margin-top: 22px; padding: 28px; }

.stats-wrap h2 {
  text-align: center;
  font-size: 24px;
  margin-bottom: 24px;
}

.stats-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  text-align: center;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
}

.stat-num {
  font-size: 32px;
  font-weight: 800;
  color: var(--accent-strong);
}

.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.map-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  justify-content: center;
}

.map-tab {
  padding: 8px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all .16s ease;
}

.map-tab.active {
  background: var(--accent-strong);
  color: #fff;
  border-color: var(--accent-strong);
}

#mapChart {
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.type-rank { margin-top: 24px; }

.type-rank h3 {
  text-align: center;
  font-size: 16px;
  margin-bottom: 14px;
}

.type-rank-list { display: grid; gap: 8px; }

.rank-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.rank-left { display: flex; align-items: center; gap: 10px; }

.rank-pos {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  background: var(--soft);
  color: var(--accent-strong);
}

.rank-pos.gold { background: #fef3c7; color: #92400e; }
.rank-pos.silver { background: #f1f5f9; color: #475569; }
.rank-pos.bronze { background: #fed7aa; color: #9a3412; }

.rank-name { font-size: 14px; font-weight: 600; }

.rank-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
}

.rank-tag.common { background: #dbeafe; color: #1e40af; }
.rank-tag.rare { background: #fef3c7; color: #92400e; }

.rank-count { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ===== Compare ===== */
.compare-wrap {
  margin-top: 22px;
  padding: 28px;
  text-align: center;
}

.compare-wrap h2 { font-size: 24px; margin-bottom: 8px; }
.compare-sub { color: var(--muted); font-size: 15px; margin-bottom: 24px; }

.compare-link-box {
  display: flex;
  gap: 8px;
  margin: 20px auto;
  max-width: 500px;
}

.compare-link-box input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.compare-link-box button {
  padding: 12px 20px;
  border-radius: 14px;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.compare-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 28px 0;
}

.compare-type { text-align: center; }
.compare-type .code { font-size: 32px; font-weight: 800; color: var(--accent-strong); }
.compare-type .name { font-size: 14px; color: var(--muted); }
.compare-vs-symbol { font-size: 32px; font-weight: 900; color: var(--accent); }

.compat-score {
  font-size: 56px;
  font-weight: 900;
  line-height: 1;
  color: var(--accent-strong);
}

.compat-label { color: var(--muted); font-size: 15px; margin-top: 4px; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .result-top { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .shell { padding: 14px 12px 42px; }
  .hero, .test-wrap, .result-wrap, .stats-wrap, .compare-wrap { padding: 16px; }
  .hero h1 { font-size: 32px; }
  .question-text, .question-title { font-size: 15px; }
  .stats-overview { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
  .compare-link-box { flex-direction: column; }
  .compare-vs { flex-direction: column; gap: 12px; }
}
