:root {
    --bg-main: #0a0a0c;
    --text-main: #f2e8cf;
    --accent-red: #d32f2f;
    --accent-gold: #c29952;
    --border-color: rgba(211, 47, 47, 0.4);
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Lora", serif;
    overflow: hidden;
    background: #000;
    -webkit-tap-highlight-color: transparent;
}

.back-btn {
    position: absolute;
    top: 30px;
    left: 30px;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.9);
    color: var(--text-main);
    border: 1px solid var(--accent-red);
    padding: 12px 25px;
    font-family: "Playfair Display", serif;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 2px;
    box-shadow: 0 0 15px rgba(211, 47, 47, 0.3);
    transition: 0.3s;
}
.back-btn:hover {
    background: var(--accent-red);
    color: #fff;
    box-shadow: 0 0 20px rgba(211, 47, 47, 0.8);
}

#isometric-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #000;
    overflow: hidden;
}

#leaflet-map-3d {
    width: 100%;
    height: 100%;
    background: #0b0b0b;
    outline: none;
}

/* Lớp sương tĩnh (không animation) để tránh tốn GPU */
#fog-layer-3d {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 400;
    background: radial-gradient(ellipse 90% 70% at 50% 45%, transparent 0%, rgba(8, 6, 10, 0.22) 100%);
    mix-blend-mode: multiply;
}

.leaflet-container {
    font-family: inherit;
}
.leaflet-container img.leaflet-tile {
    /* Tránh filter không cần thiết khi kéo */
    image-rendering: auto;
}

/* Icon chấm trên bản đồ */
.isometric-castle-icon,
.isometric-blood-icon,
.isometric-road-icon {
    position: relative;
    border-radius: 50%;
}
.isometric-castle-icon {
    width: 18px;
    height: 18px;
    background: var(--accent-gold);
    border: 2px solid #000;
    box-shadow: 0 0 10px var(--accent-gold);
}
.isometric-blood-icon {
    width: 22px;
    height: 22px;
    background: var(--accent-red);
    border: 2px solid #000;
}
.isometric-road-icon {
    width: 15px;
    height: 15px;
    background: #555;
    border: 1px solid #fff;
}

/* Chỉ pulse trên desktop — mobile/coarse tắt animation để ổn định khung hình */
@media (pointer: fine) and (prefers-reduced-motion: no-preference) {
    .isometric-blood-icon {
        animation: pulseKhauban 2s infinite;
    }
}

@keyframes pulseKhauban {
    0% {
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(211, 47, 47, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .isometric-blood-icon {
        animation: none;
    }
}

/* UI Boxes */
.map-floating-box {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px dashed var(--accent-red);
    padding: 15px 25px;
    z-index: 1000;
    cursor: default;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
    color: var(--text-main);
    text-align: right;
}
.map-floating-box p {
    font-size: 24px;
    color: var(--accent-red);
    margin: 0 0 5px 0;
    font-family: "Playfair Display", serif;
    text-shadow: 0 0 10px rgba(211, 47, 47, 0.5);
}
.map-floating-box small {
    font-size: 12px;
    opacity: 0.85;
}

#map-controls {
    position: absolute;
    bottom: 30px;
    left: 30px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border-color);
    padding: 15px;
    z-index: 1000;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.8);
    border-radius: 2px;
    color: var(--text-main);
    max-width: min(92vw, 360px);
}
#map-controls h4 {
    margin: 0 0 10px;
    font-size: 14px;
    font-family: "Playfair Display", serif;
    color: var(--accent-red);
}
#map-controls label {
    display: block;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}
.dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 5px currentColor;
}
.bg-yellow {
    background: var(--accent-gold);
    color: var(--accent-gold);
}
.bg-red {
    background: var(--accent-red);
    color: var(--accent-red);
}

/* Sidebar */
#map-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: min(450px, 100vw);
    height: 100%;
    height: 100dvh;
    background: var(--bg-main);
    z-index: 9999;
    transform: translateX(105%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-left: 2px solid var(--accent-red);
    box-shadow: -10px 0 25px rgba(0, 0, 0, 0.9);
}
.map-sidebar-open {
    transform: translateX(0) !important;
}
#close-map-sidebar {
    position: absolute;
    top: 15px;
    right: 20px;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.9);
    width: 35px;
    height: 35px;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: 0.2s;
    line-height: 1;
}
#close-map-sidebar:hover {
    background: var(--accent-red);
    color: #fff;
    box-shadow: 0 0 10px var(--accent-red);
}
.sidebar-image-header {
    height: 260px;
    background-size: cover;
    background-position: center;
    border-bottom: 2px solid var(--accent-red);
}
.map-sidebar-content {
    padding: 35px 30px;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-main);
}
.badge {
    background: #222;
    color: var(--accent-gold);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 2px;
    border: 1px solid var(--accent-gold);
}
.badge-story {
    background: #222;
    color: var(--accent-red);
    border: 1px solid var(--accent-red);
}
.map-divider {
    width: 40px;
    height: 2px;
    background: var(--border-color);
    margin: 20px 0;
}
.map-sidebar-content h2 {
    font-family: "Playfair Display", serif;
    font-size: 32px;
    margin: 0 0 10px 0;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    padding-right: 40px;
}
.content-header {
    font-family: "Playfair Display", serif;
    font-size: 18px;
    color: var(--accent-gold);
    margin-bottom: 5px;
    border-bottom: 1px dashed var(--border-color);
    display: inline-block;
    padding-bottom: 5px;
}
.content-header.highlight {
    color: var(--accent-red);
}
.info-text {
    color: var(--text-main);
}

.leaflet-tooltip.custom-game-tooltip {
    background-color: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--accent-red);
    color: #fff;
    font-family: "Playfair Display", serif;
    font-size: 14px;
    font-weight: bold;
    padding: 8px 15px;
    box-shadow: 0 5px 15px rgba(211, 47, 47, 0.4);
    text-shadow: 1px 1px 2px #000;
}
.leaflet-tooltip-top:before {
    border-top-color: var(--accent-red);
}

@media (max-width: 768px) {
    .back-btn {
        top: 12px;
        left: 12px;
        padding: 10px 16px;
        font-size: 13px;
    }
    .map-floating-box {
        display: none;
    }
    #map-controls {
        bottom: 12px;
        left: 12px;
        padding: 12px;
    }
}
