/* ================= 基本 ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-deep: #0a0604;
  --bg-paper: #1a120a;
  --paper-light: #2b1d10;
  --paper-tex: #3d2a18;
  --ink: #e8d9b8;
  --ink-dim: #9b8866;
  --gold: #c9a654;
  --gold-bright: #e8c97b;
  --red: #8b2b1e;
  --red-bright: #c2412e;
  --jade: #4a7a6a;
  --purple: #4a1e5c;
  --border: #6b5a47;
  --shadow: rgba(0,0,0,0.6);
}

body {
  font-family: "Noto Serif KR", "Nanum Myeongjo", serif;
  background: var(--bg-deep);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at top, rgba(201,166,84,0.05), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(139,43,30,0.05), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ================= 배경 파티클 ================= */
#bg-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(201,166,84,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(139,43,30,0.03) 0%, transparent 50%);
}

/* ================= NSFW 토글 ================= */
#nsfw-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 6, 4, 0.8);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  backdrop-filter: blur(8px);
}

.nsfw-label {
  font-size: 13px;
  color: var(--ink-dim);
  letter-spacing: 0.1em;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--paper-tex);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: 0.3s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 14px; width: 14px;
  left: 2px; top: 2px;
  background: var(--ink-dim);
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider { background: var(--red); }
input:checked + .slider::before { transform: translateX(20px); background: var(--gold); }

/* ================= VIEW 전환 ================= */
#app { position: relative; z-index: 1; }

.view {
  display: none;
  min-height: 100vh;
  padding: 60px 40px;
  animation: viewFade 0.5s ease-out;
}

.view.active { display: block; }

@keyframes viewFade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= LANDING ================= */
#landing {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 20px;
}

#landing.active { display: flex; }

.landing-inner {
  text-align: center;
  max-width: 800px;
  animation: landingIn 1.2s ease-out;
}

@keyframes landingIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.landing-ornament {
  display: flex;
  justify-content: center;
  margin: 30px 0;
}

.landing-ornament svg {
  width: 260px;
  height: 40px;
}

.main-title {
  margin: 20px 0;
}

.main-title .hanja {
  display: block;
  font-family: "Ma Shan Zheng", "Noto Serif KR", serif;
  font-size: clamp(70px, 12vw, 140px);
  color: var(--gold);
  text-shadow:
    0 0 20px rgba(201,166,84,0.4),
    0 0 40px rgba(201,166,84,0.2);
  letter-spacing: 0.15em;
  line-height: 1;
  font-weight: 400;
}

.main-title .kor {
  display: block;
  font-size: clamp(18px, 3vw, 28px);
  color: var(--ink-dim);
  letter-spacing: 0.4em;
  margin-top: 10px;
}

.main-sub {
  color: var(--ink-dim);
  font-size: 16px;
  letter-spacing: 0.1em;
  margin-bottom: 40px;
}

.enter-btn {
  background: linear-gradient(180deg, var(--paper-tex) 0%, var(--paper-light) 100%);
  color: var(--gold);
  border: 1px solid var(--gold);
  padding: 14px 48px;
  font-family: inherit;
  font-size: 20px;
  letter-spacing: 0.5em;
  cursor: pointer;
  position: relative;
  transition: all 0.4s;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.enter-btn::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(201,166,84,0.3);
  pointer-events: none;
  transition: 0.3s;
}

.enter-btn:hover {
  color: var(--gold-bright);
  box-shadow: 0 0 30px rgba(201,166,84,0.3), inset 0 0 20px rgba(201,166,84,0.1);
}

.enter-btn:hover::before { inset: -8px; }

.btn-deco { width: 18px; height: 18px; }

/* ================= BREADCRUMB ================= */
.breadcrumb {
  font-size: 13px;
  color: var(--ink-dim);
  margin-bottom: 20px;
  letter-spacing: 0.1em;
}

.breadcrumb a {
  color: var(--gold);
  cursor: pointer;
  text-decoration: none;
}

.breadcrumb a:hover { color: var(--gold-bright); }
.breadcrumb span { margin: 0 8px; }
.breadcrumb .current { color: var(--ink); }

.view-title {
  font-size: 36px;
  color: var(--gold);
  letter-spacing: 0.3em;
  text-align: center;
  margin: 20px 0;
  font-weight: 600;
  position: relative;
  padding-bottom: 20px;
}

.view-title::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.view-desc {
  text-align: center;
  color: var(--ink-dim);
  margin-bottom: 40px;
  letter-spacing: 0.05em;
}

/* ================= CATEGORY GRID ================= */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.cat-card {
  background: linear-gradient(145deg, var(--paper-light) 0%, var(--bg-paper) 100%);
  border: 1px solid var(--border);
  padding: 40px 30px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: 0.4s;
  overflow: hidden;
}

.cat-card::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(201,166,84,0.2);
  pointer-events: none;
  transition: 0.3s;
}

.cat-card::after {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(201,166,84,0.1), transparent);
  transition: 0.6s;
}

.cat-card:hover {
  transform: translateY(-6px);
  border-color: var(--gold);
  box-shadow: 0 10px 40px rgba(201,166,84,0.2);
}

.cat-card:hover::before { inset: 8px; }
.cat-card:hover::after { left: 100%; }

.cat-card .cat-hanja {
  font-family: "Ma Shan Zheng", serif;
  font-size: 64px;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 0 20px rgba(201,166,84,0.3);
}

.cat-card .cat-name {
  font-size: 22px;
  color: var(--ink);
  letter-spacing: 0.3em;
  margin: 16px 0 12px;
}

.cat-card .cat-desc {
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.7;
  letter-spacing: 0.03em;
}

.cat-card .cat-count {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(201,166,84,0.2);
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.2em;
}

/* ================= SECT GRID ================= */
.sect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
}

.sect-card {
  background: var(--bg-paper);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: 0.4s;
  aspect-ratio: 3/4;
}

.sect-card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.45;
  transition: 0.5s;
  filter: saturate(0.8) contrast(1.1);
}

.sect-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.2) 0%, rgba(10,6,4,0.9) 100%);
  z-index: 1;
}

.sect-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: var(--gold);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 30px rgba(201,166,84,0.2);
}

.sect-card:hover .sect-card-bg {
  opacity: 0.7;
  transform: scale(1.1);
}

.sect-card-inner {
  position: absolute;
  inset: 0;
  z-index: 2;
  padding: 30px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.sect-card-top {
  text-align: center;
}

.sect-card-hanja {
  font-family: "Ma Shan Zheng", serif;
  font-size: 48px;
  color: var(--gold);
  letter-spacing: 0.15em;
  line-height: 1.1;
  text-shadow: 0 0 20px rgba(0,0,0,0.9);
}

.sect-card-name {
  font-size: 18px;
  color: var(--ink);
  letter-spacing: 0.3em;
  margin-top: 8px;
}

.sect-card-bottom {
  border-top: 1px solid rgba(201,166,84,0.3);
  padding-top: 14px;
  text-align: center;
}

.sect-card-symbol {
  color: var(--ink-dim);
  font-size: 13px;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.sect-card-loc {
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.15em;
}

/* ================= SECT DETAIL (비급) ================= */
.scroll-paper {
  max-width: 960px;
  margin: 0 auto;
  background:
    radial-gradient(ellipse at top, #3d2a18 0%, #1a120a 100%);
  border: 1px solid var(--gold);
  padding: 60px 50px;
  position: relative;
  animation: scrollOpen 0.8s ease-out;
}

.scroll-paper::before,
.scroll-paper::after {
  content: "";
  position: absolute;
  left: -10px; right: -10px;
  height: 20px;
  background: linear-gradient(90deg, var(--red-bright) 0%, var(--red) 50%, var(--red-bright) 100%);
  border: 1px solid var(--gold);
}

.scroll-paper::before { top: -20px; }
.scroll-paper::after { bottom: -20px; }

@keyframes scrollOpen {
  0% { transform: scaleY(0.1); opacity: 0; }
  50% { transform: scaleY(0.3); opacity: 0.5; }
  100% { transform: scaleY(1); opacity: 1; }
}

.sect-head {
  text-align: center;
  padding-bottom: 30px;
  border-bottom: 1px solid rgba(201,166,84,0.3);
  margin-bottom: 30px;
}

.sect-head .hanja-big {
  font-family: "Ma Shan Zheng", serif;
  font-size: 80px;
  color: var(--gold);
  line-height: 1;
  letter-spacing: 0.1em;
}

.sect-head .name-kor {
  font-size: 28px;
  color: var(--ink);
  letter-spacing: 0.4em;
  margin-top: 12px;
}

.sect-head .meta {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 24px;
  font-size: 13px;
  color: var(--ink-dim);
}

.sect-head .meta span { letter-spacing: 0.05em; }
.sect-head .meta .label { color: var(--gold); margin-right: 6px; }

.sect-section {
  margin-bottom: 32px;
}

.sect-section-title {
  font-size: 18px;
  color: var(--gold);
  letter-spacing: 0.25em;
  padding-left: 16px;
  border-left: 3px solid var(--red);
  margin-bottom: 14px;
}

.sect-section-body {
  color: var(--ink);
  line-height: 1.9;
  letter-spacing: 0.02em;
  padding-left: 19px;
}

.sect-section-body ul { list-style: none; }

.sect-section-body li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 6px;
}

.sect-section-body li::before {
  content: "◇";
  position: absolute;
  left: 0;
  color: var(--gold);
  font-size: 10px;
}

.heart-item {
  background: rgba(10,6,4,0.4);
  border-left: 2px solid var(--gold);
  padding: 10px 14px;
  margin-bottom: 10px;
}

.heart-item .hi-name {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.heart-item .hi-tier {
  color: var(--red-bright);
  font-size: 12px;
  margin-left: 10px;
}

.heart-item .hi-desc {
  color: var(--ink-dim);
  font-size: 14px;
  margin-top: 4px;
  line-height: 1.6;
}

.legend-item {
  background: linear-gradient(90deg, rgba(139,43,30,0.15) 0%, transparent 100%);
  border-left: 2px solid var(--red);
  padding: 12px 16px;
  margin-bottom: 10px;
}

.legend-item .li-name {
  color: var(--red-bright);
  font-weight: 600;
  letter-spacing: 0.05em;
}

.legend-item .li-desc {
  color: var(--ink-dim);
  font-size: 14px;
  margin-top: 4px;
  line-height: 1.6;
}

/* NPC 칸 */
.sect-npcs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.npc-card {
  background: rgba(10,6,4,0.6);
  border: 1px solid var(--border);
  padding: 14px;
  cursor: pointer;
  transition: 0.3s;
  text-align: center;
}

.npc-card:hover {
  border-color: var(--gold);
  background: rgba(10,6,4,0.9);
  transform: translateY(-3px);
}

.npc-cover {
  width: 100%;
  aspect-ratio: 1;
  background: var(--paper-tex);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  background-size: cover;
  background-position: center top;
}

.npc-name { color: var(--gold); font-size: 15px; font-weight: 600; letter-spacing: 0.1em; }
.npc-tier { color: var(--ink-dim); font-size: 11px; margin-top: 4px; letter-spacing: 0.1em; }

/* ================= CHARACTER SCROLL MODAL ================= */
.char-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.char-modal.active { display: flex; }

.char-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.3s;
}

@keyframes fadeIn { from {opacity:0} to {opacity:1} }

.char-scroll {
  position: relative;
  width: min(900px, 95vw);
  max-height: 92vh;
  background: linear-gradient(180deg, #3d2a18 0%, #2b1d10 50%, #3d2a18 100%);
  border-left: 2px solid var(--gold);
  border-right: 2px solid var(--gold);
  box-shadow: 0 30px 80px rgba(0,0,0,0.9), inset 0 0 80px rgba(0,0,0,0.4);
  animation: scrollUnroll 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
}

@keyframes scrollUnroll {
  0% { transform: scaleX(0); opacity: 0; }
  40% { transform: scaleX(0.1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 1; }
}

.scroll-top, .scroll-bottom {
  flex-shrink: 0;
  height: 30px;
  background: linear-gradient(90deg, var(--red) 0%, var(--red-bright) 50%, var(--red) 100%);
  border: 2px solid var(--gold);
  border-left: none;
  border-right: none;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
  position: relative;
}

.scroll-top::before, .scroll-bottom::before {
  content: "";
  position: absolute;
  inset: 4px 10px;
  border-top: 1px solid rgba(201,166,84,0.4);
  border-bottom: 1px solid rgba(201,166,84,0.4);
}

.scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  animation: contentFade 0.6s 0.3s both;
}

@keyframes contentFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.scroll-content::-webkit-scrollbar { width: 10px; }
.scroll-content::-webkit-scrollbar-track { background: rgba(0,0,0,0.3); }
.scroll-content::-webkit-scrollbar-thumb { background: var(--border); }
.scroll-content::-webkit-scrollbar-thumb:hover { background: var(--gold); }

.char-close {
  position: absolute;
  top: 50px;
  right: 20px;
  background: var(--bg-paper);
  color: var(--gold);
  border: 1px solid var(--gold);
  width: 36px; height: 36px;
  font-size: 16px;
  cursor: pointer;
  z-index: 10;
  transition: 0.3s;
}

.char-close:hover {
  background: var(--red);
  color: var(--ink);
  transform: rotate(90deg);
}

/* 캐릭터 컨텐츠 */
.char-head {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 30px;
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(201,166,84,0.3);
}

.char-cover-big {
  width: 220px;
  height: 280px;
  background: var(--bg-paper);
  border: 2px solid var(--gold);
  background-size: cover;
  background-position: center top;
  box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}

.char-info .c-name-hanja {
  font-family: "Ma Shan Zheng", serif;
  font-size: 42px;
  color: var(--gold);
  line-height: 1.1;
  letter-spacing: 0.1em;
}

.char-info .c-name-kor {
  font-size: 24px;
  color: var(--ink);
  letter-spacing: 0.3em;
  margin-top: 6px;
}

.char-info .c-tier-badge {
  display: inline-block;
  margin-top: 14px;
  padding: 4px 12px;
  background: rgba(139,43,30,0.3);
  border: 1px solid var(--red-bright);
  color: var(--red-bright);
  font-size: 13px;
  letter-spacing: 0.2em;
}

.char-info .c-meta {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 13px;
  color: var(--ink-dim);
}

.char-info .c-meta .label { color: var(--gold); margin-right: 4px; }

.char-info .c-rep {
  margin-top: 10px;
  font-size: 13px;
  color: var(--ink-dim);
}
.char-info .c-rep .val { color: var(--gold); margin-left: 8px; }

.char-section {
  margin-bottom: 24px;
}

.char-section-title {
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 0.25em;
  padding-left: 14px;
  border-left: 3px solid var(--red);
  margin-bottom: 12px;
}

.char-section-body {
  color: var(--ink);
  line-height: 1.9;
  padding-left: 17px;
}

.speech-bubble {
  background: rgba(10,6,4,0.5);
  border: 1px dashed rgba(201,166,84,0.3);
  padding: 10px 16px;
  margin-bottom: 8px;
  color: var(--ink-dim);
  font-style: italic;
}

.skill-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.skill-item {
  background: rgba(10,6,4,0.5);
  border-left: 2px solid var(--jade);
  padding: 12px 14px;
}

.skill-item .sk-name {
  color: var(--jade);
  font-weight: 600;
  letter-spacing: 0.05em;
  font-size: 14px;
}

.skill-item .sk-desc {
  color: var(--ink-dim);
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.5;
}

/* 갤러리 */
.gallery-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.gallery-tab {
  background: var(--bg-paper);
  color: var(--ink-dim);
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 8px 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.15em;
  transition: 0.3s;
}

.gallery-tab.active {
  background: var(--paper-light);
  color: var(--gold);
  border-color: var(--gold);
}

.gallery-tab.nsfw-tab {
  background: rgba(139,43,30,0.2);
  color: var(--red-bright);
  border-color: var(--red);
}

.gallery-tab.nsfw-tab.active {
  background: rgba(139,43,30,0.4);
  color: var(--red-bright);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.gallery-item {
  aspect-ratio: 3/4;
  background: var(--bg-paper);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: 0.3s;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  transition: 0.5s;
}

.gallery-item:hover {
  border-color: var(--gold);
  transform: scale(1.05);
  z-index: 5;
}

.gallery-item:hover img { transform: scale(1.08); }

.gallery-item.broken { display: none; }

/* 이미지 lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.95);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 20px;
}

.lightbox.active { display: flex; }

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border: 2px solid var(--gold);
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

/* ================= 반응형 ================= */
@media (max-width: 720px) {
  .view { padding: 40px 16px; }
  .char-head {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .char-cover-big { width: 180px; height: 230px; }
  .scroll-paper { padding: 40px 20px; }
  .scroll-content { padding: 24px 20px; }
  .main-title .hanja { letter-spacing: 0.05em; }
  .view-title { font-size: 26px; letter-spacing: 0.15em; }
}
