/* styles.css -- 12-14-25 */

body {
    margin: 0;
    padding: 0;
    background-color: #111;
    text-align: center;
    font-family: Arial, sans-serif;
    color: #ddd;
    overflow: hidden;
}

#app-container {
    display: grid;
    grid-template-areas:
        "header header  header"
        "nav    main    aside";
    grid-template-rows: auto 1fr; 
    grid-template-columns: 250px 1fr 250px; 
    width: 100vw;
    height: 100vh;
}

#top-bar { grid-area: header; }
#left-menu { grid-area: nav; }
#map-container { grid-area: main; }
#right-menu { grid-area: aside; }

#map-container {
    width: 100%;
    height: 90vh;
    margin: auto;
    border: 2px solid #444;
    position: relative;
    box-sizing: border-box;
}

#left-menu, #right-menu {
    background: #2a2a2a;
    padding: 15px;
    border-left: 1px solid #444;
    border-right: 1px solid #444;
    overflow-y: auto;
}

#left-menu, #right-menu {
    background: #2a2a2a;
    padding: 15px;
    border-left: 1px solid #444;
    border-right: 1px solid #444;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#activity-log-panel, #faction-relations-panel, #character-status-panel {
    background-color: #333;
    border: 1px solid #444; /* The border you requested */
    border-radius: 2px;
    padding: 5px;
}

#activity-log-panel, #faction-relations-panel {
    flex-shrink: 0; /* Prevents these panels from shrinking */
}

#top-bar {
    background-color: #1e1e1e;
    border-bottom: 1px solid #444;
    padding: 5px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
} 

.top-bar-button {
    padding: 8px 15px;
    background-color: #444;
    color: white;
    border: 1px solid #666;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
}

.top-bar-button:hover {
    background-color: #666;
}

.active {
    background-color: #888;
}

/* Logo styling */
#return-logo img {
    height: 40px; /* Adjust size as needed */
    vertical-align: middle;
}

/* Icon button styling */
.top-bar-button-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar-icon-button {
    background: none;
    border: 2px solid #555;
    border-radius: 5px;
    padding: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.top-bar-icon-button:hover:not(:disabled) {
    background-color: #444;
}
.top-bar-icon-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.top-bar-icon-button img {
    height: 24px; /* Adjust icon size */
    width: 24px;
    vertical-align: middle;
}


.relations-slider-container {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

#relations-slider {
    flex-grow: 1;
}

#relations-input {
    width: 60px; 
    margin-top: 5px;
}

#apply-relations-button {
    margin-top: 10px;
}

#log-entries {
    background-color: #1c1c1c;
    border: 1px solid #111;
    border-radius: 3px;
    padding: 10px;
    max-height: 120px;        
    overflow-y: auto;  
    font-family: monospace; 
    font-size: 0.9em; 
}

.log-entry {
    margin: 0 0 5px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid #333; 
    word-break: break-word; 
}

.log-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.control-grid {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

.control-grid input[type="range"] {
    grid-column: 1 / 4; /* Span all 3 columns */
}

.control-grid input[type="number"] {
    width: 60px;
    padding: 5px;
    background-color: #333;
    color: white;
    border: 1px solid #555;
    text-align: center;
}

.apply-button {
    padding: 6px 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.apply-button:hover {
    background-color: #0056b3;
}

/* -- Character Panel Current Status -- */
.status-label {
    text-align: center;
    margin-top: 5px;
    font-style: italic;
    color: var(--pico-muted-color);
}

#right-menu h2 {
    margin-top: 0;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
    font-size: 1.2em;
    color: #eee;
}

.hidden {
    display: none !important;
}

/* --- Global Status Window Styles --- */
#status-window-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#status-window {
    width: 80%;
    max-width: 1200px;
    height: 80%;
    background-color: var(--pico-card-background-color);
    border: var(--pico-border-width) solid var(--pico-card-border-color);
    border-radius: var(--pico-border-radius);
    box-shadow: var(--pico-card-box-shadow);
    display: flex;
    flex-direction: column;
}

#status-window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--pico-spacing);
    border-bottom: var(--pico-border-width) solid var(--pico-muted-border-color);
    flex-shrink: 0;
}

#status-window-header h2 {
    margin: 0;
}

#status-window-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--pico-spacing);
    padding: var(--pico-spacing);
    overflow: hidden;
    flex-grow: 1;
    min-height: 0; 
}

.status-column {
    background-color: var(--pico-background-color);
    border-radius: var(--pico-border-radius);
    padding: var(--pico-spacing);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#global-relations-list,
#global-characters-list,
#global-states-list {
    overflow-y: auto;
    margin: 0;
    padding: 0;
    padding-right: 0.75rem;
    list-style: none;
    font-family: monospace;
    font-size: 0.9em;
    flex-grow: 1;
}

#global-relations-list p,
#global-characters-list p,
#global-states-list p {
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: var(--pico-border-width) solid var(--pico-muted-border-color);
    margin-block-start: 0; /* Override default paragraph margins */
    margin-block-end: 0;   /* Override default paragraph margins */
}

/* This removes the border from the very last item in each list */
#global-relations-list p:last-child,
#global-characters-list p:last-child,
#global-states-list p:last-child {
    border-bottom: none;
}

/* --- Status Color Classes --- */
.status-list .value.value-ally, 
.status-list .value.value-alive { 
    color: #4CAF50; /* Green */
}

.status-list .value.value-enemy, 
.status-list .value.value-dead { 
    color: #F44336; /* Red */
}

.status-list .value.value-imprisoned { 
    color: #FFC107; /* Gold */
}
/* --- Footer & Log Styles --- */

#status-window-footer {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Log : Controls ratio */
    gap: var(--pico-spacing);
    padding: var(--pico-spacing);
    border-top: var(--pico-border-width) solid var(--pico-muted-border-color);
    flex-shrink: 0; /* Prevents footer from shrinking */
}

#verbose-log-container {
    display: flex;
    flex-direction: column;
    min-height: 150px; /* Give the log a minimum height */
}

#verbose-log-readable,
#verbose-log-raw {
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.9em;
    padding: 0.5rem;
    background-color: var(--pico-background-color);
    border-radius: var(--pico-border-radius);
}

#verbose-log-readable p {
    margin: 0 0 5px 0;
    white-space: pre-wrap;
    text-align: left;
}

/* --- Close Button Style --- */
.close-button {
    background: none;
    border: none;
    color: var(--pico-muted-color);
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-button:hover {
    color: var(--pico-contrast);
}

/* -- Undo & Redo --- */
#export-controls-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.history-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.history-button {
    flex-grow: 1;
    padding: 8px;
    background-color: #555;
    color: white;
    border: 1px solid #777;
    cursor: pointer;
}
.history-button:disabled {
    background-color: #333;
    color: #666;
    cursor: not-allowed;
}

#prefs-window-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#prefs-window {
    width: 80%;
    max-width: 1200px;
    background-color: #2a2a2a;
    border: 1px solid #555;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

#prefs-window-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #444;
}

#prefs-window-content {
    padding: 20px;
}

#prefs-manifest-id {
    word-break: break-all; /* Allows long strings to wrap */
}

.prefs-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #444;
}
.prefs-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.import-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#import-save-select {
    flex-grow: 1;
    padding: 8px;
    background-color: #333;
    color: white;
    border: 1px solid #555;
}

#overlay-manager-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#overlay-manager-window {
    width: 400px;
    background-color: #2a2a2a;
    border: 1px solid #555;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

.window-header { /* Reusable header style */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #444;
}

.window-content { /* Reusable content style */
    padding: 20px;
}

.control-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Use Leaflet's built-in 'active' state styling */
.leaflet-control a.active {
    background-color: var(--pico-primary);
}

#map-info-container {
    position: absolute;
    bottom: 10px; /* A little space from the bottom */
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse; /* This is the magic! */
    align-items: flex-end;
    gap: 5px;
    pointer-events: none; /* Keep this so the container doesn't block clicks */
}

/* We also need to make the info boxes clickable again */
.map-info-box {
    pointer-events: auto; /* Re-enable pointer events on the boxes themselves */
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-family: monospace;
    white-space: nowrap;
}

/* Target the container DIV that Leaflet creates for our custom icon.
  This selector is very specific, so it will override Leaflet's defaults.
*/
.leaflet-marker-icon.custom-map-marker {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none; /* Override Pico's box-shadow for images */
}

/* Now, target the IMG tag (our SVG) INSIDE our custom marker.
  This forces it to obey the size we set in JavaScript.
*/
.custom-map-marker img {
    width: 100%;
    height: 100%;
    max-width: none !important; /* Override any max-width from Pico */
    padding: 0;
    margin: 0;
    transition: transform 0.15s ease-in-out;
}

.custom-map-marker:hover {
    transform: scale(1.3);
}

.menu-section-content {
    padding: 10px;
    background-color: #1e1e1e;
    border: 1px solid #444;
    border-top: none;
    border-radius: 0 0 5px 5px;
}

.filter-input {
    width: 100%;
    margin-bottom: 10px;
    box-sizing: border-box; /* Ensures padding doesn't affect width */
}

.menu-section-content select {
    width: 100%;
}

#info-panel {
    position: absolute;
    top: 100px;
    left: 270px; /* Position it just outside the left menu */
    width: 350px;
    max-height: 70vh;
    background-color: #2a2a2a;
    border: 1px solid #555;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    z-index: 1500; /* Above map layers, below main modals */
    display: flex;
    flex-direction: column;
}

#info-panel-header {
    padding: 10px 15px;
    background-color: #333;
    cursor: grab; /* Indicates this area is draggable */
    border-bottom: 1px solid #555;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#info-panel-header:active {
    cursor: grabbing;
}

#info-panel-title {
    margin: 0;
    font-size: 1.1em;
}

#info-panel-content {
    padding: 15px;
    overflow-y: auto;
}

#reset-panel-container {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
}

#reset-panel-btn {
    width: 34px;
    height: 34px;
    padding: 5px; /* Add some padding around the icon */
    background-color: #2a2a2a;
    color: #ddd;
    border: 1px solid #555;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
#reset-panel-btn:hover {
    background-color: #444;
}

#reset-panel-btn img {
    width: 20px;
    height: 20px;
}

#user-menu-container {
    position: relative; /* This is the anchor for the dropdown menu */
    display: flex;      /* This ensures it behaves correctly as a flex item */
}

/* Style the button just like the others */
#user-menu-button {
    display: flex;
    align-items: center;
}

#user-menu-label {
    margin-left: 8px;
    font-weight: bold;
}

/* Position the dropdown menu */
#user-menu-items {
    position: absolute;
    top: 100%; /* Position it right below the button */
    right: 0;
    left: auto;
    min-width: 220px;
    z-index: 3000; /* Ensure it's on top of everything */
    border: 1px solid var(--pico-contrast);
    background-color: var(--pico-card-background-color); /* Use a pico variable */
}

#user-menu-items li {
    margin-bottom: 0; /* Pico removes bottom margin on list items in menus */
}

#user-menu-items a {
    display: block;
    padding: 0.5rem 1rem; /* Use Pico's standard padding */
    color: var(--pico-contrast);
    text-decoration: none;
    text-align: left;
}

#user-menu-items a:hover {
    background-color: var(--pico-primary-hover);
    color: var(--pico-primary-inverse); /* Ensures text is readable on hover */
}

/* --- Spawn Area Mini Panel (Fixed Position) --- */
#spawn-mini-panel {
    position: absolute;
    bottom: 110px; /* Moves it up to sit above the coordinate display */
    right: 10px;
    z-index: 1001;
    width: 200px; /* Slightly smaller width */
    padding: 0.75rem; /* Tighter padding */
    font-size: 0.9em; /* Smaller font */

    /* Unchanged styling */
    background-color: var(--pico-card-background-color);
    border: 1px solid var(--pico-contrast);
    border-radius: var(--pico-border-radius);
    box-shadow: var(--pico-box-shadow);
    text-align: center;
}

#spawn-mini-name {
    margin: 0 0 1rem 0;
    font-weight: bold;
}

#spawn-mini-close-btn {
    position: absolute;
    top: 0;
    right: 5px;
    padding: 0;
    font-size: 1.5em;
}

/* --- Custom Town Marker Popup --- */
.custom-town-popup .leaflet-popup-content-wrapper {
    background-color: var(--pico-card-background-color);
    border: 1px solid var(--pico-contrast);
    border-radius: var(--pico-border-radius);
    box-shadow: var(--pico-box-shadow);
    padding: 1rem;
    text-align: center;
}

.custom-town-popup .leaflet-popup-content {
    margin: 0;
}

.custom-town-popup .leaflet-popup-tip-container {
    display: none; /* Hide the little triangle arrow */
}

.custom-town-popup p {
    margin: 0 0 1rem 0;
    font-weight: bold;
}

/* --- Override Network Window --- */
#override-window-backdrop {
    /* Reusing backdrop style from status window */
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.7); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
}

#override-window {
    width: 80%; max-width: 1200px; height: 80%;
    background-color: var(--pico-card-background-color);
    border: 1px solid var(--pico-contrast);
    border-radius: var(--pico-border-radius);
    display: flex; flex-direction: column;
    box-shadow: var(--pico-box-shadow);
}

#override-window-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1rem;
    padding: 1rem;
    flex-grow: 1;
    min-height: 0; 
}

#override-town-list-container, #override-path-display-container {
    background-color: var(--pico-background-color);
    border-radius: var(--pico-border-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden; 
}


#override-path-display {
    background-color: var(--pico-background-color);
    overflow-y: auto;
    font-family: monospace;
}

#override-town-list {
    overflow-y: auto; /* This makes the containers scrollable */
    font-family: monospace;
    list-style: none;
    padding: 0;
    margin: 0;
}

#override-town-list li {
    padding: 0.5rem;
    cursor: pointer;
    border-radius: var(--pico-border-radius);
}

#override-town-list li:hover {
    background-color: var(--pico-primary-hover);
    color: var(--pico-primary-inverse);
}

/* --- Tab Control Styles --- */
.tab-header {
    display: flex;
    border-bottom: 1px solid var(--pico-muted-border-color);
    margin-bottom: 1rem;
}

.tab-button {
    padding: 0.5rem 1rem;
    cursor: pointer;
    background-color: transparent;
    border: none;
    border-bottom: 3px solid transparent; /* Underline for active state */
    color: var(--pico-contrast);
    margin-bottom: -1px; /* Align with parent's border */
    border-radius: 0;
}

.tab-button.active {
    border-bottom-color: var(--pico-primary);
    font-weight: bold;
}

.tab-button:hover:not(.active) {
    border-bottom-color: var(--pico-muted-border-color);
}

.tab-content {
    display: none; /* Hide inactive tabs by default */
    flex-grow: 1;  /* This is the key: it makes the content area expand */
    min-height: 0; /* This prevents flexbox sizing issues with scrolling children */
}

.tab-content.active {
    display: block; /* Show the active tab's content */
}

/* --- Override Path Display --- */
.path-container {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
}

.path-container:last-child { 
    border-bottom: none; 
}

.path-row {
    display: flex;
    justify-content: flex-start; /* Default direction */
    align-items: center;
}

.path-row.reverse {
    flex-direction: row-reverse;
}

.path-step {
    border: 1px solid var(--pico-muted-border-color);
    padding: 0.5rem;
    border-radius: var(--pico-border-radius);
    text-align: center;
    flex-basis: 45%; /* Each step takes up ~45% of the row */
    flex-shrink: 0;
}

.string-id {
    color: var(--pico-muted-color);
    font-size: 0.8em;
}

.path-arrow {
    flex-grow: 1;
    text-align: center;
}

.path-arrow.vertical {
    margin: 0.5rem 0;
}

.path-arrow img {
    width: 24px;
    height: 24px;
    filter: invert(75%);
}

.path-arrow.vertical.align-left {
    text-align: left;
    padding-left: 25%; /* Nudge it to the center of the left box */
}

.path-arrow.vertical.align-right {
    text-align: right;
    padding-right: 25%; /* Nudge it to the center of the right box */
}


/* --- D3 Flowchart Styling --- */
.node rect {
    fill: var(--pico-card-background-color);
    stroke: var(--pico-contrast);
    stroke-width: 2px;
}

.node text {
    fill: var(--pico-contrast);
    font-size: 0.9em;
    pointer-events: none; /* Allows clicking through the text to the node */
}

.node {
    cursor: grab;
}

.node:active {
    cursor: grabbing;
}

.link {
    stroke: var(--pico-muted-border-color);
    stroke-width: 5px;                   
    stroke-opacity: 0.8;
    cursor: pointer;
}

/* Style links based on their state */
path.link[marker-end="url(#active)"] {
    stroke: var(--pico-ins-border); /* Green */
    stroke-width: 2.5px;
}
marker#arrow-active path {
    fill: var(--pico-ins-border);
}

path.link[marker-end="url(#inactive)"] {
    stroke: var(--pico-contrast);
    stroke-width: 1.5px;
}
marker#arrow-inactive path {
    fill: var(--pico-contrast);
}

path.link[marker-end="url(#implausible)"] {
    stroke: var(--pico-muted-border-color); /* Gray */
    stroke-dasharray: 5, 5;
}

marker#arrow-implausible path {
    fill: var(--pico-muted-border-color);
}

.edge-label {
    opacity: 0; 
    pointer-events: none;
    font-size: 0.8em;
    text-anchor: middle;
    fill: var(--pico-muted-color);
    background-color: var(--pico-card-background-color); /* To make it readable over lines */
    transition: opacity 0.2s ease-in-out;
}

.edge-label.active {
    opacity: 1; /* Visible when active */
}

.edge-label-bg {
    fill: var(--pico-background-color);
    rx: var(--pico-border-radius); /* Rounded corners */
}

.edge-label tspan {
    fill: var(--pico-muted-color);
    font-size: 0.8em;
}

.close-label-btn {
    font-size: 0.9em;
    cursor: pointer;
    fill: var(--pico-muted-color);
}

.close-label-btn:hover {
    fill: var(--pico-contrast);
}

.close-label-btn rect {
    fill: var(--pico-muted-border-color);
    opacity: 0.5;
}
.close-label-btn:hover rect {
    opacity: 1;
}
.close-label-btn text {
    fill: var(--pico-background-color);
    font-size: 0.8em;
    font-weight: bold;
    text-anchor: middle;
    transform: translate(8px, 12px); /* Center the '?' in the box */
    pointer-events: none; /* Make sure the text doesn't block the click on the rect */
}

/* --- Infamy Tracker Window --- */
#infamy-window-backdrop {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.7); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
}

#infamy-window {
    width: 80%; max-width: 1400px; height: 80%;
    background-color: var(--pico-card-background-color);
    border: 1px solid var(--pico-contrast);
    border-radius: var(--pico-border-radius);
    display: flex; flex-direction: column;
    box-shadow: var(--pico-box-shadow);
}

#infamy-window-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr; /* Three equal columns */
    gap: 1rem;
    padding: 1rem;
    flex-grow: 1;
    min-height: 0;
}

.infamy-column {
    background-color: var(--pico-background-color);
    border-radius: var(--pico-border-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.infamy-list {
    overflow-y: auto;
    padding-right: 0.6rem;
}

/* Status indicators for spawn list */
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

/* --- Spawn Area Status Coloring --- */
.status-default { background-color: #007bff; } /* Blue */
.status-active { background-color: #388e3c; } /* Green */
.status-potential { background-color: #FFC107; } /* Yellow */
.status-eliminated { background-color: #5c0505; } /* Red */
/* --- Future statuses! --- */
.status-deactivated { background-color: #fd7e14; } /* Orange */
.status-distant { background-color: #612063; } /* Purple */

#infamy-spawn-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#infamy-spawn-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--pico-muted-border-color);
    font-family: monospace;    
    font-size: 0.8em;
}

#infamy-spawn-list li:last-child {
    border-bottom: none;
}

.infamy-list .value {
    font-weight: bold;
}
.infamy-list .value-ally {
    color: var(--pico-ins-border);
}
.infamy-list .value-enemy {
    color: var(--pico-del-border);
}

/* Style for the bounty cards */
.bounty-card {
    margin-bottom: 1rem;
    padding: 0.75rem;
}
.bounty-card header {
    padding: 0;
    margin-bottom: 0.5rem;
}
.bounty-card footer {
    padding: 0;
    margin-top: 0.5rem;
    background-color: transparent;
}

.status-alive {
    background-color: #388e3c; /* Green */
}
.status-imprisoned {
    background-color: #FFC107; /* Yellow */
}
.status-dead {
    background-color: #5c0505; /* Red */
}
.status-stateless {
    background-color: #612063; /* Purple */
}

/* --- Environment Info Window --- */
#environment-window-backdrop {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background-color: rgba(0, 0, 0, 0.7); z-index: 2000;
    display: flex; justify-content: center; align-items: center;
}
#environment-window {
    width: 80%; max-width: 1400px; height: 80%;
    background-color: var(--pico-card-background-color);
    border: 1px solid var(--pico-contrast);
    border-radius: var(--pico-border-radius);
    display: flex; flex-direction: column;
    box-shadow: var(--pico-box-shadow);
}
#environment-window-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    flex-grow: 1;
    min-height: 0;
    overflow: hidden;
}
.environment-column {
    background-color: var(--pico-background-color);
    border-radius: var(--pico-border-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.environment-list {
    overflow-y: auto;
}

.area-block {
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--pico-muted-border-color);
}
.area-block:last-child {
    border-bottom: none;
}

.area-block h4 {
    margin-bottom: 0.5rem;
    cursor: pointer;
    color: var(--pico-primary-hover);
}
.area-block h4:hover {
    text-decoration: underline;
}

.area-block ul {
    list-style: none;
    padding-left: 1rem;
    margin: 0;
}

/* --- Unified Toggle Controls --- */

.unified-controls-container {
    background-color: var(--pico-card-background-color);
    border-radius: var(--pico-border-radius) !important; /* Override Leaflet's default */
    box-shadow: var(--pico-card-box-shadow) !important;
}

.unified-control-btn {
    width: 34px;
    height: 34px;
    display: flex !important; /* Use !important to ensure override */
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--pico-muted-border-color) !important;
}

.unified-control-btn img {
    width: 20px;
    height: 20px;
}

.unified-control-btn:last-child {
    border-bottom: none !important;
}

.unified-control-btn.active {
    background-color: var(--pico-primary-focus);
}

.control-separator {
    height: 8px; /* This creates the visual gap */
    background-color: var(--pico-background-color); /* A slightly different color for the gap */
    border-bottom: 1px solid var(--pico-muted-border-color);
}

/* --- On-Map Tracker Container --- */

#tracker-container {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 1000; /* Ensures it's on top of the map */
    
    display: flex;
    flex-direction: column; /* Stacks the panels vertically */
    align-items: flex-end;   /* Aligns panels to the right edge */
    gap: 10px;               /* Creates a clean space between panels */
}

/* This is the generic style for ALL panels inside the container */
.map-overlay-panel {
    background-color: var(--pico-card-background-color);
    padding: 0.5rem 1rem;
    border-radius: var(--pico-border-radius);
    box-shadow: var(--pico-card-box-shadow);
    min-width: 180px; /* Gives the panels a consistent minimum width */
    text-align: left;
    transition: all 0.2s ease-in-out; /* Smooth transitions for later */
}

/* Specific styles for panel contents */
.map-overlay-panel h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1em;
}

.map-overlay-panel p {
    margin: 0.25rem 0;
    font-size: 0.9em;
}

.leaflet-popup-pane .kenshi-popup-pane .leaflet-popup-content-wrapper {
    background: var(--pico-card-background-color);
    color: var(--pico-contrast);
    border-radius: var(--pico-border-radius);
    box-shadow: var(--pico-card-box-shadow);
}

.leaflet-popup-pane .kenshi-popup-pane .leaflet-popup-content {
    margin: var(--pico-spacing); /* Use Pico spacing for padding */
}

/* This targets the tip of the popup arrow */
.leaflet-popup-pane .kenshi-popup-pane .leaflet-popup-tip {
    background: var(--pico-card-background-color);
}

/* Style the content inside our popup */
.kenshi-popup h4 {
    margin: 0 0 0.75rem 0;
    text-align: center;
}

/* Style the new, bigger "View Details" button using Pico's button styles */
.kenshi-popup button {
    width: 100%;
    margin: 0;
}

/* --- Collapsible Layer Control Styles --- */

/* Style for the new, independent toggle button's container */
#layer-toggle-control {
    box-shadow: var(--pico-card-box-shadow) !important;
}

/* Style for the link inside the button */
.layer-toggle-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-toggle-btn img {
    width: 20px;
    height: 20px;
}

/* Visibility control for the layers panel */
.leaflet-control-layers {
    display: none; /* Hidden by default */
}

.leaflet-control-layers.visible {
    display: block; /* Shown when toggled by our button */
}

/* Power Ranks Table */
.ranks-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--pico-background-color);
}

.ranks-table th, .ranks-table td {
    padding: 10px;
    border-bottom: 1px solid var(--pico-muted-border-color);
    text-align: left;
}

.ranks-table th {
    background-color: #333;
    font-weight: bold;
}

.rank-details {
    padding: 10px;
    background-color: rgba(0,0,0,0.2);
    margin-top: 5px;
    border-left: 2px solid var(--pico-primary);
    font-size: 0.9em;
}

/* World History Log */
#world-history-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    height: 100%;
    padding: 10px;
}

.history-entry {
    background-color: var(--pico-background-color);
    padding: 10px;
    border-left: 3px solid var(--pico-primary);
    border-radius: 0 5px 5px 0;
    text-align: left;
}

.history-entry .timestamp {
    color: var(--pico-muted-color);
    font-size: 0.8em;
    display: block;
    margin-bottom: 5px;
}

.history-entry .narrative {
    font-size: 1em;
    line-height: 1.4;
}

/* Modals (Reuse existing styles, but specific IDs) */
#power-ranks-window, #world-history-window {
    width: 80%;
    max-width: 1000px;
    height: 80%;
    background-color: var(--pico-card-background-color);
    border: 1px solid var(--pico-contrast);
    border-radius: var(--pico-border-radius);
    display: flex;
    flex-direction: column;
    box-shadow: var(--pico-box-shadow);
}

#power-ranks-content, #world-history-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

#power-ranks-backdrop,
#world-history-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.region-nameplate {
    background: transparent;
    border: none;
    text-align: center;
}

.region-nameplate span {
    background: rgba(0, 0, 0, 0.6);
    color: #eee;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: 600;
    white-space: nowrap;
    text-shadow: 1px 1px 2px black;
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: none; /* Let clicks pass through to the map */
}

/* Force sharp edges for our generated overlays */
.pixelated-overlay {
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* Position the color pickers nicely (if not already styled) */
.color-picker-tool {
    position: absolute;
    top: 80px; /* Adjust based on your UI */
    right: 15px;
    z-index: 1000;
    width: 30px;
    height: 30px;
    cursor: pointer;
    border: 2px solid #444;
    background: #222;
    padding: 0;
}
#border-color-shifter {
    top: 120px; /* Stack below road picker */
}

/* --- COMPACT DARK LAYER CONTROL --- */

/* 1. The Container */
.leaflet-control-layers {
    background: rgba(20, 20, 20, 0.95) !important; /* Dark Glass */
    border: 1px solid #555 !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6) !important;
    color: #ccc !important;
    font-family: 'Segoe UI', Tahoma, sans-serif !important;
    font-size: 11px !important; /* Smaller text */
    
    /* SCROLLING MAGIC */
    max-height: 50vh; /* Never take up more than 60% of screen height */
    overflow-y: auto; /* Scroll if too tall */
    overflow-x: hidden;
    
    /* Width control */
    min-width: 180px;
    padding: 4px !important;
}

/* 2. The List Items */
.leaflet-control-layers-list {
    margin-bottom: 0; /* Fix Pico CSS interference */
}

.leaflet-control-layers label {
    display: flex !important;
    align-items: center;
    padding: 2px 6px; /* Very tight vertical padding */
    margin: 0 !important; /* Remove gaps */
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.leaflet-control-layers label:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* 3. The Radio/Checkbox Inputs */
.leaflet-control-layers input[type="radio"],
.leaflet-control-layers input[type="checkbox"] {
    margin: 0 8px 0 0 !important; /* Space between dot and text */
    cursor: pointer;
    /* Optional: If you want to force them smaller */
    transform: scale(0.9); 
}

/* 4. The Separator (Between Base and Overlays) */
.leaflet-control-layers-separator {
    border-top: 1px solid #444 !important;
    margin: 6px 0 !important;
}

/* 5. Custom Scrollbar (Webkit only - Chrome/Edge/Safari) */
.leaflet-control-layers::-webkit-scrollbar {
    width: 6px;
}
.leaflet-control-layers::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.3);
}
.leaflet-control-layers::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}
.leaflet-control-layers::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Landmarks Styling */
.leaflet-marker-icon.landmark-icon {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0;
}

/* Optional: Add a hover effect for the landmark icons */
.landmark-icon img {
    transition: transform 0.2s ease-in-out;
}
.landmark-icon:hover img {
    transform: scale(1.2);
}