:root {
  --paper: #f2ecdc;
  --paper-deep: #e6dbc3;
  --sand: #c8b79a;
  --ink: #1f1c18;
  --ink-soft: #62594c;
  --accent: #c44a2a;
  --accent-soft: #f1d2c3;
  --line: rgba(31, 28, 24, 0.66);
  --space: 24px;
  --display: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --body: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --utility: ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ink);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button {
  border: 0;
  font: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
.gate-input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

img {
  display: block;
  max-width: 100%;
}

#app {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.055'/%3E%3C/svg%3E");
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.35);
}

.screen {
  position: relative;
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  padding: max(22px, env(safe-area-inset-top)) var(--space) max(22px, env(safe-area-inset-bottom));
}

.screen--gate {
  isolation: isolate;
  display: grid;
  overflow: hidden;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  background: #1b1814;
}

.screen--gate::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: rgba(20, 17, 13, 0.38);
}

.gate-backdrop {
  position: absolute;
  z-index: -2;
  display: flex;
  inset: -24px;
  flex-direction: column;
  padding: 48px 46px;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  filter: blur(10px) saturate(0.66);
  transform: scale(1.06);
}

.gate-backdrop__topline {
  display: flex;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--utility);
  font-size: 10px;
}

.gate-backdrop__copy {
  margin-top: 36px;
  font-family: var(--display);
  font-size: clamp(46px, 13vw, 62px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.gate-backdrop__image {
  width: 100%;
  aspect-ratio: 1 / 1;
  margin-top: 34px;
  border: 1px solid var(--line);
  object-fit: cover;
  object-position: center 22%;
}

.gate-panel {
  position: relative;
  width: min(100%, 350px);
  padding: 28px 24px 22px;
  border: 1px solid rgba(31, 28, 24, 0.82);
  color: var(--ink);
  background: rgba(242, 236, 220, 0.94);
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.28);
}

.gate-kicker,
.gate-note,
.gate-label {
  font-family: var(--utility);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.gate-kicker {
  margin: 0 0 18px;
  color: var(--accent);
}

.gate-title {
  margin: 0;
  font-family: var(--display);
  font-size: 42px;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.gate-copy {
  margin: 12px 0 24px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.6;
}

.gate-label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
}

.gate-input {
  min-height: 56px;
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  outline: 0;
  color: var(--ink);
  background: rgba(255, 252, 242, 0.74);
  font-family: var(--utility);
  font-size: 23px;
  text-align: center;
  letter-spacing: 0.34em;
}

.gate-input:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.gate-input[aria-invalid="true"] {
  border-color: var(--accent);
}

.gate-error {
  min-height: 24px;
  margin: 7px 0 0;
  color: var(--accent);
  font-size: 13px;
}

.gate-error[hidden] {
  display: block;
  visibility: hidden;
}

.gate-button {
  min-height: 56px;
  width: 100%;
  margin-top: 14px;
  border: 1px solid #9f361d;
  cursor: pointer;
  color: #fff8ea;
  background: var(--accent);
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.1em;
}

.gate-button:active {
  transform: scale(0.985);
}

.gate-note {
  margin: 15px 0 0;
  color: var(--ink-soft);
  text-align: center;
}

.screen--home,
.screen--intro,
.screen--result {
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.topline,
.screen-nav,
.question-meta,
.result-kicker {
  font-family: var(--utility);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topline,
.screen-nav {
  display: flex;
  min-height: 40px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
}

.topline__code {
  color: var(--accent);
}

.hero-copy {
  position: relative;
  z-index: 2;
  padding-top: clamp(22px, 5vh, 46px);
}

.hero-title,
.intro-title,
.question-title,
.result-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.hero-title {
  max-width: 9em;
  font-size: clamp(48px, 13.5vw, 64px);
}

.hero-subtitle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 17px;
}

.hero-subtitle::before {
  width: 46px;
  height: 1px;
  content: "";
  background: var(--ink);
}

.hero-art {
  position: relative;
  display: grid;
  min-height: 0;
  flex: 1;
  place-items: center;
  margin: 24px 0;
}

.hero-art img {
  position: relative;
  width: min(100%, 340px);
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  object-fit: cover;
  object-position: center 22%;
}

.screen-actions {
  position: relative;
  z-index: 2;
  display: grid;
  gap: 10px;
}

.primary-button,
.secondary-button,
.previous-button,
.next-button {
  min-height: 54px;
  width: 100%;
  cursor: pointer;
  transition: transform 180ms ease, background-color 180ms ease, color 180ms ease;
}

.primary-button,
.next-button {
  border: 1px solid #9f361d;
  color: #fff8ea;
  background: var(--accent);
  font-family: var(--display);
  font-size: 19px;
  letter-spacing: 0.12em;
}

.primary-button:active,
.next-button:active,
.previous-button:active,
.secondary-button:active {
  transform: scale(0.985);
}

.primary-button:disabled,
.next-button:disabled,
.previous-button:disabled {
  cursor: not-allowed;
  border-color: transparent;
  color: rgba(31, 28, 24, 0.38);
  background: rgba(200, 183, 154, 0.52);
}

.secondary-button {
  border: 1px solid var(--ink);
  color: var(--ink);
  background: rgba(242, 236, 220, 0.76);
  font-size: 17px;
}

.fine-print {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--utility);
  font-size: 10px;
  text-align: center;
  letter-spacing: 0.06em;
}

.disclaimer {
  margin: -4px 0 0;
  color: rgba(98, 89, 76, 0.78);
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.04em;
}

.intro-title {
  margin-top: clamp(38px, 9vh, 80px);
  font-size: clamp(42px, 11vw, 56px);
}

.cross-rule {
  display: grid;
  grid-template-columns: 1fr 18px 1fr;
  align-items: center;
  gap: 12px;
  margin: 26px 0;
  color: var(--accent);
  font-family: var(--utility);
  text-align: center;
}

.cross-rule::before,
.cross-rule::after {
  height: 1px;
  content: "";
  background: var(--line);
}

.intro-copy {
  max-width: 22em;
  margin: 0;
  color: var(--ink-soft);
  font-size: 17px;
}

.intro-figure {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 0;
  place-items: center;
  margin: 28px 0;
}

.intro-figure img {
  width: min(100%, 310px);
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  object-fit: cover;
  object-position: center 18%;
}

.text-button {
  min-width: 60px;
  min-height: 44px;
  padding: 0;
  cursor: pointer;
  color: var(--ink);
  background: transparent;
  font-family: var(--body);
  text-align: left;
}

.text-button:last-child {
  text-align: right;
}

.question-header {
  padding-top: 20px;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
}

.question-number strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}

.progress-track {
  width: 84px;
  height: 4px;
  overflow: hidden;
  background: var(--paper-deep);
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transition: width 220ms ease;
}

.question-body {
  display: grid;
  min-height: 0;
  flex: 1;
  align-content: start;
  padding-top: 20px;
}

.question-lead {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 18px;
  margin-bottom: 22px;
}

.question-title {
  max-width: 12em;
  font-size: clamp(26px, 7.2vw, 32px);
  line-height: 1.28;
  letter-spacing: -0.035em;
}

.question-image {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  object-fit: cover;
  object-position: center 28%;
}

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

.option {
  display: grid;
  min-height: 62px;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  align-items: stretch;
  padding: 0;
  border: 1px solid rgba(31, 28, 24, 0.5);
  cursor: pointer;
  color: var(--ink);
  background: rgba(255, 252, 242, 0.58);
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.option + .option {
  border-top: 1px solid rgba(31, 28, 24, 0.5);
}

.option__letter,
.option__check {
  display: grid;
  place-items: center;
  font-family: var(--display);
}

.option__letter {
  border-right: 1px solid rgba(196, 74, 42, 0.34);
  color: var(--accent);
  font-family: var(--utility);
  font-size: 15px;
}

.option__text {
  align-self: center;
  padding: 12px 14px;
  font-size: 16px;
  line-height: 1.5;
}

.option__check {
  color: transparent;
  font-size: 21px;
}

.option.is-selected {
  color: #a8341b;
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.option.is-selected .option__check {
  color: var(--accent);
}

.quiz-footer {
  display: grid;
  grid-template-columns: 0.55fr 1fr;
  gap: 10px;
  padding-top: 20px;
}

.previous-button {
  min-height: 54px;
  width: 100%;
  border: 1px solid var(--ink);
  cursor: pointer;
  color: var(--ink);
  background: rgba(242, 236, 220, 0.76);
  font-family: var(--display);
  font-size: 16px;
  white-space: nowrap;
}

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

.loading-title {
  margin: 0;
  font-family: var(--display);
  font-size: 26px;
  font-weight: 500;
}

.loading-note {
  margin: 4px 0 0;
  color: var(--accent);
}

.loading-orbit {
  position: relative;
  width: 214px;
  height: 214px;
  margin: 48px auto 34px;
  border: 1px solid var(--accent);
  border-radius: 50%;
}

.loading-orbit::before,
.loading-orbit::after {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  content: "";
  background: var(--accent);
}

.loading-orbit::before {
  top: -4px;
  left: 50%;
}

.loading-orbit::after {
  right: -4px;
  top: 50%;
}

.loading-orbit img {
  width: 184px;
  height: 184px;
  margin: 14px;
  border-radius: 50%;
  object-fit: cover;
  filter: saturate(0.76);
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 17px;
  margin-bottom: 16px;
}

.loading-dots span {
  width: 9px;
  height: 9px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: transparent;
}

.loading-dots span.is-filled {
  background: var(--accent);
}

.loading-percent {
  margin: 0;
  color: var(--ink-soft);
}

.loading-percent strong {
  color: var(--accent);
  font-family: var(--utility);
  font-weight: 500;
}

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

.result-kicker {
  margin: 12px 0 0;
  color: var(--ink-soft);
}

.result-name {
  margin-top: 4px;
  color: var(--accent);
  font-size: clamp(54px, 15vw, 70px);
}

.result-type {
  margin: 8px 0 0;
  font-size: 18px;
}

.result-keywords {
  margin: 14px 0 0;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.14em;
}

.result-photo {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  margin-top: 24px;
  border: 1px solid var(--line);
  object-fit: cover;
  object-position: center 24%;
}

.result-copy {
  padding: 24px 2px 16px;
}

.result-meme {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.45;
}

.result-summary,
.result-description {
  color: var(--ink-soft);
}

.result-summary {
  margin: 10px 0 0;
  font-size: 17px;
}

.result-description {
  margin: 22px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.strength-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 22px 0;
  padding: 0;
  list-style: none;
}

.strength-list li {
  border: 1px solid var(--line);
  padding: 9px 4px;
  font-size: 14px;
  text-align: center;
}

.result-note {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.result-note strong {
  color: var(--ink);
}

.export-status {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--accent);
  font-size: 13px;
  text-align: center;
}

.audio-replay-button {
  border-color: var(--accent);
  color: var(--accent);
}

.boot-screen {
  display: grid;
  min-height: 100dvh;
  place-content: center;
  text-align: center;
}

.boot-mark {
  width: 20px;
  height: 20px;
  margin: 0 auto;
  border: 1px solid var(--accent);
  border-radius: 50%;
  animation: pulse 1.2s ease-in-out infinite;
}

noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--paper);
  background: var(--ink);
}

@keyframes pulse {
  50% {
    opacity: 0.3;
    transform: scale(0.78);
  }
}

@media (min-width: 620px) {
  body {
    padding: 22px 0;
  }

  #app {
    min-height: calc(100dvh - 44px);
    border-radius: 22px;
  }

  .screen {
    min-height: calc(100dvh - 44px);
  }
}

@media (max-height: 720px) {
  .hero-title {
    font-size: 46px;
  }

  .hero-art {
    min-height: 260px;
  }

  .option {
    min-height: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
