:root {
  color-scheme: dark;
  --bg: #090c0d;
  --panel: rgba(13, 18, 19, 0.96);
  --panel-soft: #111718;
  --line: rgba(255, 255, 255, 0.09);
  --text: #edf2ef;
  --muted: #87928e;
  --ice: #a8d5d0;
  --acid: #c8f04b;
  --danger: #ff5b4d;
  --sidebar: 326px;
  --details: 354px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: 66px minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
  background: var(--bg);
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #0b0f10;
  z-index: 1002;
}

.brand { display: flex; align-items: center; gap: 11px; letter-spacing: .08em; }
.brand strong { display: block; font-size: 13px; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(200, 240, 75, .5);
  color: var(--acid);
  background: rgba(200, 240, 75, .07);
  font-weight: 900;
}

.server-mode { display: flex; gap: 7px; font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.server-mode span { padding: 7px 9px; border: 1px solid; border-radius: 2px; }
.mode-pve { color: var(--acid); border-color: rgba(200, 240, 75, .35) !important; background: rgba(200, 240, 75, .07); }
.mode-pvp { color: #ff8c82; border-color: rgba(255, 91, 77, .35) !important; background: rgba(255, 91, 77, .07); }

.sidebar {
  position: relative;
  z-index: 1001;
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.panel-section { padding: 18px 18px 16px; border-bottom: 1px solid var(--line); }
.panel-section h2, .panel-section label { margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.panel-section > label { display: block; margin-bottom: 9px; color: var(--muted); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--ice); cursor: pointer; font-size: 11px; }

.search-box { position: relative; }
.search-box input, select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
  background: #0a0e0f;
  color: var(--text);
}
.search-box input { padding: 0 44px 0 12px; }
.search-box input:focus, select:focus { border-color: rgba(168, 213, 208, .6); box-shadow: 0 0 0 2px rgba(168, 213, 208, .08); }
.search-box kbd { position: absolute; right: 10px; top: 10px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); background: #151b1c; }
select { padding: 0 10px; text-transform: none; }
.field-note { margin: 8px 0 0; color: var(--muted); font-size: 9px; line-height: 1.4; }

.search-results { margin-top: 6px; border: 1px solid var(--line); background: #0a0e0f; }
.search-result { display: block; width: 100%; padding: 9px 10px; border: 0; border-bottom: 1px solid var(--line); text-align: left; background: transparent; cursor: pointer; }
.search-result:last-child { border-bottom: 0; }
.search-result:hover { background: rgba(168, 213, 208, .08); }
.search-result strong { display: block; font-size: 12px; }
.search-result small { color: var(--muted); }

.layer-row {
  display: grid !important;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  margin: 0 !important;
  border-bottom: 1px solid rgba(255,255,255,.05);
  cursor: pointer;
  color: var(--text) !important;
  letter-spacing: normal !important;
  text-transform: none !important;
}
.layer-row:last-child { border-bottom: 0; }
.layer-icon { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid; border-radius: 50%; font-size: 12px; font-weight: 900; }
.pvp-icon { color: var(--danger); background: rgba(255,91,77,.08); }
.location-icon { color: #f3e2a4; background: rgba(243,226,164,.08); }
.building-icon { color: var(--ice); background: rgba(168,213,208,.08); }
.world-icon { color: #f3dc32; background: rgba(243,220,50,.08); }
.animal-icon { color: #c7ef58; background: rgba(199,239,88,.08); font-size: 11px; }
.water-icon { color: #45b8ff; background: rgba(69,184,255,.08); }
.water-icon svg { width: 13px; height: 17px; }
.water-icon path { fill: currentColor; }
.grid-icon { color: #9ba5a1; background: rgba(155,165,161,.08); }
.layer-copy strong { display: block; font-size: 12px; }
.layer-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.layer-row input { width: 16px; height: 16px; accent-color: var(--acid); }

.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 8px; margin-top: 13px; color: var(--muted); font-size: 10px; }
.legend-grid span { display: flex; align-items: center; gap: 7px; }
.legend-grid i { width: 7px; height: 7px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 8px var(--dot); }
.sidebar-footer { padding: 17px 18px 24px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.sidebar-footer strong { color: var(--ice); text-transform: uppercase; letter-spacing: .08em; }
.sidebar-footer p { margin: 7px 0 0; }

.map-shell { position: relative; min-width: 0; min-height: 0; background: #060809; }
#map { width: 100%; height: 100%; background: #060809; }
.leaflet-container { font-family: inherit; }
.leaflet-control-zoom { border: 1px solid var(--line) !important; box-shadow: none !important; }
.leaflet-control-zoom a { border-bottom-color: var(--line) !important; background: rgba(10,14,15,.92) !important; color: var(--text) !important; }
.leaflet-interactive:focus { outline: none; }
.leaflet-tooltip { padding: 4px 6px; border: 1px solid rgba(255,255,255,.14); border-radius: 3px; box-shadow: 0 4px 12px rgba(0,0,0,.34); background: rgba(8,12,13,.96); color: #f4f7f5; font-size: 9px; }
.leaflet-tooltip-top::before { border-top-color: rgba(8,12,13,.96); }

.map-action {
  position: absolute;
  z-index: 900;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(10, 14, 15, .91);
  cursor: pointer;
}
.fullscreen-button { right: 14px; top: 14px; font-size: 22px; }
.map-action:hover { border-color: rgba(168,213,208,.5); }

.coordinate-bar {
  position: absolute;
  z-index: 900;
  left: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(10,14,15,.9);
  font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.coordinate-bar button { padding: 0 0 0 8px; border: 0; border-left: 1px solid var(--line); background: none; color: var(--ice); cursor: pointer; font-size: 10px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--acid); box-shadow: 0 0 8px var(--acid); }
.map-attribution { position: absolute; z-index: 850; right: 12px; bottom: 8px; color: rgba(255,255,255,.45); font-size: 8px; pointer-events: none; }
.zoom-hint { position: absolute; z-index: 850; left: 50%; top: 16px; transform: translateX(-50%); padding: 8px 11px; border: 1px solid var(--line); background: rgba(10,14,15,.88); color: var(--muted); font-size: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.zoom-hint.visible { opacity: 1; }

.details-panel {
  position: absolute;
  z-index: 1000;
  top: 66px;
  right: 0;
  width: min(var(--details), calc(100vw - var(--sidebar)));
  height: calc(100dvh - 66px);
  padding: 26px 23px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: rgba(10, 14, 15, .97);
  transform: translateX(101%);
  transition: transform .22s ease;
}
.details-panel.open { transform: translateX(0); }
.details-close { position: absolute; right: 14px; top: 11px; border: 0; background: none; color: var(--muted); font-size: 28px; cursor: pointer; }
.eyebrow { color: var(--acid); font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.details-panel h2 { margin: 9px 32px 6px 0; font-size: 21px; line-height: 1.15; }
.details-panel p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.building-preview { position: relative; margin: 16px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #080b0c; }
.building-preview img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; image-rendering: auto; }
.animal-preview img { object-fit: contain; background: #080b0c; }
.building-preview::after { content: ""; position: absolute; inset: 0 0 24px; pointer-events: none; background: linear-gradient(180deg, transparent 62%, rgba(5,8,9,.55)); }
.building-preview figcaption { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 8px; padding: 7px 9px; color: var(--muted); background: #0d1213; font-size: 9px; }
.preview-count { flex: none; color: var(--ice); font-size: 9px; }
.preview-nav { position: absolute; top: 50%; z-index: 2; display: grid; place-items: center; width: 34px; height: 44px; padding: 0; transform: translateY(-70%); border: 1px solid rgba(255,255,255,.28); border-radius: 3px; background: rgba(5,8,9,.82); color: #fff; font: 28px/1 system-ui, sans-serif; cursor: pointer; }
.preview-nav:hover { border-color: var(--accent); color: var(--accent); }
.preview-previous { left: 8px; }
.preview-next { right: 8px; }
.building-preview-fallback { display: grid; place-items: center; align-content: center; gap: 8px; width: 100%; aspect-ratio: 4 / 3; color: var(--muted); }
.building-preview-fallback[hidden] { display: none; }
.building-preview-fallback span { color: var(--ice); font-size: 38px; }
.building-preview-fallback strong { font-size: 10px; }
.raw-name { display: block; margin-bottom: 17px; color: #5f6a66; font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.detail-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 16px 0; background: var(--line); border: 1px solid var(--line); }
.detail-stat { padding: 11px; background: #0d1213; }
.detail-stat small { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.detail-stat strong { display: block; margin-top: 5px; font-size: 13px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 17px; }
.tag { padding: 5px 7px; border: 1px solid var(--line); border-radius: 2px; background: rgba(255,255,255,.025); color: #bcc5c1; font-size: 9px; }
.loot-heading { display: flex; align-items: baseline; justify-content: space-between; margin-top: 19px; }
.loot-heading h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.loot-heading span { color: var(--muted); font-size: 9px; }
.loot-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; padding: 0; list-style: none; }
.loot-list li { padding: 7px 8px; border-left: 2px solid rgba(168,213,208,.45); background: rgba(168,213,208,.045); color: #cbd3d0; font-size: 10px; line-height: 1.25; }
.loot-groups { display: grid; gap: 13px; margin: 11px 0; }
.loot-group h4 { margin: 0 0 7px; color: var(--accent); font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.loot-group .loot-list { margin: 0; }
.loot-note { padding: 9px; border: 1px solid rgba(244,163,64,.18); background: rgba(244,163,64,.045); color: #bca884 !important; font-size: 10px !important; }
.copy-location { width: 100%; margin-top: 12px; padding: 10px; border: 1px solid rgba(168,213,208,.3); background: rgba(168,213,208,.06); color: var(--ice); cursor: pointer; }

.water-marker { width: 9px !important; height: 11px !important; margin: -10px 0 0 -4.5px !important; background: transparent; }
.water-marker svg { width: 9px; height: 11px; overflow: visible; filter: drop-shadow(0 0 2px rgba(69,184,255,.8)) drop-shadow(0 1px 1px #000); }
.water-marker path { fill: #2dafff; stroke: #082536; stroke-width: 1.8; }
.map-overview .water-marker svg { transform: scale(.65); transform-origin: center bottom; }
.location-marker { width: 180px !important; height: 26px !important; margin: -13px 0 0 -90px !important; background: transparent; text-align: center; pointer-events: none; }
.location-marker span { display: inline-block; color: #f3eee1; font-size: 10px; font-weight: 750; letter-spacing: .045em; text-shadow: -1px -1px 1px #000, 1px -1px 1px #000, -1px 1px 1px #000, 1px 1px 1px #000, 0 2px 5px #000; white-space: nowrap; }
.location-marker.capital span { color: #fff7d6; font-size: 14px; font-weight: 900; letter-spacing: .09em; text-transform: uppercase; }
.location-marker.city span { color: #fff7d6; font-size: 12px; font-weight: 850; text-transform: uppercase; }
.location-marker.village span { font-size: 10px; }
.location-marker.hill span { color: #bac4bf; font-size: 9px; font-style: italic; }
.location-marker.marine span { color: #7fd4ff; }
.grid-label { color: rgba(255,255,255,.35); font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; text-shadow: 0 1px 2px #000; }
.zone-label { width: 250px !important; height: 32px !important; margin: -16px 0 0 -125px !important; background: transparent; text-align: center; pointer-events: auto; cursor: pointer; }
.zone-label span { display: inline-block; padding: 6px 9px; border: 2px solid currentColor; border-radius: 3px; background: rgba(8,10,11,.86); color: #ff6558; font-size: 11px; font-weight: 950; letter-spacing: .09em; text-shadow: 0 2px 4px #000; box-shadow: 0 3px 12px rgba(0,0,0,.55); white-space: nowrap; }
.zone-label.temporary span { color: #f4a340; }
.map-overview .zone-label span { padding: 4px 7px; font-size: 9px; }
.map-detailed .zone-label { display: none !important; }

.mobile-only { display: none; }
.icon-button { border: 1px solid var(--line); background: #111617; }

@media (max-width: 860px) {
  :root { --sidebar: min(330px, 88vw); }
  .app-shell { grid-template-columns: 1fr; }
  .mobile-only { display: block; width: 36px; height: 36px; margin-right: 10px; }
  .topbar { justify-content: flex-start; padding: 0 12px; }
  .server-mode { margin-left: auto; }
  .server-mode span { padding: 6px; font-size: 8px; }
  .sidebar { position: absolute; top: 66px; bottom: 0; left: 0; width: var(--sidebar); transform: translateX(-101%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .map-shell { grid-row: 2; }
  .details-panel { width: 100%; height: min(65dvh, 620px); top: auto; bottom: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateY(101%); border-left: 0; border-top: 1px solid var(--line); }
  .details-panel.open { transform: translateY(0); }
  .map-attribution { bottom: 52px; }
  .loot-list { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .brand strong { font-size: 11px; }
  .brand small { font-size: 8px; }
  .brand-mark { width: 30px; height: 30px; }
  .mode-pve { display: none; }
  .coordinate-bar { left: 8px; bottom: 8px; }
  .fullscreen-button { top: 8px; right: 8px; }
}
