:root {
  --paper: #050505;
  --paper-deep: #0d0d0d;
  --ink: #f4f4f4;
  --muted: #7f7f7f;
  --quiet: #474747;
  --line: #d7d7d7;
  --line-soft: rgba(255, 255, 255, .16);
  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, .08);
  --surface: #050505;
  --option-bg: rgba(255, 255, 255, .025);
  --option-selected: rgba(255, 255, 255, .10);
  --button-text: #050505;
  --shadow: none;
  color-scheme: dark;
}

:root[data-theme="dark"] {
  --paper: #050505;
  --paper-deep: #0d0d0d;
  --ink: #f4f4f4;
  --muted: #7f7f7f;
  --quiet: #474747;
  --line: #d7d7d7;
  --line-soft: rgba(255, 255, 255, .16);
  --accent: #ffffff;
  --accent-soft: rgba(255, 255, 255, .08);
  --surface: #050505;
  --option-bg: rgba(255, 255, 255, .025);
  --option-selected: rgba(255, 255, 255, .10);
  --button-text: #050505;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, .045), transparent 24%),
    linear-gradient(180deg, #070707 0%, #000 46%, #050505 100%);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, a { -webkit-tap-highlight-color: transparent; }

.test-shell {
  position: relative;
  width: min(100%, 680px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro-panel,
.question-panel,
.verify-panel {
  min-height: 100vh;
  min-height: 100svh;
  padding: max(34px, env(safe-area-inset-top)) 28px max(34px, env(safe-area-inset-bottom));
}

.intro-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.overline,
.scene-label {
  margin: 0 auto 22px;
  color: rgba(255, 255, 255, .46);
  font-size: 12px;
  letter-spacing: .44em;
}

.overline {
  width: min(100%, 440px);
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .18);
}

.intro-panel h1 {
  margin: 0 auto;
  color: #f7f7f7;
  font-size: clamp(48px, 13vw, 82px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: .10em;
  text-indent: .10em;
}

.ornament { display: none; }

.intro-copy {
  margin: 22px auto 0;
  color: rgba(255, 255, 255, .36);
  font-size: clamp(14px, 4vw, 17px);
  font-weight: 600;
  line-height: 1.8;
  letter-spacing: .08em;
}

.test-note {
  display: grid;
  gap: 10px;
  margin: clamp(44px, 7svh, 86px) 0 clamp(38px, 6svh, 68px);
  color: rgba(255, 255, 255, .62);
  font-size: clamp(15px, 4.3vw, 21px);
  font-weight: 300;
  line-height: 1.68;
  letter-spacing: .045em;
}

.test-note span { padding: 0; }
.test-note span + span { border-left: 0; }

.primary-button {
  display: block;
  width: min(100%, 390px);
  min-height: 64px;
  margin: 0 auto;
  border: 1px solid rgba(255, 255, 255, .88);
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-size: clamp(17px, 4.8vw, 21px);
  font-weight: 300;
  letter-spacing: .42em;
  text-align: center;
  text-indent: .42em;
  text-decoration: none;
  cursor: pointer;
}

.primary-button:active {
  color: #050505;
  background: #f4f4f4;
  transform: translateY(1px);
}

.primary-button:disabled { opacity: .35; cursor: default; }

.fine-print {
  margin: 18px 0 0;
  color: rgba(255, 255, 255, .22);
  font-size: 11px;
  letter-spacing: .12em;
}

.local-record {
  width: min(100%, 430px);
  margin: 28px auto 0;
  padding: 18px 0 2px;
  border-top: 1px solid var(--line-soft);
}

.local-record-label {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, .34);
  font-size: 10px;
  letter-spacing: .26em;
}

.local-action {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-top: 9px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 0;
  color: rgba(255, 255, 255, .72);
  background: transparent;
  font: inherit;
  font-size: 12px;
  letter-spacing: .10em;
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.entertainment-note {
  width: min(100%, 440px);
  margin: 22px auto 0;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, .10);
  color: rgba(255, 255, 255, .30);
  font-size: 10px;
  line-height: 1.9;
  letter-spacing: .04em;
}

.question-panel {
  display: flex;
  flex-direction: column;
  padding-top: 26px;
}

.progress-header {
  position: relative;
  padding: 0 0 22px;
}

.back-button,
.theme-toggle {
  position: absolute;
  top: 0;
  height: 42px;
  border: 0;
  color: rgba(255, 255, 255, .56);
  background: transparent;
  font: inherit;
  font-size: 12px;
  letter-spacing: .10em;
  cursor: pointer;
}

.back-button {
  left: 0;
  width: auto;
  padding: 0 6px 0 0;
  color: rgba(255, 255, 255, .40);
  font-size: 0;
}

.back-button::before {
  content: "‹";
  font-size: 34px;
  font-weight: 200;
  line-height: 1;
}

.theme-toggle { display: none; }

.progress-meta {
  display: grid;
  justify-content: center;
  gap: 6px;
  padding: 4px 82px 0;
  color: rgba(255, 255, 255, .38);
  text-align: center;
  letter-spacing: .20em;
}

.progress-meta span:first-child {
  color: rgba(255, 255, 255, .82);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  letter-spacing: .18em;
}

.progress-meta span:last-child {
  color: rgba(255, 255, 255, .28);
  font-size: 10px;
  letter-spacing: .30em;
}

.progress-track {
  height: 1px;
  margin-top: 20px;
  overflow: hidden;
  background: rgba(255, 255, 255, .13);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: #f4f4f4;
  transition: width .35s ease;
}

.chapter-card {
  margin: 22px 0 8px;
  padding: 13px 0;
  border-top: 1px solid rgba(255, 255, 255, .18);
  border-bottom: 1px solid rgba(255, 255, 255, .18);
  color: rgba(255, 255, 255, .42);
  background: transparent;
  font-size: 12px;
  letter-spacing: .30em;
  text-align: center;
}

.question-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  padding-top: clamp(18px, 3.6svh, 42px);
  padding-bottom: clamp(28px, 5svh, 54px);
}

.chapter-card:not([hidden]) + .question-content { padding-top: clamp(14px, 3svh, 30px); }

.scene-label {
  margin-bottom: clamp(16px, 3svh, 24px);
  color: rgba(255, 255, 255, .32);
  font-size: 12px;
  line-height: 1.8;
  letter-spacing: .34em;
  text-align: center;
}

.question-content h2 {
  position: relative;
  margin: 0 0 clamp(28px, 4.8svh, 44px);
  padding: 0 4px clamp(22px, 3.6svh, 30px);
  color: #f2f2f2;
  font-size: clamp(24px, 6vw, 32px);
  font-weight: 500;
  line-height: 1.82;
  letter-spacing: .055em;
  text-align: center;
}

.question-content h2::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 56px;
  height: 1px;
  background: rgba(255, 255, 255, .28);
  transform: translateX(-50%);
}

.options {
  display: grid;
  gap: 12px;
  width: 100%;
  margin: 0 auto;
  padding-bottom: 4px;
}

.option-button {
  position: relative;
  width: 100%;
  min-height: 70px;
  padding: 18px 18px 18px 58px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 0;
  color: rgba(255, 255, 255, .70);
  background:
    linear-gradient(90deg, rgba(255,255,255,.04), transparent 34%),
    var(--option-bg);
  font: inherit;
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: .03em;
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}

.option-button::before {
  content: attr(data-letter);
  position: absolute;
  left: 18px;
  top: 50%;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .20);
  color: rgba(255, 255, 255, .42);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  font-style: normal;
  transform: translateY(-50%);
}

.option-button.selected {
  border-color: rgba(255, 255, 255, .82);
  color: #fff;
  background: var(--option-selected);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.38);
}

.option-button.selected::before {
  border-color: #f4f4f4;
  color: #050505;
  background: #f4f4f4;
}

.verify-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.verify-index {
  position: absolute;
  top: max(30px, env(safe-area-inset-top));
  left: 28px;
  right: 28px;
  display: flex;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .16);
  color: rgba(255, 255, 255, .32);
  font-size: 10px;
  letter-spacing: .22em;
}

.verify-sigil {
  margin: 6px 0 28px;
  color: rgba(255, 255, 255, .42);
  font-size: 20px;
}

.verify-panel h2 {
  margin: 0;
  color: #f4f4f4;
  font-size: 38px;
  font-weight: 500;
  line-height: 1.52;
  letter-spacing: .10em;
}

.verify-copy {
  margin: 27px 0 36px;
  color: rgba(255, 255, 255, .46);
  font-size: 14px;
  line-height: 1.9;
  letter-spacing: .05em;
}

.code-label {
  margin-bottom: 12px;
  color: rgba(255, 255, 255, .36);
  font-size: 10px;
  letter-spacing: .30em;
}

.code-input {
  width: min(100%, 270px);
  height: 66px;
  padding: 0 12px 0 25px;
  border: 1px solid rgba(255, 255, 255, .30);
  border-radius: 0;
  outline: none;
  color: #f4f4f4;
  background: transparent;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  letter-spacing: .48em;
  text-align: center;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.code-input:focus {
  border-color: rgba(255, 255, 255, .86);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .08);
}

.code-input.invalid {
  border-color: #b87878;
  animation: code-shake .22s linear 2;
}

.code-input.valid { border-color: #f4f4f4; }

.code-message {
  min-height: 20px;
  margin: 12px 0 8px;
  color: rgba(255, 255, 255, .34);
  font-size: 11px;
  letter-spacing: .10em;
}

.code-message.error { color: #d69b9b; }
.code-message.success { color: #f4f4f4; }

.verify-button {
  width: min(100%, 270px);
  min-height: 52px;
  margin-top: 4px;
  color: #f4f4f4;
}

@keyframes code-shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.text-button {
  margin-top: 19px;
  border: 0;
  color: rgba(255, 255, 255, .42);
  background: transparent;
  font: inherit;
  font-size: 12px;
  letter-spacing: .14em;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

[hidden] { display: none !important; }

@media (min-width: 681px) {
  body { padding: 0; }
  .test-shell,
  .intro-panel,
  .question-panel,
  .verify-panel { min-height: 100vh; }
  .intro-panel,
  .question-panel,
  .verify-panel {
    padding-left: 64px;
    padding-right: 64px;
  }
  .question-content {
    max-width: 620px;
  }
}

@media (max-width: 380px) {
  .intro-panel {
    padding-left: 22px;
    padding-right: 22px;
  }
  .overline {
    font-size: 10px;
    letter-spacing: .30em;
  }
  .intro-panel h1 {
    font-size: 46px;
    letter-spacing: .08em;
    text-indent: .08em;
  }
  .intro-copy {
    margin-top: 18px;
    font-size: 14px;
    letter-spacing: .06em;
  }
  .test-note {
    margin: 42px 0 36px;
    gap: 8px;
    font-size: 15px;
    line-height: 1.62;
  }
  .primary-button {
    min-height: 58px;
    font-size: 17px;
    letter-spacing: .30em;
    text-indent: .30em;
  }
  .question-content h2 { font-size: 22px; }
  .option-button {
    padding-right: 14px;
    font-size: 14px;
  }
}

@media (max-height: 720px) {
  .intro-panel h1 { font-size: 48px; }
  .intro-copy { margin-top: 18px; font-size: 15px; }
  .test-note { margin: 38px 0 34px; gap: 7px; font-size: 16px; }
  .question-content {
    justify-content: flex-start;
    padding-top: 18px;
    padding-bottom: 18px;
  }
  .question-content h2 {
    margin-bottom: 20px;
    padding-bottom: 18px;
    font-size: 20px;
  }
  .options { gap: 9px; }
  .option-button { min-height: 56px; padding-top: 12px; padding-bottom: 12px; }
}

@media (max-width: 430px) and (min-width: 381px) {
  .intro-panel h1 {
    font-size: 54px;
    letter-spacing: .085em;
    text-indent: .085em;
  }
  .test-note {
    margin: 48px 0 42px;
    font-size: 16px;
  }
  .primary-button {
    min-height: 60px;
    letter-spacing: .34em;
    text-indent: .34em;
  }
}

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