:root {
    --bg: #0d0809;
    --panel: rgba(20, 11, 12, .82);
    --panel-solid: #160c0d;
    --line: rgba(255, 255, 255, .08);
    --text: #f4eeee;
    --muted: #a8999a;
    --accent: #e73f1e;
    --accent-2: #ff6a3d;
    --ok: #3ddc84;
    --radius: 16px;
    --font: 'Karla', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    overflow: hidden;
}

#map {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse at center, rgba(231, 63, 30, .10), transparent 65%),
        var(--bg);
}

.leaflet-container { font-family: var(--font); background: transparent; }
.leaflet-tile { image-rendering: auto; }
.zoom-pixel .leaflet-tile { image-rendering: pixelated; }

/* world border */
.world-border {
    stroke: var(--accent);
    filter: drop-shadow(0 0 10px rgba(231, 63, 30, .8));
}

/* zoom control */
.leaflet-bar { border: 0 !important; border-radius: 12px !important; overflow: hidden; box-shadow: 0 8px 24px rgba(0, 0, 0, .45) !important; }
.leaflet-bar a {
    background: var(--panel) !important;
    color: var(--text) !important;
    border-bottom: 1px solid var(--line) !important;
    width: 38px !important; height: 38px !important; line-height: 38px !important;
    backdrop-filter: blur(10px);
}
.leaflet-bar a:hover { background: var(--accent) !important; }
.leaflet-control-attribution { display: none; }

/* ---------- panel ---------- */
.panel {
    position: fixed;
    top: 16px; left: 16px; bottom: 16px;
    width: 330px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
    overflow: hidden;
}

.panel-head {
    position: relative;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(231, 63, 30, .16), transparent);
}
.brand { display: block; width: 170px; }
.brand img { display: block; width: 100%; height: auto; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .5)); }

.live { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 14px; }
.live strong { color: var(--text); font-size: 15px; }
.live-dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(61, 220, 132, .7);
    animation: pulse 1.8s infinite;
    flex: none;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, .6); }
    70% { box-shadow: 0 0 0 9px rgba(61, 220, 132, 0); }
    100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); }
}

.sheet-toggle { display: none; }

.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 14px 14px 0; gap: 12px; }

.search {
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px; height: 42px;
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--muted);
}
.search:focus-within { border-color: rgba(231, 63, 30, .7); }
.search input {
    flex: 1; min-width: 0; height: 100%;
    background: none; border: 0; outline: 0;
    color: var(--text); font: inherit; font-size: 14px;
}

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: rgba(0, 0, 0, .25); border-radius: 12px; }
.tab {
    height: 34px; border: 0; border-radius: 9px;
    background: none; color: var(--muted);
    font: 600 13px var(--font); cursor: pointer;
}
.tab.is-active { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(231, 63, 30, .4); }

.list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.list-empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5; }
.list-empty i { display: block; font-size: 26px; margin-bottom: 10px; opacity: .5; }

.row {
    display: flex; align-items: center; gap: 12px;
    width: 100%; padding: 8px 10px;
    border: 0; border-radius: 10px;
    background: none; color: inherit; text-align: left;
    font: inherit; cursor: pointer;
}
.row:hover, .row.is-active { background: rgba(255, 255, 255, .06); }
.row img { width: 32px; height: 32px; border-radius: 7px; image-rendering: pixelated; flex: none; background: #2a1d1e; }
.row .ico {
    width: 32px; height: 32px; border-radius: 9px; flex: none;
    display: grid; place-items: center;
    font-size: 14px; color: #fff;
}
.row .txt { min-width: 0; }
.row .name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-title { margin: 12px 4px 4px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.layers { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 14px; border-top: 1px solid var(--line); }
.layers-title { width: 100%; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 999px;
    border: 1px solid var(--line); color: var(--muted);
    font-size: 12px; font-weight: 600; cursor: pointer; user-select: none;
}
.chip input:checked + span { background: rgba(231, 63, 30, .18); border-color: rgba(231, 63, 30, .6); color: var(--text); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }

.panel-foot { display: flex; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; }
.panel-foot a { color: var(--muted); text-decoration: none; font-weight: 600; }
.panel-foot a:hover { color: var(--accent-2); }

/* ---------- HUD ---------- */
.hud { position: fixed; right: 16px; bottom: 16px; z-index: 1000; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.coords, .follow {
    padding: 8px 12px; border-radius: 10px;
    background: var(--panel); border: 1px solid var(--line);
    backdrop-filter: blur(10px);
    font: 600 13px ui-monospace, Consolas, monospace; color: var(--muted);
}
.follow { pointer-events: auto; font-family: var(--font); color: var(--text); display: flex; align-items: center; gap: 8px; }
.follow i { color: var(--accent-2); }
.follow button { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }

/* ---------- markers ---------- */
.player { position: relative; }
.player .head {
    position: absolute; left: -17px; top: -17px;
    width: 34px; height: 34px;
    border-radius: 9px;
    border: 2px solid #fff;
    background: #2a1d1e center / cover no-repeat;
    image-rendering: pixelated;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .6);
}
.player .dir {
    position: absolute; left: -23px; top: -23px; width: 46px; height: 46px;
    pointer-events: none;
}
.player .dir::before {
    content: ''; position: absolute; left: 50%; top: -3px; transform: translateX(-50%);
    border: 6px solid transparent; border-bottom: 8px solid var(--accent);
    border-top: 0;
}
.player .tag {
    position: absolute; top: 21px; left: 50%; transform: translateX(-50%);
    padding: 2px 8px; border-radius: 6px;
    background: rgba(13, 8, 9, .85); color: #fff;
    font: 700 12px var(--font); white-space: nowrap;
}
.player.is-followed .head { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(231, 63, 30, .35), 0 4px 14px rgba(0, 0, 0, .6); }

.poi {
    width: 26px; height: 26px; margin: -13px 0 0 -13px;
    display: grid; place-items: center;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .9);
    color: #fff; font-size: 11px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .5);
    transition: transform .15s;
}
.poi:hover { transform: scale(1.18); }
.hide-pois .poi { display: none; }

.district-label {
    background: none; border: 0; box-shadow: none;
    color: #fff; font: 800 13px var(--font);
    letter-spacing: .12em; text-transform: uppercase;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .9), 0 0 2px #000;
}
.district-label::before { display: none; }
.small-labels .district-label { font-size: 10px; letter-spacing: .06em; }
.hide-labels .district-label { display: none; }

.leaflet-popup-content-wrapper, .leaflet-tooltip.rp-tip {
    background: var(--panel-solid); color: var(--text);
    border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .55);
}
.leaflet-popup-tip { background: var(--panel-solid); }
.leaflet-popup-content { margin: 12px 16px; font-size: 13px; line-height: 1.45; }
.leaflet-popup-content b { font-size: 14px; }
.leaflet-popup-content .muted { color: var(--muted); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

/* ---------- embed mode (home page iframe) ---------- */
.embed .panel, .embed .hud { display: none; }
.embed-open {
    position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
    z-index: 1000;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 999px;
    background: var(--panel); border: 1px solid var(--line);
    backdrop-filter: blur(10px);
    color: var(--text); text-decoration: none; font-size: 14px; font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    white-space: nowrap;
}
.embed-open:hover { border-color: var(--accent); }

/* ---------- mobile: panel becomes a bottom sheet ---------- */
@media (max-width: 760px) {
    .panel {
        top: auto; left: 0; right: 0; bottom: 0;
        width: auto; height: 62vh;
        border-radius: 18px 18px 0 0;
        transform: translateY(calc(100% - 96px));
        transition: transform .3s ease;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .panel.is-open { transform: none; }
    .panel-head { padding: 14px 16px 12px; }
    .brand { width: 120px; }
    .live { margin-top: 6px; }
    .sheet-toggle {
        display: grid; place-items: center;
        position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
        width: 40px; height: 40px; border-radius: 12px;
        background: rgba(255, 255, 255, .06); border: 1px solid var(--line);
        color: var(--text); cursor: pointer;
    }
    .panel.is-open .sheet-toggle i { transform: rotate(180deg); }
    .hud { bottom: 108px; right: 12px; }
    .leaflet-top.leaflet-right { top: 4px; }
}

[hidden] { display: none !important; }
.row .name, .row .sub { display: block; }
