:root {
  color-scheme: dark;
  --ink: #f4f7f5;
  --muted: #a9b8b8;
  --panel: rgba(7, 19, 28, .94);
  --line: rgba(255, 255, 255, .12);
  --accent: #e6b85c;
  --accent-2: #6bc5b5;
}

* { box-sizing: border-box; }
html, body, #map { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  background-color: #07131c;
  background-image:
    linear-gradient(rgba(4, 13, 20, .28), rgba(4, 13, 20, .56)),
    url("./background-palworld-v2.png");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font: 14px/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
.leaflet-container { background: rgba(6, 16, 23, .22); }

.topbar {
  position: fixed; inset: 14px 14px auto; z-index: 1000;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  pointer-events: none;
}
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.world-switcher { grid-column: 2; display: flex; gap: 6px; pointer-events: auto; }
.world-switcher button, .panel-toggle, .panel-actions button {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: rgba(5, 15, 22, .9); box-shadow: 0 6px 20px rgba(0, 0, 0, .3); backdrop-filter: blur(12px); cursor: pointer;
}
.world-switcher button:hover, .panel-toggle:hover, .panel-actions button:hover { background: rgba(255, 255, 255, .12); }
.world-switcher button.active { border-color: rgba(230, 184, 92, .7); color: #18140d; background: var(--accent); font-weight: 800; }
.panel-toggle { grid-column: 3; justify-self: end; pointer-events: auto; }

.layer-panel {
  position: fixed; z-index: 1001; top: 60px; right: 14px; width: min(270px, calc(100vw - 28px)); max-height: calc(100vh - 74px);
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 16px;
  background: var(--panel); box-shadow: 0 16px 50px rgba(0, 0, 0, .45); backdrop-filter: blur(14px); transition: transform .2s ease, opacity .2s ease;
}
.layer-panel.closed { transform: translateX(calc(100% + 22px)); opacity: 0; pointer-events: none; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; padding: 11px 12px 7px; }
.panel-heading > div { display: grid; }
.panel-heading strong { font-size: 15px; }
.icon-button { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.search-wrap { padding: 0 10px 8px; }
.search-wrap input { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; outline: none; color: var(--ink); background: rgba(255, 255, 255, .065); }
.search-wrap input:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(107, 197, 181, .12); }
.layer-groups { min-height: 0; overflow: auto; padding: 0 6px 6px; scrollbar-color: #53656b transparent; }
.layer-section { padding: 7px 10px; border-top: 1px solid var(--line); }
.layer-section:empty { display: none; }
.layer-section h3 { margin: 0; color: var(--muted); font-size: 10px; letter-spacing: .15em; text-transform: uppercase; }
.layer-group { border-top: 1px solid var(--line); }
.layer-group summary { display: flex; align-items: center; gap: 7px; padding: 7px 8px; color: var(--muted); cursor: pointer; list-style: none; user-select: none; }
.layer-group summary::-webkit-details-marker { display: none; }
.layer-group summary::before { content: "+"; width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); font-size: 13px; line-height: 1; }
.layer-group[open] summary::before { content: "−"; }
.layer-group summary:hover { color: var(--ink); background: rgba(255, 255, 255, .04); }
.layer-group-title { font-size: 12px; font-weight: 700; }
.layer-group summary small { margin-left: auto; color: #71878a; font-size: 10px; }
.layer-group > .layer-list { padding: 0 8px 7px 33px; }
.layer-list { display: grid; grid-template-columns: 1fr; gap: 1px; margin-top: 5px; }
.layer-row { min-width: 0; display: flex; align-items: center; gap: 6px; padding: 3px 1px; cursor: pointer; }
.layer-row input { accent-color: var(--accent); }
.layer-row span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.layer-row small { margin-left: auto; color: #71878a; font-size: 10px; }
.panel-actions { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.panel-actions button { flex: 1; padding: 6px; font-size: 11px; }
.data-status { padding: 0 10px 9px; color: var(--muted); font-size: 10px; }

.map-status { position: fixed; z-index: 999; left: 14px; bottom: 15px; max-width: 420px; padding: 7px 10px; border-radius: 9px; background: rgba(5, 15, 22, .78); color: var(--muted); pointer-events: none; }
.credit { position: fixed; z-index: 999; right: 16px; bottom: 14px; padding: 4px 7px; border-radius: 7px; background: rgba(5, 15, 22, .66); color: #8fa0a2; font-size: 10px; }
.credit a { color: inherit; }
.search-results { position: fixed; z-index: 1100; top: 155px; right: 28px; width: min(312px, calc(100vw - 56px)); max-height: 45vh; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #0a1a24; box-shadow: 0 15px 40px #0008; }
.search-result { width: 100%; display: grid; gap: 1px; padding: 9px 11px; border: 0; border-bottom: 1px solid var(--line); text-align: left; background: transparent; cursor: pointer; }
.search-result:hover { background: rgba(255,255,255,.08); }
.search-result small { color: var(--muted); }
.map-marker { position: relative; display: grid; place-items: center; }
.map-marker img { width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 2px 3px #000b); }
.map-marker .level { position: absolute; right: -5px; bottom: -6px; color: white; font: 800 10px/1 system-ui; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
.live-player { width: 16px; height: 16px; border: 2px solid white; border-radius: 50%; background: #df4f45; box-shadow: 0 2px 8px #000a; }
.live-base { width: 20px; height: 20px; display: grid; place-items: center; border: 2px solid #fff; border-radius: 5px; background: #3d86b8; font: 900 12px/1 system-ui; }
.leaflet-tooltip { border: 1px solid rgba(255,255,255,.2); border-radius: 8px; background: rgba(5,15,22,.94); color: white; box-shadow: 0 4px 16px #0008; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 720px) {
  .topbar { inset: 10px 10px auto; }
  .world-switcher button { padding: 7px 9px; font-size: 11px; }
  .panel-toggle { padding: 7px 9px; font-size: 11px; }
  .layer-panel { top: 52px; right: 10px; max-height: calc(100vh - 62px); }
  .credit { display: none; }
}
