:root {
  color-scheme: light;
  --page: #f4f8f7;
  --paper: #fffdf7;
  --white: #ffffff;
  --ink: #173747;
  --muted: #48636c;
  --line: #cbdcd9;
  --accent: #126575;
  --accent-hover: #0d4f5d;
  --accent-soft: #e4f3ef;
  --heading: "Yu Mincho", YuMincho, "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
  --body: "Yu Gothic UI", "Hiragino Sans", Meiryo, "Noto Sans CJK JP", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 1rem; }
body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 1rem/1.72 var(--body);
}
main { flex: 1; }
button, textarea { font: inherit; }
a { color: inherit; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
:focus:not(:focus-visible) { outline: none; }
.skip-link {
  position: fixed;
  top: .5rem;
  left: .5rem;
  z-index: 3;
  transform: translateY(-150%);
  padding: .5rem 1rem;
  border-radius: .4rem;
  background: var(--white);
  color: var(--ink);
}
.skip-link:focus { transform: translateY(0); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell { width: min(100% - 3rem, 72rem); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: #fcfdfa; }
.header-inner, .footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .65rem 1.5rem;
}
.header-inner { min-height: 3.9rem; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 1.8rem;
  height: 1.8rem;
  place-items: center;
  border-radius: .35rem;
  background: var(--accent);
  color: #fffdf2;
}
.brand-name { font: 800 1.16rem/1.2 var(--heading); letter-spacing: .1em; }
.header-link {
  display: grid;
  min-height: 2.75rem;
  place-items: center;
  padding-inline: .3rem;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
}
.header-link:hover { color: var(--accent-hover); text-decoration: underline; }
body:has(#quiz-screen:not([hidden]), #tie-screen:not([hidden]), #result-screen:not([hidden])) .header-link { display: none; }
.site-footer { border-top: 1px solid var(--line); padding-block: .9rem; }
.footer-inner { flex-wrap: wrap; color: var(--muted); font-size: .82rem; }

.button {
  display: inline-flex;
  min-height: 2.875rem;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .65rem 1.06rem;
  border: 1px solid transparent;
  border-radius: .55rem;
  cursor: pointer;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.button-primary { background: var(--accent); color: var(--white); }
.button-primary:hover { background: var(--accent-hover); }
.button-secondary { border-color: #a9c4c4; background: var(--white); color: var(--ink); }
.button-secondary:hover { border-color: var(--accent); background: var(--accent-soft); }
.button:disabled, .button[aria-disabled="true"] {
  border-color: #d3dfdd;
  background: #f3f7f5;
  color: #536d74;
  cursor: default;
}
.button-text { background: transparent; color: var(--muted); }
.button-text:hover, .text-control:hover { color: var(--accent-hover); text-decoration: underline; }
.status-line { margin: .65rem 0 0; color: var(--muted); font-size: .875rem; }
.status-line:empty { display: none; }
.error-line { color: #923423; }

.storage-notice {
  display: flex;
  width: min(100% - 2rem, 51rem);
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .7rem auto 0;
  padding: .55rem .65rem;
  border: 1px solid #c3d7cc;
  border-radius: .55rem;
  background: var(--paper);
}
.storage-notice p { flex: 1 1 17rem; margin: 0; font-size: .9rem; }
.storage-notice .button { font-size: .875rem; }

.page-shell { padding-top: clamp(1rem, 3.5vw, 2.4rem); }
.hero {
  position: relative;
  display: grid;
  min-height: clamp(27rem, 48vw, 35rem);
  isolation: isolate;
  overflow: hidden;
  border: 1px solid #b6d6d9;
  border-radius: 1rem;
  background: #eaf6ee;
  box-shadow: 0 .7rem 1.75rem #16485a0b;
}
.hero-art {
  position: absolute;
  inset: 0;
  z-index: -2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 61% 66%;
}
.hero::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, #f9f9edfa, #e6f5efee 24%, #e8f6eeb3 38%, #e8f6ee29 54%, transparent 66%);
}
.hero-copy {
  align-self: center;
  max-width: min(100%, 35rem);
  padding: clamp(1.75rem, 5.2vw, 4rem);
}
.eyebrow {
  margin: 0 0 .8rem;
  color: #2a5867;
  font-size: .875rem;
  font-weight: 750;
  letter-spacing: .12em;
}
.eyebrow span { margin-right: .3rem; }
.hero h1 {
  margin: 0;
  font: 800 clamp(2.55rem, 5.7vw, 4.6rem)/1.16 var(--heading);
  letter-spacing: -.05em;
}
.hero h1 span, .hero h1 em { display: block; }
.hero h1 em { color: #205e71; font-style: normal; }
.hero-description {
  margin: 1.25rem 0 .9rem;
  max-width: 29rem;
  font-size: 1rem;
  line-height: 1.85;
}
.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .55rem;
  margin: 0 0 1.3rem;
  padding: 0;
  list-style: none;
}
.hero-facts li {
  padding: .2rem .58rem;
  border: 1px solid #9cbfbd;
  border-radius: .38rem;
  background: #fffffff0;
  color: #3f5e67;
  font-size: .82rem;
}
.hero-facts b { color: var(--ink); }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .38rem .65rem; }
.hero-actions .button-primary { min-height: 3.15rem; padding-inline: 1.28rem; }

.guide { padding: clamp(1.55rem, 3vw, 2.3rem) 0 2.1rem; }
.guide-heading { display: flex; align-items: center; gap: .6rem; margin-bottom: .85rem; }
.guide-heading span { color: var(--accent); font-size: .75rem; }
.guide-heading h2, .profile-panel h2, .reason-panel h2 {
  margin: 0;
  font: 800 clamp(1.27rem, 3.75vw, 1.65rem)/1.45 var(--heading);
}
.guide-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
}
.guide-step {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--paper);
}
.step-symbol {
  display: grid;
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border-radius: .3rem;
  background: var(--accent-soft);
  color: var(--accent);
}
.guide-step h3 { margin: 0; font-size: .98rem; }
.guide-step p { margin: .15rem 0 0; color: var(--muted); font-size: .875rem; }

.play-section, .result-section {
  padding: clamp(.95rem, 3vw, 2rem) 0 clamp(2rem, 5vw, 3.2rem);
  background: linear-gradient(180deg, #e6f4f4, var(--page) 24rem);
}
.play-width { width: min(100% - 2rem, 42rem); margin-inline: auto; }
#home-button { display: none; }
body:has(#quiz-screen:not([hidden])) #home-button { display: inline-block; }
.text-control {
  min-height: 2.75rem;
  padding: .38rem .25rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 700;
}
.text-control span { margin-right: .2rem; }
.question-card {
  padding: clamp(1rem, 4vw, 2.2rem);
  border: 1px solid #c1d9da;
  border-radius: .95rem;
  background: var(--white);
  box-shadow: 0 .65rem 1.75rem #17444e0d;
}
.progress-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.chapter-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: .86rem;
  font-weight: 700;
}
#chapter-index {
  flex: none;
  white-space: nowrap;
  padding: .12rem .44rem;
  border-radius: .3rem;
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.question-progress { color: var(--muted); font-size: .86rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
#progress-meter {
  display: block;
  appearance: none;
  width: 100%;
  height: .36rem;
  margin: .65rem 0 1.28rem;
  overflow: hidden;
  border: 0;
  border-radius: 1rem;
  accent-color: var(--accent);
  background: #dcebec;
}
#progress-meter::-webkit-progress-bar { background: #dcebec; }
#progress-meter::-webkit-progress-value { border-radius: 1rem; background: var(--accent); }
#progress-meter::-moz-progress-bar { border-radius: 1rem; background: var(--accent); }
.question-card h1 {
  margin: 0 0 1.15rem;
  font: 800 clamp(1.34rem, 4.8vw, 1.96rem)/1.5 var(--heading);
  overflow-wrap: anywhere;
}
.choices { display: grid; gap: .6rem; min-width: 0; padding: 0; margin: 0; border: 0; }
.answer-option {
  position: relative;
  display: flex;
  min-height: 3.35rem;
  align-items: center;
  gap: .72rem;
  padding: .58rem .72rem;
  border: 1px solid #bdcfd0;
  border-radius: .56rem;
  background: #fbfdfb;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.answer-option:hover { border-color: #6c969c; background: #f0f7f5; }
.answer-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.answer-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.answer-option:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--accent-soft);
}
.answer-key {
  display: grid;
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  place-items: center;
  border: 1px solid #b1cbca;
  border-radius: .35rem;
  color: #3b5d66;
  font-size: .85rem;
  font-weight: 800;
}
.answer-option:has(input:checked) .answer-key { border-color: var(--accent); background: var(--accent); color: var(--white); }
.answer-text { min-width: 0; overflow-wrap: anywhere; line-height: 1.5; }
.answer-indicator {
  margin-left: auto;
  color: var(--accent-hover);
  font-size: .94rem;
  font-weight: 800;
  visibility: hidden;
}
.answer-option:has(input:checked) .answer-indicator { visibility: visible; }
.question-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: .6rem; margin-top: 1.1rem; }

.result-width { width: min(100% - 2rem, 51rem); margin-inline: auto; }
.result-cover {
  --result-tint: #e8f5f3;
  --result-ink: #245968;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 38%);
  grid-template-areas: "heading art" "details art" "share art";
  grid-template-rows: 1fr auto 1fr;
  align-items: start;
  gap: .6rem clamp(1rem, 3vw, 2rem);
  padding: clamp(1rem, 4vw, 2.15rem);
  border: 1px solid #c8dbdc;
  border-radius: 1rem;
  background: linear-gradient(140deg, var(--paper), var(--result-tint));
  box-shadow: 0 .6rem 1.8rem #1f516112;
}
.result-section[data-group="advance"] .result-cover { --result-tint: #faeee4; --result-ink: #85462f; }
.result-section[data-group="observe"] .result-cover { --result-tint: #f0ebf9; --result-ink: #594577; }
.result-section[data-group="support"] .result-cover { --result-tint: #edf4e7; --result-ink: #45603e; }
.result-section[data-group="craft"] .result-cover { --result-tint: #f9f1e2; --result-ink: #755426; }
.result-section[data-group="free"] .result-cover { --result-tint: #eaf1fb; --result-ink: #405d85; }
.result-cover h1 {
  grid-area: heading;
  align-self: end;
  margin: 0;
  font: 800 clamp(1.85rem, 6vw, 3.35rem)/1.19 var(--heading);
}
.result-label {
  display: block;
  margin-bottom: .45rem;
  color: var(--result-ink);
  font: 750 .85rem/1.4 var(--body);
  letter-spacing: .08em;
}
#result-species { display: block; overflow-wrap: anywhere; }
.result-details { grid-area: details; }
#result-tagline {
  margin: 0 0 .68rem;
  color: var(--result-ink);
  font-weight: 700;
  font-size: clamp(.92rem, 2.7vw, 1.16rem);
  line-height: 1.6;
}
.result-skill {
  display: grid;
  justify-items: start;
  gap: .12rem;
  margin: 0;
  font-size: .96rem;
  line-height: 1.55;
}
.result-skill span { color: var(--muted); font-size: .76rem; font-weight: 750; }
.result-visual {
  grid-area: art;
  align-self: center;
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid #adc5d2;
  border-radius: .65rem;
  background: #cadde9;
}
.result-illustration { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.result-crest {
  display: grid;
  width: 60%;
  max-width: 7.5rem;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #7eacbb;
  border-radius: 50%;
  background: #e9f5f7;
  color: var(--result-ink);
  font: 800 clamp(1.5rem, 5vw, 3rem)/1 var(--heading);
}
.share-panel { grid-area: share; padding-top: .65rem; }
.share-actions { display: flex; flex-wrap: wrap; gap: .48rem; }
.share-actions .button { font-size: .9rem; }
.share-panel .status-line { font-size: .8rem; }
.copy-fallback {
  width: 100%;
  margin-top: .55rem;
  padding: .7rem;
  border: 1px solid #9bb9bc;
  border-radius: .45rem;
  background: var(--white);
  color: var(--ink);
}

.profile-panel, .reason-panel {
  margin-top: .9rem;
  padding: clamp(1rem, 4vw, 1.8rem);
  border: 1px solid var(--line);
  border-radius: .85rem;
  background: var(--white);
}
.profile-portrait { max-width: 37rem; margin: .65rem 0 .95rem; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.profile-card {
  padding: .85rem .9rem;
  border: 1px solid #d2e5de;
  border-radius: .55rem;
  background: #f2f8f4;
}
.profile-card + .profile-card { border-color: #e8dfce; background: #fbf7ee; }
.profile-card h3, .profile-role h3 { margin: 0; font-size: 1rem; }
.profile-card p, .profile-role p { margin: .32rem 0 0; line-height: 1.75; }
.profile-role { margin-top: 1.1rem; padding-left: .8rem; border-left: 3px solid #83b3b9; }
.profile-role h3 span { margin-right: .25rem; color: var(--accent); }
.result-reasons { display: grid; gap: .7rem; margin: .65rem 0 0; padding-left: 1.35rem; }
.result-reasons li::marker { color: var(--accent); font-weight: 750; }
.reason-question { display: block; color: var(--muted); font-size: .875rem; }
.reason-answer { display: block; font-weight: 650; }
.result-end { margin-top: 1rem; text-align: center; }

.reset-dialog {
  width: min(100% - 2rem, 25rem);
  padding: 1.25rem;
  border: 1px solid #acc7c9;
  border-radius: .75rem;
  color: var(--ink);
  background: var(--paper);
}
.reset-dialog::backdrop { background: #112e3a9c; }
.reset-dialog h2 { margin: 0; font-size: 1.2rem; }
.reset-dialog p { margin: .5rem 0 .9rem; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .6rem; }

@media (max-width: 740px) {
  .shell { width: calc(100% - 2rem); }
  .hero { min-height: 25rem; }
  .hero-copy { max-width: 72%; }
  .guide-steps { gap: .6rem; }
}

@media (max-width: 560px) {
  body { font-size: .96rem; }
  .header-inner { min-height: 3.35rem; }
  .hero { min-height: auto; }
  .hero-art { position: static; z-index: auto; height: auto; }
  .hero::before { content: none; }
  .hero-copy { width: 100%; max-width: none; padding: 1rem 1rem 1.2rem; }
  .eyebrow { margin-bottom: .45rem; }
  .hero h1 { font-size: clamp(2.1rem, 9vw, 3.15rem); }
  .hero-description { margin: .72rem 0 .75rem; line-height: 1.7; }
  .desktop-break { display: none; }
  .hero-facts { margin-bottom: .8rem; }
  .hero-actions .button-primary { flex: 1 1 10rem; }
  .guide-steps { grid-template-columns: 1fr; }
  .question-card h1 { margin-bottom: .95rem; }
  .answer-option { gap: .55rem; }
  .result-cover {
    grid-template-columns: minmax(0, 1fr) minmax(5.4rem, 36%);
    grid-template-areas: "heading art" "details art" "share share";
    grid-template-rows: auto 1fr auto;
    gap: .48rem .62rem;
  }
  .result-cover h1 { font-size: clamp(1.45rem, 6.2vw, 2rem); }
  .result-label { margin-bottom: .26rem; font-size: .76rem; letter-spacing: .03em; }
  #result-tagline { margin-bottom: .5rem; }
  .result-skill { font-size: .87rem; }
  .share-panel { padding-top: .45rem; }
  .share-actions .button { flex: 1; padding-inline: .35rem; }
  .profile-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}


.question-axis {
  color: var(--accent-hover);
  font-size: .82rem;
  font-weight: 750;
  margin: 0 0 .3rem;
}

.tie-card > p:not(.question-axis, .status-line) { margin: -.35rem 0 1rem; }
.tie-options { display: grid; gap: .55rem; }
.tie-options .button { justify-content: flex-start; text-align: left; }
#tie-back { margin-top: .55rem; }

.result-rule { margin: .55rem 0 .8rem; color: var(--muted); }
.result-factors, .result-tallies {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
}
.result-factor {
  padding: .7rem .8rem;
  border: 1px solid #c7dfd8;
  border-radius: .58rem;
  background: #eff8f3;
}
.factor-axis, .factor-score { margin: 0; color: var(--muted); font-size: .84rem; }
.factor-trait { display: block; margin: .18rem 0; color: var(--accent-hover); line-height: 1.5; }
.reason-subheading { margin: .95rem 0 .5rem; font-size: 1rem; }
.result-reasons { margin: 0; padding: 0; list-style: none; }
.result-reasons li { padding: .65rem .72rem; border-left: 3px solid #8bbac0; background: #f6faf9; }
.reason-axis { display: block; color: var(--accent-hover); font-size: .81rem; font-weight: 750; }
.reason-answer { margin-block: .16rem; }
.reason-signal { display: block; color: var(--muted); font-size: .87rem; }
.tally-details { margin-top: .82rem; border-top: 1px solid var(--line); }
.tally-details summary, .supporting-group summary {
  display: list-item;
  min-height: 2.75rem;
  padding: .68rem .15rem;
  color: var(--accent-hover);
  cursor: pointer;
  font-size: .92rem;
  font-weight: 750;
}
.tally-details h4 { margin: 0; font-size: .89rem; }
.tally-list { margin: .2rem 0 0; padding: 0; list-style: none; }
.tally-list li {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  padding: .24rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .86rem;
}
.tally-count { flex: none; font-variant-numeric: tabular-nums; }

@media (max-width: 420px) {
  .result-factors, .result-tallies { grid-template-columns: 1fr; }
}


.factor-context { margin: .23rem 0 0; color: var(--muted); font-size: .8rem; }
.result-bridge {
  margin: .7rem 0 0;
  padding: .6rem .75rem;
  border-left: 3px solid #93b7ad;
  background: #f5faf6;
}
.result-supporting { display: grid; gap: .22rem; }
.supporting-group { border-top: 1px solid var(--line); }
.supporting-group[open] { padding-bottom: .55rem; }
.supporting-list { display: grid; gap: .5rem; margin: .35rem 0 0; padding: 0; list-style: none; }
.supporting-list li { padding: .35rem .55rem; border-left: 2px solid var(--line); }
.supporting-answer { display: block; font-size: .95rem; }

/* On a short phone, only the question text and answers scroll. */
@media (max-width: 560px) and (min-height: 380px) and (max-height: 720px) {
  body:has(#quiz-screen:not([hidden])) {
    height: 100vh;
    height: 100dvh;
  }
  body:has(#quiz-screen:not([hidden])) .header-inner { min-height: 2.75rem; }
  body:has(#quiz-screen:not([hidden])) .site-footer { display: none; }
  body:has(#quiz-screen:not([hidden])) main {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }
  #quiz-screen {
    display: grid;
    grid-row: 2;
    min-height: 0;
    padding: .24rem 0 max(.56rem, env(safe-area-inset-bottom));
  }
  #quiz-screen .play-width {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    min-height: 0;
  }
  #quiz-screen .question-card {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 0;
    padding: 0;
  }
  #quiz-screen .question-pane {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    scroll-padding-block: .45rem;
    padding: .57rem .65rem .63rem;
  }
  #quiz-screen #progress-meter { margin-block: .35rem .57rem; }
  #quiz-screen .question-card h1 { margin-bottom: .62rem; font-size: 1.19rem; line-height: 1.42; }
  #quiz-screen .choices { gap: .4rem; }
  #quiz-screen .answer-option { min-height: 2.75rem; gap: .45rem; padding: .3rem .45rem; }
  #quiz-screen .answer-text { line-height: 1.38; }
  #quiz-screen .question-actions {
    margin: 0;
    padding: .45rem .72rem;
    border-top: 1px solid var(--line);
    border-radius: 0 0 .95rem .95rem;
    background: var(--white);
  }
  #quiz-screen .question-actions .button { padding: .42rem .55rem; }
}
