/* Prevent page-level scrolling and define base layout */
html, body {
    margin: 0;
    padding: 0;
    overflow: hidden; /* CRITICAL: Prevents all browser scrollbars */
    background-color: #0c0a09; /* Dark background */
    /* UPDATED FONT */
    font-family: 'IM Fell English', serif;
    color: #f0f0f0;
}

/* Utility class for hiding elements (replaces inline style="display: none;") */
.hidden {
    display: none !important;
}

/* --- Sidebar Styles --- */
.sidebar {
    position: absolute;
    left: 0;
    top: 0;
    width: 250px;
    height: 100vh;
    background-color: #1a1a1a;
    box-shadow: 2px 0 10px rgba(0,0,0,0.5);
    z-index: 20;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

/* Mobile: collapsible sidebar */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-250px);
    }
    .sidebar.open {
        transform: translateX(0);
    }
}

/* --- NEW: Tab Styles --- */
.sidebar-tabs {
    display: flex;
    width: 100%;
}
.tab-btn {
    flex: 1;
    padding: 15px;
    background-color: #2a2a2a;
    border: none;
    border-bottom: 3px solid #2a2a2a;
    color: #888;
    font-size: 1.1em; /* Slightly larger for new font */
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    /* Apply new font */
    font-family: 'IM Fell English', serif;
}
.tab-btn:hover {
    background-color: #333;
}
.tab-btn.active {
    background-color: #1a1a1a;
    color: #fff;
    border-bottom-color: #ffd700;
}
/* --- End Tab Styles --- */

/* Search Box */
.search-container {
    position: relative;
    padding: 10px 10px 10px 15px;
    border-bottom: 1px solid #333;
}

#search-box {
    width: calc(100% - 25px);
    padding: 8px 30px 8px 10px;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    color: #fff;
    font-family: 'IM Fell English', serif;
    font-size: 14px;
    box-sizing: border-box;
}

#search-box:focus {
    outline: none;
    border-color: #ffd700;
    background-color: #333;
}

.clear-search-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 20px;
}

.clear-search-btn:hover {
    color: #ffd700;
}

.last-updated {
    font-size: 0.85em;
    color: #888;
    text-align: center;
    padding: 5px 0;
    margin: 0;
    border-bottom: 1px solid #333;
}

/* --- NEW: Tab Content Styles --- */
.tab-content {
    display: none; /* Hidden by default */
    flex-grow: 1;
    overflow-y: auto;
}
.tab-content.active {
    display: block; /* Shown when active */
}
/* --- End Tab Content Styles --- */

.port-list {
    /* This class is now used by both lists */
    flex-grow: 1;
}

.port-item {
    padding: 12px 15px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s ease;
    font-size: 1.1em; /* Slightly larger for new font */
}

.port-item:hover {
    background-color: #2c2c2c;
}

.port-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.3);
}

.port-item svg.sidebar-icon {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    flex-shrink: 0;
}

.port-item svg.sidebar-icon path {
    /* Faction colors will be applied via classes below */
}

.port-item img {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}



/* --- Map Viewport & Container --- */
.map-viewport {
    position: absolute;
    left: 250px;
    top: 0;
    width: calc(100vw - 250px);
    height: 100vh;
    overflow: hidden;
    cursor: grab;
}

.map-viewport.is-dragging {
    cursor: grabbing;
}

.map-container {
    position: absolute;
    width: 3840px;
    height: 2498px;
    transform-origin: 0 0;
}

.map-container.is-transitioning {
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.map-container img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    user-select: none;
}

/* --- Point Styles (Ports) --- */
.map-point {
    position: absolute;
    cursor: pointer;
    /* transform is set by JS */
    transition: all 0.2s ease;
    pointer-events: all;
    z-index: 10;
}

.map-point .map-icon {
    /* This is the SVG icon */
    width: 30px;
    height: 30px;
    /* UPDATED: Stroke now inherits fill color (faction color) */
    stroke: currentColor;
    stroke-width: 3px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.7));
    transition: all 0.2s ease;
    transform-origin: center center;
    /* Fill and stroke color are applied by faction classes */
}

.map-point:hover {
     /* transform is handled by JS */
}

.map-point:hover .map-icon {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6)) drop-shadow(0 1px 3px rgba(0,0,0,0.7));
}

.map-point.highlighted {
    /* transform is handled by JS */
    z-index: 11;
}

.map-point.highlighted .map-icon {
    filter: drop-shadow(0 0 8px #fff) drop-shadow(0 0 15px #0ff);
    stroke: #00ffff;
    stroke-width: 2px; /* Thinner highlight stroke */
}

/* --- NEW: Entity Styles (Ships, Storms) --- */
.map-entity {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    pointer-events: all;
}
.map-entity img {
    /* UPDATED: Reverted to smaller base size */
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.7));
    transition: all 0.2s ease;
}
.map-entity:hover {
    /* transform is handled by JS */
    z-index: 11;
}
.map-entity:hover img {
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6)) drop-shadow(0 1px 3px rgba(0,0,0,0.7));
}
.map-entity.highlighted {
    /* transform is handled by JS */
    z-index: 11;
}
.map-entity.highlighted img {
    filter: drop-shadow(0 0 8px #fff) drop-shadow(0 0 15px #0ff);
}
/* --- End Entity Styles --- */

/* --- NEW: Grid Label Styles --- */
.map-grid-label {
    position: absolute;
    transform: translate(-50%, -50%);
    /* UPDATED: Reverted to smaller base font size */
    font-size: 24px; 
    font-weight: bold;
    color: rgba(255, 255, 255, 0.5); /* Semi-transparent white */
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
    pointer-events: none; /* Labels are not interactive */
    user-select: none;
    z-index: 5; /* Behind ports and entities */
}
/* --- End Grid Label Styles --- */

/* --- NEW: Grid Line Styles --- */
.map-grid-line {
    position: absolute;
    background-color: rgba(255, 255, 255, 0.2); /* Faint white */
    pointer-events: none;
    user-select: none;
    z-index: 6; /* Above labels, below ports */
}

.map-grid-line.vertical-line {
    /* Counter-scale thickness so lines always appear as 1px regardless of zoom */
    width: calc(1px / var(--map-scale, 1));
    /* height is set by JS */
    /* top is set by JS */
}

.map-grid-line.horizontal-line {
    /* Counter-scale thickness so lines always appear as 1px regardless of zoom */
    height: calc(1px / var(--map-scale, 1));
    /* width is set by JS */
    /* left is set by JS */
}
/* --- End Grid Line Styles --- */


/* Faction colors using background-color */
.spanish .map-icon { fill: #ffff00; stroke: #ffff00; stroke-width: 3px; }
.spain .map-icon { fill: #ffff00; stroke: #ffff00; stroke-width: 3px; }
.english .map-icon { fill: #ff0000; stroke: #ff0000; stroke-width: 3px; }
.england .map-icon { fill: #ff0000; stroke: #ff0000; stroke-width: 3px; }
.dutch .map-icon { fill: #90ee90; stroke: #90ee90; stroke-width: 3px; }
.netherlands .map-icon { fill: #90ee90; stroke: #90ee90; stroke-width: 3px; }
.independent .map-icon { fill: #ffffff; stroke: #ff00e7; stroke-width: 3px; }
.french .map-icon { fill: #0000ff; stroke: #0000ff; stroke-width: 3px; }
.france .map-icon { fill: #0000ff; stroke: #0000ff; stroke-width: 3px; }
.pirate .map-icon { fill: #ffffff; stroke: #ffffff; stroke-width: 15px; }
.native .map-icon { fill: #e09300; stroke: #e09300; stroke-width: 4px; }
.jesuit .map-icon { fill: #ffffff; stroke: #0082ff; stroke-width: 4px; }
.infected .map-icon { fill: #ff0000; stroke: #ff0000; stroke-width: 4px; }

/* Sidebar icon colors */
.sidebar-icon.spanish path { fill: #ffff00; stroke: #ffff00; }
.sidebar-icon.spain path { fill: #ffff00; stroke: #ffff00; }
.sidebar-icon.english path { fill: #ff0000; stroke: #ff0000; }
.sidebar-icon.england path { fill: #ff0000; stroke: #ff0000; }
.sidebar-icon.dutch path { fill: #90ee90; stroke: #90ee90; }
.sidebar-icon.netherlands path { fill: #90ee90; stroke: #90ee90; }
.sidebar-icon.independent path { fill: #ffffff; stroke: #ff00e7; stroke-width: 2px; }
.sidebar-icon.french path { fill: #0000ff; stroke: #0000ff; }
.sidebar-icon.france path { fill: #0000ff; stroke: #0000ff; }
.sidebar-icon.pirate path { fill: #ffffff; stroke: #ffffff; }
.sidebar-icon.native path { fill: #D2691E; stroke: #D2691E; }
.sidebar-icon.jesuit path { fill: #ffffff; stroke: #0082ff; stroke-width: 2px; }
.sidebar-icon.infected path { fill: #ff0000; stroke: #ff0000; }

.dot.spanish { background-color: #ffff00; }
.dot.spain { background-color: #ffff00; }
.dot.english { background-color: #ff0000; }
.dot.england { background-color: #ff0000; }
.dot.dutch { background-color: #90ee90; }
.dot.netherlands { background-color: #90ee90; }
.dot.independent { background-color: #ff00ff; }
.dot.french { background-color: #0000ff; }
.dot.france { background-color: #0000ff; }
.dot.pirate { background-color: #ffffff; }
.dot.native { background-color: #D2691E; }
.dot.jesuit { background-color: #0082ff; }
.dot.infected { background-color: #8B0000; }
/* --- End Faction Colors --- */

/* --- Toolbar --- */
.map-toolbar {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background-color: rgba(26, 26, 26, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    z-index: 21;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    flex-wrap: wrap;
    max-width: calc(100vw - 300px);
}

.map-toolbar.collapsed {
    padding: 4px 12px;
    gap: 0;
}

.map-toolbar.collapsed .toolbar-section,
.map-toolbar.collapsed .toolbar-collapse-btn {
    display: none;
}

.map-toolbar.collapsed .toolbar-expand-btn {
    display: block;
}

.toolbar-collapse-btn,
.toolbar-expand-btn {
    background-color: rgba(255, 215, 0, 0.2);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 3px;
    color: #ffd700;
    cursor: pointer;
    padding: 6px 8px;
    font-size: 16px;
    transition: all 0.2s ease;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-collapse-btn svg,
.toolbar-expand-btn svg {
    fill: currentColor;
}

.toolbar-collapse-btn:hover,
.toolbar-expand-btn:hover {
    background-color: rgba(255, 215, 0, 0.4);
    border-color: #ffd700;
    transform: scale(1.1);
}

.toolbar-expand-btn {
    display: none;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 8px;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.toolbar-section:last-child {
    border-right: none;
    padding-right: 0;
}

.toolbar-section:first-child {
    padding-left: 0;
}

.toolbar-label {
    font-size: 9px;
    font-weight: 700;
    color: #ffd700;
    margin-bottom: 5px;
    text-align: center;
    font-family: 'IM Fell English', serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.pan-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.pan-row {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
}

.pan-btn {
    width: 28px;
    height: 28px;
    font-size: 15px;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    cursor: pointer;
    color: #fff;
    line-height: 26px;
    transition: all 0.2s ease;
    margin: 0;
}

.pan-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
    border-color: #ffd700;
    transform: scale(1.05);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.pan-btn:active {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
}

/* Zoom buttons - distinctive styling */
#zoom-in-btn,
#zoom-out-btn {
    background-color: rgba(255, 215, 0, 0.25);
    border: 1px solid rgba(255, 215, 0, 0.5);
    color: #ffd700;
}

#zoom-in-btn:hover,
#zoom-out-btn:hover {
    background-color: rgba(255, 215, 0, 0.45);
    border-color: #ffd700;
    color: #fff;
}

#zoom-in-btn:active,
#zoom-out-btn:active {
    background-color: rgba(255, 215, 0, 0.2);
}

.zoom-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 3px;
    cursor: pointer;
    margin-top: 3px;
    line-height: 26px;
    color: #fff;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
    border-color: #ffd700;
    transform: scale(1.05);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.zoom-btn:active {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(0.95);
}

/* Reset Button */
.reset-btn {
    width: 36px;
    height: 36px;
    font-size: 24px;
    font-weight: bold;
    background-color: rgba(255, 215, 0, 0.2);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 3px;
    cursor: pointer;
    color: #ffd700;
    line-height: 34px;
    transition: all 0.2s ease;
    align-self: center;
}

.reset-btn:hover {
    background-color: rgba(255, 215, 0, 0.4);
    border-color: #ffd700;
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

.reset-btn:active {
    transform: scale(0.95);
}

/* Version Badge (outside help modal in upper right) */
.version-badge {
    position: fixed;
    top: 20px;
    right: 80px;
    background-color: rgba(255, 215, 0, 0.15);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 12px;
    padding: 6px 12px;
    color: #ffd700;
    font-family: 'Merriweather', serif;
    font-size: 12px;
    font-weight: 600;
    z-index: 1001;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.version-badge:hover {
    background-color: rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
    transform: scale(1.05);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.6);
}

/* Current Location Display */
.current-location {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.location-grid {
    font-size: 11px;
    font-weight: 700;
    color: #ffd700;
    font-family: 'Merriweather', serif;
}

.location-coords {
    font-size: 9px;
    color: #aaa;
    font-family: 'Merriweather', serif;
    white-space: nowrap;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 215, 0, 0.3);
    border-top: 3px solid #ffd700;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Toggle Controls */
.toggle-controls {
    display: grid;
    grid-template-columns: auto auto;
    gap: 3px 8px;
}

.toggle-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 11px;
    color: #fff;
    user-select: none;
    white-space: nowrap;
}

.toggle-item input[type="checkbox"] {
    width: 13px;
    height: 13px;
    margin-right: 5px;
    cursor: pointer;
    accent-color: #ffd700;
}

.toggle-item span {
    font-family: 'IM Fell English', serif;
}

/* --- Map Tooltip (now has fixed font size) --- */
.map-tooltip {
    position: absolute;
    width: 200px;
    background-color: #222;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 3px 3px 10px rgba(0,0,0,0.5);
    z-index: 100;

    /* transform is now set entirely by JS to include counter-scale */

    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;

    pointer-events: auto;

    /* *** UPDATED: Set tooltip font *** */
    font-family: 'Merriweather', serif;
    font-size: 15px; /* Merriweather is readable at a smaller size */
    line-height: 1.4;

    /* UPDATED: Tooltip must have transform-origin for counter-scaling */
    transform-origin: 0 0;
}

.map-tooltip h4 {
    margin: 0 0 5px 0;
    color: #ffd700;
    font-size: 1.2em; 
    font-weight: 700;
}

.map-tooltip p {
    margin: 0;
    font-size: 1em; 
    font-weight: 400;
    color: #ccc;
}
/* --- Coordinate Tooltip Styles --- */
.coordinate-tooltip {
    position: absolute;
    background-color: rgba(34, 34, 34, 0.95);
    border: 2px solid #ffd700;
    border-radius: 4px;
    padding: 8px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
    z-index: 100;
    
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
    
    pointer-events: none;
    
    font-family: 'Merriweather', serif;
    
    transform-origin: 0 0;
    white-space: nowrap;
}

.coordinate-tooltip .coord-main {
    font-size: 16px;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
    margin-bottom: 4px;
}

.coordinate-tooltip .coord-latlon {
    font-size: 13px;
    font-weight: 400;
    color: #aaa;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
}

.coordinate-tooltip .coord-terrain {
    font-size: 13px;
    font-weight: 600;
    color: #6cf;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
    margin-top: 4px;
    text-transform: capitalize;
}

/* --- Sub-Grid Line Styles --- */
.sub-grid-line {
    opacity: 0;
    transition: opacity 0.3s ease;
    background-color: rgba(255, 255, 255, 0.1) !important; /* Fainter than major grid */
}

.major-grid {
    /* Major grid lines remain at default opacity */
}

/* --- Zoom Level Display --- */
.zoom-level-display {
    background-color: rgba(0, 0, 0, 0.3);
    color: #ffd700;
    padding: 3px 6px;
    border-radius: 3px;
    font-family: 'Merriweather', serif;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 3px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    min-width: 40px;
}

/* --- Terrain Overlay --- */
.terrain-cell {
    position: absolute;
    pointer-events: none;
    z-index: 4;
    opacity: 0.3;
}

.terrain-cell.land {
    background-color: #228B22;
}

.terrain-cell.water {
    background-color: #4169E1;
}

.terrain-cell.both {
    background-color: #D2B48C;
}

/* --- Zoom Slider --- */
.zoom-slider-container {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(26, 26, 26, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 10px 8px;
    z-index: 19;
    backdrop-filter: blur(10px);
    gap: 8px;
}

.zoom-slider-label {
    font-size: 18px;
    font-weight: bold;
    color: #ffd700;
    user-select: none;
    cursor: pointer;
    padding: 8px;
    transition: all 0.2s ease;
    background-color: rgba(255, 215, 0, 0.1);
    border-radius: 4px;
}

.zoom-slider-label:hover {
    background-color: rgba(255, 215, 0, 0.3);
    transform: scale(1.1);
}

.zoom-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 20px;
    height: 300px;
    background: linear-gradient(to bottom, rgba(255, 215, 0, 0.3) 0%, rgba(255, 255, 255, 0.2) 100%);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
    border: 1px solid rgba(255, 215, 0, 0.4);
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: #ffd700;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.zoom-slider::-webkit-slider-thumb:hover {
    background: #fff;
    border-color: #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
    transform: scale(1.2);
}

.zoom-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: #ffd700;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.zoom-slider::-moz-range-thumb:hover {
    background: #fff;
    border-color: #ffd700;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
    transform: scale(1.2);
}

/* Firefox specific slider track styling */
.zoom-slider::-moz-range-track {
    background: linear-gradient(to bottom, rgba(255, 215, 0, 0.3) 0%, rgba(255, 255, 255, 0.2) 100%);
    border-radius: 10px;
    border: 1px solid rgba(255, 215, 0, 0.4);
}

/* --- Mini Map --- */
.mini-map {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 150px;
    height: 98px;
    background-color: rgba(26, 26, 26, 0.8);
    border: 2px solid rgba(255, 215, 0, 0.4);
    border-radius: 6px;
    overflow: hidden;
    z-index: 18;
    cursor: pointer;
}

#mini-map-canvas {
    width: 100%;
    height: 100%;
}

.mini-map-viewport {
    position: absolute;
    border: 2px solid #ffd700;
    background-color: rgba(255, 215, 0, 0.2);
    pointer-events: none;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

/* --- Help Button --- */
.help-button {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: rgba(255, 215, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.6);
    color: #ffd700;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 22;
    transition: all 0.2s ease;
    font-family: serif;
    line-height: 36px;
}

.help-button:hover {
    background-color: rgba(255, 215, 0, 0.5);
    border-color: #ffd700;
    transform: scale(1.1);
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.8);
}

.help-button:active {
    transform: scale(0.95);
}

/* --- Help Modal --- */
.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.help-modal-content {
    background-color: #1a1a1a;
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 30px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

.help-modal-content h2 {
    margin: 0 0 20px 0;
    color: #ffd700;
    font-family: 'IM Fell English', serif;
    font-size: 28px;
    text-align: center;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
    padding-bottom: 10px;
}

.help-modal-content h3 {
    margin: 15px 0 10px 0;
    color: #ffd700;
    font-family: 'IM Fell English', serif;
    font-size: 18px;
}

.help-modal-content p {
    color: #ccc;
    line-height: 1.6;
    margin: 10px 0;
}

.help-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: #888;
    font-size: 36px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    line-height: 36px;
    transition: all 0.2s ease;
}

.help-modal-close:hover {
    color: #ffd700;
    transform: rotate(90deg);
}

.help-section {
    margin-bottom: 20px;
}

.help-shortcuts {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-shortcuts div {
    color: #ccc;
    font-size: 14px;
}

.help-shortcuts kbd {
    background-color: #333;
    border: 1px solid #555;
    border-radius: 3px;
    padding: 3px 8px;
    font-family: monospace;
    font-size: 13px;
    color: #ffd700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-right: 8px;
}

.help-legend {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ccc;
    font-size: 14px;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-color.spanish { background-color: #ffff00; }
.legend-color.english { background-color: #ff0000; }
.legend-color.french { background-color: #0000ff; }
.legend-color.dutch { background-color: #90ee90; }
.legend-color.pirate { background-color: #ffffff; }
.legend-color.native { background-color: #D2691E; }
.legend-color.jesuit { background-color: #0082ff; }
.legend-color.infected { background-color: #8B0000; }
.legend-color.independent { background-color: #ff00ff; }
.legend-color.terrain-land { background-color: #228B22; }
.legend-color.terrain-water { background-color: #4169E1; }
.legend-color.terrain-both { background-color: #D2B48C; }

/* Map tooltip coordinates section */
.map-tooltip .tooltip-coordinates {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #444;
    position: relative;
}

.map-tooltip .tooltip-grid {
    font-size: 0.9em;
    font-weight: 600;
    color: #6cf;
    margin-bottom: 3px;
}

.map-tooltip .tooltip-latlon {
    font-size: 0.85em;
    font-weight: 400;
    color: #999;
}

/* --- Easter Egg Dialog --- */
.easter-egg-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(26, 26, 26, 0.98);
    border: 3px solid #ffd700;
    border-radius: 10px;
    padding: 30px 40px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 2000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 215, 0, 0.3);
    font-family: 'IM Fell English', serif;
    color: #f0f0f0;
    font-size: 18px;
    line-height: 1.8;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: pre-line;
}

.easter-egg-dialog.visible {
    opacity: 1;
}

.copy-coords-btn {
    position: absolute;
    right: 0;
    top: 8px;
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid rgba(255, 215, 0, 0.4);
    border-radius: 3px;
    color: #ffd700;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    transition: all 0.2s ease;
}

.copy-coords-btn:hover {
    background: rgba(255, 215, 0, 0.4);
    border-color: #ffd700;
    transform: scale(1.1);
}

.copy-coords-btn:active {
    transform: scale(0.9);
}

.copy-coords-btn.copied {
    background: rgba(0, 255, 0, 0.3);
    border-color: #0f0;
    color: #0f0;
}

/* Entity image in tooltip */
.map-tooltip .tooltip-image {
    text-align: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
}

.map-tooltip .tooltip-image img {
    max-width: 100%;
    max-height: 80px;
    width: auto;
    height: auto;
    display: inline-block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* PiratesIRC link styling */
.piratesirc-link {
    color: #ffd700;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
}

.piratesirc-link:hover {
    color: #fff;
    border-bottom-color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
}

/* Faction icons in help dialog */
.legend-icon {
    width: 24px;
    height: 24px;
    margin-right: 8px;
    flex-shrink: 0;
    stroke-width: 3px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.legend-icon.spanish path { fill: #ffff00; stroke: #ffff00; }
.legend-icon.english path { fill: #ff0000; stroke: #ff0000; }
.legend-icon.french path { fill: #0000ff; stroke: #0000ff; }
.legend-icon.dutch path { fill: #90ee90; stroke: #90ee90; }
.legend-icon.pirate path { fill: #ffffff; stroke: #ffffff; stroke-width: 8px; }
.legend-icon.native path { fill: #e09300; stroke: #e09300; stroke-width: 3px; }
.legend-icon.jesuit path { fill: #ffffff; stroke: #0082ff; stroke-width: 3px; }
.legend-icon.infected path { fill: #ff0000; stroke: #ff0000; stroke-width: 2px; }
.legend-icon.independent path { fill: #ffffff; stroke: #ff00e7; stroke-width: 2px; }

/* Easter egg animations */
@keyframes shake {
    0%, 100% { transform: translate(0, 0) scale(var(--scale)); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-10px, 0) scale(var(--scale)); }
    20%, 40%, 60%, 80% { transform: translate(10px, 0) scale(var(--scale)); }
}

@keyframes bounce {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -60%) scale(1.2); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); box-shadow: 0 0 20px rgba(255, 215, 0, 0.8); }
}

/* Easter Egg Elements */
.jolly-roger {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
}

@keyframes wave-flag {
    0%, 100% { transform: translate(-50%, -50%) rotate(-5deg); }
    50% { transform: translate(-50%, -50%) rotate(5deg); }
}

@keyframes fade-in-out {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

.cannonball {
    position: fixed;
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at 30% 30%, #555, #000);
    border-radius: 50%;
    z-index: 10000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

@keyframes cannonball-flight {
    0% { left: -50px; top: 30%; }
    100% { left: calc(100% + 50px); top: 35%; }
}

.kraken-tentacle {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: 100px;
    height: 200px;
    z-index: 10000;
    pointer-events: none;
}

@keyframes tentacle-wave {
    0% { transform: translateX(-50%) translateY(100%); }
    20% { transform: translateX(-50%) translateY(0%) rotate(-10deg); }
    40% { transform: translateX(-50%) translateY(0%) rotate(10deg); }
    60% { transform: translateX(-50%) translateY(0%) rotate(-5deg); }
    80% { transform: translateX(-50%) translateY(0%) rotate(5deg); }
    100% { transform: translateX(-50%) translateY(100%); }
}