:root {
  --bg: #ece8df;
  --ink: #e7dcc5;
  --ink-soft: #b9ab8f;
  --paper-line: rgba(29, 24, 16, 0.1);
  --panel: #1a1713;
  --panel-soft: #211d18;
  --panel-2: #15120f;
  --panel-line: rgba(212, 175, 88, 0.16);
  --panel-line-strong: rgba(212, 175, 88, 0.32);
  --gold: #d6ab48;
  --gold-soft: #8c6a2a;
  --sea: #1b3742;
  --sea-soft: #30515c;
  --accent: #8fd17f;
  --warn: #f0b7a5;
  --shadow: 0 28px 60px rgba(12, 10, 7, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  color: var(--ink);
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  background:
    radial-gradient(circle at 1px 1px, rgba(55, 47, 33, 0.12) 1px, transparent 0) 0 0 / 16px 16px,
    linear-gradient(180deg, #f1ede5, #e8e2d7);
}

body {
  overflow: hidden;
}

input,
button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding: 16px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-color: rgba(214, 171, 72, 0.48) rgba(16, 14, 11, 0.28);
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.panel,
.map-shell {
  border: 1px solid #3f3a30;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(214, 171, 72, 0.05), transparent 20%),
    linear-gradient(180deg, var(--panel-soft), var(--panel-2));
  box-shadow: var(--shadow);
}

.panel {
  padding: 14px;
  flex: 0 0 auto;
}

.brand-panel {
  padding-bottom: 14px;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.68rem;
  font-weight: 700;
}

.brand-panel h1,
.map-header h2,
.panel h2 {
  margin: 0;
  color: #f3e6ba;
}

.brand-panel h1 {
  margin-top: 6px;
  font-size: 1.78rem;
  line-height: 0.98;
}

.lede,
.section-heading p,
.muted,
.route-summary-card p,
.search-option span,
.spawn-list article span {
  color: var(--ink-soft);
}

.brand-panel .lede {
  margin: 10px 0 0;
  line-height: 1.35;
}

.section-heading {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 1.1rem;
}

.section-heading p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.world-stats {
  display: grid;
  gap: 7px;
  margin: 14px 0 0;
}

.world-stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 11px;
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.world-stats dt {
  color: var(--ink-soft);
}

.world-stats dd {
  margin: 0;
  color: #f8efcf;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.field > span {
  color: #ecd596;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
}

.picker-shell {
  position: relative;
  display: grid;
  gap: 10px;
}

input[type="search"] {
  width: 100%;
  border-radius: 0;
  border: 1px solid rgba(214, 171, 72, 0.24);
  background: rgba(10, 10, 10, 0.18);
  color: var(--ink);
  padding: 14px 14px;
}

input[type="search"]::placeholder {
  color: #8d7d5f;
}

.selected-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--panel-line-strong);
  border-radius: 999px;
  background: rgba(214, 171, 72, 0.12);
  color: #f3e2aa;
}

.filter-chip button {
  width: auto;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  box-shadow: none;
  line-height: 1;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 6;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--panel-line-strong);
  border-radius: 14px;
  background: rgba(19, 16, 12, 0.98);
  box-shadow: var(--shadow);
}

.search-option {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.search-option:last-child {
  border-bottom: 0;
}

.search-option:hover,
.search-option.active {
  background: rgba(214, 171, 72, 0.12);
}

.search-results-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.03);
}

.search-results-panel[hidden] {
  display: none;
}

.search-results-header {
  display: grid;
  gap: 10px;
}

.search-results-header > div:first-child {
  display: grid;
  gap: 2px;
}

.search-results-header strong {
  color: #f0dfab;
}

.search-results-header span,
.search-result-item span {
  color: var(--ink-soft);
  font-size: 0.88rem;
}

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

.search-results-controls button {
  padding: 9px 10px;
  font-size: 0.72rem;
}

.search-results-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.search-result-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(214, 171, 72, 0.08);
  background: rgba(255, 255, 255, 0.025);
  color: var(--ink);
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
}

.search-result-item.active,
.search-result-item:hover {
  border-color: var(--panel-line-strong);
  background: rgba(214, 171, 72, 0.12);
}

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

.toggle-chip,
.dock-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.toggle-chip {
  border-radius: 999px;
}

.dock-chip {
  border-radius: 12px;
}

.toggle-chip input,
.dock-chip input {
  width: 16px;
  height: 16px;
}

button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 0;
  border: 1px solid rgba(214, 171, 72, 0.36);
  background: linear-gradient(180deg, rgba(90, 61, 29, 0.72), rgba(74, 47, 21, 0.72));
  color: #f2ddb0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}

button:hover {
  border-color: rgba(214, 171, 72, 0.56);
}

.ghost-button,
.route-button-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.route-button-active {
  background: linear-gradient(180deg, rgba(214, 171, 72, 0.9), rgba(130, 92, 33, 0.92));
  color: #1a1207;
}

.route-points p {
  margin: 0;
}

.route-summary {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.route-share-row {
  grid-template-columns: 1fr;
}

.route-summary:empty {
  display: none;
}

.route-summary-card,
.spawn-list article {
  border: 1px solid rgba(214, 171, 72, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
}

.route-summary-card strong,
.spawn-list strong {
  display: block;
  color: #f0dfab;
  margin-bottom: 6px;
}

.details-panel {
  min-height: 160px;
}

.spawn-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.map-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  width: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(214, 171, 72, 0.16);
}

.map-header h2 {
  font-size: 1.35rem;
}

.map-header .ghost-button {
  width: auto;
  min-width: 156px;
}

.map-frame {
  position: relative;
  width: 100%;
  min-height: 0;
  height: 100%;
  margin: 0;
  padding: 12px;
}

#mapCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border: 1px solid rgba(214, 171, 72, 0.22);
  border-radius: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(214, 171, 72, 0.18), transparent 18%),
    radial-gradient(circle at 82% 86%, rgba(214, 171, 72, 0.14), transparent 16%),
    linear-gradient(180deg, rgba(26, 57, 67, 0.95), rgba(15, 34, 40, 0.98)),
    linear-gradient(0deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: auto, auto, auto, 56px 56px, 56px 56px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  cursor: grab;
}

#mapCanvas.dragging {
  cursor: grabbing;
}

.map-controls {
  position: absolute;
  top: 42px;
  right: 42px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2;
}

.map-control,
.map-floor-badge {
  min-width: 66px;
  padding: 12px 10px;
  border: 1px solid rgba(214, 171, 72, 0.24);
  background: rgba(16, 14, 11, 0.88);
  text-align: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.map-floor-badge {
  color: #f0dfab;
  font-weight: 700;
}

.layer-dock {
  position: absolute;
  top: 42px;
  left: 42px;
  z-index: 2;
  display: grid;
  gap: 8px;
  width: min(220px, calc(100% - 140px));
  padding: 12px;
  border: 1px solid rgba(214, 171, 72, 0.2);
  background: rgba(16, 14, 11, 0.84);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

.dock-title {
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
  font-weight: 700;
}

.hud {
  position: absolute;
  left: 42px;
  right: 42px;
  bottom: 42px;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.hud span {
  padding: 10px 12px;
  border: 1px solid rgba(214, 171, 72, 0.18);
  background: rgba(16, 14, 11, 0.82);
  color: var(--ink-soft);
  min-width: 152px;
}

@media (max-width: 1100px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .sidebar {
    overflow: visible;
    padding-right: 0;
  }

  .workspace {
    min-height: auto;
  }

  .map-frame {
    width: 100%;
    min-height: min(78dvh, 860px);
    height: min(78dvh, 860px);
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 16px;
    gap: 16px;
  }

  .toggle-grid,
  .button-pair {
    grid-template-columns: 1fr;
  }

  .map-header {
    align-items: start;
    flex-direction: column;
  }

  .map-frame {
    padding: 12px;
    min-height: min(70dvh, 720px);
    height: min(70dvh, 720px);
  }

  .layer-dock,
  .map-controls,
  .hud {
    left: 24px;
    right: 24px;
  }

  .map-controls {
    right: 24px;
    left: auto;
  }

  .layer-dock {
    width: auto;
  }

  .hud {
    justify-content: flex-start;
    bottom: 24px;
  }
}
