body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* Prevent scrollbars */
    font-family: sans-serif;
    background-color: #111;
}

.leaflet-container {
    background-color: #1a1a1a;
    font-family: 'Courier New', Courier, monospace;
}

.leaflet-pane .leaflet-tile {
    filter: grayscale(1.0) brightness(0.6) contrast(1.2);
}

.leaflet-vector-layer path {
    transition: fill-opacity 0.5s ease-in-out;
}

#ui-panel {
    height: 30vh;
    background-color: #1a1a1a;
    color: white;
    box-sizing: border-box;
    display: flex;
    padding: 10px;
    gap: 15px;
    position: relative; /* Add relative positioning */
    z-index: 2000; /* Ensure it's on top */
}

#info-panel{
    padding: 0 !important;
}

#info-panel, #news-panel, #progress-panel, #trades-panel {
    padding: 15px;
    box-sizing: border-box;
    border-radius: 5px;
}

#news-panel, #progress-panel, #trades-panel {
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid #ff4d4d;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.3), inset 0 0 10px rgba(255, 0, 0, 0.2);
}

#info-panel,
#news-panel,
#progress-panel {
    flex: 1 1 33.33%; /* Equal width for all three panels */
    display: flex;
    flex-direction: column;
}

#chart {
    flex-grow: 1;
    min-height: 0;
}

#news-panel {
    justify-content: flex-start; /* Align content to the top */
}

#progress-panel {
    justify-content: flex-start; /* Align content to the top */
}


#map {
    height: calc(70vh - 84px); /* Adjust height for pop bar AND new infection bar */
    width: 100vw;
    background-color: #111;
    position: relative; /* Ensure z-index context for children */
}

#population-bar {
    position: relative; /* Changed from absolute */
    width: 100%;
    height: 40px;
    background-color: #333; /* Acts as the "empty" part of the bar */
    color: white;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    font-family: 'Courier New', Courier, monospace;
    border-top: 2px solid #555;
    border-bottom: 2px solid #555; /* Added bottom border for consistency */
    overflow: hidden; /* Hide the overflow of the fill element */
}

#population-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%; /* Updated by JS */
    background: linear-gradient(90deg, #c00, #ff4d4d);
    z-index: 1;
    transition: width 0.5s ease-out;
}

#population-text {
    position: relative;
    z-index: 2;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.7);
}

#info-bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 8px 0;
    background-color: #1a1a1a;
    border-bottom: 1px solid #333;
    position: relative;
    z-index: 2000;
}

#market-cap-value {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2.5em; /* Large market cap */
    font-weight: bold;
    color: #f0f0f0; /* Changed from blue to off-white */
    line-height: 1.1;
    transition: color 0.3s ease;
}

#contract-address {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em; /* Smaller contract address */
    color: #ccc;
    margin-top: 2px;
}

#current-infection-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px 15px;
    background-color: #111;
    border-bottom: 1px solid #ff4d4d; /* Red border */
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.3) inset; /* Red shadow */
    color: #fff;
    font-family: 'Courier New', Courier, monospace;
    z-index: 2000;
}

#current-infection-details {
    display: flex;
    align-items: center;
    width: 100%;
}

#current-infection-progress-container {
    flex-grow: 1;
    position: relative;
    height: 22px;
    background-color: #333;
    border: 1px solid #555;
    border-radius: 5px;
}

#current-infection-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%; /* JS will update this */
    background: linear-gradient(90deg, #00b359, #00e676); /* Green gradient */
    border-radius: 4px;
    transition: width 0.5s ease-out;
    z-index: 1;
}

#current-infection-progress-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1em; /* Increased font size */
    font-weight: bold; /* Make text bolder */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 2;
}


.chat-popup {
    position: absolute;
    background-color: rgba(20, 20, 40, 0.85);
    color: #fff;
    padding: 8px 15px;
    border-radius: 8px;
    border: 1px solid #6a7fdb;
    font-size: 1.2em;
    font-family: 'Courier New', Courier, monospace;
    z-index: 1001; /* Above map, below other UI maybe */
    white-space: nowrap;
    animation: fadeInThenOut 4s ease-out forwards;
    pointer-events: none; /* Can't click on them */
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-popup-username {
    font-weight: bold;
    color: #a0c4ff; /* A lighter blue */
}

.chat-popup-text {
    color: #e0e0e0; /* Off-white */
}

@keyframes fadeInThenOut {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    15% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    85% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(0.9);
    }
}


#info-panel p {
    font-family: 'Courier New', Courier, monospace;
    color: #a0c4ff; /* Light blue for "normal" data */
    font-size: 1em;
    margin: 0 0 10px 0;
    transition: color 0.3s ease; /* Smooth color transition */
}

#progress-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

#progress-list li {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.continent-info {
    flex-basis: 35%;
    white-space: nowrap;
    font-size: 0.85em;
}

.progress-info {
    /* This class is no longer used */
}

.progress-bar-container {
    flex-grow: 1;
    position: relative; /* Needed for text overlay */
    height: 20px; /* Increased height */
    background-color: #333;
    border: 1px solid #555;
    border-radius: 5px;
}

.progress-overlay-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 0.85em; /* Increased font size */
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    z-index: 2;
}

.progress-bar-fill {
    position: relative; /* Needed for z-index context */
    z-index: 1;
    height: 100%;
    width: 0%; /* Starts at 0, updated by JS */
    background: linear-gradient(90deg, #c00, #ff4d4d);
    border-radius: 4px;
    transition: width 0.5s ease-out;
}

/* --- THEME STYLES --- */

/* Titles */
#news-panel h3, #progress-panel h3 {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2em;
    color: #ff4d4d;
    text-shadow: 0 0 5px #ff1a1a, 0 0 8px #ff1a1a;
    text-transform: uppercase;
    margin: 0 0 15px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid #500;
}

/* Info Panel */
#contract-info {
    text-align: center;
}

#allow-sound-btn {
    background-color: #ff4d4d;
    color: white;
    border: 1px solid #c00;
    padding: 5px 10px;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background-color 0.3s;
}

#allow-sound-btn:hover {
    background-color: #c00;
}

#contract-info p {
    font-family: 'Courier New', Courier, monospace;
    color: #a0c4ff; /* Light blue for "normal" data */
    font-size: 1em;
    margin: 0 0 8px 0;
    transition: color 0.3s ease; /* Smooth color transition */
}

/* News Panel */
#news-ticker {
    font-family: 'Courier New', Courier, monospace;
    color: #ffcdd2; /* Pale red for the news text */
    font-size: 1.1em;
    height: 100%;
}

/* Map Trade Pop-ups */
.trade-popup {
    position: absolute;
    font-family: 'Courier New', Courier, monospace;
    font-size: 2em;
    font-weight: bold;
    z-index: 1001; /* Above map layers */
    animation: fadeInOut 2.5s ease-in-out forwards;
    white-space: nowrap;
    text-shadow: 0 0 8px rgba(0, 230, 118, 0.8), 0 0 5px rgba(0, 230, 118, 0.8);
}

.trade-popup.buy {
    color: #00e676;
}

.trade-popup.sell {
    /* No longer displayed, but keeping for future */
    display: none;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: scale(0.8) translateY(15px); }
    20% { opacity: 1; transform: scale(1) translateY(0); }
    80% { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(0.8) translateY(-15px); }
}

/* Virus Infection Particles on Map */
.virus-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background-color: #ff4d4d;
    border-radius: 50%;
    z-index: 1000;
    pointer-events: none; /* Make them unclickable */
    box-shadow: 0 0 8px #ff1a1a, 0 0 5px #ff1a1a;
    animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.5; }
}

/* --- MAP OVERLAY TEXT --- */
#map-overlay-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    text-transform: uppercase;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#map-overlay-main {
    font-size: 15vw;
    font-weight: bold;
    color: #c00;
    text-shadow: 0 0 20px #ff1a1a;
}

#map-overlay-sub {
    font-size: 5vw;
    font-weight: normal;
    color: #ff4d4d;
    text-shadow: 0 0 10px #ff1a1a;
    margin-top: -2vw;
}

/* Trades Panel */
#trades-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    height: 100%;
    overflow: hidden;
}

#trades-list li {
    padding: 2px 4px;
    border-radius: 3px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.trade-buy {
    background-color: rgba(0, 230, 118, 0.1);
    border-left: 2px solid #00e676;
}
.trade-buy .amount-sol {
    color: #00e676;
}

.trade-sell {
    background-color: rgba(255, 77, 77, 0.1);
    border-left: 2px solid #ff4d4d;
}
.trade-sell .amount-sol {
    color: #ff4d4d;
}

/* Progress Panel */
#progress-list span {
    font-size: 0.85em;
    color: #ccc;
}

@keyframes flash-red-animation {
    0% { background-color: rgba(10, 25, 47, 0.85); }
    50% { background-color: rgba(255, 0, 0, 0.6); }
    100% { background-color: rgba(10, 25, 47, 0.85); }
}

.flash-red {
    animation: flash-red-animation 1s ease-out;
}
