:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --bg: #090909;
  --panel: rgba(18, 18, 18, .94);
  --panel-solid: #121212;
  --panel-hover: #1b1b1b;
  --line: rgba(255,255,255,.07);
  --line-strong: rgba(255,255,255,.13);
  --text: #f3f3f3;
  --muted: #9a9a9a;
  --muted-2: #6f6f6f;
  --radius: 16px;
  --shadow: 0 22px 64px rgba(0,0,0,.36);

  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  background:
    linear-gradient(rgba(255,255,255,.013) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.013) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
}

a { color: inherit; text-decoration: none; }
button, select { font: inherit; }

.topbar {
  min-height: 66px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.02);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: max-content;
}

.brand-mark-logo {
  display: block;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  color: #ededed;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 720;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.brand-copy span {
  color: var(--muted-2);
  font-size: 11px;
}

.header-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.layers {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.layer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #151515;
  color: #777;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  transition: .18s ease;
}

.layer-toggle:hover {
  background: #1c1c1c;
  border-color: var(--line-strong);
  color: #cfcfcf;
}

.layer-toggle.active {
  background: #202020;
  border-color: rgba(255,255,255,.15);
  color: var(--text);
}

.world-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

select {
  min-height: 36px;
  background: #151515;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 30px 0 10px;
  outline: none;
}

select:hover,
select:focus {
  border-color: var(--line-strong);
  background: #1b1b1b;
}

.map-shell {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #111;
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#map.dragging { cursor: grabbing; }

.floating-panel,
.town-panel {
  background: rgba(18,18,18,.91);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.018);
  backdrop-filter: blur(14px);
  color: #e8e8e8;
}

#legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 9px 11px;
  display: flex;
  gap: 14px;
  border-radius: 12px;
  font-size: 11px;
  color: #bdbdbd;
}

#legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

#coords {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 8px 11px;
  border-radius: 10px;
  color: #bdbdbd;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.claim-sample {
  width: 18px;
  height: 8px;
  border-top: 2px dashed rgba(190,190,190,.78);
}

.gct-sample {
  width: 18px;
  height: 8px;
  border-top: 2px solid rgba(190,190,190,.82);
}

.town-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  width: min(330px, calc(100% - 28px));
  padding: 16px;
  border-radius: 16px;
}

.town-panel.hidden { display: none; }

.town-panel-close {
  position: absolute;
  top: 9px;
  right: 10px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #191919;
  color: #8c8c8c;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.town-panel-close:hover {
  color: #fff;
  border-color: var(--line-strong);
  background: #202020;
}

.town-panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding-right: 32px;
}

.town-panel-flag {
  width: 56px;
  height: 56px;
  object-fit: cover;
  image-rendering: auto;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px;
  background: #1b1b1b;
}

.town-panel-flag.hidden { display: none; }

.town-panel-name {
  font-weight: 750;
  font-size: 18px;
  letter-spacing: -.025em;
}

.town-panel-caption {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.town-panel-info { margin: 14px 0 0; }

.town-panel-info > div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid rgba(255,255,255,.06);
}

.town-panel-info dt {
  color: #858585;
  font-size: 12px;
}

.town-panel-info dd {
  margin: 0;
  text-align: right;
  font-size: 12px;
  font-weight: 650;
  color: #e5e5e5;
}

#loading {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 13px;
  border-radius: 11px;
  color: #bcbcbc;
  font-size: 12px;
}

#loading.hidden { display: none; }

@media (max-width: 1050px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .layers {
    overflow-x: auto;
    padding-bottom: 1px;
  }

  .layer-toggle { flex: 0 0 auto; }
}

@media (max-width: 700px) {
  body {
    padding: 8px;
    gap: 8px;
  }

  .topbar {
    padding: 9px;
    border-radius: 14px;
  }

  .brand-copy span { display: none; }

  .header-controls {
    align-items: flex-end;
    gap: 8px;
  }

  .layers {
    flex: 1 1 auto;
    justify-content: flex-start;
  }

  .layer-toggle {
    min-height: 34px;
    padding: 0 8px;
    font-size: 11px;
  }

  .world-control > span { display: none; }

  select {
    min-height: 34px;
    max-width: 120px;
  }

  .map-shell { border-radius: 14px; }

  #legend {
    max-width: calc(100% - 28px);
    gap: 8px;
    flex-wrap: wrap;
  }
}
