:root {
  --page: #eaf0f8;
  --paper: #fbfcff;
  --surface: #f1f5fa;
  --ink: #1f2a37;
  --muted: #657386;
  --line: #dbe3ee;
  --accent: #2f64d6;
  --accent-dark: #234ea9;
  --result-accent: #2f64d6;
  --result-soft: #edf2ff;
  --shadow: rgba(43, 65, 96, 0.13);
  --radius: 8px;
}

* { box-sizing: border-box; }

html { background: var(--page); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

.app-shell {
  position: relative;
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 18px 70px var(--shadow);
}

.screen {
  display: none;
  min-height: 100dvh;
  padding: 26px 22px;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
}

.hero-art {
  height: 216px;
  margin: 0 0 20px;
  overflow: hidden;
  border-radius: var(--radius);
  background: #eef2f7;
}

.hero-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 58%;
}

.kicker, .result-eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
}

h1 {
  max-width: none;
  margin: 0;
  font-size: 31px;
  line-height: 1.2;
  letter-spacing: 0;
  font-weight: 850;
  white-space: nowrap;
}

h1 span { color: var(--accent); }

.subtitle {
  margin: 12px 0 20px;
  color: var(--muted);
  line-height: 1.65;
}

.name-card {
  margin-bottom: 14px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f8fb;
}

.redeem-card {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid #c9d7ee;
  border-radius: var(--radius);
  background: #f8fbff;
}

.redeem-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.redeem-head span {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 850;
}

.redeem-head strong {
  padding: 4px 8px;
  border-radius: 6px;
  background: #e5ecfa;
  color: var(--accent-dark);
  font-size: 12px;
}

.redeem-card.is-unlocked {
  border-color: rgba(47, 100, 214, 0.42);
  background: #f3f7ff;
}

.redeem-card.is-unlocked .redeem-head strong {
  background: var(--accent-dark);
  color: #fff;
}

.redeem-card label, .name-card label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.redeem-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
}

.redeem-row input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: 0;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  text-transform: uppercase;
}

.redeem-row input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 100, 214, 0.13);
}

.redeem-row button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 850;
}

.redeem-row button:active { transform: translateY(1px) scale(0.99); }

.redeem-message {
  min-height: 19px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.redeem-message.is-error { color: #b43c43; }
.redeem-message.is-success { color: var(--accent-dark); }

.name-card input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 19px;
  font-weight: 800;
}

.name-card input:focus-visible { box-shadow: 0 2px 0 var(--accent); }

.primary-btn, .ghost-large {
  min-height: 52px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 850;
}

.primary-btn {
  color: #f9fbff;
  background: var(--accent-dark);
  box-shadow: 0 10px 24px rgba(47, 100, 214, 0.2);
}

.ghost-large {
  padding: 0 20px;
  color: var(--result-accent);
  background: var(--result-soft);
}

.primary-btn:hover { background: var(--accent); }
.primary-btn:active, .ghost-large:active, .option-btn:active { transform: translateY(1px) scale(0.99); }

.fine-print {
  margin: 12px 0 0;
  color: #8995a5;
  font-size: 12px;
  text-align: center;
}

.topbar {
  display: grid;
  grid-template-columns: 40px 1fr 52px;
  gap: 12px;
  align-items: center;
  margin-bottom: 34px;
}

.ghost-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f6f8fb;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.progress-wrap {
  height: 7px;
  overflow: hidden;
  border-radius: 4px;
  background: #e4eaf2;
}

.progress-bar {
  width: 4%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

.count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}

.question-panel { padding-top: 10px; }

.question-panel h2 {
  margin: 0 0 26px;
  font-size: 27px;
  line-height: 1.35;
  font-weight: 820;
}

.options { display: grid; gap: 12px; }

.option-btn {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9fbfd;
  color: var(--ink);
  text-align: left;
  line-height: 1.55;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.12s ease;
}

.option-btn:hover {
  border-color: #8cabec;
  background: #f1f5ff;
}

.option-letter {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  background: #e8eef9;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 900;
}

#screen-loading {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.loading-cards {
  position: relative;
  width: 134px;
  height: 112px;
  margin-bottom: 24px;
}

.loading-cards span {
  position: absolute;
  width: 64px;
  height: 82px;
  border-radius: 8px;
  animation: shuffle 1.5s ease-in-out infinite;
}

.loading-cards span:nth-child(1) { left: 4px; top: 17px; background: #ff7b63; transform: rotate(-10deg); }
.loading-cards span:nth-child(2) { left: 35px; top: 3px; background: #4c77dc; animation-delay: 0.12s; }
.loading-cards span:nth-child(3) { right: 4px; top: 17px; background: #90b64a; transform: rotate(10deg); animation-delay: 0.24s; }

@keyframes shuffle {
  50% { transform: translateY(-8px) rotate(0deg); }
}

#screen-loading h2 { margin: 0 0 8px; }
#screen-loading p { max-width: 19em; margin: 0; color: var(--muted); line-height: 1.7; }

#screen-result { gap: 16px; }

.result-card { padding-top: 8px; }

.result-card h2 {
  margin: 0;
  color: var(--result-accent);
  font-size: 44px;
  line-height: 1.1;
  font-weight: 900;
}

.result-desc {
  margin: 12px 0 18px;
  color: var(--muted);
  line-height: 1.75;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--result-soft);
  color: var(--muted);
  font-size: 14px;
}

.score-row strong { color: var(--result-accent); font-size: 19px; }

canvas {
  display: block;
  width: 100%;
  margin: 16px 0;
  aspect-ratio: 1;
}

.top-dimensions {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--result-soft);
}

.top-dimensions h3, .score-analysis > h3, .compatibility-section h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

#topList { display: grid; gap: 10px; }

.dimension-row {
  display: grid;
  grid-template-columns: 84px 1fr 36px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.mini-track, .score-track {
  overflow: hidden;
  border-radius: 4px;
  background: rgba(72, 87, 106, 0.12);
}

.mini-track { height: 7px; }
.mini-fill, .score-track span { display: block; height: 100%; border-radius: inherit; background: var(--result-accent); }

.score-analysis {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

#scoreList { display: grid; gap: 20px; }

.score-item { padding-bottom: 2px; }

.score-item-head {
  display: grid;
  grid-template-columns: 32px 1fr 48px;
  align-items: center;
  gap: 10px;
}

.score-index {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  background: var(--result-soft);
  color: var(--result-accent);
  font-size: 13px;
  font-weight: 850;
}

.score-item h4 { margin: 0; font-size: 17px; font-weight: 850; }
.score-item small { color: #8490a0; font-size: 12px; }
.score-item-head strong { color: var(--result-accent); font-size: 22px; text-align: right; }
.score-track { height: 6px; margin: 9px 0; }
.score-item p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.75; }

.full-report {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.report-head strong { font-size: 18px; }
.report-head span { color: var(--result-accent); font-size: 12px; font-weight: 800; }
.report-sections { display: grid; }

.report-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.report-block:last-child { border-bottom: 0; }
.report-block h3 { margin: 0 0 8px; color: var(--result-accent); font-size: 15px; }
.report-block p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.8; }

.rarity-section {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 14px;
  align-items: center;
  margin: 10px 0 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border-left: 3px solid var(--result-accent);
  background: var(--result-soft);
  color: var(--result-accent);
}

.rarity-section span { font-size: 14px; font-weight: 800; }
.rarity-section strong { font-size: 24px; line-height: 1; }
.rarity-section p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.compatibility-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.match-list { display: grid; gap: 10px; }

.match-item {
  display: grid;
  grid-template-columns: 44px 1fr 50px;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
}

.match-rank {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 7px;
  background: var(--result-soft);
  color: var(--result-accent);
  font-weight: 900;
}

.match-copy strong { display: block; margin-bottom: 4px; font-size: 16px; }
.match-copy p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.match-percent { color: var(--result-accent); font-size: 18px; font-weight: 900; text-align: right; }

.invite-copy {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--result-accent);
  background: var(--result-soft);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.result-actions {
  display: grid;
  grid-template-columns: 0.86fr 1.14fr;
  gap: 10px;
}

@media (max-width: 400px) {
  .screen { padding: 22px 16px; }
  h1 { font-size: 26px; }
  .hero-art { height: 200px; }
  .question-panel h2 { font-size: 24px; }
  .report-head { align-items: flex-start; flex-direction: column; gap: 4px; }
  .match-item { grid-template-columns: 38px 1fr 44px; gap: 9px; padding: 12px; }
  .match-rank { width: 36px; height: 36px; }
}

@media (max-width: 330px) {
  h1 { font-size: 24px; }
}

@media print {
  body, html { background: #f9fbff; }
  .app-shell { width: 100%; box-shadow: none; }
  .result-actions, .topbar { display: none; }
  .screen { min-height: auto; }
}

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