:root {
  --bg: #07080b;
  --bg-2: #0d0f14;
  --panel: #11141b;
  --line: #232833;
  --line-2: #343b4a;
  --text: #e7e9ee;
  --muted: #9299a8;
  --dim: #626978;
  --silver: #c9ced8;
  --danger: #c0392b;
  --spectrum: linear-gradient(90deg, #e58ad0, #e0354b, #f08a4b, #e8c36a, #74c365, #22b8ab, #4a6fe0, #b98cff);
  --display: 'Cinzel', 'Times New Roman', serif;
  --sans: 'Noto Sans KR', 'Pretendard', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  word-break: keep-all;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--silver); outline-offset: 3px; }

.spectrum { height: 2px; background: var(--spectrum); }

/* ---------- 상단 메뉴 ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: rgba(7, 8, 11, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-brand {
  font-family: var(--display); font-weight: 700;
  letter-spacing: .32em; text-decoration: none; color: var(--silver);
}
.nav nav { display: flex; gap: clamp(14px, 3vw, 32px); }
.nav nav a {
  text-decoration: none; color: var(--muted); font-size: 14px; letter-spacing: .04em;
  padding: 4px 0; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s;
}
.nav nav a:hover { color: var(--text); border-color: var(--silver); }

/* ---------- 이미지 칸 ---------- */
.hero-emblem, .uniform-slot, .card-photo, .p-photo { position: relative; }
.hero-emblem > .slot, .uniform-slot > .slot, .card-photo > .slot, .p-photo > .slot { position: absolute; inset: 0; }
.slot { width: 100%; height: 100%; }
.slot img { width: 100%; height: 100%; object-fit: contain; }
.slot-empty {
  display: grid; place-items: center;
  border: 1px dashed var(--line-2);
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.022) 0 10px, transparent 10px 20px),
    var(--bg-2);
}
.slot-label {
  font-family: var(--display); font-size: 12px; letter-spacing: .3em;
  color: var(--dim); text-align: center; padding: 8px;
}

/* ---------- 첫 화면 ---------- */
.hero {
  min-height: min(calc(100vh - 56px), 960px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 56px 16px 72px;
  background:
    radial-gradient(60% 50% at 50% 38%, rgba(120, 140, 190, .16), transparent 70%),
    var(--bg);
}
.hero-emblem { width: clamp(150px, 26vw, 240px); aspect-ratio: 1; margin-bottom: 28px; }
.hero-emblem .slot-empty { border-radius: 50%; }
.hero-tags { color: var(--muted); font-size: 13px; letter-spacing: .22em; }
.wordmark {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(52px, 13vw, 148px); line-height: 1.05;
  letter-spacing: .14em; margin: 10px 0 6px; padding-left: .14em;
  background: linear-gradient(180deg, #ffffff 0%, #c9ced8 38%, #6d7381 62%, #e7e9ee 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { font-size: 18px; letter-spacing: .5em; padding-left: .5em; color: var(--silver); }
.hero-sub span { display: block; margin-top: 6px; font-size: 12px; letter-spacing: .12em; color: var(--dim); padding: 0; }
.hero .spectrum { width: min(420px, 70vw); margin: 30px 0; }
.hero-lead { color: var(--text); font-size: clamp(15px, 2vw, 18px); font-weight: 300; }

/* ---------- 공통 섹션 ---------- */
.section { max-width: 1200px; margin: 0 auto; padding: clamp(64px, 9vw, 112px) clamp(16px, 4vw, 40px) 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; margin-bottom: 36px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.section-no { font-family: var(--display); color: var(--dim); letter-spacing: .2em; font-size: 14px; }
.section-head h2 { font-size: clamp(26px, 4vw, 38px); font-weight: 700; letter-spacing: .04em; }
.section-desc { flex-basis: 100%; color: var(--muted); font-size: 14px; }

/* ---------- 세력 ---------- */
.factions { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: stretch; }
.faction { background: var(--panel); border: 1px solid var(--line); padding: 28px; position: relative; overflow: hidden; }
.faction::before { content: ''; position: absolute; left: 0; top: 0; right: 0; height: 2px; }
.faction-khroma::before { background: var(--spectrum); }
.faction-ripansi::before { background: linear-gradient(90deg, #3a0d0d, var(--danger), #1a1a1a); }
.faction-en { font-family: var(--display); letter-spacing: .32em; font-size: 12px; color: var(--dim); }
.faction h3 { font-size: 30px; margin: 2px 0; }
.faction-ripansi h3 { color: #e3b3ad; }
.origin { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.faction p + p { margin-top: 6px; }
.faction .loc { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--silver); }
.versus { align-self: center; font-family: var(--display); color: var(--dim); letter-spacing: .2em; font-size: 14px; }

/* ---------- 용어 ---------- */
.terms { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 20px; }
.term { background: var(--bg-2); border: 1px solid var(--line); padding: 26px 28px; }
.term-wide { grid-column: 1 / -1; }
.term h3 { font-size: 21px; margin-bottom: 12px; display: flex; align-items: baseline; gap: 10px; }
.term h3::before { content: ''; width: 14px; height: 2px; background: var(--silver); align-self: center; flex: none; }
.term h3 small { font-size: 13px; color: var(--muted); font-weight: 400; }
.term p + p { margin-top: 8px; }
.term .grade { display: inline-block; font-size: 13px; letter-spacing: .08em; color: var(--silver); border: 1px solid var(--line-2); padding: 1px 12px; margin-bottom: 4px; }
.term .ex { color: var(--muted); font-size: 14px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.swatch {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid var(--line-2); border-radius: 999px;
  padding: 4px 12px 4px 6px; font-size: 11px; letter-spacing: .14em; color: var(--muted);
  transition: border-color .2s, color .2s;
}
.swatch i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(255,255,255,.28); }
.swatch:hover { border-color: var(--silver); color: var(--text); }
.decay { height: 6px; margin-top: 18px; background: linear-gradient(90deg, #f4f1e6, #8d8f96 45%, #2a2b30 75%, #000); border: 1px solid var(--line); }
.term-imprint blockquote {
  margin: 20px 0 0; padding: 22px 24px;
  border-left: 2px solid var(--silver);
  background: rgba(255, 255, 255, .03);
  font-size: clamp(16px, 2.1vw, 19px); line-height: 1.9; font-weight: 300; color: #fff;
}
.term-imprint cite { display: block; margin-top: 10px; font-style: normal; font-size: 12px; letter-spacing: .2em; color: var(--dim); }
.term-uniform { display: grid; grid-template-columns: 1fr minmax(200px, 320px); gap: 28px; align-items: start; }
.uniform-slot { aspect-ratio: 3 / 4; }

/* ---------- 서울지부 건물 ---------- */
.tower-wrap { display: grid; grid-template-columns: minmax(0, 520px) minmax(0, 1fr); gap: clamp(20px, 4vw, 48px); align-items: start; }
.tower-fig { position: relative; border: 1px solid var(--line); background: #05060a; line-height: 0; }
#towerSvg { width: 100%; height: auto; display: block; }
.tw-empty { fill: #0d0f14; }
.tw-ghost { fill: #151922; stroke: var(--line-2); stroke-width: 2; stroke-dasharray: 8 8; }
.tw-ground { fill: #0a0b0f; }
.tw-gl { stroke: #4b5263; stroke-width: 2; stroke-dasharray: 10 8; }
.tw-gltext { fill: #626978; font: 500 13px 'Cinzel', serif; letter-spacing: 3px; }
.tw-base { fill: #12151d; stroke: #343b4a; stroke-width: 2; }
.tw-baseline { stroke: #2a303c; stroke-width: 1.5; }
.tw-room { fill: #e58ad0; opacity: .32; }
.tw-btext { fill: #9299a8; font: 500 15px 'Cinzel', serif; letter-spacing: 1px; }
.tw-zone {
  fill: var(--z); fill-opacity: 0;
  stroke: var(--z); stroke-opacity: .34; stroke-width: 1.5;
  cursor: pointer; outline: none;
  transition: fill-opacity .18s, stroke-opacity .18s;
}
.tw-zone.hot, .tw-zone:focus-visible { fill-opacity: .34; stroke-opacity: 1; stroke-width: 3; }
.tw-zone.on { fill-opacity: .24; stroke-opacity: 1; stroke-width: 3; }
.tw-zone.on.hot { fill-opacity: .4; }

.tower-tip {
  position: absolute; z-index: 3; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 150px; max-width: 240px;
  padding: 10px 14px; line-height: 1.5;
  background: rgba(8, 9, 13, .94); border: 1px solid var(--line-2); border-left: 3px solid var(--z);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.tower-tip[hidden] { display: none; }
.tower-tip b { font-family: var(--display); font-size: 13px; letter-spacing: .12em; color: var(--z); }
.tower-tip span { font-size: 15px; font-weight: 500; }
.tower-tip em { font-style: normal; font-size: 11px; color: var(--dim); }

.tower-side { position: sticky; top: 84px; }
.floor-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); }
.floor-list li + li { border-top: 1px solid var(--line); }
.floor-row {
  width: 100%; display: grid; grid-template-columns: 104px 1fr; align-items: center; gap: 12px;
  background: transparent; border: 0; border-left: 3px solid transparent;
  padding: 11px 16px; text-align: left; transition: background .18s, border-color .18s;
}
.floor-no { font-family: var(--display); font-size: 13px; letter-spacing: .1em; color: var(--z); }
.floor-name { font-size: 15px; }
.floor-row.hot { background: rgba(255, 255, 255, .05); border-left-color: var(--z); }
.floor-row.on { background: rgba(255, 255, 255, .08); border-left-color: var(--z); }

.floor-detail { margin-top: 20px; min-height: 200px; padding: 24px 26px; background: var(--panel); border: 1px solid var(--line); border-top: 2px solid var(--z, var(--line-2)); }
.fd-hint { color: var(--dim); font-size: 14px; }
.fd-floor { font-family: var(--display); letter-spacing: .16em; color: var(--z); font-size: 14px; }
.fd-name { font-size: 24px; line-height: 1.4; margin-top: 2px; }
.fd-label { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.fd-desc + .fd-desc { margin-top: 4px; }
.fd-facts { margin: 16px 0 0; border-top: 1px solid var(--line); }
.fd-facts div { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.fd-facts dt { color: var(--muted); }
.fd-facts dd { margin: 0; }
.fd-note { margin-top: 14px; font-size: 14px; color: var(--silver); }
.fd-people { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.fd-person { background: transparent; border: 1px solid var(--c); color: var(--text); font-size: 13px; padding: 5px 14px; border-radius: 999px; transition: background .2s; }
.fd-person:hover { background: rgba(255, 255, 255, .08); }

/* ---------- 인물 명단 ---------- */
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.card {
  display: flex; flex-direction: column; text-align: left; padding: 0;
  background: var(--panel); border: 1px solid var(--line);
  transition: transform .25s, border-color .25s, box-shadow .25s;
}
.card:hover, .card:focus-visible { transform: translateY(-4px); border-color: var(--c); box-shadow: 0 14px 34px rgba(0, 0, 0, .45); }
.card-photo { aspect-ratio: 3 / 4; background: var(--bg-2); border-bottom: 2px solid var(--c); }
.card-photo .slot-empty { border: 0; }
.card-photo .slot-label { color: var(--c); opacity: .7; font-size: 15px; }
.card-info { display: flex; flex-direction: column; padding: 16px 18px 18px; position: relative; }
.card-no { position: absolute; right: 16px; top: 16px; font-family: var(--display); font-size: 11px; letter-spacing: .14em; color: var(--dim); }
.card-code { font-family: var(--display); font-size: 13px; letter-spacing: .22em; color: var(--c); }
.card-name { font-size: 22px; font-weight: 700; line-height: 1.5; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-meta b { color: var(--text); font-weight: 500; }
.card-villain .card-meta { color: #d08e86; }

/* ---------- 프로필 모달 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: clamp(0px, 3vw, 32px); }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 4, 6, .82); backdrop-filter: blur(6px); }
.modal-card {
  position: relative; width: min(1080px, 100%); max-height: 100%; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .7);
}
.modal-close {
  position: sticky; top: 10px; display: block; margin: 10px 10px -50px auto; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(7, 8, 11, .85); border: 1px solid var(--line-2); font-size: 22px; line-height: 1;
}
.modal-close:hover { border-color: var(--silver); }
.modal-body { display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr); border-top: 3px solid var(--c); }
.p-media { padding: 28px; background: #090a0e; border-right: 1px solid var(--line); }
.p-photo { aspect-ratio: 3 / 4; position: sticky; top: 28px; }
.p-photo .slot-label { color: var(--c); font-size: 16px; }
.p-thumbs { display: flex; gap: 8px; margin-top: 12px; }
.p-thumb { width: 64px; height: 84px; padding: 0; background: var(--bg); border: 1px solid var(--line-2); opacity: .6; }
.p-thumb.on { opacity: 1; border-color: var(--c); }
.p-thumb img { width: 100%; height: 100%; object-fit: contain; }
.p-text { padding: 36px clamp(20px, 4vw, 44px) 40px; min-width: 0; }
.p-eyebrow { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .3em; color: var(--dim); }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--sw); box-shadow: 0 0 0 1px rgba(255, 255, 255, .35); }
.p-code { font-family: var(--display); font-weight: 700; font-size: clamp(34px, 6vw, 60px); line-height: 1.15; letter-spacing: .1em; color: var(--c); overflow-wrap: anywhere; }
.p-name { font-size: 26px; margin-top: 4px; }
.p-name small { font-size: 14px; font-weight: 400; color: var(--muted); margin-left: 10px; }
.p-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip { font-size: 12px; letter-spacing: .06em; padding: 2px 12px; border: 1px solid var(--line-2); color: var(--silver); }
.chip:first-child { border-color: var(--c); color: var(--text); }
.p-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 1px; margin: 24px 0 0; padding: 1px; }
.p-stats div { background: var(--bg-2); padding: 12px 14px; box-shadow: 0 0 0 1px var(--line); }
.p-stats dt { font-size: 11px; letter-spacing: .14em; color: var(--dim); }
.p-stats dd { margin: 0; font-size: 16px; font-weight: 500; }
.p-block { margin-top: 28px; }
.p-block h4 { font-size: 12px; letter-spacing: .26em; color: var(--muted); font-weight: 500; padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.p-block > p + p { margin-top: 12px; }
.p-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; padding: 3px 12px; background: rgba(255, 255, 255, .05); border-radius: 999px; }
.tag-on { background: transparent; border: 1px solid var(--c); }
.p-habit { margin-top: 12px; font-size: 14px; color: var(--silver); padding-left: 12px; border-left: 2px solid var(--c); }
.p-abilities { margin: 0; padding: 0; list-style: none; counter-reset: ab; }
.p-abilities li { counter-increment: ab; display: grid; grid-template-columns: 28px 1fr; column-gap: 8px; padding: 8px 0; }
.p-abilities li::before { content: counter(ab) '.'; font-family: var(--display); color: var(--c); grid-row: span 2; }
.p-abilities b { font-weight: 700; }
.p-abilities span { color: var(--muted); font-size: 14px; }
.p-timeline { margin: 0; padding: 0 0 0 14px; list-style: none; border-left: 1px solid var(--line-2); }
.p-timeline li { position: relative; display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 7px 0; font-size: 15px; }
.p-timeline li::before { content: ''; position: absolute; left: -18px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.p-timeline b { color: var(--silver); font-weight: 500; }
.p-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 32px; font-size: 14px; }
.p-foot .k { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); margin-right: 10px; }
.p-foot a { color: var(--text); text-underline-offset: 4px; }
.p-foot a:hover { color: var(--c); }

/* ---------- 하단 ---------- */
.footer { margin-top: clamp(72px, 10vw, 128px); text-align: center; }
.footer p { padding: 28px 16px 40px; font-family: var(--display); font-size: 12px; letter-spacing: .28em; color: var(--dim); }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 900px) {
  .factions { grid-template-columns: 1fr; }
  .versus { justify-self: center; }
  .tower-wrap { grid-template-columns: 1fr; }
  .tower-fig { max-width: 520px; margin: 0 auto; width: 100%; }
  .tower-side { position: static; }
}
@media (max-width: 720px) {
  .terms { grid-template-columns: 1fr; }
  .term-uniform { grid-template-columns: 1fr; }
  .uniform-slot { max-width: 320px; }
  .modal-body { grid-template-columns: 1fr; }
  .p-media { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px; }
  .p-photo { position: relative; top: auto; max-width: 280px; margin: 0 auto; }
  .p-thumbs { justify-content: center; }
  .roster { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-name { font-size: 18px; }
  .card-no { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
