:root {
    --bg: #07090d;
    --panel: rgba(12, 16, 24, 0.88);
    --panel-strong: #111827;
    --line: rgba(255, 255, 255, 0.14);
    --text: #f4f7fb;
    --muted: #9aa6b8;
    --accent: #38bdf8;
    --old: #facc15;
    --rocker: #ef4444;
    --police: #3b82f6;
    --ok: #22c55e;
    --danger: #f43f5e;
}

* {
    box-sizing: border-box;
}

html,
body,
.app-shell,
#map {
    width: 100%;
    height: 100%;
}

html,
body {
    margin: 0;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

button,
input {
    font: inherit;
}

.app-shell {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#map {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    background: #050914;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.leaflet-container {
    background: #05070b;
    font-family: Arial, Helvetica, sans-serif;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.leaflet-image-layer {
    user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    pointer-events: none;
}

.leaflet-container.leaflet-dragging,
.leaflet-container.is-right-panning {
    cursor: grabbing;
}

.leaflet-control-zoom a {
    background: rgba(17, 24, 39, 0.92);
    border-color: var(--line);
    color: var(--text);
}

.leaflet-control-zoom a:hover {
    background: #1f2937;
    color: #fff;
}

.hud-panel {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 500;
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: calc(100vw - 36px);
    padding: 14px 16px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(14px);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

.hud-panel h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.1;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend strong {
    color: var(--text);
    font-size: 13px;
    white-space: nowrap;
}

.legend-emoji {
    display: inline-grid;
    width: 22px;
    height: 22px;
    place-items: center;
    font-style: normal;
    line-height: 1;
}

.map-pin {
    position: relative;
    width: 28px;
    height: 28px;
    border: 3px solid #fff;
    border-radius: 50% 50% 50% 0;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.58);
    transform: rotate(-45deg);
}

.map-pin::after {
    content: "";
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
}

.pin-old {
    background: var(--old);
}

.pin-rocker {
    background: var(--rocker);
}

.pin-police {
    background: var(--police);
}

.leaflet-overlay-pane {
    z-index: 400 !important;
}

.leaflet-marker-pane {
    z-index: 650 !important;
}

.leaflet-tooltip.emoji-marker-tooltip {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    box-shadow: none;
    color: #fff;
    font-size: 21px;
    line-height: 1;
    pointer-events: none;
}

.leaflet-tooltip.emoji-marker-tooltip::before {
    display: none;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
    background: #111827;
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.leaflet-popup-content {
    min-width: 210px;
    margin: 14px;
}

.leaflet-popup {
    z-index: 1200;
}

.leaflet-popup-pane {
    z-index: 1200 !important;
}

.leaflet-popup-close-button {
    top: 8px !important;
    right: 8px !important;
    width: 26px !important;
    height: 26px !important;
    color: var(--text) !important;
    font-size: 20px !important;
    line-height: 24px !important;
    border-radius: 6px;
    z-index: 2;
}

.leaflet-popup-close-button:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
}

.location-info-panel {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1300;
    width: min(320px, calc(100vw - 36px));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: #111827;
    color: var(--text);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.46);
    padding: 14px;
}

.location-info-panel .popup-content {
    padding-right: 22px;
}

.info-close {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: #1f2937;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    line-height: 1;
}

.popup-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 800;
}

.popup-meta {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.popup-actions {
    display: flex;
    gap: 8px;
}

.btn {
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--accent);
    color: #02111d;
}

.btn-muted {
    background: #1f2937;
    border-color: var(--line);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    place-items: center;
    padding: 18px;
    background: rgba(3, 7, 18, 0.72);
}

.modal-backdrop.is-open {
    display: grid;
}

.modal {
    position: relative;
    width: min(460px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #0f172a;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
    padding: 24px;
}

.modal h2 {
    margin-bottom: 8px;
    font-size: 24px;
}

.modal p {
    margin-bottom: 18px;
    color: var(--muted);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111827;
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
}

.type-grid {
    display: grid;
    gap: 10px;
}

.type-card {
    display: flex;
    min-height: 58px;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111827;
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
    font-weight: 800;
}

.type-card input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.type-card:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.type-old:has(input:checked) {
    border-color: var(--old);
}

.type-rocker:has(input:checked) {
    border-color: var(--rocker);
}

.type-police:has(input:checked) {
    border-color: var(--police);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1200;
    max-width: min(420px, calc(100vw - 36px));
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #111827;
    color: var(--text);
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.36);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.is-success {
    border-color: rgba(34, 197, 94, 0.7);
}

.toast.is-error {
    border-color: rgba(244, 63, 94, 0.8);
}

.map-warning {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: grid;
    place-items: center;
    padding: 24px;
    color: var(--text);
    text-align: center;
}

.map-warning div {
    max-width: 620px;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
}

@media (max-width: 720px) {
    .hud-panel {
        right: 12px;
        left: 12px;
        top: 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .hud-panel h1 {
        font-size: 18px;
    }

    .modal {
        padding: 20px;
    }

    .modal-actions,
    .popup-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .leaflet-popup {
        position: fixed !important;
        right: 10px !important;
        bottom: 72px !important;
        left: 10px !important;
        top: auto !important;
        transform: none !important;
        width: auto !important;
        max-width: none !important;
    }

    .leaflet-popup-content-wrapper {
        border-radius: 8px;
    }

    .leaflet-popup-content {
        width: auto !important;
        min-width: 0;
        margin: 10px;
    }

    .leaflet-popup-tip-container {
        display: none;
    }

    .popup-title {
        margin-bottom: 6px;
        font-size: 16px;
    }

    .popup-meta {
        margin-bottom: 8px;
        font-size: 12px;
        line-height: 1.3;
    }

    .popup-actions {
        gap: 8px;
    }

    .popup-actions .btn {
        min-height: 34px;
        padding: 0 12px;
        font-size: 13px;
    }

    .location-info-panel {
        right: 10px;
        bottom: 76px;
        left: 10px;
        width: auto;
        padding: 12px;
    }

    .location-info-panel .popup-content {
        padding-right: 18px;
    }
}
