:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #11100d;
  --panel-2: #181612;
  --gold: #f4c76a;
  --gold-2: #9d7427;
  --ink: #f7f0df;
  --muted: #b9aa8a;
  --line: rgba(244, 199, 106, 0.22);
  --danger: #ff6b6b;
  --radius: 8px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, rgba(244, 199, 106, 0.16), transparent 32rem),
    linear-gradient(135deg, #050505 0%, #0c0b09 50%, #050505 100%);
  color: var(--ink);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(rgba(244, 199, 106, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 199, 106, 0.04) 1px, transparent 1px),
    rgba(5, 5, 5, 0.82);
  background-size: 28px 28px;
  box-shadow: var(--shadow);
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 24px;
  animation: screenIn 0.36s ease both;
}

.screen-active {
  display: flex;
}

.landing-screen {
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}

.hero-mark {
  width: min(78vw, 360px);
  aspect-ratio: 1;
  margin: 0 auto -10px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background:
    linear-gradient(145deg, rgba(244, 199, 106, 0.18), transparent 58%),
    #0c0b09;
  overflow: hidden;
}

.hero-mark span,
.share-card-bg {
  font-family: "Songti SC", STSong, serif;
  font-weight: 900;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 2px rgba(244, 199, 106, 0.75);
  text-shadow: 0 0 26px rgba(244, 199, 106, 0.28);
}

.hero-mark span {
  font-size: clamp(9rem, 45vw, 16rem);
}

.hero-mark i {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(244, 199, 106, 0.18);
  border-radius: 50%;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.15rem, 10vw, 3.8rem);
  line-height: 1.06;
  letter-spacing: 0;
}

.hero-subtitle,
.disclaimer,
.result-name,
.match-panel p,
.share-card p,
.meme-dialog p {
  color: var(--muted);
  line-height: 1.75;
}

.hero-actions,
.result-actions {
  display: grid;
  gap: 12px;
}

.primary-btn,
.ghost-btn,
.text-btn {
  min-height: 52px;
  border-radius: var(--radius);
  padding: 0 18px;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--gold), #fff0b8 48%, var(--gold-2));
  color: #171107;
  font-weight: 800;
}

.ghost-btn {
  background: rgba(244, 199, 106, 0.07);
  border: 1px solid var(--line);
  color: var(--gold);
}

.text-btn {
  background: transparent;
  color: var(--muted);
  min-height: 42px;
}

.primary-btn:active,
.ghost-btn:active,
.text-btn:active,
.option-btn:active {
  transform: scale(0.98);
}

.quiz-screen {
  flex-direction: column;
  gap: 28px;
}

.quiz-topbar {
  display: grid;
  grid-template-columns: 42px 42px 1fr;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.icon-btn:disabled {
  cursor: default;
  opacity: 0.34;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress-bar {
  height: 100%;
  width: 3%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  transition: width 0.28s ease;
}

.question-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.question-kicker {
  color: var(--gold);
  font-size: 0.88rem;
}

.question-card h2 {
  margin-bottom: 26px;
  font-size: clamp(1.85rem, 9vw, 3rem);
  line-height: 1.18;
}

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

.option-btn {
  min-height: 72px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(244, 199, 106, 0.2);
  background: linear-gradient(135deg, rgba(244, 199, 106, 0.11), rgba(255, 255, 255, 0.035));
  text-align: left;
  color: var(--ink);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.option-btn:hover {
  border-color: rgba(244, 199, 106, 0.48);
  background: rgba(244, 199, 106, 0.16);
}

.option-label {
  color: var(--gold);
  font-weight: 800;
  margin-right: 8px;
}

.result-screen {
  flex-direction: column;
  gap: 16px;
  background: #090908;
}

.result-name {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.share-card,
.score-panel,
.match-panel,
.type-gallery,
.dialog-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(244, 199, 106, 0.11), transparent 45%),
    var(--panel);
}

.share-card {
  min-height: auto;
  padding: 22px;
  position: relative;
  overflow: hidden;
  background: #11100d;
}

.share-card-bg {
  display: none;
}

.share-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--gold);
  font-size: 0.82rem;
}

.result-hero {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 22px;
  align-items: center;
  margin-top: 18px;
}

.result-main h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: clamp(2rem, 8vw, 3.15rem);
  line-height: 1.06;
}

.result-code {
  margin-bottom: 8px;
  color: var(--gold);
  font-size: clamp(3.8rem, 18vw, 6.5rem);
  font-weight: 900;
  line-height: 0.9;
}

.character-stage,
.gallery-avatar {
  background-image: url("./assets/hbti-character-grid.png");
  background-repeat: no-repeat;
}

.character-stage {
  width: 210px;
  aspect-ratio: 1;
  margin: 0;
  border-radius: var(--radius);
  border: 1px solid rgba(244, 199, 106, 0.22);
  background-color: #efe6d3;
  background-size: 400% 400%;
  box-shadow: none;
}

.share-card h3 {
  width: 100%;
  margin: 20px 0 10px;
  color: var(--gold);
  font-size: 1.25rem;
  line-height: 1.12;
}

.character-text {
  color: var(--gold);
  font-size: 0.92rem;
}

.trait-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.trait-grid div {
  min-height: 132px;
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.trait-grid span,
.score-row-label,
.match-panel span {
  color: var(--gold);
  font-size: 0.78rem;
}

.score-panel,
.type-gallery {
  padding: 16px;
  background: #11100d;
}

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

.section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.section-head span,
#rarityTag {
  color: var(--muted);
  font-size: 0.78rem;
}

.score-bars {
  display: grid;
  gap: 14px;
}

.score-row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 0.84rem;
}

.score-row-value {
  color: var(--muted);
}

.score-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.score-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
}

.score-row-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.74rem;
}

blockquote {
  margin: 18px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--gold);
  color: #fff5cf;
  line-height: 1.65;
}

.match-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  overflow: hidden;
}

.match-panel div {
  padding: 14px;
  background: #11100d;
}

.match-panel p {
  margin: 8px 0 0;
}

.type-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.type-card {
  min-height: 184px;
  border-radius: var(--radius);
  border: 1px solid rgba(244, 199, 106, 0.14);
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
  color: var(--muted);
  text-align: center;
}

.type-card.active {
  border-color: rgba(244, 199, 106, 0.8);
  background: rgba(244, 199, 106, 0.12);
  color: var(--ink);
}

.gallery-avatar {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  background-color: #efe6d3;
  background-size: 400% 400%;
  margin-bottom: 8px;
}

.type-code {
  display: block;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 800;
}

.type-name {
  display: block;
  margin-top: 3px;
  font-size: 0.86rem;
  line-height: 1.25;
}

.meme-dialog {
  width: min(calc(100% - 32px), 520px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.meme-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}

.dialog-card {
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 22px;
  position: relative;
}

.dialog-card h2,
.meme-section h3 {
  margin-bottom: 10px;
}

.meme-section {
  margin-top: 18px;
}

.meme-section h3 {
  color: var(--gold);
  font-size: 0.96rem;
}

.meme-points {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.68;
}

.meme-points strong {
  color: var(--ink);
}

.dialog-close {
  position: absolute;
  right: 12px;
  top: 12px;
}

.meme-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.meme-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--gold);
  background: rgba(244, 199, 106, 0.06);
  font-size: 0.84rem;
}

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

.meme-type-list article,
.caution {
  border: 1px solid rgba(244, 199, 106, 0.14);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.meme-type-list span {
  display: block;
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 0.86rem;
  font-weight: 800;
}

.meme-type-list p {
  margin-bottom: 8px;
}

.meme-type-list p:last-child {
  margin-bottom: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  min-width: 180px;
  max-width: calc(100% - 40px);
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(244, 199, 106, 0.95);
  color: #171107;
  text-align: center;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 740px) {
  body {
    padding: 28px 0;
  }

  .app-shell {
    min-height: calc(100vh - 56px);
    border: 1px solid var(--line);
    border-radius: 24px;
  }

  .screen {
    min-height: calc(100vh - 56px);
  }
}

@media (min-width: 620px) {
  .type-gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 380px) {
  .screen {
    padding: 18px;
  }

  .share-card h3 {
    width: 100%;
    font-size: 1.15rem;
  }

  .trait-grid,
  .match-panel {
    grid-template-columns: 1fr;
  }

  .type-gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .result-hero {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .character-stage {
    width: min(100%, 260px);
    margin: 0 auto;
  }

  .result-main {
    text-align: center;
  }
}
