@font-face {
  font-family: 'Quiz Brush';
  src: url("../assets/fonts/quiz-caption.ttf?v=4e1c7a0527b1") format('truetype');
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #101c19;
  --paper: #f4ead5;
  --muted: #c3c4b2;
  --gold: #e3c995;
  --line: #a88f5e57;
  --serif: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  --sans: system-ui, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(ellipse at 76% 11%, #293c34, transparent 62%), #101b19;
  color: var(--paper);
  font: 16px/1.65 var(--sans);
}

a { color: inherit; text-decoration: none; }
@media (min-width: 701px) {
  body {
    background:
      linear-gradient(180deg, #10221ee8, #15251e85 33%, #14251c99 75%, #11221dcc),
      url("scenes/river-panorama.webp?v=c411204d8c17") center / cover fixed,
      #101b19;
  }
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
h1:focus { outline: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header {
  width: min(1200px, calc(100% - 88px));
  height: 92px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: inline-flex; align-items: center; gap: 17px; }
.brand img { width: 86px; height: 82px; object-fit: contain; }
.brand span {
  padding-left: 17px;
  border-left: 1px solid var(--line);
  color: var(--gold);
  font: 700 23px/1.4 var(--serif);
  letter-spacing: .13em;
}
.site-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--paper); font-size: 19px; }
.site-link span { margin-left: 6px; color: var(--gold); }
.site-link:hover, .text-button:hover { color: #fff1ca; }

.stage {
  --accent: #e3c995;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(1200px, calc(100% - 88px));
  min-height: 620px;
  margin: clamp(18px, 4.5vh, 56px) auto 56px;
  border: 1px solid var(--line);
  background: radial-gradient(ellipse at 8% 1%, #2a3c31, transparent 64%), var(--ink);
  box-shadow: 0 22px 65px #060e0c67;
}

.stage[data-view="result"] { background: radial-gradient(ellipse at 13% 0%, var(--result-wash), transparent 67%), var(--ink); }
.panel { display: flex; align-items: center; min-width: 0; padding: clamp(32px, 4.2vw, 66px); }
.screen { width: 100%; }
.screen h1, .share-dialog h2 { margin: 0; font-family: var(--serif); }
.intro h1 {
  font-size: clamp(37px, 4.35vw, 66px);
  line-height: 1.22;
  letter-spacing: .025em;
  text-wrap: balance;
}
.lede { margin: 22px 0 28px; color: var(--muted); font-size: clamp(15px, 1.35vw, 18px); }
.intro-actions, .question-actions, .result-actions, .share-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.intro-actions { gap: 18px; }
.time-note { font-size: 13px; color: var(--muted); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  min-height: 47px;
  padding: 9px 20px;
  border: 1px solid transparent;
  border-radius: 2px;
  font-weight: 680;
  font-size: 15px;
  white-space: nowrap;
  transition: background-color 150ms, border-color 150ms, opacity 150ms;
}
.button.primary { color: #241e13; background: #e3c995; border-color: #f0dcb5; }
.button.primary:hover:not(:disabled) { background: #f0dcb5; }
.button.primary:disabled { opacity: .4; }
.button.secondary { color: var(--paper); background: #ffffff08; border-color: var(--line); }
.button.secondary:hover:not(:disabled) { background: #ffffff13; border-color: var(--gold); }
.intro .button { min-width: 150px; min-height: 51px; }
.text-button { padding: 8px 0; border: 0; background: none; color: var(--muted); font-size: 14px; }

.factions, .result-tags { padding: 0; list-style: none; }
.factions {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(12px, 2vw, 24px);
  margin: 35px 0 0;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}
.factions li { display: flex; align-items: center; gap: 7px; color: var(--paper); font: 700 clamp(18px, 1.7vw, 22px) var(--serif); }
.factions img { width: clamp(41px, 4vw, 54px); height: auto; aspect-ratio: 1; object-fit: contain; }

.artwork { position: relative; isolation: isolate; margin: 0; overflow: hidden; min-height: 100%; background: #253d38; }
.scene-images { position: absolute; inset: 0; display: flex; }
.landscape { flex: 1 1 0; min-width: 0; height: 100%; object-fit: cover; object-position: center; }
.artwork-shade { position: absolute; inset: 0; background: linear-gradient(90deg, #1a28266e, transparent 28%), linear-gradient(0deg, #2b241e48, transparent 54%); }
.artwork-border { position: absolute; inset: 15px; border: 1px solid #f4e4af79; pointer-events: none; }
.artwork-border::before, .artwork-border::after {
  content: '';
  position: absolute;
  width: 19px;
  height: 19px;
  border: solid #f4e4af;
}
.artwork-border::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.artwork-border::after { right: -1px; bottom: -1px; border-width: 0 2px 2px 0; }
.stage[data-view="question"] .artwork-shade { background: linear-gradient(0deg, #382e1c24, transparent 32%); }
.stage[data-view="result"] .artwork-shade { background: radial-gradient(ellipse at center, #0c171824, #0c171869 95%); }
.result-heading { --name-size: clamp(58px, 6.1vw, 86px); display: flex; align-items: center; flex-wrap: wrap; gap: 8px 9px; }
.result-emblem { display: flex; align-items: center; gap: 3px; }
.result-emblem img { width: calc(var(--name-size) * 1.05); aspect-ratio: 1; object-fit: contain; }
.stage[data-mixed="true"] .result-emblem img { width: 32px; }
.result-portrait, .portrait-caption { display: none; }
.stage[data-view="result"][data-mixed="false"] .result-portrait {
  display: block;
  position: absolute;
  top: 53%;
  left: 50%;
  width: auto;
  height: 87%;
  max-width: none;
  transform: translate(var(--portrait-offset, -50%), -50%);
}
.stage[data-view="result"][data-faction="xuanji"] .result-portrait {
  inset: 82px 20px 20px;
  width: calc(100% - 40px);
  height: calc(100% - 102px);
  object-fit: contain;
  transform: none;
}
@media (width > 700px) {
  .stage[data-view="result"][data-faction="xuanji"] .result-portrait {
    left: 50%;
    right: auto;
    width: 118%;
    transform: translateX(-55%);
  }
}
.stage[data-faction="tongbao"] { --portrait-offset: -47%; }
.stage[data-view="result"][data-mixed="false"] .portrait-caption {
  display: block;
  position: absolute;
  top: 26px;
  left: 26px;
  margin: 0;
  padding: 6px 20px 7px 12px;
  color: #ffe6b8;
  background: linear-gradient(100deg, #242522ef 38%, #282822ba 78%, transparent);
  border-left: 2px solid #d5af79;
  font: 400 clamp(23px, 2.2vw, 32px)/1.15 'Quiz Brush', 'KaiTi', 'STKaiti', var(--serif);
  letter-spacing: .09em;
  white-space: nowrap;
  text-shadow: 0 1px 3px #282015;
}

.progress-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.progress-row span { flex: none; color: var(--gold); font-size: 13px; font-variant-numeric: tabular-nums; }
progress { flex: 1; width: 100%; height: 4px; border: 0; appearance: none; background: #ffffff1b; color: var(--gold); }
progress::-webkit-progress-bar { background: #ffffff1b; }
progress::-webkit-progress-value { background: var(--gold); transition: width 160ms; }
progress::-moz-progress-bar { background: var(--gold); }
.question h1 { font-size: clamp(24px, 2.35vw, 37px); line-height: 1.43; }
fieldset { padding: 0; margin: 23px 0; min-inline-size: 0; border: 0; }
.option-list { display: grid; gap: 10px; }
.option { position: relative; display: block; cursor: pointer; }
.option-body {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 13px;
  border: 1px solid #d9d0a538;
  border-radius: 2px;
  background: #d1d3b507;
  color: var(--paper);
  line-height: 1.5;
}
.option:hover .option-body { background: #e3c99512; border-color: #e3c9959e; }
.option input:checked + .option-body { border-color: var(--gold); background: #e3c9951c; }
.option input:focus-visible + .option-body { outline: 2px solid var(--gold); outline-offset: 3px; }
.option-letter {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid var(--line);
  color: var(--gold);
  font: 700 14px Georgia, serif;
}
.option input:checked + .option-body .option-letter { border-color: var(--gold); background: var(--gold); color: var(--ink); }
.question-actions { justify-content: space-between; }

.result-summary { display: contents; }
.result-label {
  margin: 0 0 10px;
  font: 600 clamp(20px, 1.9vw, 26px)/1.4 var(--serif);
  letter-spacing: .12em;
  color: var(--accent);
}
.result h1 { font-size: var(--name-size); line-height: 1.1; letter-spacing: .12em; }
.stage[data-mixed="true"] .result h1 { font-size: clamp(25px, 3.4vw, 52px); letter-spacing: .035em; }
.result-motto { margin: 13px 0 15px; font: 700 clamp(17px, 2vw, 23px)/1.5 var(--serif); color: var(--accent); }
.result-tags { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 20px; }
.result-tags li {
  padding: 6px 12px;
  border: 1px solid var(--accent);
  background: #ffffff0a;
  color: var(--accent);
  font: 700 18px/1.5 var(--serif);
  letter-spacing: .04em;
}
.result-description, .result-lore { margin: 0; font-size: 15px; }
.result-lore { margin-top: 12px; color: var(--muted); }
.result-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 15px;
  padding: 12px 0 0;
  margin: 17px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
  color: var(--accent);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.result-actions { margin-top: 23px; }
.retake { margin-top: 8px; }

.share-dialog {
  width: min(480px, calc(100% - 32px));
  padding: 30px 24px 19px;
  border: 1px solid #ab956a;
  border-radius: 2px;
  background: #1e2f29;
  color: var(--paper);
  box-shadow: 0 22px 65px #08100c83;
}
.share-dialog::backdrop { background: #060d0ccb; }
.share-preview { display: block; max-width: 100%; height: auto; max-height: 40vh; margin: 0 auto 14px; }
.share-dialog h2 { font-size: 26px; }
.share-dialog p { margin: 8px 0 14px; color: var(--muted); font-size: 14px; }
.share-dialog input { display: block; width: 100%; margin: 0 0 12px; padding: 8px; border: 1px solid var(--line); border-radius: 2px; background: #111d19; color: var(--paper); font-size: 13px; }
.close-button { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; padding: 0; border: 0; background: transparent; color: var(--gold); font-size: 25px; }
.share-dialog .share-status { margin: 10px 0 0; min-height: 21px; color: var(--gold); }

@media (max-width: 980px) {
  .factions { column-gap: 8px; }
  .factions li { gap: 4px; }
  .stage, .site-header { width: calc(100% - 48px); }
  .stage { min-height: 560px; }
  .panel { padding: 32px; }
  .artwork-border { inset: 11px; }
}

@media (max-width: 700px), (orientation: landscape) and (max-height: 600px) and (max-width: 1100px) {
  html { scrollbar-width: none; }
  html::-webkit-scrollbar { display: none; }
  .intro .button, .question-actions .button, .question-actions .text-button { min-height: 44px; }
  .option-letter { width: 23px; height: 23px; flex-basis: 23px; }
  .result-label { margin-bottom: 3px; font-size: 15px; }
  .result-heading { gap: 4px 8px; }
  .result-motto { margin: 5px 0 8px; font-size: 16px; }
  .result-tags { gap: 6px; margin-bottom: 9px; }
  .result-tags li { padding: 3px 8px; font-size: 14px; }
  .result-description, .result-lore { font-size: 14px; line-height: 1.5; }
  .result-lore { margin-top: 6px; }
  .result-scores { margin-top: 8px; padding-top: 6px; font-size: 12px; }
  .result-actions { display: inline-flex; gap: 6px; margin-top: 8px; }
  .result-actions .button { min-height: 44px; gap: 7px; padding-inline: 8px; font-size: 13px; }
  .retake { min-height: 44px; margin: 0 0 0 6px; font-size: 13px; }
  .stage[data-view="result"][data-mixed="false"] .result-portrait {
    inset: 39px 8px 8px;
    width: calc(100% - 16px);
    height: calc(100% - 47px);
    object-fit: contain;
    transform: none;
  }
  .stage[data-view="result"][data-mixed="false"] .portrait-caption {
    top: 12px;
    left: 12px;
    padding-block: 4px;
    font-size: 19px;
  }
  .share-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; }
}

@media (max-width: 700px) {
  .stage, .site-header { width: calc(100% - 24px); }
  .site-header { height: 56px; }
  .brand { gap: 8px; }
  .brand img { width: 53px; height: 51px; }
  .brand span { padding-left: 8px; font-size: 17px; }
  .site-link { font-size: 14px; }
  .stage { grid-template-columns: minmax(0, 1fr); min-height: 0; margin: 6px auto 10px; }
  .panel { padding: 16px 14px; }
  .intro h1 { font-size: clamp(30px, 8.5vw, 45px); }
  .lede { margin: 10px 0 14px; }
  .factions { margin-top: 14px; padding-top: 9px; gap: 5px 10px; }
  .factions li { font-size: 16px; }
  .factions img { width: 32px; }
  .artwork { min-height: clamp(132px, 28dvh, 245px); }
  .artwork-border { inset: 8px; }
  .stage[data-view="question"] .artwork {
    order: -1;
    min-height: clamp(96px, calc(100dvh - 466px), 280px);
  }
  .stage[data-view="question"] .landscape { object-position: var(--scene-position, center); }
  .progress-row { margin-bottom: 7px; }
  .question h1 { font-size: clamp(19px, 5.5vw, 26px); line-height: 1.36; }
  fieldset { margin-block: 9px; }
  .option-list { gap: 6px; }
  .option-body { min-height: 44px; padding: 6px 8px; gap: 8px; font-size: 14px; line-height: 1.4; }
  .stage[data-view="result"] .artwork { order: -1; min-height: clamp(108px, calc(100dvh - 470px), 270px); }
  .result-heading { --name-size: clamp(35px, 10vw, 52px); }
  .stage[data-mixed="true"] .result h1 { font-size: clamp(22px, 6.2vw, 37px); }
}

@media (orientation: landscape) and (max-height: 600px) and (max-width: 1100px) {
  .share-dialog[open] {
    --share-padding-block: clamp(12px, 4dvh, 22px);
    display: grid;
    grid-template-areas: 'preview heading' 'preview controls';
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.65fr);
    align-content: safe center;
    gap: 10px clamp(12px, 3vw, 28px);
    width: min(680px, calc(100% - 24px));
    min-height: min(300px, calc(100dvh - 24px));
    padding: var(--share-padding-block) clamp(12px, 3vw, 24px);
  }
  .share-dialog > form { position: absolute; inset: 4px 4px auto auto; }
  .share-dialog .close-button { position: static; width: 44px; height: 44px; line-height: 1; }
  .share-dialog .share-preview {
    grid-area: preview;
    place-self: center;
    max-height: min(268px, calc(100dvh - 26px - 2 * var(--share-padding-block)));
    margin: 0;
  }
  .share-heading { grid-area: heading; align-self: end; padding-inline-end: 32px; }
  .share-heading h2 { font-size: clamp(18px, 3.2vw, 26px); line-height: 1.3; }
  .share-heading p { margin: 6px 0 0; line-height: 1.5; }
  .share-controls { grid-area: controls; align-self: start; min-width: 0; }
  .share-dialog input { margin-bottom: 8px; }
  .share-actions { gap: 8px; }
  .share-actions .button { min-height: 44px; padding: 7px 12px; font-size: 14px; }
  .share-dialog .share-status { margin-top: 6px; line-height: 1.45; }

  .stage, .site-header { width: calc(100% - clamp(24px, 5vw, 48px)); }
  .site-header { height: 50px; }
  .brand { gap: 8px; }
  .brand img { width: 49px; height: 47px; }
  .brand span { padding-left: 8px; font-size: 17px; }
  .site-link { font-size: 14px; }
  .stage {
    grid-template-columns: minmax(0, .75fr) minmax(0, 1.55fr);
    min-height: 0; margin: 5px auto 8px;
  }
  .panel { grid-area: 1 / 2; padding: clamp(8px, 1.65vw, 18px); }
  .artwork { grid-area: 1 / 1; min-height: 0; }
  .stage[data-view="question"] .artwork {
    order: 0;
    align-self: center;
    min-height: 0;
    aspect-ratio: 1;
  }
  .stage[data-view="question"] .landscape { object-fit: contain; }
  .stage[data-view="question"] .artwork.has-panels .landscape {
    object-fit: cover;
    object-position: var(--scene-position, center);
  }
  .intro h1 { font-size: clamp(23px, 4vw, 40px); }
  .lede { margin: 8px 0 11px; }
  .factions { margin-top: 11px; padding-top: 8px; gap: 5px 10px; }
  .factions li { font-size: 15px; }
  .factions img { width: 28px; }
  .progress-row { margin-bottom: 5px; }
  .question h1 { font-size: clamp(17px, 2.6vw, 23px); line-height: 1.34; }
  fieldset { margin-block: 8px; }
  .option-list { gap: 5px; }
  .option-body { min-height: 44px; padding: 5px 8px; gap: 8px; font-size: 14px; line-height: 1.4; }
  .stage[data-view="result"] { grid-template-columns: minmax(0, .64fr) minmax(0, 1.66fr); }
  .stage[data-view="result"] .artwork { order: 0; min-height: 0; }
  .result-heading { --name-size: clamp(31px, 4.8vw, 50px); }
  .result-description, .result-lore { font-size: 13px; line-height: 1.4; }
  .result-motto { margin-block: 3px 6px; }
  .result-tags { margin-bottom: 6px; }
  .result-scores { margin-top: 5px; padding-top: 4px; }
}

@media (orientation: portrait) and (max-width: 700px) and (max-height: 600px) {
  .stage[data-view="result"] .artwork { min-height: 96px; }
  .stage[data-view="result"] .panel { padding-block: 12px; }
  .result-description, .result-lore { font-size: 13px; }
  .result-actions { margin-top: 5px; }
}

@media (orientation: landscape) and (max-height: 320px) and (max-width: 1100px) {
  .stage { grid-template-columns: minmax(0, .57fr) minmax(0, 1.73fr); margin: 4px auto 5px; }
  .site-header { height: 44px; }
  .brand img { width: 43px; height: 41px; }
  .panel { padding-block: 6px; }
  .lede { margin-block: 6px 8px; }
  .factions { margin-top: 8px; padding-top: 6px; }
  .stage[data-view="question"] { --scene-thumb: clamp(46px, 10vw, 62px); grid-template-columns: minmax(0, 1fr); }
  .stage[data-view="question"] .panel { grid-area: 1 / 1; }
  .stage[data-view="question"] .artwork {
    position: absolute;
    inset: 7px 8px auto auto;
    width: var(--scene-thumb);
  }
  .stage[data-view="question"] .artwork-border { display: none; }
  .question :is(.progress-row, h1) { margin-inline-end: calc(var(--scene-thumb) + 8px); }
  .question h1 { min-height: calc(var(--scene-thumb) - 20px); }
  .option-list { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .option-body { display: block; height: 100%; font-size: 13px; }
  .option-letter { display: inline-grid; width: 18px; height: 18px; margin-inline-end: 4px; }
  .stage[data-view="result"] { grid-template-columns: minmax(0, 1fr); }
  .stage[data-view="result"] .panel { grid-area: 1 / 1; }
  .stage[data-view="result"] .artwork {
    position: absolute; inset: 7px 8px auto auto; width: 72px; height: 56px;
  }
  .stage[data-view="result"][data-mixed="false"] .result-portrait {
    inset: 3px; width: calc(100% - 6px); height: calc(100% - 6px);
  }
  .stage[data-view="result"] :is(.artwork-border, .portrait-caption) { display: none; }
  .result { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; }
  .result-summary {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0 8px;
    grid-column: 1 / -1; margin-inline-end: 80px;
  }
  .result-summary :is(.result-label, .result-motto) { margin: 0; font-size: 12px; }
  .result-heading { --name-size: 26px; }
  .stage[data-mixed="true"] .result h1 { font-size: 22px; }
  .result-tags { grid-column: 1 / -1; margin: 3px 80px 5px 0; }
  .result-tags li { padding: 2px 6px; font-size: 12px; }
  .result-description, .result-lore { font-size: 12px; line-height: 1.4; }
  .result-description { grid-area: 3 / 1; }
  .result-lore { grid-area: 3 / 2; margin: 0; }
  .result-description:has(+ .result-lore[hidden]), .result-description[hidden] + .result-lore { grid-column: 1 / -1; }
  .result-scores { grid-area: 4 / 1 / 5 / -1; }
  .result-actions { grid-area: 5 / 1 / 6 / -1; margin-top: 4px; padding-inline-end: 66px; }
  .retake { grid-area: 5 / 2; justify-self: end; align-self: end; }
}

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