.dark-mode {
  --bg: #121212;
  --text: #ffffff;
  --sidebar: #1e1e1e;
  --card: #1a1a1a;
  --border: #333;
  --hover: #2a2a2a;
  --brightness: brightness(0.85);
  
  /* Checkbox styling */
  --cb-bg: #1a1a1a;
  --cb-border: #3a3a3a;
  --cb-hover: #262626;
}
:root {
            --civ-blue-bg: rgba(25, 45, 85, 0.92);
            --civ-border: #4a6fa5;
            --civ-white: #e0e0e0;
            --civ-gold: #ffcc66; 
            --civ-glow-blue: #0099ff; /* Softer light blue instead of bright cyan */
            --civ-list-bg: rgba(5, 15, 30, 0.5);
        }
.light-mode {
  --bg: #ffffff;
  --text: #000000;
  --sidebar: #ddd;
  --sb-border: #ccc;
  --card: #fafafa;
  --bg-map: #ddd;
  --hover: #eee;
  --border: #ddd;
  --brightness: brightness(1);
  
  /* Checkbox styling */
  --cb-bg: #fafafa;
  --cb-border: #bbb;
  --cb-hover: #f0f0f0;
}



html, body {
    height: 100%;
    margin: 0;
    background-color: #1f3a52;
}

#map {
    position: absolute;
    inset: 0; /* full screen */
    z-index: 0;
    will-change: transform; /* hint for better performance */
}

/* About header styling */

#about-header {
  position: fixed;
  top: 0px;
  right: 5px;
  
  z-index: 1090;
  display: flex;
  align-items: center;
  font-size: 0.75rem;
  line-height: 1.5;
  gap: 5px;
  padding: 2px 2px;
  background: var(--civ-blue-bg);
  border: 1px solid var(--civ-border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#header-meta {
  text-align: right;
  opacity: 0.85;
  color: var(--civ-white);
}





/* resource filter dropdown */
#city-planner-container {
    position: absolute;
    top: 64vh; /* last third of the screen, below the opened bonus filter panel */
    right: 5px;
    width: 60px;
    box-sizing: border-box;
    z-index: 1100;
    font-size: 10px;

    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;

    font-weight: bold;
    color: var(--civ-white);
    cursor: pointer;
    background: var(--civ-blue-bg);
    border: 2px solid var(--civ-border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#city-planner-toggle, #city-planner-clear, #city-planner-show {
    font: inherit;
    color: var(--civ-white);
    width: auto;
    cursor: pointer;
    border: 1px solid var(--civ-border);
    border-radius: 6px;
    background: var(--civ-list-bg);
}



#city-planner-toggle.active {
  color: var(--civ-gold);
  text-shadow: 0 0 6px rgba(255, 204, 102, 0.55);
}
#city-planner-show.active {
  color: var(--civ-gold);
  text-shadow: 0 0 6px rgba(255, 204, 102, 0.55);
}



/* Bonus filter: funnel button that opens a checkbox list (checkboxes reuse .checkbox-container) */
#bonus-filter {
    position: absolute;
    top: 30px; /* directly under the about box */
    right: 5px;
    z-index: 1100;
}
#bonus-filter.hidden {
    display: none;
}
#bonus-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    color: var(--civ-white);
    cursor: pointer;
    background: var(--civ-blue-bg);
    border: 2px solid var(--civ-border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
/* same size as the burger button */
#burger, #bonus-filter-toggle {
    box-sizing: border-box;
    width: 36px;
    height: 36px;
}
#bonus-filter-panel {
    box-sizing: border-box;
    width: 200px;
    margin-top: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    background: var(--civ-blue-bg);
    border: 2px solid var(--civ-border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#bonus-filter-search {
    box-sizing: border-box;
    width: 100%;
    padding: 6px;
    margin-bottom: 8px;
    border: 1px solid var(--civ-border);
    border-radius: 6px;
    background: var(--civ-list-bg);
    color: var(--civ-white);
    font-size: 14px;
}
/* ticked options are moved here: they stay under the search bar and do not scroll or get hidden by the search */
#bonus-filter-selected {
    margin-bottom: 8px;
    padding: 0 8px;
    border-radius: 2px;
    background: var(--civ-list-bg);
    border: 1px solid var(--civ-border);
}
#bonus-filter-selected:empty {
    display: none;
}

/* title of the full screen panel (portrait only), click closes it */
#bonus-filter-header {
    display: none;
}

/* only the list scrolls, the search bar stays on top */
#bonus-filter-list {
    /* up to 50vh, but never so tall that the panel reaches the city planner buttons (64vh) */
    max-height: min(50vh, calc(60vh - 140px));
    overflow-y: auto;
    padding: 8px;
    border-radius: 2px;
    background: var(--civ-list-bg);
    border: 1px solid var(--civ-border);
}
#bonus-filter-panel.hidden {
    display: none;
}

/* Year filter: number input - bar with two handles - number input */
#year-filter {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 66vw;
    box-sizing: border-box;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    color: var(--civ-white);
    background: var(--civ-blue-bg);
    border: 2px solid var(--civ-border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    --thumb: 18px;
}
#year-filter.hidden {
    display: none;
}
#year-filter input[type="number"] {
    box-sizing: border-box;
    width: 72px;
    padding: 4px;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: var(--civ-white);
    background: var(--civ-list-bg);
    border: 1px solid var(--civ-border);
    border-radius: 6px;
    -moz-appearance: textfield;
}
#year-filter input[type="number"]::-webkit-outer-spin-button,
#year-filter input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#year-slider {
    flex: 1;
    min-width: 0;
    position: relative;
}
#year-slider-inner {
    position: relative;
    height: 28px;
}
/* the bar; inset by half a handle so that the handle centres line up with the percentages */
#year-track {
    position: absolute;
    left: calc(var(--thumb) / 2);
    right: calc(var(--thumb) / 2);
    top: 50%;
    height: 8px;
    transform: translateY(-50%);
    background: var(--civ-list-bg);
    border: 1px solid var(--civ-border);
    border-radius: 5px;
}
#year-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--civ-gold);
    border-radius: 4px;
    box-shadow: 0 0 6px rgba(255, 204, 102, 0.55);
}
/* two range inputs on top of each other: only the handles take mouse/touch input */
#year-slider-inner input[type="range"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}
#year-range-start { z-index: 1; }
#year-range-end { z-index: 2; }
#year-slider-inner input[type="range"]::-webkit-slider-runnable-track {
    background: transparent;
}
#year-slider-inner input[type="range"]::-moz-range-track {
    background: transparent;
}
#year-slider-inner input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: auto;
    width: var(--thumb);
    height: var(--thumb);
    box-sizing: border-box;
    border-radius: 50%;
    cursor: grab;
    background: var(--civ-list-bg);
    border: 2px solid var(--civ-glow-blue);
    box-shadow: 0 0 6px var(--civ-glow-blue);
}
#year-slider-inner input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: var(--thumb);
    height: var(--thumb);
    box-sizing: border-box;
    border-radius: 50%;
    cursor: grab;
    background: var(--civ-list-bg);
    border: 2px solid var(--civ-glow-blue);
    box-shadow: 0 0 6px var(--civ-glow-blue);
}

/* burger button */
#burger {
  position: absolute;
  top: 10px;
  left: 10px; /* center over sidebar */
  z-index: 1100;
  font-size: 15px;
  font-weight: bold;
  color: var(--civ-white);
  cursor: pointer;
  background: var(--civ-blue-bg);
  border: 2px solid var(--civ-border);
  border-radius: 8px;
    
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#burger.hidden {
  display: none;
}

/* Deselect All button */
#deselect-all {
    position: absolute;
    top: 10px;
    left: 290px;
    z-index: 1100;
    font-size: 10px;
    font-weight: bold;
    color: var(--civ-white);
    cursor: pointer;
    background: var(--civ-blue-bg);
    border: 2px solid var(--civ-border);
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* Legend box */
#legend {
  position: absolute;
  top: 10px;
  left: 380px;
  z-index: 1100;
  font-size: 15px;
  color: var(--civ-white);
  background: var(--civ-blue-bg);
  border: 2px solid var(--civ-border);
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
#legend.hidden {
  display: none;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}
.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--civ-border);
}
.CORE {
  background-color: rgba(41, 249, 255, 1.0);
}
.HISTORICAL {
  background-color: rgba(8, 179, 69, 1.0);
}
.CONQUEST {
  background-color: rgba(250, 184, 56, 1.0);
}
.PERIPHERY {
  background-color: rgba(250, 184, 56, 1.0);
}
.MINORITY {
  background-color: rgba(255, 220, 115, 1.0);
}


/* Sidebar styling */

#sidebar {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 250px;
    /* height: auto; */
    max-height: 75vh;
    background: var(--civ-blue-bg);
    border: 2px solid var(--civ-border);
    border-radius: 8px;
    z-index: 1100;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    transition: transform 0.45s ease-in-out, opacity 0.45s ease-in-out, background-color 0.3s ease;
    cursor: default;
}

#sidebar.hidden {
    transform: translateY(-110%);
}

#sidebar h3 {
            text-align: center;
            text-transform: uppercase;
            font-size: 20px;
            font-weight: bold;
            color: var(--civ-white);
            margin: 0 0 12px 0; 
            letter-spacing: 1.5px;
            border-bottom: 1px solid var(--civ-border);
            padding-bottom: 4px;
            cursor: pointer;
        }


/* Scrollable options container */
.options-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    border-radius: 2px;
    background: var(--civ-list-bg);
    border: 1px solid var(--civ-border);
    transition: background-color 0.3s ease;
}

/* search bar styling */
#options-search {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--civ-border);
    border-radius: 6px;
    background: var(--civ-list-bg);
    color: var(--civ-white);
    font-size: 14px;
}


/* Dropdowns */
details {
    border: 1px solid var(--civ-border);
    border-radius: 6px;
    background: var(--civ-list-bg);

    
}
detauls[hidden] {
    display: none;
}


summary {
    padding: 8px;
    font-weight: bold;
    cursor: pointer;
    align-items: center;

    color: var(--civ-white);
    font-size: 17px;
    padding-bottom: 5px;

}

details[open] summary {
    border-bottom: 1px solid var(--civ-border);
}    

/* --- Circular Glowing Checkboxes --- */
.checkbox-container {
    display: flex;
    align-items: flex-start;
    position: relative;
    min-height: 18px;
    padding: 8px 8px 8px 28px;
    margin: 0;
    cursor: pointer;
    font-size: 15px;
    color: var(--civ-white);
    user-select: none;
    line-height: 18px;
    border-bottom: 1px solid var(--civ-border);
}

.label-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.checkbox-container[hidden] {
    display: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

/* Circular outer ring */
.checkmark {
    position: absolute;
    top: 11px;
    left: 5px;
    height: 12px;
    width: 12px;
    background-color: transparent;
    border: 1px solid #999;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.4);
}

/* Text becomes gold when checked */
.checkbox-container input:checked ~ .label-text {
    color: #ffcc66;
    text-shadow: 0 0 3px rgba(255, 204, 102, 0.4);
    font-weight: 600;
}

/* Glowing blue dot when checked */
.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    top: 4px;
    left: 4px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #0099ff;
    box-shadow: 
            0 0 5px 2px #0099ff,
            0 0 12px 4px #0099ff,
            0 0 20px 6px #0099ff,
            0 0 2px white;
}
        
  

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}


/* marker styling */

.custom-marker {
  background: transparent; /* No background for the marker itself */
  border: none;           /* No border for the marker itself */
  padding: 0;             /* No padding for the marker itself */
  box-shadow: none;          /* No shadow for the marker itself */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* whole marker box */
.custom-marker .marker-box {
  position: absolute;     /* Leaflet's icon element is a 0x0 dot on the lat/lng */
  left: 0;
  top: 0;
  width: max-content;
  max-width: 170px;
  padding: 4px 4px;
  /* border-radius: 6px; */
  text-align: center;     /* centers image and text */
  display: flex;
  flex-direction: column; /* stack children vertically */
  align-items: center;    /* center horizontally */
}

/* put the arrow tip exactly on the lat/lng (the 4px is the box padding) */
.custom-marker.marker-anchor-bottom .marker-box {
  transform: translate(-50%, calc(-100% + 4px));
}
.custom-marker.marker-anchor-top .marker-box {
  transform: translate(-50%, -4px);
}

/* Area layers of markers: hovering a marker puts a gold glowing outline around its area, keeps its own area on top and
   dims all the other areas. Leaflet sets opacity and z-index of an image overlay inline, hence !important. */
.area-layer.area-highlight {
  z-index: 10 !important;
}
.area-outline {
  filter: drop-shadow(0 0 3px var(--civ-gold)) drop-shadow(0 0 6px var(--civ-gold));
}
.area-dim .area-layer:not(.area-highlight) {
  opacity: 0.25 !important;
}

/* the image */
.custom-marker .marker-spawn {
  overflow: hidden;
  width: 64px;
  height: 64px;
  border: 2px solid #7fff19;
  
  background: rgba(0, 0, 0, 1);
  border-radius: 50%;
  margin-bottom: 2px;     /* space between image and text */
}
.custom-marker .marker-despawn {
  width: 64px;
  height: 64px;
  border: 2px solid #ff0000;
  direction: right;
  background: rgba(0, 0, 0, 1);
  border-radius: 50%;
  margin-bottom: 2px;     /* space between image and text */
}

/* the text */
.custom-marker .marker-text {
  
  background: rgba(0, 0, 0, 1);
  color: white;
  font-weight: bold;
  font-family: monospace;
  font-size: 12px;
  border-radius: 2px;
  white-space: pre-line; /* allow line breaks */
}

/* Arrow pointing to the lat/lng position */
.custom-marker .marker-arrow-bottom {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(255, 255, 255, 1);
  margin-top: 3px;
}
.custom-marker .marker-arrow-top {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid rgba(255, 255, 255, 1);
  margin-bottom: 3px;
}



#tooltip-box {
    position: absolute;
    bottom: 5px;
    left: 5px;
    width: 250px;
    pointer-events: none; /* allow clicks to pass through */
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    max-width: 200px;
    z-index: 1200;
}

@media (orientation: portrait) {
    #burger {
        position: absolute;
        left: auto;
        top: 25px;
        right: 5px;
        font-size: 30px;
        width: 60px;
        height: 60px;
    }
    #sidebar {
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        height: auto;
        max-height: 90vh;
    }
    #deselect-all {
        position: absolute;
        top: 50vh;
        left: auto;
        right: 5px;
        font-size: 15px;
        width: 60px;
        height: 60px;
    }
    #legend {
        position: absolute;
        top: 5px;
        left: 5px;
        font-size: 8px;
        max-height: 20px;
    }
    #about-header {
        position: absolute;
        bottom: 0px;
        left: 0px;
        top: auto;
        right: auto;
        font-size: 0.5rem;
    }
    #tooltip-box {
        position: absolute;
        bottom: 25px;
        left: 5px;
    }
  #city-planner-container {
        position: absolute;
        left: auto;
        right: 5px;
        width: 60px;
        box-sizing: border-box;
    }

    /* year filter: smaller vertical bar on the left side of the screen (top 2/3), earliest year at the top.
       The horizontal bar is rotated by 90 degrees; container query units give it the swapped size. */
    #year-filter {
        top: 35px;                  /* below the legend */
        bottom: auto;
        height: calc(66vh - 35px);  /* ends at 2/3 of the screen */
        left: 5px;
        transform: none;
        width: 54px;
        gap: 8px;
        flex-direction: column;
        padding: 6px 3px;
        --thumb: 24px;
    }
    #year-filter input[type="number"] {
        width: 100%;
        padding: 3px 0;
        font-size: 12px;
    }
    #year-slider {
        align-self: stretch;
        min-height: 0;
        container-type: size;
    }
    #year-slider-inner {
        position: absolute;
        top: 0;
        left: 0;
        width: 100cqh;
        height: 100cqw;
        transform-origin: top left;
        transform: translateX(100cqw) rotate(90deg);
    }

    /* bonus filter: funnel button under the burger, options slide in from the right over the whole screen */
    #bonus-filter {
        top: 95px;
    }
    #bonus-filter-toggle {
        width: 60px;
        height: 60px;
    }
    #bonus-filter-toggle svg {
        width: 30px;
        height: 30px;
    }
    #bonus-filter-panel,
    #bonus-filter-panel.hidden {
        display: flex;              /* stay in the layout so the slide can be animated */
    }
    #bonus-filter-panel {
        position: fixed;
        top: 10px;
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        margin: 0;
        max-height: none;
        z-index: 1100;
        transform: translateX(0);
        visibility: visible;
        transition: transform 0.45s ease-in-out, visibility 0s;
    }
    #bonus-filter-panel.hidden {
        transform: translateX(110%);
        visibility: hidden;         /* not focusable while off screen */
        transition: transform 0.45s ease-in-out, visibility 0s 0.45s;
    }
    #bonus-filter-header {
        display: block;
        text-align: center;
        text-transform: uppercase;
        font-size: 20px;
        font-weight: bold;
        color: var(--civ-white);
        margin: 0 0 12px 0;
        letter-spacing: 1.5px;
        border-bottom: 1px solid var(--civ-border);
        padding-bottom: 4px;
        cursor: pointer;
    }
    #bonus-filter-list {
        flex: 1;
        min-height: 0;
        max-height: none;
    }
}

