:root {
  --paper: #f2efe9;
  --ink: #2b2b2b;
  --ink-soft: #5a5650;
  --line: rgba(43, 43, 43, 0.18);
  --accent-wrong: #a63d33;
  --accent-right: #3d6b4f;
  --btn: #2b2b2b;
  --btn-text: #f7f4ee;
  --paper-texture: url("/assets/textures/paper-base.webp");
  --theme-ink: var(--ink);
  --theme-soft: var(--ink-soft);
  --radius: 10px;
  --serif: "Libre Baskerville", "Spectral", Georgia, serif;
  --sans: "Source Sans 3", "Noto Sans", system-ui, sans-serif;
  --ease: 280ms ease;
  --wipe-ms: 780ms;
  --ink-ms: calc(var(--wipe-ms) * 0.7);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--sans);
  color: var(--theme-ink);
  background: transparent;
  transition: color var(--ink-ms) ease;
}

.brand,
.eyebrow,
.quote,
.status,
.linkish,
.option,
.option .name,
.ornament,
.lede,
.feedback-banner h2,
.feedback-banner p,
.compare-side .label,
.compare-side .country,
.reveal .label,
.reveal .specimen,
.reveal .meta,
.reveal .system,
.results-hero .score,
.results-hero .score-label,
.results-hero .message,
.stats-panel h3,
.stats-panel .sub,
.avg,
.mixups,
.global-note,
.diffui {
  transition: color var(--ink-ms) ease, border-color var(--ink-ms) ease, background-color var(--ink-ms) ease;
}

body.theme-dark-paper {
  --btn: #f4f1ea;
  --btn-text: #1a1a1a;
}

body.theme-light-paper {
  --btn: #2b2b2b;
  --btn-text: #f7f4ee;
}

.paper-stack {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.paper-layer {
  position: absolute;
  inset: 0;
  background-color: #f2efe9;
  background-image: url("/assets/textures/paper-base.webp");
  background-size: 420px 420px;
  background-repeat: repeat;
}

.wipe-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.wipe-canvas.active {
  opacity: 1;
}

.illu {
  position: fixed;
  top: 50%;
  width: min(28vw, 320px);
  height: min(42vh, 420px);
  background-color: transparent;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition:
    transform 560ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 380ms ease;
}

.illu-left {
  left: 0;
  transform: translate(-110%, -50%) rotate(-18deg);
  transform-origin: left center;
}

.illu-right {
  right: 0;
  transform: translate(110%, -50%) rotate(18deg);
  transform-origin: right center;
}

.illu.blend-screen {
  mix-blend-mode: screen;
  isolation: auto;
}

.illu.blend-multiply {
  mix-blend-mode: multiply;
  isolation: auto;
}

.illu.visible.illu-left {
  opacity: 1;
  transform: translate(0, -50%) rotate(8deg);
}

.illu.visible.illu-right {
  opacity: 1;
  transform: translate(0, -50%) rotate(-8deg);
}

.illu.leaving.illu-left {
  opacity: 0;
  transform: translate(-110%, -50%) rotate(-18deg);
}

.illu.leaving.illu-right {
  opacity: 0;
  transform: translate(110%, -50%) rotate(18deg);
}

@media (max-width: 720px) {
  .illu {
    width: min(42vw, 180px);
    height: min(28vh, 220px);
  }

  .illu-left {
    top: var(--illu-left-top, 28%);
    transform: translate(-110%, 0) rotate(-14deg);
    transform-origin: left top;
  }

  .illu-right {
    top: var(--illu-right-top, 55%);
    transform: translate(110%, 0) rotate(14deg);
    transform-origin: right bottom;
  }

  .illu.visible.illu-left,
  .illu.visible.illu-right {
    opacity: 0.7;
  }

  .illu.visible.illu-left {
    transform: translate(-50px, -50px) rotate(6deg);
  }

  .illu.visible.illu-right {
    transform: translate(50px, 50px) rotate(-6deg);
  }

  .illu.leaving.illu-left {
    transform: translate(-110%, 0) rotate(-14deg);
  }

  .illu.leaving.illu-right {
    transform: translate(110%, 0) rotate(14deg);
  }
}

.option.selected {
  background: rgba(0, 0, 0, 0.06);
}

body.theme-dark-paper .option.selected {
  background: rgba(255, 255, 255, 0.12);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 3;
}

.chrome {
  width: min(920px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2.5rem 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex-shrink: 0;
  position: relative;
  z-index: 4;
}

.chrome.is-hidden {
  display: none;
}

.chrome .status {
  margin-bottom: 0.25rem;
}

.chrome.feedback-mode .status {
  margin-bottom: 1.4rem;
}

.screen {
  display: none;
  flex: 1;
  width: min(920px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2.5rem 0 4.5rem;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.screen.active {
  display: flex;
}

.screen.active.animates {
  animation: rise 480ms ease both;
}

#screen-quiz.active,
#screen-feedback.active {
  padding-top: 1.25rem;
}

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

.brand {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0.08em;
  font-weight: 400;
  margin: 0;
  color: var(--theme-ink);
}

.eyebrow {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--theme-soft);
}

.status {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  margin: 1.6rem 0 2.2rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--theme-soft);
}

.progress {
  height: 2px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--theme-ink);
  transition: width 400ms ease;
}

.status-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-right .divider {
  width: 1px;
  height: 0.9rem;
  background: var(--line);
}

.linkish {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  padding: 0;
}

.linkish:hover {
  opacity: 0.7;
}

.quote {
  margin: 0;
  max-width: 42rem;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.35;
  font-weight: 400;
  color: var(--theme-ink);
}

.quote em {
  font-style: italic;
}

.ornament {
  margin: 1.8rem 0 1.4rem;
  color: var(--theme-soft);
  font-size: 0.85rem;
  letter-spacing: 0.4em;
}

#screen-quiz {
  padding-bottom: 0;
  justify-content: flex-start;
  width: 100%;
  max-width: none;
}

#screen-quiz .quote,
#screen-quiz .ornament {
  width: min(920px, calc(100% - 2.5rem));
}

#screen-quiz .quote {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#screen-quiz .ornament {
  margin-bottom: 0.5rem;
}

#screen-quiz .options {
  width: 100%;
  max-width: none;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background: transparent;
  padding: 0.5rem 0 calc(1.25rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

#screen-quiz .options .option {
  max-width: none;
}

.confirm-tip {
  position: fixed;
  left: 50%;
  bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(8px);
  z-index: 30;
  padding: 0.7rem 1rem;
  max-width: min(20rem, calc(100% - 2rem));
  border-radius: 8px;
  background: var(--theme-ink);
  color: var(--btn-text, #f7f4ee);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 8px 24px rgba(20, 16, 12, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.confirm-tip.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

body.theme-dark-paper .confirm-tip {
  color: #1a1a1a;
}

body.theme-light-paper .confirm-tip {
  color: #f7f4ee;
}

.options {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.option {
  appearance: none;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  padding: 1.25rem 0.75rem;
  cursor: pointer;
  color: var(--theme-ink);
  transition: background 180ms ease, transform 180ms ease;
}

.option:last-child {
  border-right: 0;
}

.option:hover {
  background: rgba(0, 0, 0, 0.04);
}

body.theme-dark-paper .option:hover {
  background: rgba(255, 255, 255, 0.08);
}

.option:focus-visible {
  outline: 2px solid var(--theme-ink);
  outline-offset: -2px;
}

.option .flag {
  font-size: 1.85rem;
  line-height: 1;
  display: block;
  margin-bottom: 0.55rem;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.08));
}

.option .name {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.btn {
  appearance: none;
  border: 0;
  background: var(--btn);
  color: var(--btn-text);
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.95rem 1.6rem;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  opacity: 0.9;
}

.btn.wide {
  width: min(100%, 22rem);
  margin-top: 1.75rem;
}

.lede {
  margin: 0 auto;
  max-width: 28rem;
  color: var(--theme-soft);
  line-height: 1.55;
  font-size: 0.98rem;
}

.landing {
  justify-content: flex-start;
}

.landing .brand {
  margin-top: 0;
}

.landing-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  width: 100%;
}

.landing .btn.wide {
  margin-top: 0;
}

.diffui {
  position: fixed;
  right: 1rem;
  bottom: 0.85rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: rgba(43, 43, 43, 0.38);
  text-decoration: none;
  z-index: 20;
}

body.theme-dark-paper .diffui {
  color: var(--theme-soft);
}

.diffui:hover {
  color: inherit;
}

/* Feedback */
.feedback-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
  width: 100%;
  margin: 0.75rem 0 1.5rem;
  color: var(--theme-ink);
}

.feedback-banner .mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 1.15rem;
  color: inherit;
}

.feedback-banner.right {
  flex-direction: column;
  gap: 0;
}

.feedback-banner.right .mark {
  width: 3.4rem;
  height: 3.4rem;
  font-size: 1.7rem;
  margin: 0.2rem 0 0.4rem;
}

.feedback-banner.right #fb-title {
  display: none;
}

.feedback-banner h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.55rem;
  font-weight: 400;
  color: inherit;
}

.feedback-banner.correct-only .mark {
  margin: 0.5rem auto 1rem;
}

.compare {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  border: 1px solid rgba(43, 43, 43, 0.14);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  background-color: #f2efe9;
  background-image: url("/assets/textures/paper-base.webp");
  background-size: 420px 420px;
  background-repeat: repeat;
  color: #2b2b2b;
  box-shadow: 0 10px 28px rgba(20, 16, 12, 0.18), 0 2px 6px rgba(20, 16, 12, 0.08);
}

.compare.is-hidden {
  display: none;
}

.compare-side {
  padding: 1.25rem 1rem;
  color: #2b2b2b;
}

.compare-side .label {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5a5650;
  margin-bottom: 0.7rem;
}

.compare-side .flag {
  font-size: 2rem;
}

.compare-side .country {
  margin: 0.45rem 0 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  color: #2b2b2b;
}

.compare-vs {
  display: grid;
  place-items: center;
  position: relative;
  width: 2.6rem;
}

.compare-vs::before {
  content: "";
  position: absolute;
  top: 0.75rem;
  bottom: 0.75rem;
  width: 1px;
  background: rgba(43, 43, 43, 0.16);
}

.compare-vs span {
  position: relative;
  z-index: 1;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: 1px solid rgba(43, 43, 43, 0.16);
  background: #f2efe9;
  display: grid;
  place-items: center;
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  color: #5a5650;
}

.reveal {
  margin-top: 0.4rem;
}

.reveal .label {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--theme-soft);
}

.reveal .specimen {
  margin: 0.55rem 0 0.35rem;
  font-size: clamp(2.8rem, 7vw, 4.6rem);
  line-height: 1.05;
}

.reveal .meta {
  color: var(--theme-soft);
  font-size: 0.92rem;
  max-width: 32rem;
  margin: 0 auto;
  line-height: 1.5;
}

.reveal .system {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--theme-soft);
}

/* Results */
.results-hero .score {
  font-family: var(--serif);
  font-size: clamp(3rem, 8vw, 4.6rem);
  margin: 0.6rem 0 0.2rem;
  line-height: 1;
}

.results-hero .score-label {
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--theme-soft);
}

.results-hero .message {
  margin: 1rem auto 0;
  max-width: 28rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--theme-soft);
}

.stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 2rem 0 0.5rem;
  text-align: left;
  position: relative;
}

.stats-grid::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 1px;
  background: var(--line);
}

.stats-panel h3 {
  margin: 0 0 0.2rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 400;
}

.stats-panel .sub {
  margin: 0 0 1rem;
  font-size: 0.78rem;
  color: var(--theme-soft);
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 9rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 0.25rem;
}

.bar .pct {
  font-size: 0.58rem;
  color: var(--theme-soft);
}

.bar .fill {
  width: 100%;
  border-radius: 3px 3px 0 0;
  background: #8d7f6d;
  min-height: 4px;
  transition: height 500ms ease;
}

.bar:nth-child(even) .fill {
  background: #c4b7a4;
}

.bar .q {
  position: absolute;
  bottom: -1.2rem;
  font-size: 0.62rem;
  color: var(--theme-soft);
}

.bars-wrap {
  position: relative;
}

.avg {
  margin-top: 1.4rem;
  font-size: 0.85rem;
  color: var(--theme-soft);
}

.mixups {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.mixups li {
  display: grid;
  grid-template-columns: 1.2rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
  font-size: 0.86rem;
}

.mixups .rank {
  color: var(--theme-soft);
  font-size: 0.75rem;
}

.mixups .pair {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.mixups .pct {
  font-variant-numeric: tabular-nums;
  color: var(--theme-soft);
}

.global-note {
  margin-top: 1.2rem;
  font-size: 0.78rem;
  color: var(--theme-soft);
  width: 100%;
  text-align: left;
}

@media (max-width: 720px) {
  .options {
    grid-template-columns: 1fr 1fr;
  }

  .option {
    border-bottom: 1px solid var(--line);
  }

  .option:nth-child(2n) {
    border-right: 0;
  }

  .option:nth-child(n + 3) {
    border-bottom: 0;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid::before {
    display: none;
  }

  .feedback-banner {
    margin: 0.4rem 0 1rem;
    gap: 0.5rem;
  }

  .feedback-banner .mark {
    width: 1.65rem;
    height: 1.65rem;
    font-size: 0.85rem;
  }

  .feedback-banner h2 {
    font-size: 1.1rem;
  }

  .compare {
    grid-template-columns: 1fr auto 1fr;
    margin-bottom: 1rem;
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(20, 16, 12, 0.14), 0 1px 3px rgba(20, 16, 12, 0.06);
  }

  .compare-side {
    padding: 0.7rem 0.55rem;
  }

  .compare-side .label {
    font-size: 0.55rem;
    letter-spacing: 0.14em;
    margin-bottom: 0.4rem;
  }

  .compare-side .flag {
    font-size: 1.35rem;
  }

  .compare-side .country {
    margin-top: 0.25rem;
    font-size: 0.88rem;
  }

  .compare-vs {
    width: 2rem;
  }

  .compare-vs span {
    font-size: 0.62rem;
  }
}
