:root {
  color-scheme: light;
  --background: #fff9f2;
  --panel: #fffdfb;
  --panel-light: #f4ebf9;
  --line: #d4c3db;
  --text: #32273e;
  --muted: #5f5069;
  --accent: #744483;
  --gold: #79502f;
  --paper: #fffaf4;
  --ink: #302236;
  --ui: "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  --display: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif CJK JP", serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0, #eee2f5 0, transparent 70%), var(--background);
  color: var(--text);
  font: 16px/1.65 var(--ui);
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, p, dl, dd { margin: 0; }
h1 { overflow-wrap: anywhere; }
h1[tabindex="-1"]:focus { outline: none; }

.shell {
  --pad-left: max(16px, env(safe-area-inset-left));
  --pad-right: max(16px, env(safe-area-inset-right));
  max-width: 1160px;
  margin-inline: auto;
  padding: env(safe-area-inset-top) var(--pad-right) env(safe-area-inset-bottom) var(--pad-left);
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  border-bottom: 1px solid var(--line);
}
.home-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font: 700 14px/1.25 var(--display);
  letter-spacing: .065em;
}
.moon-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #c2a8c7;
  background: #fff8ed;
  color: var(--gold);
  font: 22px/1 var(--ui);
}
.edition { color: var(--muted); font-size: 12px; }
.site-footer {
  padding: 24px 0 18px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}
.stage { margin: 0 auto; min-width: 0; }
.narrow { max-width: 590px; }

.home {
  display: grid;
  grid-template-areas: "copy" "art" "actions";
  max-width: 550px;
  padding-top: clamp(22px, 5vh, 48px);
  text-align: center;
}
.hero-copy { grid-area: copy; }
.chapter {
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .075em;
}
.chapter span { margin-left: 4px; color: var(--accent); }
.hero-copy h1 {
  margin: 8px 0 9px;
  font: 700 clamp(35px, 10vw, 60px)/1.14 var(--display);
  letter-spacing: .025em;
}
.hero-copy em { font-style: normal; color: var(--accent); }
.intro {
  color: var(--muted);
  font-size: clamp(13px, 3.8vw, 16px);
  line-height: 1.7;
}
.hero-art, .result-illustration, .pair-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 52% 76%, #f8dce8 0, transparent 69%),
    linear-gradient(145deg, #ece4fa, #f3e6f3 58%, #fff0de);
}
.hero-art {
  grid-area: art;
  height: clamp(172px, 27vh, 290px);
  margin-top: 14px;
  border: 1px solid #d7c1dd;
  border-radius: 21px;
}
.moon-disc {
  position: absolute;
  z-index: -1;
  top: 4%;
  left: 50%;
  width: min(51%, 245px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  border: 1px solid #f4dfb6;
  background: radial-gradient(circle at 38% 28%, #fffef2, #fff1d5 76%, #f4dabc);
  box-shadow: 0 0 60px #fff2d9ba, inset -9px -8px 25px #c88c8e20;
}
.moon-ring {
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: 94%;
  height: 55%;
  transform: translate(-50%, -50%) rotate(-13deg);
  border: 1px solid #b987ab70;
  border-radius: 50%;
}
.spark { position: absolute; color: #9a6594; line-height: 1; }
.star-a { top: 26%; left: 11%; font-size: 23px; }
.star-b { top: 12%; right: 16%; font-size: 18px; }
.star-c { right: 8%; bottom: 34%; font-size: 24px; }
.star-d { left: 23%; bottom: 13%; font-size: 13px; }
.hero-portrait {
  position: absolute;
  top: 7%;
  width: 58%;
  height: 110%;
  object-fit: contain;
  object-position: center top;
  filter: drop-shadow(0 5px 9px #54314d38);
}
.hero-left { left: 1%; transform: rotate(-5deg); }
.hero-right { right: -1%; transform: translateY(4%) rotate(5deg); }
.art-edge {
  position: absolute;
  z-index: 2;
  inset: auto 0 0;
  height: 30%;
  pointer-events: none;
  background: linear-gradient(transparent, #f3d9e6b0);
}
.hero-actions { grid-area: actions; margin: 14px 0 0; }
.hero-actions .primary { max-width: 360px; margin-inline: auto; }
.hero-actions .quiet { max-width: 360px; margin: 5px auto 0; }
.quiz-size { margin-top: 7px; color: var(--muted); font-size: 12px; letter-spacing: .075em; }

.button {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.4;
  color: inherit;
}
.button .arrow { line-height: 1; font-size: 19px; }
.primary { border-color: #bb7fa3; background: #f3c9df; color: #3b243c; box-shadow: 0 3px 0 #bd86a5; }
.primary:hover { background: #f6d5e7; }
.secondary { border-color: #b49bc1; background: var(--panel-light); }
.secondary:hover, .option:hover, .person:hover { background: #ece2f4; }
.quiet { border-color: transparent; background: none; color: var(--muted); font-weight: 600; }
.quiet:hover, .back:hover { color: var(--text); }
.button:active, .option:active, .person:active { transform: translateY(1px); }

.quiz-screen, .select-screen, .card-screen { padding-top: clamp(12px, 4vh, 38px); }
.back {
  min-height: 44px;
  padding: 0 4px 0 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}
.progress-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
}
.counter { justify-self: end; color: var(--muted); font-variant-numeric: tabular-nums; }
progress {
  display: block;
  width: 100%;
  height: 5px;
  appearance: none;
  border: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #e5d6ed;
}
progress::-webkit-progress-bar { background: #e5d6ed; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 10px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 10px; }
.question {
  margin: clamp(20px, 5vh, 38px) 0 17px;
  font: 700 clamp(22px, 6.1vw, 36px)/1.45 var(--display);
}
.options, .action-stack { display: grid; gap: 10px; }
.option, .person {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  font-size: 15px;
  line-height: 1.45;
}
.option { padding: 12px 15px; }
.option span, .person-arrow { color: var(--accent); font-size: 22px; line-height: 1; }

.result-screen { display: grid; max-width: 580px; gap: 16px; padding-top: 16px; }
.result-illustration { border: 1px solid #d7c1dd; border-radius: 19px; height: clamp(158px, 29vh, 265px); }
.result-illustration .moon-disc { width: min(52%, 225px); top: 4%; }
.result-portrait { display: block; width: 100%; height: 108%; object-fit: contain; object-position: center top; filter: drop-shadow(0 5px 9px #54314d38); }
.result-copy { min-width: 0; }
.result-copy h1, .select-screen h1 {
  margin: 4px 0;
  font: 700 clamp(27px, 7vw, 41px)/1.35 var(--display);
}
.result-copy h1 small { font: 700 .51em/1 var(--ui); margin-left: .34em; }
.type-line { color: var(--accent); font-size: 15px; font-weight: 700; }
.result-description, .section-description { color: var(--muted); font-size: 14px; margin: 7px 0 13px; }
.answer-reason {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid #c196ad;
  border-radius: 8px;
  margin-top: 15px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}
.answer-reason strong { color: var(--gold); }
.answer-reason p { margin-top: 4px; }
.action-stack { gap: 11px; }
.result-copy > .quiet { min-height: 44px; margin-top: 3px; }

.select-screen .secondary { margin: 13px 0 18px; }
.search-label { display: block; margin: 13px 0 6px; color: var(--muted); font-size: 13px; }
#character-search {
  width: 100%;
  min-height: 45px;
  padding: 8px 12px;
  border: 1px solid #af94bb;
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
}
#character-search::placeholder { color: #6e5d77; }
.people { display: grid; gap: 7px; margin-top: 12px; }
.person { padding: 3px 11px 3px 4px; }
.person span:nth-child(2) { flex: 1; overflow-wrap: anywhere; }
.person-portrait { width: 43px; height: 43px; border-radius: 7px; background: #f0e3f3; object-fit: cover; object-position: center 15%; }
.empty-search { padding: 15px 5px; color: var(--muted); }

.pair-card { overflow: hidden; border: 1px solid #c7aecb; border-radius: 18px; box-shadow: 0 10px 32px #6f487019; }
.pair-hero { padding-top: 10px; text-align: center; }
.pair-hero .moon-disc { top: 11%; width: min(46%, 190px); }
.card-eyebrow { position: relative; z-index: 2; color: #604467; font-size: 12px; font-weight: 750; letter-spacing: .13em; }
.pair-art { display: grid; grid-template-columns: 1fr 1fr; height: clamp(130px, 27vh, 210px); }
.pair-art img {
  min-width: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  filter: drop-shadow(0 4px 8px #54314d38);
}
.pair-art .pair-left { transform: translateX(5%); }
.pair-art .pair-right { transform: translateX(-5%); }
.pair-names {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto minmax(0,1fr);
  align-items: center;
  gap: 4px;
  padding: 7px 9px 10px;
  background: #fcf0f9;
  border-top: 1px solid #dbc0d9;
}
.pair-names div { min-width: 0; }
.portrait-label { display: block; color: var(--gold); font-size: 10px; }
.pair-names strong { display: block; font: 700 clamp(14px, 4.3vw, 23px)/1.3 var(--display); overflow-wrap: anywhere; }
.pair-names small { margin-left: 2px; font: 700 10px/1 var(--ui); }
.pair-cross { color: var(--accent); font: 20px/1 var(--display); }
.pair-content { padding: clamp(13px, 4vw, 24px); background: var(--paper); color: var(--ink); }
.pair-content h1 { font: 700 clamp(22px, 6vw, 33px)/1.3 var(--display); }
.pair-story { margin: 9px 0 13px; font-size: 14px; line-height: 1.65; }
.roles { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.roles div { min-width: 0; border: 1px solid #ddc8d1; border-radius: 8px; padding: 7px 8px; background: #f0e5ec; }
.roles span { display: block; font-size: 10px; font-weight: 700; color: #6b4660; }
.roles strong { display: block; margin-top: 2px; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.reading { margin-top: 11px; }
.reading div { border-top: 1px solid #dfcdda; padding: 7px 0; }
.reading dt { color: #68405c; font-size: 12px; font-weight: 800; }
.reading dd { font-size: 13px; line-height: 1.5; }
.card-note { margin-top: 4px; color: #654b60; font-size: 10px; }
.card-screen > .quiet { margin-top: 5px; }

@media (min-width: 710px) and (min-height: 500px) {
  .shell { --pad-left: max(28px, env(safe-area-inset-left)); --pad-right: max(28px, env(safe-area-inset-right)); }
  .site-header { min-height: 68px; }
  .home {
    max-width: 1030px;
    min-height: min(630px, 83vh);
    grid-template-areas: "copy art" "actions art";
    grid-template-columns: minmax(300px, .9fr) minmax(0, 1.1fr);
    grid-template-rows: 1fr auto;
    align-items: center;
    gap: 0 32px;
    padding: clamp(25px, 8vh, 75px) 0;
    text-align: left;
  }
  .hero-copy { align-self: end; }
  .hero-copy h1 { font-size: clamp(56px, 7vw, 96px); }
  .hero-actions { align-self: start; margin-top: 24px; }
  .hero-actions .button { margin-inline: 0; }
  .hero-actions .quiet { justify-content: flex-start; padding-left: 0; }
  .hero-art { height: min(59vh, 475px); margin: 0; border-radius: 26px; }
  .hero-art .moon-disc { top: 9%; width: 60%; }
  .hero-portrait { top: 13%; width: 63%; height: 100%; }
  .hero-left { left: -3%; }
  .hero-right { right: -4%; }
  .result-screen { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-width: 875px; gap: 25px; padding-top: 36px; }
  .result-illustration { min-height: 405px; height: 100%; }
  .result-illustration .moon-disc { top: 10%; }
  .result-portrait { height: 100%; }
  .people { grid-template-columns: 1fr 1fr; }
  .empty-search { grid-column: 1 / -1; }
}

@media (max-height: 620px) and (max-width: 500px) {
  .site-header { min-height: 50px; }
  .home { padding-top: 14px; }
  .hero-art { margin-top: 9px; height: 158px; }
  .hero-actions { margin-top: 10px; }
  .intro { font-size: 12px; }
  .result-illustration { height: 140px; }
  .site-footer { padding: 16px 0 10px; }
}

@media (orientation: landscape) and (max-height: 499px) {
  .home {
    max-width: 700px;
    grid-template-areas: "copy art" "actions art";
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 0 18px;
    padding-top: 12px;
    text-align: left;
  }
  .hero-copy h1 { font-size: clamp(29px, 6vw, 38px); }
  .hero-art { height: 230px; margin-top: 0; }
  .hero-actions .button { margin-inline: 0; }
  .site-header { min-height: 46px; }
  .result-screen { max-width: 700px; grid-template-columns: 1fr 1fr; }
  .result-illustration { height: 240px; }
}
