:root {
  --bg: #030204;
  --panel: rgba(12, 9, 12, .94);
  --panel-strong: #0c090d;
  --text: #f4eee9;
  --muted: #a99da0;
  --line: rgba(220, 198, 190, .13);
  --blood: #9f102b;
  --blood-light: #e0475d;
  --gold: #c9a96a;
  --shadow: 0 28px 80px rgba(0, 0, 0, .42);
}

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

html { min-height: 100%; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(84, 15, 30, .16), transparent 35%),
    radial-gradient(ellipse at 50% 110%, rgba(50, 10, 24, .1), transparent 42%),
    linear-gradient(145deg, #020102 0%, #080508 54%, #020102 100%);
  font-family: "Noto Serif JP", serif;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
  z-index: 20;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 19;
  box-shadow: inset 0 0 180px 38px rgba(0, 0, 0, .9);
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

.ambient {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border: 1px solid rgba(201, 169, 106, .045);
  border-radius: 50%;
  pointer-events: none;
}

.ambient::before, .ambient::after {
  content: "";
  position: absolute;
  inset: 10%;
  border: inherit;
  border-radius: inherit;
}

.ambient::after { inset: 24%; }
.ambient-one { top: -21rem; left: -16rem; }
.ambient-two { right: -22rem; bottom: -19rem; }

.app-shell {
  position: relative;
  width: min(100%, 1080px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  display: grid;
  align-items: center;
  z-index: 1;
}

.screen { display: none; width: 100%; animation: reveal .55s ease both; }
.screen.is-active { display: block; }

.intro-screen { position: relative; text-align: center; padding: 44px 0; }
.intro-screen::before {
  content: "";
  position: absolute;
  inset: 8% 12%;
  z-index: -1;
  border: 1px solid rgba(201, 169, 106, .055);
  background: radial-gradient(circle, rgba(93, 16, 34, .09), transparent 61%);
  clip-path: polygon(4% 0, 96% 0, 100% 8%, 100% 92%, 96% 100%, 4% 100%, 0 92%, 0 8%);
}
.eyebrow, .question-kicker, .result-index {
  margin: 0;
  color: var(--gold);
  font: 600 .72rem/1.4 Georgia, serif;
  letter-spacing: .25em;
}

.crest {
  position: relative;
  display: grid;
  place-items: center;
  width: 104px;
  aspect-ratio: 1;
  margin: 28px auto 24px;
  color: var(--gold);
  border: 1px solid rgba(201, 169, 106, .5);
  transform: rotate(45deg);
}

.crest::before, .crest::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(201, 169, 106, .18);
}

.crest::after { inset: -8px; border-color: rgba(159, 16, 43, .3); }
.crest span { transform: rotate(-45deg); font: 400 2.4rem/1 Georgia, serif; }

h1 {
  margin: 0;
  font-family: "Shippori Mincho", serif;
  font-size: clamp(3rem, 8vw, 5.8rem);
  font-weight: 800;
  line-height: .98;
  letter-spacing: .06em;
  text-shadow: 0 8px 38px rgba(159, 16, 43, .28);
}

h1 span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .26em;
  font-weight: 500;
  letter-spacing: .34em;
}

.intro-copy { margin: 30px 0 0; font-size: clamp(1.05rem, 3vw, 1.35rem); line-height: 1.9; }
.intro-note { margin: 10px 0 34px; color: var(--muted); font-size: .9rem; }

.primary-button, .secondary-button {
  width: min(100%, 360px);
  min-height: 58px;
  border: 0;
  cursor: pointer;
  letter-spacing: .08em;
  transition: transform .2s ease, filter .2s ease, background .2s ease;
}

.text-button {
  display: block;
  margin: 18px auto 0;
  padding: 4px 8px;
  color: #918386;
  border: 0;
  border-bottom: 1px solid rgba(201, 169, 106, .22);
  background: transparent;
  cursor: pointer;
  font-size: .8rem;
  letter-spacing: .08em;
  transition: color .2s, border-color .2s;
}
.text-button:hover { color: var(--text); border-color: var(--gold); }

.primary-button {
  position: relative;
  color: #fff8f5;
  background: linear-gradient(135deg, #7f0a22, #b11835);
  box-shadow: 0 12px 34px rgba(128, 8, 32, .28), inset 0 1px rgba(255, 255, 255, .15);
}

.primary-button:hover { filter: brightness(1.13); transform: translateY(-2px); }
.time-note { margin: 13px 0 0; color: #786f72; font-size: .75rem; }

.quiz-screen { max-width: 720px; margin: auto; }
.quiz-header { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; }
.back-button {
  width: 44px;
  height: 44px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.back-button:disabled { opacity: .25; cursor: default; }
.lineage-back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 82px;
  height: 42px;
  color: #f3e9df;
  border-color: rgba(201,169,106,.55);
  border-radius: 4px;
  background: rgba(30,18,23,.92);
  box-shadow: 0 7px 22px rgba(0,0,0,.42), inset 0 0 0 1px rgba(255,255,255,.025);
  font-size: .76rem;
  letter-spacing: .1em;
}
.lineage-back-button:hover { color: #fff; border-color: var(--gold); background: rgba(74,19,32,.9); }
.progress-label { margin: 0; color: var(--muted); text-align: center; letter-spacing: .13em; }
.progress-label span:first-child { color: var(--text); font-size: 1.35rem; }
.progress-track { height: 2px; margin: 18px 0 56px; overflow: hidden; background: rgba(255,255,255,.08); }
.progress-track span { display: block; width: 8.33%; height: 100%; background: linear-gradient(90deg, var(--blood), var(--blood-light)); transition: width .4s ease; }
.question-wrap { min-height: 480px; }
.question-kicker { margin-bottom: 14px; }
.question-wrap h2 {
  min-height: 3.2em;
  margin: 0 0 34px;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.6;
  letter-spacing: .025em;
}
.answer-list { display: grid; gap: 13px; }
.answer-button {
  position: relative;
  width: 100%;
  min-height: 64px;
  padding: 15px 56px 15px 22px;
  color: var(--text);
  text-align: left;
  line-height: 1.65;
  border: 1px solid var(--line);
  background: rgba(26, 17, 26, .74);
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.answer-button::after { content: "›"; position: absolute; top: 50%; right: 22px; color: var(--gold); font-size: 1.35rem; transform: translateY(-53%); }
.answer-button:hover { border-color: rgba(201, 169, 106, .58); background: rgba(53, 25, 34, .82); transform: translateX(3px); }
.answer-button.is-selected { border-color: var(--blood-light); background: rgba(113, 15, 37, .32); }

.loading-screen { text-align: center; }
.blood-orbit {
  position: relative;
  width: 116px;
  height: 116px;
  margin: 0 auto 32px;
  border: 1px solid rgba(201,169,106,.2);
  border-radius: 50%;
  animation: spin 2.8s linear infinite;
}
.blood-orbit::before, .blood-orbit::after { content: ""; position: absolute; inset: 16px; border: 1px solid rgba(159,16,43,.42); border-radius: 50%; }
.blood-orbit::after { inset: 40px; background: var(--blood); box-shadow: 0 0 34px rgba(206, 28, 57, .68); }
.blood-orbit span { position: absolute; top: 4px; left: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.loading-screen h2 { margin: 16px 0 10px; font-size: clamp(1.45rem, 5vw, 2.2rem); }
.loading-screen > p:last-child { color: var(--muted); font-size: .9rem; }

.result-screen { max-width: 760px; margin: auto; padding: 30px 0; text-align: center; }
.result-lead { margin: 12px 0 24px; color: var(--muted); }
.result-card {
  overflow: hidden;
  border: 1px solid rgba(201,169,106,.18);
  background: rgba(9, 7, 9, .95);
  box-shadow: var(--shadow);
}
.result-visual {
  --accent: #8f1530;
  position: relative;
  aspect-ratio: 16 / 9;
  min-height: 0;
  overflow: hidden;
  background: #050405;
}
.result-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 31%, rgba(3,2,4,.14) 43%, rgba(3,2,4,.62) 66%, rgba(3,2,4,.36));
}
.result-character-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.result-name-layer {
  position: absolute;
  top: 50%;
  right: 5%;
  z-index: 2;
  width: 45%;
  text-align: center;
  transform: translateY(-48%);
}
.result-name-layer::before, .result-name-layer::after {
  content: "";
  display: block;
  width: 64%;
  height: 1px;
  margin: 14px auto;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 65%, var(--gold)), transparent);
}
.result-name-layer h2 { margin: 0; font-size: clamp(3rem, 8vw, 6.6rem); line-height: 1.05; letter-spacing: .16em; text-shadow: 0 4px 25px #000; }
.result-content { padding: 34px clamp(22px, 7vw, 64px) 38px; }
.result-reading { margin: 5px 0 0; color: var(--gold); font-size: .82rem; letter-spacing: .28em; }
.result-caption { margin: 0; text-align: left; font-size: 1rem; line-height: 2; }
.habitat-box { margin-top: 28px; padding: 18px 20px; border: 1px solid var(--line); text-align: left; background: rgba(255,255,255,.025); }
.habitat-box p { margin: 0; }
.habitat-box p:first-child { margin-bottom: 8px; color: var(--gold); font-size: .72rem; letter-spacing: .12em; }
.habitat-box p:last-child { color: #d3c9c8; line-height: 1.75; }
.night-invitations { margin-top: 30px; padding: 30px 24px 26px; border: 1px solid rgba(201,169,106,.17); background: linear-gradient(160deg, rgba(34,7,15,.48), rgba(5,4,6,.92)); }
.night-invitations h3 { margin: 8px 0 24px; font-size: clamp(1.25rem, 4vw, 1.7rem); font-weight: 600; letter-spacing: .08em; }
.invitation-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.invitation-card { position: relative; display: grid; align-content: end; min-height: 190px; overflow: hidden; padding: 22px; color: var(--text); border: 1px solid rgba(201,169,106,.22); text-align: left; text-decoration: none; background: #080608; isolation: isolate; transition: transform .2s, border-color .2s, filter .2s; }
.invitation-card::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .5; background: radial-gradient(circle at 74% 22%, rgba(135,20,42,.7), transparent 34%), linear-gradient(145deg, rgba(0,0,0,.08), #030203 76%); }
.invitation-day::before { background: radial-gradient(circle at 78% 18%, rgba(193,168,108,.34), transparent 22%), linear-gradient(145deg, rgba(50,34,52,.42), #030203 76%); }
.invitation-card:hover { transform: translateY(-3px); border-color: rgba(201,169,106,.58); filter: brightness(1.12); }
.invitation-card span { color: var(--gold); font-size: .68rem; letter-spacing: .12em; }
.invitation-card strong { margin: 8px 0 18px; font-size: 1.2rem; line-height: 1.5; letter-spacing: .08em; }
.invitation-card small { color: #aaa0a2; font-size: .72rem; }
.result-actions { display: grid; justify-items: center; gap: 12px; margin-top: 28px; }
.secondary-button { color: var(--muted); border: 1px solid var(--line); background: transparent; }
.secondary-button:hover { color: var(--text); border-color: rgba(201,169,106,.45); }
.share-hook { color: #867c7e; font-size: .78rem; }
footer { display: flex; justify-content: center; gap: 12px; margin-top: 54px; color: #625a5d; font-size: .68rem; letter-spacing: .12em; }

.lineage-screen { max-width: 1040px; margin: auto; padding: 28px 0 46px; }
.lineage-header { display: grid; grid-template-columns: 88px 1fr 88px; align-items: center; text-align: center; }
.lineage-header h2 { margin: 6px 0 0; font-size: clamp(2rem, 5vw, 3.4rem); letter-spacing: .16em; }
.lineage-intro, .lineage-note { color: var(--muted); text-align: center; font-size: .82rem; line-height: 1.8; }
.lineage-intro { margin: 18px 0 30px; }
.lineage-note { margin: 24px 0 0; color: #756b6d; }
.lineage-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(201,169,106,.12);
  background: rgba(0,0,0,.35);
  box-shadow: 0 28px 80px rgba(0,0,0,.48);
}
.lineage-card {
  --lineage-accent: #7f1730;
  position: relative;
  min-width: 0;
  aspect-ratio: .72;
  overflow: hidden;
  padding: 0;
  color: var(--text);
  border: 1px solid rgba(255,255,255,.06);
  background: #090709;
  cursor: pointer;
  transition: transform .22s, border-color .22s, filter .22s;
}
.lineage-card:nth-child(n+6) { background: #050405; }
.lineage-card:not(.is-hidden-origin):hover { z-index: 2; border-color: color-mix(in srgb, var(--lineage-accent) 70%, var(--gold)); filter: brightness(1.14); transform: translateY(-5px) scale(1.018); }
.lineage-card:not(.is-hidden-origin):focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.lineage-card img { width: 100%; height: 100%; object-fit: cover; object-position: 18% center; filter: saturate(.82) brightness(.76); transform: scale(1.48); transform-origin: 17% 50%; }
.lineage-card.is-hidden-origin { cursor: not-allowed; }
.lineage-card.is-hidden-origin img { filter: brightness(0) opacity(.72); }
.lineage-card.is-hidden-origin::before { content: "?"; position: absolute; top: 43%; left: 50%; z-index: 2; color: rgba(201,169,106,.28); font: 400 clamp(2.5rem, 5vw, 4.5rem)/1 Georgia, serif; transform: translate(-50%, -50%); text-shadow: 0 0 28px rgba(201,169,106,.22); }
.lineage-card.is-hidden-origin .lineage-card-copy small { color: #776f72; }
.lineage-card::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 48%, rgba(3,2,4,.9) 82%); pointer-events: none; }
.lineage-card-number { position: absolute; top: 8px; right: 9px; z-index: 2; color: rgba(230,218,204,.45); font: 600 .62rem/1 Georgia, serif; letter-spacing: .12em; }
.lineage-card-copy { position: absolute; right: 8px; bottom: 12px; left: 8px; z-index: 2; display: grid; text-align: center; text-shadow: 0 2px 10px #000; }
.lineage-card-copy strong { font-size: clamp(1.1rem, 2.3vw, 1.6rem); letter-spacing: .14em; }
.lineage-card-copy small { margin-top: 2px; color: var(--gold); font-size: .58rem; letter-spacing: .16em; }

noscript { position: fixed; inset: auto 12px 12px; padding: 12px; color: white; background: #7f0a22; z-index: 30; }
.mobile-only { display: none; }

@keyframes reveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .app-shell { padding-inline: 18px; align-items: start; }
  .intro-screen { padding-top: max(54px, 8vh); }
  .mobile-only { display: initial; }
  .crest { width: 84px; margin-top: 24px; }
  .intro-copy { margin-top: 24px; }
  .quiz-screen { padding-top: 14px; }
  .progress-track { margin-bottom: 42px; }
  .question-wrap h2 { min-height: 3.8em; margin-bottom: 26px; }
  .answer-button { min-height: 68px; padding-left: 18px; font-size: .92rem; }
  .result-screen { padding-top: 20px; }
  .result-visual { aspect-ratio: 16 / 10; }
  .result-name-layer { right: 2%; width: 47%; }
  .result-name-layer h2 { font-size: clamp(2.15rem, 12vw, 3.3rem); letter-spacing: .1em; }
  .result-name-layer .result-index { font-size: .54rem; letter-spacing: .14em; }
  .result-reading { font-size: .65rem; }
  .result-caption { font-size: .94rem; }
  .night-invitations { padding: 25px 15px 20px; }
  .invitation-grid { grid-template-columns: 1fr; }
  .invitation-card { min-height: 150px; }
  .lineage-screen { padding-top: 16px; }
  .lineage-header { grid-template-columns: 76px 1fr 76px; }
  .lineage-back-button { width: 72px; height: 40px; font-size: .7rem; }
  .lineage-intro { margin-bottom: 22px; padding-inline: 12px; }
  .lineage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 7px; }
  .lineage-card { aspect-ratio: .82; }
  footer { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
