:root {
  --ink: #211a14;
  --ink-soft: #5e5245;
  --paper: #f4efdf;
  --paper-deep: #e7ddc4;
  --red: #8e2431;
  --red-dark: #631922;
  --gold: #b58a2c;
  --gold-bright: #d6b85c;
  --night: #17120f;
  --line: rgba(74, 55, 40, .22);
  --shadow: 0 18px 50px rgba(36, 25, 15, .16);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 96px; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(125, 100, 62, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 100, 62, .025) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "MS PMincho", serif;
  line-height: 1.8;
}

button, input, select { font: inherit; }
a { color: inherit; }
button { cursor: pointer; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; z-index: 999; top: 8px; left: 8px; padding: 8px 14px;
  background: #fff; color: #111; transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky; top: 0; z-index: 30; height: 70px; padding: 0 max(22px, calc((100vw - 1240px) / 2));
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  color: #efe6d0; background: rgba(23, 18, 15, .94); border-bottom: 1px solid rgba(214, 184, 92, .28);
  backdrop-filter: blur(14px); box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; line-height: 1.15; }
.brand-mark { font-size: 28px; filter: drop-shadow(0 2px 3px #000); }
.brand b { display: block; letter-spacing: .08em; }
.brand small { display: block; margin-top: 4px; color: #b8aa8b; letter-spacing: .24em; font-size: 9px; }
.site-header nav { display: flex; align-items: center; gap: 28px; font-size: 13px; }
.site-header nav a { text-decoration: none; color: #cfc1a2; }
.site-header nav a:hover, .site-header nav a:focus-visible { color: #fff0bb; }
.site-header .play-link { padding: 7px 15px; color: #fff0c9; border: 1px solid #9e7d2a; border-radius: 4px; }

.section-shell { width: min(1240px, calc(100% - 44px)); margin-inline: auto; }
.eyebrow { margin: 0 0 8px; color: var(--red); font: 700 11px/1.3 system-ui, sans-serif; letter-spacing: .25em; }
.section-heading { margin-bottom: 30px; }
.section-heading h2 { margin: 0; font-size: clamp(28px, 4vw, 46px); line-height: 1.35; letter-spacing: .06em; }

.hero {
  position: relative; min-height: 650px; padding: 92px max(22px, calc((100vw - 1240px) / 2)) 80px;
  display: grid; grid-template-columns: minmax(0, 1.03fr) minmax(420px, .97fr); align-items: center; gap: 40px;
  color: #f2ead8; overflow: hidden;
  background:
    radial-gradient(circle at 70% 30%, rgba(181, 138, 44, .17), transparent 30%),
    radial-gradient(circle at 12% 110%, rgba(142, 36, 49, .32), transparent 42%),
    linear-gradient(135deg, #201715, #130f0d 58%, #231812);
}
.hero::after {
  content: ""; position: absolute; inset: auto 0 0; height: 88px;
  background: linear-gradient(174deg, transparent 48%, var(--paper) 49%);
}
.hero-pattern {
  position: absolute; inset: 0; opacity: .12; pointer-events: none;
  background-image: radial-gradient(circle, #d6b85c 1px, transparent 1.5px);
  background-size: 24px 24px; mask-image: linear-gradient(90deg, #000, transparent 70%);
}
.hero-copy { position: relative; z-index: 2; padding-bottom: 50px; }
.hero .eyebrow { color: var(--gold-bright); }
.hero h1 { margin: 0; font-size: clamp(52px, 7vw, 92px); line-height: 1; letter-spacing: .05em; white-space: nowrap; text-shadow: 0 5px 25px #000; }
.hero h1 span { color: #d9ba62; }
.hero-lead { margin: 30px 0 5px; color: #fff2cf; font-size: clamp(18px, 2vw, 24px); letter-spacing: .08em; }
.hero-text { max-width: 680px; margin: 0; color: #bfb39d; font-size: 15px; }
.hero-stats { display: flex; gap: 0; margin: 34px 0 28px; }
.hero-stats div { min-width: 128px; padding: 0 24px; border-left: 1px solid rgba(214, 184, 92, .32); }
.hero-stats div:first-child { padding-left: 0; border-left: 0; }
.hero-stats strong { display: block; color: #f4d984; font: 700 clamp(28px, 4vw, 42px)/1 system-ui, sans-serif; }
.hero-stats span { color: #9e927e; font-size: 11px; letter-spacing: .16em; }
.hero-cta { display: inline-flex; gap: 44px; align-items: center; padding: 11px 18px; border-bottom: 1px solid #c4a64d; text-decoration: none; color: #f1dfaa; font-size: 14px; letter-spacing: .12em; }
.hero-portraits { position: relative; z-index: 1; min-height: 510px; }
.hero-figure {
  position: absolute; filter: drop-shadow(0 22px 22px rgba(0, 0, 0, .52));
  animation: portrait-float 4s ease-in-out infinite;
}
.hero-figure:nth-child(1) { left: 4%; bottom: 6%; transform: rotate(-7deg); }
.hero-figure:nth-child(2) { left: 31%; top: 0; z-index: 2; animation-delay: -.8s; }
.hero-figure:nth-child(3) { right: 0; bottom: 4%; transform: rotate(8deg); animation-delay: -1.8s; }
.hero-figure span { display: block; margin-top: -15px; text-align: center; color: #d4c7a9; font-size: 12px; letter-spacing: .12em; }
@keyframes portrait-float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -10px; } }

.about { padding-block: 82px 94px; }
.method-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.method-grid article { position: relative; min-height: 230px; padding: 32px 28px; background: rgba(255, 253, 246, .76); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(49, 35, 21, .06); }
.method-no { position: absolute; top: 18px; right: 22px; color: rgba(142, 36, 49, .12); font-size: 70px; line-height: 1; font-weight: bold; }
.method-grid h3 { position: relative; margin: 22px 0 12px; font-size: 20px; letter-spacing: .06em; }
.method-grid p { position: relative; margin: 0; color: var(--ink-soft); font-size: 13.5px; }
.source-note { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 25px; margin-top: 20px; padding: 22px 28px; color: #e9dec8; background: #28201a; }
.source-note-mark { width: 58px; height: 58px; display: grid; place-items: center; border: 1px solid #a88638; border-radius: 50%; color: #dfc472; font-size: 26px; }
.source-note p { margin: 0; color: #c6b9a2; font-size: 13px; }
.source-note strong { color: #f4e9d2; font-size: 15px; }

.era-band { padding: 64px 0 74px; color: #ebdfc7; background: #2a201b; }
.era-band .eyebrow { color: #d1af51; }
.era-band h2 { color: #fff5df; }
.section-heading.compact { margin-bottom: 24px; }
.era-line { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; padding-top: 24px; }
.era-line::before { content: ""; position: absolute; top: 31px; left: 2%; right: 2%; height: 1px; background: linear-gradient(90deg, #705c37, #d0ad50, #705c37); }
.era-line div { position: relative; padding-top: 24px; text-align: center; }
.era-line div::before { content: ""; position: absolute; top: 2px; left: 50%; width: 13px; height: 13px; border: 3px solid #2a201b; border-radius: 50%; background: #d0ad50; box-shadow: 0 0 0 1px #d0ad50; translate: -50%; }
.era-line b { display: block; color: #e1c36d; font: 700 17px/1.2 system-ui, sans-serif; }
.era-line span { color: #a99c87; font-size: 11px; white-space: nowrap; }

.catalog { padding-block: 86px 110px; }
.catalog-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.result-summary { margin: 0 0 6px; color: var(--ink-soft); font-size: 13px; }
.result-summary b { color: var(--red); font: 700 22px/1 system-ui, sans-serif; }
.filters {
  position: sticky; z-index: 20; top: 82px; display: grid; grid-template-columns: minmax(280px, 1.8fr) repeat(3, minmax(140px, .8fr)) auto;
  gap: 10px; margin-bottom: 18px; padding: 13px; background: rgba(244, 239, 223, .94); border: 1px solid rgba(74, 55, 40, .2); box-shadow: 0 12px 32px rgba(50, 34, 20, .1); backdrop-filter: blur(12px);
}
.filters label { min-width: 0; }
.filters label > span { display: block; margin: 0 0 3px 3px; color: #746756; font: 700 9px/1.3 system-ui, sans-serif; letter-spacing: .14em; }
.filters input, .filters select { width: 100%; height: 42px; padding: 0 12px; color: #332820; background: #fffdf7; border: 1px solid #cfc4ad; border-radius: 3px; outline: none; }
.filters input:focus, .filters select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(142, 36, 49, .12); }
.search-box { position: relative; align-self: end; }
.search-box > span[aria-hidden] { position: absolute; z-index: 1; left: 14px; bottom: 7px; color: #7b6b58; font-size: 22px; }
.search-box input { padding-left: 43px; padding-right: 42px; }
.search-box kbd { position: absolute; right: 11px; bottom: 10px; width: 24px; height: 23px; display: grid; place-items: center; color: #7a6e60; background: #eee7d7; border: 1px solid #d2c5ad; border-radius: 3px; font: 12px/1 system-ui, sans-serif; }
.reset-btn { align-self: end; height: 42px; padding: 0 14px; color: #665846; background: transparent; border: 1px solid #bbae94; border-radius: 3px; }
.reset-btn:hover { color: var(--red); border-color: var(--red); }
.active-filter { margin: 0 0 16px; color: #665a4b; font-size: 12px; }

.character-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.character-card {
  --clan: #8a7a5a; position: relative; min-width: 0; min-height: 330px; padding: 0; overflow: hidden;
  text-align: left; color: var(--ink); background: rgba(255, 253, 246, .84); border: 1px solid rgba(74, 55, 40, .2); border-radius: 4px;
  box-shadow: 0 7px 18px rgba(55, 38, 22, .07); transition: translate .18s, box-shadow .18s, border-color .18s;
}
.character-card::before { content: ""; position: absolute; z-index: 2; inset: 0 0 auto; height: 4px; background: var(--clan); }
.character-card:hover, .character-card:focus-visible { translate: 0 -5px; border-color: var(--clan); box-shadow: var(--shadow); outline: none; }
.card-art { height: 194px; display: grid; place-items: end center; overflow: hidden; background: radial-gradient(circle at 50% 78%, color-mix(in srgb, var(--clan) 16%, transparent), transparent 55%), linear-gradient(#eee6d4, #f7f1e3); }
.card-art::before { content: ""; position: absolute; top: 24px; left: 50%; width: 98px; height: 98px; border: 1px solid color-mix(in srgb, var(--clan) 26%, transparent); border-radius: 50%; translate: -50%; }
.card-art svg { position: relative; z-index: 1; margin-bottom: -18px; filter: drop-shadow(0 10px 8px rgba(44, 31, 19, .2)); }
.art-placeholder { align-self: center; width: 68px; height: 68px; border: 1px solid #d5cab4; border-radius: 50%; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.card-body { display: block; width: 100%; padding: 18px 20px 20px; }
.card-kicker { display: flex; justify-content: space-between; gap: 8px; color: #806f5b; font: 10px/1.3 system-ui, sans-serif; letter-spacing: .08em; }
.card-kicker span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-name { display: block; margin: 8px 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 20px; line-height: 1.35; letter-spacing: .04em; }
.card-life { display: block; color: #6d6255; font: 12px/1.4 system-ui, sans-serif; }
.card-trait { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 11px; padding-top: 10px; border-top: 1px solid #ddd3c0; color: #7a6b59; font-size: 10px; }
.card-trait b { color: var(--red); font-size: 11px; }
.card-arrow { color: var(--red); font: 18px/1 system-ui, sans-serif; }
.load-more { display: block; min-width: 260px; margin: 32px auto 0; padding: 13px 24px; color: #f5ead2; background: #33271f; border: 1px solid #8a6d2c; border-radius: 3px; }
.load-more:hover { background: #4b3528; }
.empty-state { padding: 70px 20px; text-align: center; color: #746856; }
.empty-state span { font-size: 60px; filter: grayscale(1); opacity: .48; }
.empty-state h3 { margin: 8px 0 4px; color: #4a3d31; }
.empty-state p { margin: 0; font-size: 13px; }

.site-footer { padding: 38px max(22px, calc((100vw - 1240px) / 2)); display: flex; justify-content: space-between; gap: 30px; color: #a99a82; background: #17120f; border-top: 1px solid #554425; font-size: 12px; }
.site-footer b { color: #e0d4bd; letter-spacing: .08em; }
.site-footer p { margin: 6px 0 0; }
.footer-links { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.footer-links a { color: #c7b98f; }

.profile-dialog {
  width: min(970px, calc(100% - 28px)); max-height: min(900px, calc(100dvh - 28px)); margin: auto; padding: 0;
  color: var(--ink); background: #f7f1e3; border: 1px solid #96752c; border-radius: 5px; box-shadow: 0 30px 100px rgba(0, 0, 0, .62); overflow: auto;
}
.profile-dialog::backdrop { background: rgba(13, 9, 7, .78); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; z-index: 4; top: 13px; float: right; margin: 13px 13px -54px 0; width: 40px; height: 40px; color: #eee2cb; background: rgba(35, 26, 20, .86); border: 1px solid #81692c; border-radius: 50%; font: 26px/1 system-ui, sans-serif; }
.profile-hero { --clan: #8a7a5a; min-height: 330px; padding: 38px 68px 32px 42px; display: grid; grid-template-columns: 250px 1fr; align-items: end; gap: 34px; color: #f3ead7; background: radial-gradient(circle at 23% 55%, color-mix(in srgb, var(--clan) 45%, transparent), transparent 28%), linear-gradient(135deg, #2b211c, #17120f); border-bottom: 4px solid var(--clan); }
.profile-art { height: 255px; display: grid; place-items: end center; }
.profile-art svg { filter: drop-shadow(0 18px 16px rgba(0, 0, 0, .5)); }
.profile-clan { margin: 0; color: #d9c78d; font: 700 11px/1.4 system-ui, sans-serif; letter-spacing: .18em; }
.profile-hero h2 { margin: 7px 0 8px; color: #fff4db; font-size: clamp(34px, 6vw, 58px); line-height: 1.15; letter-spacing: .06em; }
.profile-life { margin: 0; color: #bcb09d; font: 14px/1.5 system-ui, sans-serif; }
.profile-intro { margin: 18px 0 0; color: #d0c3ad; font-size: 13px; }
.profile-body { padding: 34px 42px 46px; }
.fact-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 32px; }
.fact-grid div { padding: 14px 15px; background: #ede4d1; border-top: 2px solid #b39752; }
.fact-grid span { display: block; color: #7a6a55; font: 9px/1.3 system-ui, sans-serif; letter-spacing: .12em; }
.fact-grid b { display: block; margin-top: 4px; color: #35291f; font-size: 15px; }
.profile-section { margin-top: 30px; }
.profile-section h3 { display: flex; align-items: center; gap: 12px; margin: 0 0 13px; color: #3b2e24; font-size: 20px; letter-spacing: .05em; }
.profile-section h3::before { content: ""; width: 24px; height: 3px; background: var(--red); }
.bio-text { margin: 0; color: #514538; white-space: pre-line; font-size: 14px; line-height: 2; }
.bio-status { min-height: 96px; padding: 20px; color: #756856; background: #eee6d5; border-left: 3px solid #b09550; font-size: 13px; }
.bio-status.loading { background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.attribution { margin: 13px 0 0; color: #766955; font: 10px/1.7 system-ui, sans-serif; }
.attribution a { color: #71333a; }
.static-bio { padding: 22px 24px; color: #514538; background: #eee6d5; border-left: 3px solid #a78337; }
.static-bio p { margin: 0; font-size: 14px; line-height: 2; }
.static-bio p + p { margin-top: 12px; }
.history-fact-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.history-fact-grid div { min-height: 88px; padding: 14px 15px; background: #ede4d1; border-top: 2px solid #b39752; }
.history-fact-grid span { display: block; margin-bottom: 6px; color: #7a6a55; font: 9px/1.3 system-ui, sans-serif; letter-spacing: .12em; }
.history-fact-grid b { color: #3d3025; font-size: 12px; line-height: 1.7; }
.clan-context { margin: 0; padding: 21px 23px; color: #e2d7c2; background: #2b221c; border-left: 3px solid #b48d36; font-size: 13px; line-height: 2; }
.life-timeline { display: grid; gap: 0; border-left: 1px solid #bcae92; margin-left: 8px; }
.life-event { position: relative; display: grid; grid-template-columns: 74px 1fr; gap: 18px; padding: 0 0 22px 23px; }
.life-event:last-child { padding-bottom: 0; }
.life-event::before { content: ""; position: absolute; top: 6px; left: -6px; width: 9px; height: 9px; border: 1px solid #8d6d2c; border-radius: 50%; background: #f7f1e3; }
.life-event time { color: var(--red); font: 700 14px/1.5 system-ui, sans-serif; }
.life-event p { margin: 0; color: #625647; font-size: 13px; }
.life-event p b { display: block; color: #3e3228; }
.accuracy-note { margin-top: 28px; padding: 15px 18px; color: #6d604e; background: #eee5d3; border: 1px solid #d7c9ad; font-size: 11px; }
.stat-bars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.stat-bar { padding: 10px; background: #ede4d1; }
.stat-bar div { height: 4px; margin-top: 7px; background: #d2c4a9; overflow: hidden; }
.stat-bar i { display: block; height: 100%; background: var(--red); }
.stat-bar span { display: flex; justify-content: space-between; color: #6d604f; font: 10px/1.2 system-ui, sans-serif; }

@media (max-width: 1050px) {
  .hero { grid-template-columns: 1fr 390px; }
  .character-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1.6fr repeat(2, 1fr); }
  .filters label:nth-child(4), .reset-btn { grid-row: 2; }
  .reset-btn { grid-column: 3; }
}

@media (max-width: 820px) {
  .site-header nav a:not(.play-link) { display: none; }
  .hero { min-height: auto; grid-template-columns: 1fr; padding-top: 70px; }
  .hero-copy { padding-bottom: 0; }
  .hero-portraits { min-height: 370px; }
  .hero-figure:nth-child(1) { left: 8%; }
  .hero-figure:nth-child(2) { left: 38%; }
  .method-grid { grid-template-columns: 1fr; }
  .method-grid article { min-height: 0; }
  .era-line { grid-template-columns: repeat(4, 1fr); row-gap: 24px; }
  .era-line::before { display: none; }
  .era-line div::before { top: 3px; }
  .character-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .profile-hero { grid-template-columns: 190px 1fr; padding-left: 24px; gap: 20px; }
  .fact-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  html { scroll-padding-top: 75px; }
  .site-header { height: 58px; padding-inline: 14px; }
  .brand b { font-size: 13px; }
  .brand small { display: none; }
  .site-header .play-link { font-size: 11px; }
  .section-shell { width: min(100% - 26px, 1240px); }
  .hero { padding: 52px 18px 55px; }
  .hero h1 { font-size: clamp(48px, 14vw, 64px); }
  .hero-text { font-size: 13px; }
  .hero-stats div { min-width: 0; flex: 1; padding-inline: 12px; }
  .hero-stats strong { font-size: 29px; }
  .hero-portraits { min-height: 270px; }
  .hero-figure svg { width: 145px; height: auto; }
  .hero-figure:nth-child(1) { left: 0; }
  .hero-figure:nth-child(2) { left: 33%; }
  .hero-figure:nth-child(3) { right: -4%; }
  .hero-figure span { display: none; }
  .about { padding-block: 60px; }
  .source-note { grid-template-columns: 1fr; }
  .source-note-mark { display: none; }
  .era-band { padding-block: 50px; }
  .era-line { grid-template-columns: repeat(2, 1fr); }
  .catalog { padding-block: 62px 80px; }
  .catalog-heading { display: block; }
  .result-summary { margin-top: 10px; }
  .filters { position: static; grid-template-columns: 1fr 1fr; }
  .search-box { grid-column: 1 / -1; }
  .filters label:nth-child(4), .reset-btn { grid-row: auto; }
  .reset-btn { grid-column: 1 / -1; }
  .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .character-card { min-height: 286px; }
  .card-art { height: 165px; }
  .card-art svg { width: 112px; height: auto; }
  .card-body { padding: 15px 16px 17px; }
  .card-name { font-size: 17px; }
  .site-footer { flex-direction: column; }
  .footer-links { align-items: flex-start; }
  .profile-dialog { width: calc(100% - 12px); max-height: calc(100dvh - 12px); }
  .profile-hero { min-height: 0; grid-template-columns: 120px 1fr; padding: 48px 18px 24px; gap: 12px; }
  .profile-art { height: 170px; }
  .profile-art svg { width: 125px; height: auto; }
  .profile-hero h2 { font-size: 30px; }
  .profile-intro { display: none; }
  .profile-body { padding: 25px 18px 35px; }
  .fact-grid { gap: 6px; }
  .fact-grid div { padding: 10px; }
  .history-fact-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .history-fact-grid div { min-height: 76px; padding: 11px; }
  .static-bio { padding: 17px; }
  .stat-bars { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
  .stat-bar { padding: 6px 4px; }
  .stat-bar span { display: block; text-align: center; font-size: 8px; }
  .life-event { grid-template-columns: 56px 1fr; gap: 10px; padding-left: 17px; }
}

@media (max-width: 390px) {
  .character-grid { grid-template-columns: 1fr; }
  .character-card { min-height: 300px; }
  .card-art { height: 180px; }
}

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