
*, *::before, *::after { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    background: #111;
    font-family: 'Oswald', 'Arial Narrow', Arial, sans-serif;
    user-select: none;
}

#map-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#map {
    position: absolute;
    inset: 0;
    background: #1a1e22;
}

.leaflet-container { background: #1a1e22 !important; }
.leaflet-tile-pane { filter: brightness(0.85) contrast(1.1) saturate(0.9); }
.leaflet-tile { image-rendering: crisp-edges; image-rendering: pixelated; }

.leaflet-overlay-pane canvas { image-rendering: auto !important; }


#coord-display {
    position: absolute;
    bottom: 12px; left: 12px;
    z-index: 1000;
    background: rgba(0,0,0,0.75);
    color: #4cff50;
    padding: 4px 10px;
    font-family: monospace;
    font-size: 13px;
    border: 1px solid #2a5c2a;
    box-shadow: 0 0 6px rgba(76,255,80,0.3);
    pointer-events: none;
}


#mode-selector {
    position: absolute;
    top: 15px; left: 50%;
    transform: translateX(-50%);
    display: flex; gap: 4px;
    z-index: 1001;
    background: #1f2224;
    padding: 5px;
    border: 3px solid #111;
    box-shadow: inset -2px -2px 0 #2d3133, inset 2px 2px 0 #0a0a0a, 0 6px 20px rgba(0,0,0,0.7);
}

.mode-btn {
    background: linear-gradient(to bottom, #2a2e31, #1a1e21);
    border: 2px solid #0d0f10;
    color: #8a9498;
    padding: 7px 18px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: inset 1px 1px 0 rgba(255,255,255,0.05), inset -1px -1px 0 rgba(0,0,0,0.5);
    transition: color 0.15s;
}
.mode-btn:hover { color: #ccc; background: linear-gradient(to bottom, #333, #222); }
.mode-btn.active {
    background: linear-gradient(to bottom, #263b24, #162314);
    border-color: #0f1c0d;
    color: #6cff5e;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.6);
}
.mode-btn.editor-btn { color: #f0a830; }
.mode-btn.editor-btn:hover { color: #ffc844; }
.mode-btn.music-btn { color: #4ab0ff; }
.mode-btn.music-btn:hover { color: #7ec9ff; }
.mode-btn.disabled {
    background: linear-gradient(to bottom, #151718, #0e1011) !important;
    color: #4a5255 !important;
    border-color: #08090a !important;
    box-shadow: none !important;
    opacity: 0.6;
}

/* Hide player markers when toggled OFF */
html.cqn-hide-players .leaflet-marker-pane .pl3xmap-player-marker,
html.cqn-hide-players .leaflet-marker-pane img[src*="player"],
html.cqn-hide-players .leaflet-marker-pane .player-marker,
html.cqn-hide-players .leaflet-marker-pane .pl3x-player,
html.cqn-hide-players .leaflet-marker-pane .leaflet-marker-icon:has(img[src*="player"]),
html.cqn-hide-players .pl3xmap-player-layer {
    display: none !important;
}


.hoi4-mc-panel {
    position: absolute;
    top: 80px; left: -420px;
    width: 380px;
    background: #252829;
    border: 4px solid #111;
    box-shadow:
        inset -3px -3px 0 #343a3d,
        inset 3px 3px 0 #141618,
        8px 10px 25px rgba(0,0,0,0.85);
    padding: 14px;
    transition: left 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
    z-index: 1000;
    color: #d4d8da;
    overflow: hidden;
}
.hoi4-mc-panel.open { left: 15px; }


#cqn-editor-panel {
    position: absolute;
    top: 80px; right: -310px;
    width: 280px;
    background: #252829;
    border: 4px solid #111;
    box-shadow:
        inset -3px -3px 0 #343a3d,
        inset 3px 3px 0 #141618,
        -8px 10px 25px rgba(0,0,0,0.85);
    padding: 14px;
    transition: right 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
    z-index: 1000;
    color: #d4d8da;
}
#cqn-editor-panel.open { right: 15px; }


.rivet {
    position: absolute;
    width: 7px; height: 7px;
    background: radial-gradient(circle at 35% 35%, #6a7072, #1a1c1e);
    border-radius: 50%;
    border: 1px solid #0d0f10;
}
.r-tl { top: 5px; left: 5px; } .r-tr { top: 5px; right: 5px; }
.r-bl { bottom: 5px; left: 5px; } .r-br { bottom: 5px; right: 5px; }


.close-btn {
    position: absolute;
    top: 20px; right: 20px;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    color: #8a9498 !important;
    font-size: 16px !important;
    cursor: pointer;
    z-index: 10;
    line-height: 1 !important;
}
.close-btn:hover { color: #ff5555 !important; }


.panel-header {
    background: linear-gradient(to bottom, #1d2b1b, #101b0f);
    border: 2px solid #0c130b;
    padding: 8px 0;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #a4d39c;
    box-shadow: inset -2px -2px 0 #253324, inset 2px 2px 0 #090f08;
    margin-bottom: 14px;
}


.portrait-wrapper {
    float: left;
    width: 140px; height: 140px;
    background: #111;
    border: 3px solid #0d0f10;
    box-shadow: inset -2px -2px 0 #2a2c2e, inset 2px 2px 0 #000;
    margin: 0 12px 10px 0;
    position: relative;
    overflow: hidden;
}
.skin-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: #3a3e40;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}


.top-right-stats {
    float: right; 
    width: 190px;
}
.name-plate {
    clear: both;
    background: #1c1e20;
    border: 2px solid #0d0f10;
    color: #b0b4b6;
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    padding: 5px 6px;
    margin-bottom: 10px;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.data-slot {
    background: #161819;
    border: 2px solid #0d0f10;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.8);
    padding: 7px 10px;
    margin-bottom: 8px;
}
.data-label {
    font-size: 9px; color: #6a7072;
    text-transform: uppercase;
    font-weight: 700; letter-spacing: 0.5px;
    margin-bottom: 3px;
}
.data-value {
    font-size: 14px; color: #e8eaeb;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    display: flex; align-items: center; gap: 6px;
}
.faction-flag {
    display: inline-block;
    width: 18px; height: 12px;
    border: 1px solid rgba(0,0,0,0.5);
    box-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    flex-shrink: 0;
}


.cqn-lbl {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: rgba(255,255,255,0.9);
    font-family: 'Oswald', 'Arial Narrow', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-align: center;
    pointer-events: none;
    white-space: nowrap;
    text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000, 0 0 10px rgba(0,0,0,1);
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
}
.cqn-lbl::before, .cqn-lbl::after { display: none !important; }


.cqn-player-marker { background: transparent; border: none; }


.editor-group {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2d3133;
}
.editor-label {
    font-size: 9px; color: #5a6062;
    text-transform: uppercase; font-weight: 700;
    letter-spacing: 0.5px; margin-bottom: 6px;
}
.editor-radio {
    display: block;
    font-size: 12px; color: #8a9498;
    margin-bottom: 4px; cursor: pointer;
}
.editor-radio input { accent-color: #6cff5e; margin-right: 5px; }
.editor-input {
    width: 100%;
    background: #131516;
    border: 2px solid #1a1e21;
    color: #d4d8da;
    padding: 5px 8px;
    font-family: inherit;
    font-size: 13px;
    outline: none;
}
.editor-input:focus { border-color: #3a4840; }
.editor-hint {
    font-size: 10px; color: #4a5254;
    text-align: center; margin: 8px 0;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.editor-btn-action {
    display: block; width: 100%;
    padding: 7px; margin-bottom: 5px;
    border: 2px solid #0d0f10;
    font-family: inherit; font-size: 12px;
    font-weight: 700; text-transform: uppercase;
    letter-spacing: 1px; cursor: pointer;
}
.editor-btn-action.success { background: #1a3a18; color: #6cff5e; }
.editor-btn-action.success:hover { background: #224a20; }
.editor-btn-action.danger { background: #3a1818; color: #ff5e5e; }
.editor-btn-action.danger:hover { background: #4a2020; }
.editor-btn-action.neutral { background: #252829; color: #8a9498; border-color: #2d3133; }
.editor-btn-action.neutral:hover { background: #2d3133; }


.leaflet-control-container { display: none !important; }
.sidebar { display: none !important; }


.cqn-nation-polygon {
    filter: url(#hoi4-glow);
    transition: fill-opacity 0.25s, stroke-width 0.25s;
    stroke-linejoin: round;
    stroke-linecap: round;
}


.cqn-prov-inner-border {
    stroke-dasharray: 4 6 !important;
    stroke-opacity: 0.35 !important;
    stroke-width: 1px !important;
}


.cqn-curved-label {
    font-family: 'Oswald', 'Arial Narrow', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    pointer-events: none;
    fill: #ffffff;
    stroke: #000000;
    stroke-width: 1.5px;
    paint-order: stroke fill;
    filter: drop-shadow(2px 2px 3px rgba(0,0,0,0.85));
}

@keyframes cqn-pulse-highlight {
    0% {
        stroke-width: 3px;
        stroke: #ffffff;
        stroke-opacity: 1;
        fill-opacity: 0.55;
    }
    50% {
        stroke-width: 5px;
        stroke: #ffeb3b;
        stroke-opacity: 1;
        fill-opacity: 0.75;
    }
    100% {
        stroke-width: 3px;
        stroke: #ffffff;
        stroke-opacity: 1;
        fill-opacity: 0.55;
    }
}

.cqn-highlight-selected {
    animation: cqn-pulse-highlight 1.5s infinite ease-in-out !important;
    stroke-dasharray: none !important;
    z-index: 1000 !important;
}

/* Mobile responsive styles */
@media (max-width: 480px) {
    #mode-selector {
        width: calc(100% - 30px);
        max-width: 360px;
        justify-content: space-around;
        gap: 3px;
        padding: 4px;
        border-width: 2px;
    }
    
    .mode-btn {
        flex: 1;
        padding: 9px 5px;
        font-size: 11px;
        text-align: center;
        letter-spacing: 0.5px;
    }

    .hoi4-mc-panel {
        width: calc(100% - 30px);
        max-width: 380px;
        left: -120%;
        top: 75px;
        padding: 10px;
        border-width: 3px;
    }
    
    .hoi4-mc-panel.open {
        left: 15px;
    }

    .portrait-wrapper {
        width: 100px;
        height: 100px;
        margin-right: 8px;
        margin-bottom: 6px;
    }

    .portrait-wrapper img {
        width: 94px !important;
        height: 94px !important;
    }

    .top-right-stats {
        width: calc(100% - 108px);
    }

    .name-plate {
        font-size: 10px;
        padding: 4px;
        margin-bottom: 6px;
    }

    .data-slot {
        padding: 5px 8px;
        margin-bottom: 6px;
    }

    .data-label {
        font-size: 8px;
        margin-bottom: 2px;
    }

    .data-value {
        font-size: 12px;
    }

    #cqn-editor-panel {
        width: calc(100% - 30px);
        right: -120%;
        top: 75px;
        padding: 10px;
        border-width: 3px;
    }

    #cqn-editor-panel.open {
        right: 15px;
    }
    
    #coord-display {
        bottom: 8px;
        left: 8px;
        font-size: 11px;
        padding: 3px 6px;
    }
}
