/* P3 pigment tokens; deeper water shades keep the original gouache art untouched. */
:root {
  --paper: #EADCC0;
  --gold: #D5A34E;
  --terra: #B97059;
  --green: #4E9B88;
  --blue: #425A78;
  --ink: #252535;
  --red: #C94F45;
  --water: #183446;
  --deep: #102735;
  --surface: #335568;
  --card: #b6d0d4;
  --card-white: #d5e3de;
  --white: #f0ead9;
  --muted: #afc7ce;
  --line: #759aab50;
  --card-line: #425a7852;
  --font: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  font-family: var(--font);
  color: var(--white);
  background: var(--deep);
  font-synthesis: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 25% 0, #425a7860, transparent 60%), var(--deep);
}
button, a, textarea { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
a { color: inherit; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, a:focus-visible, summary:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 4px;
}
button:not(:disabled):active { transform: translateY(2px); }
h1, h2, p { overflow-wrap: anywhere; }
h1, h2, p, figure { margin: 0; }
h1 { font-family: var(--serif); font-weight: 800; }
h1:focus { outline: none; }
p { line-height: 1.8; }
[hidden] { display: none !important; }
.book {
  width: 100%; max-width: 430px; min-height: 100svh;
  margin: auto; position: relative; isolation: isolate;
  background: radial-gradient(ellipse at 14% 0%, #4e9b8830, transparent 38%),
    radial-gradient(ellipse at 95% 22%, #425a7860, transparent 52%),
    linear-gradient(174deg, #2b4b5d 0, var(--water) 45%, #102a39 100%);
  box-shadow: 0 20px 100px #0004;
}
/* Soft light through water, never a substitute for illustrated characters. */
.book::before {
  content: ""; position: absolute; z-index: -1; inset: 0 0 auto; height: 790px;
  background: linear-gradient(114deg, transparent 13%, #b6d0d408 14%, #b6d0d414 19%, transparent 31%),
    linear-gradient(103deg, transparent 31%, #b6d0d40c 32%, transparent 49%);
  pointer-events: none;
}
.masthead {
  min-height: 87px; margin: 0 26px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 1px solid var(--line);
}
.masthead a { text-decoration: none; font-family: var(--serif); font-size: 21px; font-weight: 800; letter-spacing: 1px; }
.masthead a span { display: block; font: 8px/1.5 var(--font); letter-spacing: 1.9px; color: var(--muted); margin-top: 5px; }
.edition { font-size: 9px; text-align: right; line-height: 1.9; letter-spacing: 1.3px; color: var(--muted); }
.page-tabs { display: flex; gap: 26px; padding: 0 26px; height: 44px; }
.page-tabs button { border: 0; border-bottom: 2px solid transparent; padding: 0 1px; background: transparent; font-size: 11px; color: var(--muted); }
.page-tabs button[aria-current=page] { color: var(--paper); border-bottom-color: var(--gold); }
main { padding: 25px 24px 28px; min-height: 420px; }
.eyebrow { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); }
.cover { text-align: center; }
.cover-heading { position: relative; z-index: 1; }
.cover h1 { font-size: 30px; line-height: 1.48; letter-spacing: 2px; margin: 12px 0 10px; }
.cover h1 span { display: block; color: var(--paper); font-size: 38px; line-height: 1.35; letter-spacing: 5px; }
.cover-intro { font-size: 12px; color: var(--muted); }
.cover-vignette {
  position: relative; height: 276px; margin: 20px 0 21px; overflow: hidden;
  border: 1px solid #d5a34e65; border-radius: 48% 48% 8px 8px;
  box-shadow: 0 9px 22px #0b202936; background: var(--water);
}
.cover-art { width: 100%; height: auto; display: block; position: absolute; top: -118px; left: 0; }
.cover-bottom { padding: 0 5px; }
.primary, .secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 50px; padding: 13px 19px; border: 1px solid var(--ink); border-radius: 5px;
  font-size: 14px; font-weight: 700; line-height: 1.5;
}
.primary { background: var(--gold); color: var(--ink); box-shadow: 0 3px 0 #122938; }
.primary:not(:disabled):hover { background: #dfb261; }
.cover .primary { width: 100%; justify-content: space-between; padding-left: 23px; padding-right: 23px; }
.cover .primary span { font-size: 21px; font-weight: 400; }
.cover-meta { font-size: 10px; letter-spacing: .6px; color: var(--muted); margin-top: 12px; }
.secondary { background: #27485a; color: var(--white); border-color: var(--line); }
.text-button { min-height: 44px; border: 0; background: transparent; padding: 10px 0; font-size: 12px; text-underline-offset: 4px; }
.small, .storage-note { font-size: 10px; line-height: 1.8; color: var(--muted); }
.home-storage { margin-top: 12px; text-align: center; }
.question-sheet {
  position: relative; isolation: isolate; color: var(--ink); padding: 25px 23px 27px;
  background: var(--card); border-radius: 6px; box-shadow: 0 8px 24px #061a2c33;
}
/* Reuse the inked PNG frame and paper grain with a cool printed-paper tint. */
.question-sheet::before, .specimen-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: url('../assets/bestiary/question-paper.png') center / 100% 100% no-repeat;
  filter: grayscale(1); mix-blend-mode: multiply; opacity: .58; border-radius: inherit;
}
.quiz-top { display: flex; justify-content: space-between; gap: 8px; padding: 0 15px; font-size: 10px; color: #425a78; }
.progress { height: 3px; border-radius: 2px; overflow: hidden; background: #425a7825; margin-top: 12px; }
.progress span { display: block; height: 100%; background: #376d69; transition: width .2s; }
.question-heading { display: flex; justify-content: space-between; align-items: center; height: 85px; margin-top: 12px; }
.question-number { font: 48px/1 var(--serif); color: var(--blue); }
.question-number span { font: 11px/1 var(--font); letter-spacing: 1px; margin-left: 9px; color: var(--blue); }
.ornament-slot { width: 81px; height: 81px; flex-shrink: 0; }
.question-ornament { width: 100%; height: 100%; display: block; object-fit: contain; }
.question-prompt {
  min-height: calc(1.5em * 2 + 8px);
  margin: 4px 0 8px;
}
.question-sheet h1 {
  font-size: 22px; line-height: 1.5; letter-spacing: .3px; margin: 0; text-wrap: pretty;
  min-height: calc(1.5em * 2);
}
.question-hint { font-size: 10px; color: var(--blue); margin: 0 0 16px; min-height: 1.4em; }
.options {
  display: grid; gap: 10px;
  min-height: calc(4 * 64px + 3 * 10px);
}
.option {
  display: flex; align-items: center; gap: 12px; width: 100%;
  height: 64px; min-height: 64px; max-height: 64px;
  padding: 10px 14px; border: 1px solid var(--card-line); border-radius: 5px;
  background: #e0eae3a6; text-align: left; font-size: 13px; line-height: 1.45;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.option > span:last-child {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; flex: 1; min-width: 0;
}
.option-key { flex: 0 0 22px; font: 18px/1.2 var(--serif); color: var(--blue); }
.option:hover:not([aria-checked=true]) { background: #e8f0eacc; border-color: #425a7880; }
.option[aria-checked=true] {
  color: var(--white); background: var(--water); border-color: var(--water);
  box-shadow: 2px 2px 0 var(--gold);
}
.option[aria-checked=true] .option-key { color: var(--gold); }
.question-sheet button:focus-visible { outline-color: var(--ink); }
.quiz-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 25px; }
.quiz-nav .primary { min-width: 133px; min-height: 47px; font-size: 13px; }
.quiz-nav .text-button { color: var(--blue); }
.storage-note { margin: 17px 5px 0; text-align: center; }
.result { padding-top: 0; }
.preview-note { padding: 0 2px 16px; font-size: 10px; color: var(--muted); }
.specimen-card {
  position: relative; isolation: isolate; aspect-ratio: 3/4; display: flex; flex-direction: column;
  padding: 9px 25px 16px; background: var(--card); border-radius: 5px; color: var(--ink);
  box-shadow: 0 10px 30px #061a2c44;
}
.specimen-card::before { background-image: url('../assets/bestiary/result-frame.png'); opacity: .72; }
.specimen-meta { height: 26px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; font-size: 10px; letter-spacing: 1.7px; }
/* specimen-no + specimen-who both visible */
.reveal-art { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; }
.creature { width: 100%; height: 100%; object-fit: contain; max-height: 310px; }
.stage-label { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 9px; color: var(--blue); }
.specimen-label { position: relative; text-align: center; min-height: 50px; margin-top: 10px; }
.mini-label { font-size: 9px; letter-spacing: 1.5px; color: var(--blue); }
.specimen-label h1 { font-size: 25px; line-height: 1.4; margin: 4px 0 0; }
.result-copy { margin: 25px 4px 0; }
.tagline { font: 700 22px/1.6 var(--serif); letter-spacing: .5px; margin: 0 0 15px; color: var(--paper); }
.description { font-size: 13px; line-height: 2; color: #d1dfdf; }
.traits { display: flex; flex-wrap: wrap; gap: 6px; margin: 19px 0; }
.trait { font-size: 10px; padding: 4px 9px; color: #b6d0d4; border: 1px solid var(--line); border-radius: 3px; background: #4e9b8810; }
blockquote { margin: 21px 0 26px; padding: 3px 0 3px 14px; border-left: 2px solid var(--green); font: 16px/1.8 var(--serif); color: var(--paper); }
.detail-grid { display: grid; }
.detail { padding: 17px 4px; border-top: 1px solid var(--line); }
.detail h2 { font-size: 10px; letter-spacing: 1px; color: var(--muted); margin: 0 0 7px; font-weight: 500; }
.detail p { font-size: 12px; line-height: 1.85; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 22px; }
.result-actions .primary, .result-actions .text-button { grid-column: 1/-1; }
.result-actions .secondary { font-size: 12px; padding: 12px 7px; }
.result-details > .small { margin-top: 18px; }
.about { border-top: 1px solid var(--line); margin-top: 23px; padding-top: 14px; }
.about summary { font-size: 11px; cursor: pointer; padding: 7px 0; color: var(--muted); line-height: 1.7; }
.about p { font-size: 12px; line-height: 1.85; margin: 14px 0; color: #c4d7da; }
.axis-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.axis-row strong { font-size: 12px; }
.axis-row span { display: block; font-size: 10px; color: var(--muted); margin-top: 5px; }
.axis-row p { margin: 7px 0 0; }
.site-footer {
  margin: 0 26px; min-height: 100px; padding: 20px 0 max(22px, env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-top: 1px solid var(--line); color: var(--muted);
}
.footer-contact { display: flex; align-items: center; gap: 9px; text-decoration: none; font-size: 9px; line-height: 1.8; }
.footer-contact b { font-size: 10px; font-weight: 500; color: #d1dfdf; }
.pixel-monkey { image-rendering: pixelated; flex-shrink: 0; }
.footer-note { font-size: 9px; line-height: 1.9; text-align: right; letter-spacing: .5px; }
.notice { position: fixed; z-index: 10; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 36px); padding: 12px 16px; background: var(--ink); color: var(--white); border: 1px solid var(--gold); font-size: 12px; border-radius: 5px; }
.notice:empty { display: none; }
.manual-copy textarea { display: block; width: 100%; min-height: 170px; margin-top: 12px; padding: 12px; background: var(--water); color: var(--white); border: 1px solid var(--line); font: 12px/1.8 var(--font); }
.error { padding: 35px 4px; }
.error h1 { font-size: 28px; margin: 16px 0; }
.error p { font-size: 13px; }
.error .primary { margin-top: 22px; }
.loading { text-align: center; margin-top: 120px; font-size: 13px; }
.asset-missing { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; color: var(--blue); padding: 20px; text-align: center; }
.reveal-art[data-stage=prepared] .creature { opacity: 0; }
.reveal-art[data-stage=silhouette] .creature { filter: brightness(0); opacity: .88; }
.reveal-art[data-stage=fill] .creature { animation: ink-in .65s steps(5) both; }
.reveal-art[data-stage=motion] .creature,
.reveal-art[data-stage=dock] .creature,
.reveal-art[data-stage=shown] .creature { filter: none; opacity: 1; }
.reveal-art[data-stage=motion] .creature { animation: specimen-hop .55s steps(3) 2; }
.reveal-copy[data-stage=pending] { opacity: 0; transform: translateY(12px); pointer-events: none; }
.reveal-copy[data-stage=shown] { opacity: 1; transform: none; transition: opacity .55s ease, transform .55s ease; }
.specimen-label[data-stage=pending] { visibility: hidden; max-height: 0; min-height: 0; margin: 0; overflow: hidden; }
.specimen-label[data-stage=shown] { visibility: visible; max-height: 80px; transition: max-height .35s ease; }
.result[data-revealing=true] .result-details { visibility: hidden; height: 0; overflow: hidden; margin: 0; padding: 0; border: 0; }
.result[data-revealing=true]:not([data-stage=dock]):not([data-stage=shown]) .specimen-label { visibility: hidden; }
@keyframes ink-in { from { opacity: .35; filter: grayscale(1) brightness(.55); } to { opacity: 1; filter: none; } }
@keyframes specimen-hop { 0%,100% { transform: translateY(0) rotate(0); } 40% { transform: translateY(-7px) rotate(-2deg); } 70% { transform: translateY(-3px) rotate(2deg); } }
@media (min-width: 431px) { body { padding: 24px 0; } .book { min-height: calc(100svh - 48px); border: 1px solid var(--line); } }
@media (min-width: 410px) { .cover-vignette { height: 292px; } .cover-art { top: -125px; } }
@media (max-width: 374px) {
  main { padding-left: 18px; padding-right: 18px; }
  .masthead { margin: 0 21px; } .masthead a { font-size: 19px; }
  .page-tabs { padding-left: 21px; }
  .question-sheet { padding-left: 21px; padding-right: 21px; }
  .question-sheet h1 { font-size: 21px; }
  .cover h1 { font-size: 27px; } .cover h1 span { font-size: 34px; }
  .cover-vignette { height: 246px; } .cover-art { top: -108px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal-copy { opacity: 1 !important; transform: none !important; }
  .specimen-label { visibility: visible !important; max-height: none !important; }
}
