:root {
  color-scheme: light;
  --paper: #8a6038;
  --window: #faf3e5;
  --panel: #fffcf5;
  --panel-soft: #f6ead6;
  --line: #edddc1;
  --line-strong: #d9bd90;
  --ink: #4a3a2a;
  --muted: #9a876b;
  --brown: #7a5230;
  --brown-dark: #604026;
  --orange: #e8915b;
  --orange-dark: #c9743f;
  --green: #6fa17a;
  --blue: #5e86c2;
  --red: #b85d50;
  --violet: #8b75bd;
  --shadow-line: #ecdcbe;
  --font-title: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 248, 236, 0.18), transparent 28%),
    linear-gradient(180deg, #9b7046 0%, var(--paper) 42%, #704a2b 100%);
  color: var(--ink);
  font-family: var(--font-ui);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 24px auto 44px;
}

.app-window {
  overflow: hidden;
  border-radius: 18px;
  background: var(--window);
  box-shadow: 0 18px 40px rgba(50, 31, 18, 0.22);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 0 32px;
  background: linear-gradient(180deg, #9c6f47, var(--paper));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff8ec;
  text-decoration: none;
  font-family: var(--font-title);
  font-size: 17px;
  font-weight: 900;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--window);
  color: var(--orange);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
  font-size: 17px;
}

.nav-actions {
  display: flex;
  align-self: stretch;
  align-items: end;
  gap: 2px;
}

.nav-button {
  height: 40px;
  margin-bottom: 0;
  border: 0;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: #f6e4ce;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.nav-button.active {
  height: 52px;
  background: var(--window);
  color: var(--brown);
}

.search-panel {
  margin-left: auto;
  width: 260px;
}

.search-panel label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.search-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  padding: 8px 10px 8px 13px;
  color: #f0d9be;
  font-size: 12px;
}

#global-search {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #fff8ec;
  outline: none;
}

#global-search::placeholder {
  color: #f0d9be;
}

#clear-search {
  border: 0;
  border-radius: 8px;
  background: rgba(250, 243, 229, 0.18);
  color: #fff8ec;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.page-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 32px 18px;
}

.breadcrumb {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

h1,
.section-heading h2,
.detail-title h2,
.panel-title {
  font-family: var(--font-title);
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  letter-spacing: 0;
}

.data-summary {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
}

.data-summary strong {
  display: block;
  color: var(--brown);
  font-size: 14px;
}

.content-window {
  margin-top: 16px;
  padding: 18px 32px 32px;
}

.stat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.stat-pill {
  border-radius: 12px;
  background: #f3e3c9;
  color: var(--brown);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.filters,
.detail-panel,
.result-card,
.mob-drop-card,
.item-drop-card,
.link-row,
.description-list,
.stat,
.collection-preview {
  border: 2px solid var(--line);
  background: var(--panel);
  box-shadow: 0 3px 0 var(--shadow-line);
}

.filters,
.detail-panel {
  position: sticky;
  top: 16px;
  border-radius: 16px;
}

.filters {
  padding: 16px;
}

.panel-title {
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.filter-group + .filter-group {
  margin-top: 16px;
}

.filter-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.filter-group input,
.filter-group select {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 11px;
  background: #fffaf1;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

.filter-group input:focus,
.filter-group select:focus,
#global-search:focus {
  outline: none;
}

.range-filter div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#result-count {
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

.result-grid {
  display: grid;
  gap: 10px;
}

.world-map-block {
  grid-column: 1 / -1;
}

.world-map-panel {
  overflow: auto;
  overscroll-behavior: contain;
  max-height: min(78vh, 820px);
  user-select: none;
  border: 2px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(154, 135, 107, 0.12) 1px, transparent 1px),
    linear-gradient(rgba(154, 135, 107, 0.12) 1px, transparent 1px),
    #fffaf1;
  background-size: 24px 24px;
  box-shadow: 0 3px 0 var(--shadow-line);
}

.world-map-block.dedicated {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - 154px);
  min-height: 660px;
}

.world-map-panel.dedicated {
  height: 100%;
  min-height: 0;
  max-height: none;
  cursor: grab;
}

.world-map-panel.dedicated.dragging {
  cursor: grabbing;
}

.world-map-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px 8px;
}

.world-map-block.dedicated .world-map-head {
  padding: 0 4px 8px;
}

.world-map-head h3 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-title);
  font-size: 18px;
}

.world-map-head p,
.world-map-head span {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.world-map-svg {
  display: block;
  max-width: none;
  touch-action: none;
}

.world-map-node {
  cursor: pointer;
}

.world-map-tile {
  fill: transparent;
  stroke: none;
}

.world-map-minimap {
  image-rendering: auto;
  pointer-events: none;
}

.world-map-hitbox {
  fill: rgba(255, 255, 255, 0.001);
  cursor: pointer;
  pointer-events: all;
}

.world-map-missing {
  fill: rgba(243, 227, 201, 0.76);
}

.world-map-node text {
  fill: #fffaf1;
  paint-order: stroke;
  stroke: rgba(74, 58, 42, 0.86);
  stroke-width: 4;
  font-size: 14px;
  font-weight: 900;
  pointer-events: none;
}

.world-map-node.dimmed:not(.matched) {
  opacity: 0.72;
}

.world-map-node.unreachable {
  opacity: 0.5;
}

.world-map-node.unreachable.matched,
.world-map-node.unreachable.selected {
  opacity: 0.86;
}

.world-map-node.matched,
.world-map-node.selected,
.world-map-node:hover {
  filter: brightness(1.12) saturate(1.08);
}

.world-map-tooltip {
  position: fixed;
  z-index: 20;
  width: min(420px, calc(100vw - 20px));
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 252, 245, 0.98);
  box-shadow: 0 10px 28px rgba(50, 31, 18, 0.22);
  padding: 10px;
  pointer-events: none;
}

.world-map-tooltip-main {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.tooltip-map-image {
  display: grid;
  place-items: center;
  width: 112px;
  height: 68px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf1;
}

.tooltip-map-image img {
  max-width: 112px;
  max-height: 68px;
}

.tooltip-map-copy strong,
.tooltip-map-copy span {
  display: block;
}

.tooltip-map-copy strong {
  color: var(--ink);
  font-size: 14px;
}

.tooltip-map-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tooltip-mob-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.tooltip-mob {
  position: relative;
}

.tooltip-mob small {
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 18px;
  border-radius: 999px;
  background: var(--brown);
  color: #fff8ec;
  padding: 1px 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 900;
}

.catalog-tab .workspace {
  grid-template-columns: 220px minmax(0, 1fr);
}

.catalog-tab .detail-panel {
  display: none;
}

.world-tab .page-shell {
  width: calc(100% - 12px);
  margin-top: 6px;
  margin-bottom: 6px;
}

.world-tab .app-window {
  border-radius: 10px;
}

.world-tab .page-title {
  padding: 10px 16px 10px;
}

.world-tab .content-window {
  margin-top: 0;
  padding: 8px 8px 10px;
}

.world-tab .stat-strip,
.world-tab .section-heading {
  display: none;
}

.world-tab .workspace {
  display: block;
}

.world-tab .filters,
.world-tab .detail-panel {
  display: none;
}

.world-tab .result-grid {
  display: block;
}

.map-detail-view .workspace {
  display: block;
}

.map-detail-view .filters,
.map-detail-view .detail-panel {
  display: none;
}

.map-detail-view .result-grid {
  display: block;
}

.result-grid.item-grid,
.result-grid.mob-grid {
  grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  gap: 12px;
}

.result-card {
  width: 100%;
  border-radius: 14px;
  padding: 13px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.result-card:hover,
.result-card.active {
  border-color: var(--orange);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #e0c294;
}

.card-top,
.detail-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-with-media {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.item-card-body {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.mob-card-body {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.mob-drop-grid,
.map-mob-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

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

.mob-drop-card,
.map-mob-card,
.item-drop-card {
  display: grid;
  gap: 12px;
  align-items: center;
  min-height: 104px;
  border-radius: 14px;
  padding: 12px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.mob-drop-card,
.map-mob-card {
  grid-template-columns: 72px minmax(0, 1fr);
}

.item-drop-card {
  grid-template-columns: 52px minmax(0, 1fr);
}

.mob-drop-card:hover,
.map-mob-card:hover,
.item-drop-card:hover {
  border-color: var(--orange);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #e0c294;
}

.mob-drop-card h3,
.map-mob-card h3,
.item-drop-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.item-result-card,
.mob-result-card {
  min-height: 124px;
}

.item-result-card .card-top,
.mob-result-card .card-top {
  display: block;
}

.item-result-card h3,
.mob-result-card h3 {
  min-height: 2.6em;
  line-height: 1.3;
}

.media-frame {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(180deg, #fff9ed, #f2dfbe);
  box-shadow: inset 0 -2px 0 rgba(120, 82, 48, 0.08);
  flex: 0 0 auto;
}

.media-frame img {
  max-width: 42px;
  max-height: 42px;
  image-rendering: pixelated;
}

.media-frame.mob {
  width: 72px;
  height: 72px;
}

.media-frame.mob img {
  max-width: 66px;
  max-height: 66px;
}

.media-frame.mob-mini {
  width: 38px;
  height: 38px;
  border-radius: 9px;
}

.media-frame.mob-mini img {
  max-width: 34px;
  max-height: 34px;
}

.media-frame.fallback::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--orange), var(--green));
}

.result-card h3,
.detail-title h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.meta,
.muted {
  color: var(--muted);
}

.meta {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.4;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 10px;
  padding: 3px 9px;
  background: #f3e3c9;
  color: var(--brown);
  font-size: 11px;
  font-weight: 800;
}

.tag.teal { background: #e3efd9; color: #3c6b53; }
.tag.amber { background: #fbe6cf; color: #c0703a; }
.tag.red { background: #f5ddd5; color: #9f4b42; }
.tag.green { background: #e3efd9; color: #3c6b53; }
.tag.violet { background: #e8e2f5; color: #6f5aa5; }

.detail-panel {
  min-height: 430px;
  padding: 18px;
}

.detail-title {
  align-items: center;
}

.detail-title .detail-media {
  width: 66px;
  height: 66px;
}

.detail-title .detail-media img {
  max-width: 54px;
  max-height: 54px;
}

.item-detail-page {
  max-width: 920px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 3px 0 var(--shadow-line);
  padding: 18px;
}

.map-detail-page {
  max-width: 1180px;
}

.detail-toolbar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 16px;
}

.back-button {
  border: 2px solid var(--line-strong);
  border-radius: 11px;
  background: #f3e3c9;
  color: var(--brown);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.back-button:hover {
  border-color: var(--orange);
  background: #fbe6cf;
}

.empty-detail {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.detail-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: #f3e3c9;
}

.detail-icon::after {
  content: "RO";
  color: var(--orange);
  font-family: var(--font-title);
  font-weight: 900;
}

.collection-preview {
  display: grid;
  place-items: center;
  min-height: 130px;
  margin-top: 16px;
  border-radius: 14px;
  background:
    linear-gradient(90deg, rgba(154, 135, 107, 0.13) 1px, transparent 1px),
    linear-gradient(rgba(154, 135, 107, 0.13) 1px, transparent 1px),
    #fffaf1;
  background-size: 12px 12px;
}

.collection-preview img {
  max-width: min(100%, 184px);
  max-height: 164px;
  image-rendering: pixelated;
}

.detail-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed #decba9;
}

.detail-section h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}

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

.stat {
  border-radius: 12px;
  padding: 9px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
}

.link-list {
  display: grid;
  gap: 8px;
}

.link-row {
  border-radius: 12px;
  padding: 9px;
}

.row-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.row-link:hover {
  border-color: var(--orange);
  box-shadow: 0 5px 0 #e0c294;
  transform: translateY(-1px);
}

.description-list {
  display: grid;
  gap: 3px;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
}

.description-line {
  min-height: 1.3em;
  word-break: break-word;
}

.inline-item-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: 0 2px;
  padding: 0;
  vertical-align: -5px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fffaf1;
  cursor: pointer;
}

.inline-item-icon:hover {
  border-color: var(--orange);
  background: #fbe6cf;
}

.inline-item-icon img {
  max-width: 18px;
  max-height: 18px;
  image-rendering: pixelated;
}

.script-box {
  overflow: auto;
  max-height: 170px;
  border-radius: 12px;
  background: #4a3a2a;
  color: #fff8ec;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1060px) {
  .topbar {
    align-items: stretch;
    flex-wrap: wrap;
    padding: 12px 18px 0;
  }

  .search-panel {
    width: 100%;
    margin: 0 0 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .catalog-tab .workspace {
    grid-template-columns: 1fr;
  }

  .filters,
  .detail-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 16px, 1180px);
    margin-top: 8px;
  }

  .topbar,
  .page-title,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-actions {
    width: 100%;
    overflow-x: auto;
  }

  .content-window,
  .page-title {
    padding-left: 16px;
    padding-right: 16px;
  }

  .card-with-media {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }
}
