@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600;700&family=Gowun+Batang:wght@400;700&family=IBM+Plex+Sans+KR:wght@400;500;600&display=swap');

:root {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #111111;
  --line: #252525;
  --text: #e8e4dc;
  --muted: #9b9b9b;
  --gold: #cdb477;
  --gold-dim: #8d7b50;
  --max: 920px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-bottom: 90px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Gowun Batang", serif;
  line-height: 1.6;
}

button {
  font: inherit;
  color: inherit;
}

.topbar {
  height: 92px;
  padding: 0 5%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 17, 24, .97);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--gold);
}

.brand-mark svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-title {
  letter-spacing: .12em;
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  font-size: 22px;
}

.brand-sub {
  color: var(--gold);
  font-family: "Cormorant Garamond", serif;
  letter-spacing: .18em;
  font-size: 13px;
  margin-top: 2px;
}

.era {
  color: var(--gold);
  font-family: "IBM Plex Sans KR", sans-serif;
  font-size: 18px;
}

main {
  width: min(var(--max), 100%);
  margin: 0 auto;
  padding: 56px 5% 120px;
}

.hero {
  margin-bottom: 44px;
}

.eyebrow, .section-kicker {
  color: var(--gold);
  font-family: "IBM Plex Sans KR", sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .15em;
}

.hero h1 {
  margin: 12px 0 16px;
  font-family: "Gowun Batang", serif;
  font-size: clamp(42px, 8vw, 72px);
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1.1;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.panel {
  border-top: 1px solid var(--line);
  padding: 44px 0;
  scroll-margin-top: 20px;
}

.section-heading h2 {
  margin: 7px 0 25px;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 500;
}

.map-frame {
  border: 1px solid var(--line);
  padding: 14px;
  background: var(--surface);
}

.map-placeholder {
  aspect-ratio: 16 / 9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #364550;
  background:
    radial-gradient(circle at 50% 45%, rgba(205,180,119,.12), transparent 35%),
    linear-gradient(135deg, #14222b, #0b151d);
  text-align: center;
}

.map-placeholder span {
  color: var(--gold);
  font-family: "IBM Plex Sans KR", sans-serif;
  letter-spacing: .25em;
  font-size: 12px;
}

.map-placeholder strong {
  margin-top: 8px;
  font-family: "IBM Plex Sans KR", sans-serif;
  letter-spacing: .12em;
  font-size: clamp(17px, 3vw, 28px);
}

.map-placeholder small {
  margin-top: 10px;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  margin: 17px 0 25px;
}

.faction-grid,
.character-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.faction-grid button,
.lore-list button {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 21px;
  text-align: left;
  cursor: pointer;
  transition: .18s ease;
}

.faction-grid button:hover,
.lore-list button:hover {
  border-color: var(--gold-dim);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  margin-top: 34px;
  padding-top: 25px;
  gap: 10px;
}

.stats div { text-align: center; }

.stats strong {
  display: block;
  color: var(--gold);
  font-size: 31px;
  font-weight: 500;
}

.stats span {
  color: var(--muted);
  font-size: 13px;
}

.character-card {
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
}

.portrait {
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  background: linear-gradient(145deg, #27343d, #0d171e);
  color: rgba(255,255,255,.25);
  font-family: "IBM Plex Sans KR", sans-serif;
  font-size: 13px;
  letter-spacing: .14em;
}

.character-info {
  padding: 17px;
}

.character-info span {
  color: var(--gold);
  font-family: "IBM Plex Sans KR", sans-serif;
  font-size: 10px;
  letter-spacing: .14em;
}

.character-info h3 {
  margin: 5px 0;
  font-size: 18px;
  font-weight: 500;
}

.character-info p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.lore-list {
  display: grid;
  gap: 10px;
}

.lore-list button {
  display: grid;
  grid-template-columns: 40px 150px 1fr;
  align-items: center;
}

.lore-list span {
  color: var(--gold);
  font-family: "IBM Plex Sans KR", sans-serif;
}

.lore-list b { font-weight: 500; }

.lore-list em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.bottom-nav {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(14, 24, 32, .97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.bottom-nav button {
  position: relative;
  border: 0;
  background: transparent;
  color: #aeb6bc;
  padding: 18px 8px;
  cursor: pointer;
}

.bottom-nav button.active {
  color: var(--gold);
  background: rgba(255,255,255,.025);
}

.bottom-nav button.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 25%;
  right: 25%;
  height: 4px;
  background: var(--gold);
}

@media (max-width: 620px) {
  .topbar { height: 84px; }
  main { padding-top: 42px; }

  .faction-grid,
  .character-grid {
    grid-template-columns: 1fr;
  }

  .lore-list button {
    grid-template-columns: 32px 1fr;
  }

  .lore-list em {
    grid-column: 2;
  }
}

@media (min-width: 800px) {
  .bottom-nav {
    left: 50%;
    right: auto;
    width: min(var(--max), 100%);
    transform: translateX(-50%);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}

/* Interactive world and character directory */
.topbar { background: #050505; }
.faction-grid button { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 74px; }
.faction-grid button span { color: var(--gold-dim); font: 11px "IBM Plex Sans KR", sans-serif; letter-spacing: .08em; white-space: nowrap; }
.character-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.character-card { transition: border-color .18s ease, transform .18s ease; }
.character-card:hover, .character-card:focus-visible { border-color: var(--gold-dim); transform: translateY(-2px); outline: none; }
.portrait { position: relative; aspect-ratio: 4 / 5; padding: 0; overflow: hidden; background: radial-gradient(circle at 50% 35%, #242018, #090909 72%); }
.portrait-image { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.portrait-fallback::after { content: "PORTRAIT UNAVAILABLE"; position: absolute; left: 10px; right: 10px; bottom: 12px; color: #777; text-align: center; font: 10px "IBM Plex Sans KR", sans-serif; letter-spacing: .08em; }
.character-info { min-height: 124px; }
.character-info h3 { line-height: 1.45; overflow-wrap: anywhere; }
.hint { line-height: 1.8; }
.detail-dialog { width: min(640px, calc(100% - 28px)); max-height: min(82vh, 800px); overflow-y: auto; padding: clamp(24px, 5vw, 42px); border: 1px solid #3b3425; background: #080808; color: var(--text); box-shadow: 0 24px 100px #000; }
.detail-dialog::backdrop { background: rgba(0,0,0,.82); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; top: 12px; right: 15px; border: 0; background: transparent; color: var(--muted); font-size: 30px; cursor: pointer; line-height: 1; }
.dialog-kicker { padding-right: 35px; color: var(--gold); font: 11px "IBM Plex Sans KR", sans-serif; letter-spacing: .14em; }
.detail-dialog h2 { margin: 12px 0 18px; font-size: clamp(25px, 5vw, 36px); line-height: 1.35; font-weight: 500; }
.detail-dialog > p { color: #c1bdb4; line-height: 1.9; }
.dialog-section { margin-top: 27px; padding-top: 20px; border-top: 1px solid var(--line); }
.dialog-section h3 { margin: 0 0 12px; color: var(--gold); font-size: 16px; font-weight: 500; }
.dialog-section ul { margin: 0; padding-left: 21px; color: #c4c0b7; }
.dialog-section li { padding: 4px 0 7px; line-height: 1.75; }
.intervention { border-top-color: #55482d; }
.bottom-nav { background: rgba(4,4,4,.97); }
@media (max-width: 760px) { .character-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .character-info { padding: 13px; } .character-info h3 { font-size: 16px; } }
@media (max-width: 420px) { .faction-grid button { align-items: flex-start; flex-direction: column; gap: 5px; } .character-grid { gap: 8px; } .character-info p { font-size: 12px; } }


/* Fix: show the complete square character artwork and prevent names from being clipped */
.portrait {
  aspect-ratio: 1 / 1;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #000;
}

.portrait-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.character-info {
  min-width: 0;
  min-height: 124px;
  overflow: visible;
}

.character-info h3 {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.5;
}

.character-info p {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.6;
}

@media (max-width: 420px) {
  .character-info {
    padding: 11px;
    min-height: 0;
  }

  .character-info h3 {
    font-size: 15px;
  }
}
