:root {
  --ink: #0b2528;
  --muted: #557478;
  --paper: #f5fbfb;
  --paper-deep: #ddf0f2;
  --card: #ffffff;
  --red: #087d9e;
  --red-dark: #0c678f;
  --blue: #1679ad;
  --green: #287b68;
  --line: rgba(13, 104, 117, 0.15);
  --shadow: 0 24px 70px rgba(21, 71, 78, 0.16);
  --display: "Iowan Old Style", "Baskerville", "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --type-caption: 12px;
  --type-small: 13px;
  --type-body: 16px;
  --type-question: 28px;
  --type-card-title: 48px;
  --type-page-title: 52px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(8, 125, 158, 0.08), transparent 27rem),
    radial-gradient(circle at 85% 70%, rgba(39, 183, 198, 0.08), transparent 30rem),
    var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  text-wrap: pretty;
}

body.save-preview-open { overflow: hidden; }

h1,
h2 { text-wrap: balance; }

h1,
h2,
p,
li,
button,
strong,
span {
  word-break: normal;
  overflow-wrap: break-word;
  line-break: strict;
}

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

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(8, 125, 158, 0.42);
  outline-offset: 4px;
}

.page-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.32;
  background-image:
    repeating-linear-gradient(0deg, rgba(13, 104, 117, 0.018) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.16) 0 1px, transparent 1px 6px);
}

.topbar,
.site-footer,
.app-shell {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

.topbar {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.wordmark-mark {
  width: 37px;
  height: 37px;
  aspect-ratio: 1;
  display: block;
  overflow: hidden;
}

.wordmark-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.wordmark-text {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}
.wordmark strong,
.wordmark small { display: inline; }
.wordmark strong { font-size: 16px; letter-spacing: 0.13em; }
.wordmark small { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }

.edition {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.18em;
}

.app-shell { min-height: calc(100vh - 160px); }

.screen {
  animation: screen-in 420ms cubic-bezier(.22, .8, .25, 1) both;
}

.screen[hidden] { display: none !important; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.landing-screen {
  min-height: 690px;
  padding: 72px 0 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.68fr);
  gap: clamp(50px, 8vw, 110px);
  align-items: center;
  position: relative;
}

.eyebrow,
.question-scene {
  margin: 0 0 20px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.landing-copy h1,
.result-heading h1 {
  margin: 0;
  font-family: var(--display);
  font-size: var(--type-page-title);
  font-weight: 700;
  letter-spacing: -0.012em;
  line-height: 1.03;
}

.landing-copy h1 em,
.result-heading h1 em {
  color: var(--red);
  font-weight: 500;
}

.title-after-emphasis { margin-left: 0.12em; }
.title-after-text { margin-left: 0.08em; }

.title-after-emphasis,
.title-after-text { white-space: nowrap; }

.title-line {
  display: block;
  text-wrap: balance;
}

.landing-intro,
.specimen-card > p,
.question-card h2,
.answer-copy,
.quiz-footnote,
.result-tagline,
.result-brief p,
.analysis-item p,
.roast-block p,
.result-destination strong {
  text-wrap: pretty;
}

.landing-intro {
  max-width: 510px;
  margin: 26px 0 0;
  color: #365a5e;
  font-size: 18px;
  line-height: 1.75;
}

.landing-actions { margin-top: 36px; }
.landing-actions > p {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: var(--type-small);
}

.primary-button,
.secondary-button {
  min-height: 54px;
  padding: 0 22px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  color: var(--card);
  background: var(--ink);
  box-shadow: 6px 6px 0 var(--red);
}

.primary-button:hover,
.secondary-button:hover { transform: translate(-2px, -2px); }
.primary-button:hover { box-shadow: 9px 9px 0 var(--red); }
.primary-button:active,
.secondary-button:active { transform: translate(0, 0); }

.secondary-button { background: transparent; }

.dimension-list {
  max-width: 560px;
  margin: 44px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none;
  border-top: 1px solid var(--line);
}

.dimension-list li {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 13px;
  border-bottom: 1px solid var(--line);
  font-size: var(--type-body);
  line-height: 1.45;
}

.dimension-list li:nth-child(odd) { padding-right: 18px; border-right: 1px solid var(--line); }
.dimension-list li:nth-child(even) { padding-left: 18px; }
.dimension-list span { color: var(--red); font-family: var(--display); font-style: italic; }

.specimen-card,
.result-card {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(140deg, transparent 0 62%, rgba(8, 125, 158, 0.055) 62% 100%),
    var(--card);
  border: 1px solid rgba(13, 104, 117, 0.27);
  box-shadow: var(--shadow);
}

.specimen-card {
  width: min(100%, 430px);
  min-height: 560px;
  justify-self: center;
  padding: 30px 30px 26px;
  transform: rotate(1.5deg);
}

.specimen-card::before,
.result-card::before {
  content: "";
  position: absolute;
  width: 250px;
  height: 250px;
  right: -130px;
  top: 90px;
  border: 1px solid rgba(8, 125, 158, 0.22);
  border-radius: 50%;
  box-shadow: 0 0 0 18px transparent, 0 0 0 19px rgba(8, 125, 158, 0.14), 0 0 0 38px transparent, 0 0 0 39px rgba(8, 125, 158, 0.1);
}

.specimen-stamp {
  position: absolute;
  right: 24px;
  top: 78px;
  padding: 5px 9px;
  color: var(--red);
  border: 2px solid var(--red);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.18em;
  transform: rotate(9deg);
}

.specimen-topline,
.result-card-topline,
.result-signature {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.specimen-code,
.result-code {
  margin-top: 52px;
  color: var(--red);
  font-family: var(--display);
  font-size: 20px;
  font-style: italic;
  letter-spacing: 0.2em;
}

.specimen-code {
  max-width: 255px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0.12em;
}

.specimen-card h2 {
  max-width: 340px;
  margin: 18px 0 0;
  font-family: var(--display);
  font-size: 38px;
  letter-spacing: -0.018em;
  line-height: 1.14;
}

.specimen-card > p {
  max-width: 270px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.specimen-image {
  display: block;
  width: 170px;
  height: 170px;
  aspect-ratio: 1;
  margin-top: 24px;
  object-fit: cover;
  border: 1px solid var(--line);
  box-shadow: 7px 7px 0 var(--paper-deep);
}

.passport-strip {
  margin-top: 28px;
  padding: 11px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  color: var(--blue);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-align: center;
}

.specimen-footer {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mini-globe { color: var(--red); font-size: 26px; }

.privacy-note {
  position: absolute;
  left: 0;
  bottom: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.quiz-screen {
  width: min(960px, 100%);
  min-height: 650px;
  margin: 0 auto;
  padding: 52px 0 74px;
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.text-button {
  padding: 7px 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
}

.text-button:hover { color: var(--ink); }

.progress-meta {
  display: flex;
  gap: 18px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.progress-meta span:last-child { color: var(--red); }

.progress-track {
  height: 2px;
  margin-top: 14px;
  overflow: hidden;
  background: var(--line);
}

.progress-track span {
  display: block;
  width: 4%;
  height: 100%;
  background: var(--red);
  transition: width 300ms ease;
}

.question-card { padding: 72px 0 40px; }
.question-scene { margin-bottom: 24px; }
.question-card h2 {
  max-width: 940px;
  margin: 0;
  font-family: var(--display);
  font-size: var(--type-question);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.32;
  word-break: auto-phrase;
  overflow-wrap: normal;
  text-wrap: pretty;
}

.answer-list {
  margin-top: 46px;
  display: grid;
  gap: 14px;
}

.answer-button {
  width: 100%;
  min-height: 94px;
  padding: 21px 24px;
  display: grid;
  grid-template-columns: 34px 1fr 18px;
  gap: 14px;
  align-items: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.answer-button:hover {
  transform: translateX(5px);
  background: var(--card);
  border-color: rgba(8, 125, 158, 0.65);
}

.answer-letter {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: var(--display);
  font-size: 15px;
  font-style: italic;
}

.answer-copy { font-size: 16px; line-height: 1.65; }
.answer-arrow { color: var(--red); font-size: 18px; }

.quiz-footnote {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}

.result-screen {
  width: min(850px, 100%);
  margin: 0 auto;
  padding: 64px 0 80px;
}

.result-heading { margin-bottom: 40px; }
.result-heading h1 {
  max-width: 720px;
  font-size: 42px;
  line-height: 1.15;
}

.result-card {
  padding: clamp(28px, 5vw, 58px);
}

.result-code {
  margin-top: 38px;
  max-width: 100%;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.12;
  letter-spacing: clamp(0.08em, 0.15vw, 0.2em);
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.result-card h2 {
  max-width: 700px;
  margin: 28px 0 0;
  font-family: var(--display);
  font-size: var(--type-card-title);
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.12;
}

.result-tagline {
  max-width: 590px;
  margin: 24px 0 0;
  color: var(--red-dark);
  font-family: var(--display);
  font-size: 21px;
  line-height: 1.6;
}

.result-tags {
  margin-top: 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-tags span {
  padding: 7px 10px;
  color: var(--blue);
  border: 1px solid rgba(22, 121, 173, 0.32);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 750;
}

.result-profile {
  margin: 34px 0 0;
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(280px, 1fr);
  gap: clamp(22px, 4vw, 42px);
  align-items: start;
}

.result-visual { margin: 0; }

.result-visual figcaption {
  max-width: 260px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.result-brief {
  max-width: 260px;
  margin-top: 25px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.result-brief span {
  color: var(--red);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.result-brief p {
  margin: 9px 0 0;
  color: #365a5e;
  font-size: 13px;
  line-height: 1.78;
}

.result-image-frame {
  width: min(100%, 260px);
  aspect-ratio: 1;
  margin-inline: auto;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 9px 9px 0 var(--paper-deep);
}

.result-image {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.result-image[hidden] { display: none; }

.result-analysis { margin: 0; }

.result-analysis-title {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.analysis-grid {
  display: grid;
  grid-template-columns: 1fr;
  border-top: 1px solid var(--line);
}

.analysis-item {
  min-width: 0;
  padding: 16px 0 18px;
  border-bottom: 1px solid var(--line);
}

.analysis-item span {
  color: var(--red);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
}

.analysis-item p {
  margin: 7px 0 0;
  color: #365a5e;
  font-size: 14px;
  line-height: 1.78;
}

.roast-block {
  margin: 38px 0 0;
  padding: 22px 24px;
  background: rgba(8, 125, 158, 0.07);
  border-left: 4px solid var(--red);
}

.roast-block span {
  color: var(--red);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.roast-block p {
  margin: 9px 0 0;
  font-family: var(--display);
  font-size: 22px;
  line-height: 1.55;
}

.score-grid {
  margin-top: 42px;
  display: grid;
  gap: 20px;
}

.score-row {
  display: grid;
  grid-template-columns: 96px 1fr 96px;
  gap: 14px;
  align-items: center;
}

.score-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.score-label:last-child { text-align: right; }
.score-line {
  height: 7px;
  position: relative;
  background: var(--paper-deep);
  border-radius: 99px;
}

.score-line::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -3px;
  width: 1px;
  height: 13px;
  background: rgba(13, 104, 117, 0.34);
}

.score-dot {
  position: absolute;
  top: 50%;
  width: 15px;
  height: 15px;
  background: var(--red);
  border: 3px solid var(--card);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--red);
  transform: translate(-50%, -50%);
}

.result-destination {
  margin-top: 42px;
  padding: 18px 0;
  display: flex;
  justify-content: space-between;
  gap: 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.55;
}

.result-destination span { color: var(--muted); }
.result-destination strong { text-align: right; }
.result-signature { margin-top: 36px; }

.result-actions {
  margin-top: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.restart-button { grid-column: 1 / -1; justify-self: center; margin-top: 8px; }
.action-feedback { min-height: 22px; margin: 8px 0 0; color: var(--green); font-size: 11px; text-align: center; }

.save-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  display: grid;
  place-items: start center;
  overflow-y: auto;
  background: rgba(4, 27, 30, 0.78);
  backdrop-filter: blur(8px);
}

.save-overlay[hidden] { display: none; }

.save-panel {
  width: min(100%, 620px);
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.save-panel-header {
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.save-panel-header strong { display: block; font-size: 17px; }

.save-panel-header p {
  max-width: 440px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.save-panel-close {
  flex: 0 0 auto;
  padding: 5px 2px;
  color: var(--red);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
}

.save-preview {
  display: block;
  width: 100%;
  height: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  -webkit-touch-callout: default;
  user-select: auto;
}

.site-footer {
  min-height: 72px;
  padding: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.05em;
}

@media (max-width: 820px) {
  .topbar,
  .site-footer,
  .app-shell { width: min(100% - 32px, 680px); }

  .landing-screen {
    padding-top: 48px;
    grid-template-columns: 1fr;
    gap: 52px;
  }

  .specimen-card { width: min(92%, 430px); }
  .question-card h2 { max-width: 680px; }
  .privacy-note { position: static; grid-column: 1; text-align: center; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 560px) {
  :root {
    --type-caption: 11px;
    --type-small: 12px;
    --type-body: 16px;
    --type-question: 22px;
    --type-card-title: 34px;
    --type-page-title: 34px;
  }

  .topbar { min-height: 72px; }
  .edition { display: none; }
  .landing-screen { padding: 42px 0 52px; }
  .landing-copy h1 { font-size: var(--type-page-title); line-height: 1.16; }
  .landing-intro { font-size: 16px; line-height: 1.75; }
  .primary-button { width: calc(100% - 7px); gap: 20px; }
  .dimension-list { grid-template-columns: 1fr; }
  .dimension-list li:nth-child(odd),
  .dimension-list li:nth-child(even) { padding-inline: 0; border-right: 0; }
  .specimen-card { width: 100%; min-height: 500px; padding: 25px 24px; transform: none; }
  .specimen-card h2 { font-size: 32px; line-height: 1.2; }
  .passport-strip { margin-top: 46px; }

  .quiz-screen { padding: 34px 0 60px; }
  .question-card { padding-top: 52px; }
  .question-card h2 { font-size: var(--type-question); line-height: 1.46; }
  .answer-list { margin-top: 36px; }
  .answer-button { min-height: 94px; padding: 18px 15px; grid-template-columns: 30px 1fr 14px; gap: 11px; }
  .answer-copy { font-size: 16px; line-height: 1.58; }

  .result-screen { padding: 45px 0 64px; }
  .result-card { padding: 26px 21px; }
  .result-heading h1 { font-size: 30px; line-height: 1.2; }
  .result-card-topline { gap: 8px; font-size: 10px; letter-spacing: 0.1em; }
  .result-code { font-size: clamp(24px, 8vw, 30px); }
  .result-card h2 { font-size: var(--type-card-title); line-height: 1.25; }
  .result-tags span { font-size: 11px; }
  .result-profile { grid-template-columns: 1fr; gap: 32px; }
  .result-image-frame { width: min(100%, 280px); }
  .result-visual figcaption { max-width: 280px; }
  .result-brief { max-width: none; }
  .analysis-item { padding: 17px 0; }
  .score-row { grid-template-columns: 74px 1fr 74px; gap: 9px; }
  .score-label { font-size: 12px; }
  .result-destination { flex-direction: column; gap: 7px; }
  .result-destination strong { text-align: left; }
  .result-signature { flex-direction: column; gap: 7px; }
  .result-actions { grid-template-columns: 1fr; }
  .result-actions .primary-button,
  .result-actions .secondary-button { width: 100%; }
  .restart-button { grid-column: 1; }
}

@media (max-width: 380px) {
  :root {
    --type-question: 21px;
    --type-page-title: 32px;
  }

  .topbar,
  .site-footer,
  .app-shell { width: calc(100% - 24px); }

  .result-heading h1 { font-size: 28px; }

  .answer-button { padding-inline: 13px; grid-template-columns: 28px 1fr 12px; gap: 9px; }
  .answer-letter { width: 28px; height: 28px; }
  .result-card { padding-inline: 17px; }
  .score-row { grid-template-columns: 68px 1fr 68px; gap: 7px; }
  .score-label { font-size: 11.5px; }
}

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