:root {
  color-scheme: dark;
  --ink: #17120f;
  --ink-soft: #2b221c;
  --paper: #e8dcc4;
  --paper-bright: #f4ecd9;
  --paper-muted: #cbbb9e;
  --gold: #b89456;
  --gold-bright: #e2c88f;
  --red: #9e3f35;
  --line: rgba(206, 176, 122, 0.34);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.46);
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--paper);
  background:
    radial-gradient(circle at 50% -20%, rgba(126, 91, 48, 0.25), transparent 44%),
    linear-gradient(135deg, #110d0b, #211812 52%, #100c0a);
  font-family: var(--serif);
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 4px;
}

img {
  display: block;
  max-width: 100%;
}

.site-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 10px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgba(211, 179, 122, 0.24);
  background: rgba(20, 15, 12, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--paper-bright);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50% 50% 46% 54%;
  color: var(--gold-bright);
  background: rgba(151, 56, 43, 0.24);
  font-size: 21px;
  box-shadow: inset 0 0 0 4px rgba(184, 148, 86, 0.08);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0.14em;
}

.brand small {
  margin-top: 3px;
  color: #a9987d;
  font-size: 11px;
  letter-spacing: 0.28em;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
}

.main-nav a,
.about-button {
  position: relative;
  border: 0;
  padding: 10px 0;
  color: #bcae96;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.main-nav a::after,
.about-button::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 1px;
  background: var(--gold-bright);
  transform: scaleX(0);
  transition: transform 180ms ease;
}

.main-nav a:hover,
.main-nav a.active,
.about-button:hover {
  color: var(--paper-bright);
}

.main-nav a:hover::after,
.main-nav a.active::after,
.about-button:hover::after {
  transform: scaleX(1);
}

#app {
  flex: 1;
}

.map-view {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 5vw, 70px) clamp(16px, 4vw, 54px) 72px;
}

.map-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

.map-heading h1,
.roster-heading h1,
.character-copy h1 {
  margin: 0;
  color: var(--paper-bright);
  font-weight: 500;
  letter-spacing: 0.1em;
}

.map-heading h1 {
  font-size: clamp(34px, 5vw, 70px);
}

.map-heading p:last-child,
.roster-heading p:last-child {
  max-width: 680px;
  margin: 14px 0 0;
  color: #b3a48c;
  line-height: 1.9;
}

.map-instruction {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid rgba(190, 151, 91, 0.28);
  color: #cbbb9e;
  background: rgba(31, 23, 18, 0.62);
  font-size: 13px;
  white-space: nowrap;
}

.map-instruction::before {
  content: "◆";
  color: var(--red);
  font-size: 12px;
}

.map-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(202, 170, 112, 0.55);
  background: #b9a887;
  box-shadow: var(--shadow);
  isolation: isolate;
}

.map-stage::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 7px rgba(35, 25, 18, 0.35),
    inset 0 0 80px rgba(28, 17, 10, 0.44);
}

.map-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
}

.map-canvas > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  filter: sepia(0.08) contrast(1.02) saturate(0.88);
}

.map-pin {
  --pin-color: var(--red);
  position: absolute;
  z-index: 4;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(248, 227, 185, 0.82);
  border-radius: 50%;
  color: #fff4dc;
  background: color-mix(in srgb, var(--pin-color) 82%, #25160f);
  box-shadow:
    0 0 0 6px rgba(245, 224, 181, 0.14),
    0 8px 22px rgba(0, 0, 0, 0.36);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.map-pin:hover,
.map-pin[aria-pressed="true"] {
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow:
    0 0 0 9px rgba(245, 224, 181, 0.2),
    0 10px 26px rgba(0, 0, 0, 0.46);
}

.map-pin span {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  padding: 5px 8px;
  border: 1px solid rgba(82, 57, 34, 0.55);
  color: #2a1d13;
  background: rgba(239, 220, 183, 0.92);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
}

.city-pin {
  --pin-color: #8a6d3f;
  position: absolute;
  z-index: 3;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: 13px;
  height: 13px;
  border: 2px solid #f3dfb8;
  border-radius: 2px;
  background: color-mix(in srgb, var(--pin-color) 80%, #21150e);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.42);
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(45deg);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.city-pin:hover,
.city-pin[aria-pressed="true"] {
  z-index: 5;
  transform: translate(-50%, -50%) rotate(45deg) scale(1.35);
  box-shadow:
    0 0 0 6px rgba(245, 224, 181, 0.18),
    0 6px 16px rgba(0, 0, 0, 0.5);
}

.city-pin span {
  position: absolute;
  top: -10px;
  left: 15px;
  padding: 3px 6px;
  border: 1px solid rgba(82, 57, 34, 0.5);
  color: #2f2116;
  background: rgba(241, 224, 186, 0.92);
  font-size: 11px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transform: rotate(-45deg);
  transform-origin: left center;
}

.location-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.75fr);
  gap: clamp(22px, 4vw, 52px);
  margin: 18px 12px 0;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(202, 170, 112, 0.42);
  background:
    linear-gradient(125deg, rgba(51, 36, 26, 0.98), rgba(22, 17, 14, 0.98)),
    #17120f;
  box-shadow: var(--shadow);
  animation: panel-in 240ms ease both;
}

.location-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 10px;
}

.location-title-row h2 {
  margin: 0;
  color: var(--paper-bright);
  font-size: clamp(28px, 3.3vw, 46px);
  font-weight: 500;
  letter-spacing: 0.08em;
}

.location-kind {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--region-tone) 70%, #d9bd84);
  color: #ead6ad;
  background: color-mix(in srgb, var(--region-tone) 18%, transparent);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.location-subtitle {
  margin: 0 0 18px;
  color: var(--gold-bright);
}

.location-description {
  max-width: 820px;
  margin: 0;
  color: #c5b79e;
  line-height: 2;
}

.location-parent {
  display: inline-block;
  margin-top: 18px;
  color: #9f9078;
  font-size: 13px;
}

.location-choices {
  display: grid;
  align-content: start;
  gap: 8px;
}

.location-choices > p {
  margin: 0 0 6px;
  color: #9f9078;
  font-size: 12px;
  letter-spacing: 0.18em;
}

.location-choice {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(202, 170, 112, 0.22);
  color: #d9c8a8;
  background: rgba(255, 255, 255, 0.025);
  text-align: left;
  cursor: pointer;
}

.location-choice:hover,
.location-choice.active {
  border-color: color-mix(in srgb, var(--region-tone) 65%, #d9bd84);
  background: color-mix(in srgb, var(--region-tone) 15%, transparent);
}

.location-choice strong {
  font-weight: 500;
  letter-spacing: 0.08em;
}

.location-choice small,
.location-empty {
  color: #95866f;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.5;
}

.region-panel {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 2fr);
  gap: clamp(20px, 4vw, 48px);
  margin: -2px 12px 0;
  padding: clamp(24px, 4vw, 44px);
  border: 1px solid rgba(202, 170, 112, 0.42);
  border-top: 0;
  background:
    linear-gradient(120deg, rgba(39, 28, 21, 0.98), rgba(20, 16, 13, 0.98)),
    #17120f;
  box-shadow: var(--shadow);
  animation: panel-in 260ms ease both;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
}

.region-copy h2 {
  margin: 8px 0 10px;
  color: var(--paper-bright);
  font-size: clamp(26px, 3vw, 42px);
  font-weight: 500;
  letter-spacing: 0.08em;
}

.region-subtitle {
  margin: 0 0 18px;
  color: var(--gold-bright);
}

.region-description {
  margin: 0;
  color: #b9aa91;
  line-height: 1.9;
}

.region-count {
  display: inline-flex;
  margin-top: 22px;
  padding: 6px 10px;
  border-left: 2px solid var(--region-tone, var(--red));
  color: #d7c7a9;
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.region-characters {
  display: grid;
  grid-template-columns: repeat(auto-fill, 134px);
  gap: 14px;
  align-content: start;
  justify-content: start;
}

.mini-character,
.roster-card {
  position: relative;
  aspect-ratio: 44 / 67;
  overflow: hidden;
  border: 1px solid rgba(202, 170, 112, 0.35);
  color: inherit;
  background: #211812;
  text-align: left;
  cursor: pointer;
}

.mini-character img,
.roster-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 450ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.mini-character::after,
.roster-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 42%, rgba(9, 7, 6, 0.94) 100%);
  pointer-events: none;
}

.mini-character:hover img,
.roster-card:hover img {
  transform: scale(1.045);
}

.mini-character-content,
.roster-card-content {
  position: absolute;
  z-index: 2;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 16px 14px 13px;
}

.mini-character strong,
.roster-card strong {
  display: block;
  color: #fff7e8;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.12em;
}

.mini-character small,
.roster-card small {
  display: block;
  margin-top: 5px;
  color: #c8b898;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.45;
}

.roster-view {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: clamp(34px, 6vw, 78px) clamp(16px, 4vw, 54px) 84px;
}

.roster-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 26px;
  margin-bottom: 34px;
}

.roster-heading h1 {
  font-size: clamp(34px, 4vw, 58px);
}

.filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.filter-button {
  border: 1px solid rgba(201, 169, 111, 0.3);
  padding: 8px 12px;
  color: #b7a88f;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.filter-button:hover,
.filter-button.active {
  border-color: var(--gold);
  color: #fff5df;
  background: rgba(150, 58, 46, 0.22);
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 18px;
}

.character-view {
  position: relative;
  min-height: calc(100vh - 74px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--character-tone) 15%, transparent), transparent 38%),
    #120d0a;
}

.character-page {
  position: relative;
  z-index: 2;
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: clamp(30px, 5vw, 70px) clamp(18px, 5vw, 72px) 90px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 0;
  color: #c7b798;
  background: transparent;
  cursor: pointer;
}

.back-link::before {
  content: "←";
  color: var(--gold);
}

.character-layout {
  display: flex;
  flex-direction: column;
  gap: clamp(28px, 5vw, 58px);
  align-items: stretch;
  margin-top: 30px;
}

.character-art {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
}

.character-art::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -12px;
  border: 1px solid rgba(202, 170, 112, 0.28);
}

.character-art img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.52);
}

.character-copy {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding: clamp(26px, 4vw, 48px) 0 20px;
  border-top: 1px solid rgba(202, 170, 112, 0.22);
}

.character-copy h1 {
  font-size: clamp(42px, 6vw, 76px);
}

.roman-name {
  margin: 8px 0 30px;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.45em;
}

.identity {
  margin: 0;
  color: #f2e3c7;
  font-size: 18px;
}

.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 28px;
}

.meta-list span {
  padding: 7px 10px;
  border: 1px solid rgba(197, 162, 102, 0.3);
  color: #bfae90;
  background: rgba(255, 255, 255, 0.025);
  font-family: var(--sans);
  font-size: 12px;
}

.character-quote {
  margin: 0 0 28px;
  padding: 16px 0 16px 20px;
  border-left: 2px solid var(--character-tone, var(--red));
  color: #ddccb0;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.7;
}

.story-tabs {
  display: flex;
  gap: 22px;
  border-bottom: 1px solid rgba(203, 172, 115, 0.22);
}

.story-tab {
  border: 0;
  padding: 10px 0;
  color: #95866f;
  background: transparent;
  cursor: pointer;
}

.story-tab.active {
  color: var(--paper-bright);
  box-shadow: 0 1px 0 var(--gold-bright);
}

.story-content {
  min-height: 190px;
  padding-top: 22px;
}

.story-content p {
  margin: 0;
  color: #bbae97;
  font-size: 16px;
  line-height: 2;
}

.character-pagination {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
}

.character-pagination button {
  border: 1px solid rgba(202, 170, 112, 0.26);
  padding: 10px 14px;
  color: #c9b999;
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
}

.character-pagination button:hover {
  border-color: var(--gold);
  color: #fff4dc;
}

.empty-state {
  padding: 80px 20px;
  color: #ad9d84;
  text-align: center;
}

.about-dialog {
  width: min(620px, calc(100% - 32px));
  border: 1px solid rgba(205, 171, 112, 0.6);
  padding: clamp(28px, 6vw, 58px);
  color: var(--paper);
  background:
    radial-gradient(circle at 100% 0%, rgba(143, 59, 45, 0.22), transparent 45%),
    #211812;
  box-shadow: var(--shadow);
}

.about-dialog::backdrop {
  background: rgba(8, 6, 5, 0.76);
  backdrop-filter: blur(5px);
}

.about-dialog h2 {
  margin: 4px 0 20px;
  color: var(--paper-bright);
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 500;
}

.about-dialog p:not(.eyebrow) {
  color: #b8a990;
  line-height: 1.95;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 18px;
  border: 0;
  color: #ab9b82;
  background: transparent;
  font-size: 30px;
  cursor: pointer;
}

.text-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--gold-bright);
  text-decoration: none;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(20px, 4vw, 64px);
  border-top: 1px solid rgba(205, 173, 117, 0.18);
  color: #806f5b;
  background: #100c0a;
  font-size: 11px;
  letter-spacing: 0.12em;
}

@media (max-width: 1000px) {
  .map-heading,
  .roster-heading,
  .character-layout {
    grid-template-columns: 1fr;
  }

  .map-heading {
    align-items: start;
  }

  .map-instruction {
    justify-self: start;
  }

  .region-panel,
  .location-detail {
    grid-template-columns: 1fr;
  }

  .roster-heading {
    display: grid;
    align-items: start;
  }

  .filter-list {
    justify-content: flex-start;
  }

  .character-layout {
    max-width: 820px;
    margin-inline: auto;
  }

  .character-copy {
    order: -1;
  }
}

@media (max-width: 700px) {
  .site-header {
    position: relative;
    align-items: flex-start;
    padding: 14px 16px;
  }

  .brand small {
    display: none;
  }

  .main-nav {
    gap: 14px;
    font-size: 13px;
  }

  .main-nav .about-button {
    display: none;
  }

  .map-view,
  .roster-view {
    padding-top: 30px;
  }

  .map-stage {
    overflow-x: auto;
  }

  .map-canvas {
    width: 100%;
    min-width: 720px;
  }

  .region-panel,
  .location-detail {
    margin-inline: 0;
    padding: 22px 16px;
  }

  .region-characters {
    display: flex;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
  }

  .mini-character {
    min-width: 154px;
    scroll-snap-align: start;
  }

  .roster-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .character-page {
    padding-inline: 16px;
  }

  .character-copy h1 {
    font-size: 48px;
  }

  .character-pagination {
    flex-direction: column;
  }

  .site-footer {
    display: block;
    text-align: center;
  }

  .site-footer span:last-child {
    display: none;
  }
}

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