body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0; /* Remove default margin */
    padding: 20px;
    background-color: #1a1a1a; /* Dark background */
    color: #e0e0e0; /* Light text */
}

h1 {
    text-align: center;
    color: #f5f5f5; /* Brighter title */
    margin-bottom: 25px;
}

.container {
    max-width: 1400px; /* Reduced max-width to leave side space */
    margin: auto; /* Keep centered */
    background: #2a2a2a; /* Slightly lighter dark background for container */
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.4);
    border: 1px solid #444; /* Subtle border */
}

.parameters {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    padding-bottom: 20px;
    border-bottom: 1px solid #444; /* Separator */
}

.entity-params {
    flex: 1;
    min-width: 320px;
    background-color: #333; /* Darker parameter sections */
    padding: 20px;
    border-radius: 6px;
    border: 1px solid #555;
}

.entity-params h2 {
    margin-top: 0;
    color: #00bfff; /* Brighter heading color (Deep Sky Blue) */
    border-bottom: 1px solid #555;
    padding-bottom: 8px;
    font-size: 1.3em;
}

.param-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #555;
}

.param-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.param-group h3 {
    margin-bottom: 12px;
    color: #ccc; /* Lighter subheading color */
    font-size: 1.1em;
}

.param {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.param label {
    flex-basis: 180px;
    margin-right: 10px;
    color: #d0d0d0;
}

/* Dark theme sliders */
.param input[type="range"] {
    flex-grow: 1;
    min-width: 100px;
    height: 6px;
    cursor: pointer;
    background: #555; /* Darker track */
    border-radius: 3px;
    -webkit-appearance: none; /* Override default look */
    appearance: none;
}
.param input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #00bfff; /* Bright thumb */
    border-radius: 50%;
    cursor: pointer;
}
.param input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #00bfff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.param input[type="number"] {
    width: 60px;
    padding: 6px;
    border: 1px solid #555;
    border-radius: 4px;
    background-color: #444;
    color: #e0e0e0;
}

.param .value-display {
    margin-left: 10px;
    font-weight: bold;
    min-width: 30px;
    color: #f5f5f5;
}

.simulation-controls {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
     border-bottom: 1px solid #444;
}

#startSimulation {
    padding: 12px 30px;
    font-size: 1.2em;
    cursor: pointer;
    background-color: #28a745; /* Green */
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
    margin-right: 20px; /* Space before donate button */
}
#startSimulation:hover {
    background-color: #218838;
}
#startSimulation:disabled {
    background-color: #555;
    color: #aaa;
    cursor: not-allowed;
}

/* Donate Button Style */
.donate-button {
    display: inline-block;
    padding: 10px 25px;
    font-size: 1.1em;
    background-color: #ffc107; /* Yellow */
    color: #333;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s ease;
}
.donate-button:hover {
    background-color: #e0a800;
    color: #222;
}


/* Main Simulation Area Layout */
.simulation-main-area {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Align tops */
    gap: 25px;
    margin-bottom: 30px;
}

/* Stats Panels */
.stats-panel {
    background-color: #333;
    padding: 15px 20px;
    border-radius: 6px;
    border: 1px solid #555;
    flex-shrink: 0; /* Prevent shrinking */
}
.stats-panel h3 {
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
    color: #ccc;
    font-size: 1.15em;
    border-bottom: 1px dashed #555;
    padding-bottom: 8px;
}

.left-panel {
    width: 200px; /* Fixed width for left panel */
}

.right-panel {
    width: 240px; /* Fixed width for right panel */
}

/* Visualization Container */
.visualization-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column; /* Stack canvas and log */
    justify-content: center;
    align-items: center;
    min-height: 450px; /* Adjusted min-height for log */
    background-color: #222;
    border-radius: 5px;
    border: 1px solid #444;
    padding: 10px;
    gap: 10px; /* Gap between canvas and log */
    position: relative; /* Needed for absolute positioning of children */
}

#simulationCanvasContainer canvas {
    display: block;
    margin: auto;
}

/* Pop-up Notification Styles */
#popupNotificationContainer {
    position: absolute; /* Position relative to visualization-container */
    top: 10px; /* Distance from the top of canvas container */
    left: 50%;
    transform: translateX(-50%); /* Center horizontally */
    z-index: 50; /* Above canvas, below overlay */
    display: flex;
    flex-direction: column; /* Stack notifications vertically */
    align-items: center; /* Center notifications */
    gap: 8px;
    pointer-events: none; /* Allow clicks through to canvas */
    width: 80%; /* Limit width */
    max-width: 400px;
}

.popup-message {
    background-color: rgba(40, 40, 40, 0.85); /* Semi-transparent dark */
    color: #f0f0f0;
    padding: 8px 15px;
    border-radius: 15px; /* Pill shape */
    font-size: 1em; /* Adjust as needed */
    font-weight: bold;
    text-align: center;
    border: 1px solid rgba(100, 100, 100, 0.7);
    box-shadow: 0 2px 5px rgba(0,0,0,0.4);
    opacity: 0;
    animation: fadeInOut 2s ease-in-out forwards; /* 4s total duration */
    pointer-events: all; /* Allow interaction with the text if needed, though container prevents clicks */
}

/* Type-specific styles */
.popup-message.kill {
    background-color: rgba(192, 57, 43, 0.9); /* Dark red */
    color: #fff;
    border-color: rgba(255, 100, 100, 0.8);
}

.popup-message.knockout {
    background-color: rgba(241, 196, 15, 0.9); /* Yellow */
    color: #333;
    border-color: rgba(255, 255, 150, 0.8);
}

.popup-message.rage {
    background-color: rgba(230, 126, 34, 0.9); /* Orange */
    color: #fff;
    border-color: rgba(255, 150, 80, 0.8);
}

/* Fade In/Out Animation */
@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-10px); }
    15% { opacity: 1; transform: translateY(0); } /* Fade in fast */
    85% { opacity: 1; transform: translateY(0); } /* Hold */
    100% { opacity: 0; transform: translateY(10px); } /* Fade out */
}

/* Combat Log Styles */
#combatLogContainer {
    width: 95%; /* Take most of the container width */
    height: 200px; /* Increased height */
    background-color: #1c1c1c;
    border: 1px solid #444;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hide overflowing content */
    margin: 25px auto; /* Center and add margin */
}

#combatLogHeader {
    background-color: #383838;
    color: #ccc;
    padding: 4px 8px;
    font-size: 0.9em;
    font-weight: bold;
    border-bottom: 1px solid #444;
    text-align: center;
}

#combatLog {
    flex-grow: 1;
    overflow-y: scroll; /* Enable vertical scroll */
    padding: 5px 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
    color: #bbb;
    line-height: 1.4;
    /* Scrollbar styling (optional, browser-specific) */
    scrollbar-width: thin;
    scrollbar-color: #666 #333;
    text-align: center;
}
#combatLog p {
    margin: 0 0 3px 0; /* Spacing between log entries */
    white-space: normal; /* Allow wrapping */
    word-break: break-word; /* Break long words if needed */
}
#combatLog p:first-child { /* Style the newest entry */
    color: #eee;
}

/* Status Bars within Panels */
.stats-group {
    display: flex;
    flex-direction: column;
    gap: 12px; /* Space between bars */
}

.bar-container {
    display: flex;
    flex-direction: column;
    align-items: stretch; /* Stretch items horizontally */
    gap: 4px;
}

.bar-container label {
    font-size: 0.9em;
    color: #bbb;
    text-align: left;
}

.bar-container .stat-value {
    font-size: 0.95em;
    font-weight: bold;
    color: #f0f0f0;
    text-align: right;
}

/* Dark theme progress bars */
progress {
    width: 100%;
    height: 10px;
    border-radius: 5px;
    border: none; /* Remove default border */
    background-color: #555; /* Dark background */
}
progress::-webkit-progress-bar {
    background-color: #555;
    border-radius: 5px;
}
progress::-moz-progress-bar {
    background-color: #555;
    border-radius: 5px;
}

/* Specific bar colors (make them brighter) */
#gorillaHealthBar::-webkit-progress-value { background-color: #e74c3c; } /* Red */
#gorillaHealthBar::-moz-progress-bar { background-color: #e74c3c; }

#gorillaStaminaBar::-webkit-progress-value { background-color: #f39c12; } /* Orange */
#gorillaStaminaBar::-moz-progress-bar { background-color: #f39c12; }

#humanHealthBar::-webkit-progress-value { background-color: #3498db; } /* Blue */
#humanHealthBar::-moz-progress-bar { background-color: #3498db; }

#humanMoraleBar::-webkit-progress-value { background-color: #f1c40f; } /* Yellow */
#humanMoraleBar::-moz-progress-bar { background-color: #f1c40f; }

#humanStaminaBar::-webkit-progress-value { background-color: #9b59b6; } /* Purple */
#humanStaminaBar::-moz-progress-bar { background-color: #9b59b6; }


.final-stats {
    text-align: center;
    margin-top: 20px;
    font-size: 0.95em;
    color: #ccc;
    padding-top: 10px;
    border-top: 1px dashed #555;
}
.final-stats span {
    display: block; /* Stack stats vertically */
    margin-bottom: 5px;
}

.disclaimer {
    margin-top: 30px;
    padding: 15px;
    background-color: #444;
    border: 1px solid #666;
    color: #bbb;
    border-radius: 5px;
    font-size: 0.9em;
}
.disclaimer strong {
    color: #ddd;
}

/* Add styles for Canvas */
.visualization-container {
    margin-top: 20px;
    margin-bottom: 20px;
    text-align: center; /* Center canvas */
}

.visualization-container h2 {
     margin-bottom: 10px;
}

#simulationCanvas {
    border: 1px solid #ccc;
    background-color: #f0f0f0; /* Match JS background */
    display: inline-block; /* Allow centering */
}

/* Advanced Settings */
.advanced-settings-container {
    margin-top: 30px;
    border-top: 1px solid #444;
    padding-top: 20px;
}

#toggleAdvancedSettings {
    background-color: #444;
    color: #eee;
    border: 1px solid #666;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 15px;
    display: block; /* Make it full width */
    width: 100%;
    text-align: left;
}

#toggleAdvancedSettings:hover {
    background-color: #555;
}

.advanced-settings-panel {
    background-color: #333;
    border: 1px solid #555;
    border-radius: 5px;
    padding: 20px;
    max-height: 500px; /* Limit height */
    overflow-y: auto; /* Allow scrolling */
    transition: max-height 0.5s ease-out, padding 0.5s ease-out, opacity 0.5s ease-out;
    opacity: 1;
}

.advanced-settings-panel.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
    overflow: hidden;
    border-width: 0;
}

.advanced-settings-panel .warning {
    color: #ffc107; /* Yellow warning text */
    background-color: rgba(255, 193, 7, 0.1);
    border: 1px solid #ffc107;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    font-size: 0.95em;
}

.advanced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); /* Responsive grid */
    gap: 15px 25px; /* Row and column gap */
}

.adv-param {
    display: flex;
    flex-direction: column; /* Stack label and input */
    gap: 5px;
}

.adv-param label {
    font-size: 0.9em;
    color: #ccc;
}

.adv-param input[type="number"] {
     padding: 6px;
     border: 1px solid #555;
     border-radius: 4px;
     background-color: #444;
     color: #e0e0e0;
     width: 100px; /* Fixed width for number inputs */
}

/* End Game Overlay */
.overlay {
    position: fixed; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85); /* Dark translucent background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000; /* Ensure it's on top */
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none; /* Disable interaction when hidden */
}

.overlay-content {
    background-color: #333;
    padding: 30px 40px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #555;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    color: #eee;
}

.overlay-content h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 2em;
    color: #00bfff; /* Match other headings */
}

.overlay-content p {
    margin-bottom: 25px;
    font-size: 1.1em;
    color: #ccc;
}

#restartSimulationButton {
     padding: 10px 25px;
     font-size: 1.1em;
     cursor: pointer;
     background-color: #28a745; /* Match start button green */
     color: white;
     border: none;
     border-radius: 5px;
     transition: background-color 0.3s ease;
}

#restartSimulationButton:hover {
    background-color: #218838;
} 
.logo {
    display: block; /* Changed from flex to block */
    margin: 0 auto 20px auto; /* Center using margin */
    width: 150px; /* Fixed width for logo */
    height: auto; /* Maintain aspect ratio */
    object-fit: contain;
}

/* --- Responsive Design --- */

/* Smaller Desktops / Large Tablets */
@media (max-width: 1200px) {
    .container {
        max-width: 95%;
        padding: 20px;
    }
    .parameters {
        gap: 20px;
    }
    .entity-params {
        min-width: 280px;
    }
    .simulation-main-area {
        gap: 15px;
    }
    .left-panel, .right-panel {
        width: 180px;
    }
}

/* Tablets */
@media (max-width: 992px) {
    h1 {
        font-size: 1.8em;
    }
    .parameters {
        flex-direction: column;
        gap: 25px;
    }
    .entity-params {
        min-width: unset;
        width: 100%; /* Take full width */
        box-sizing: border-box; /* Include padding/border in width */
    }
    .param label {
        flex-basis: 150px; /* Adjust label width */
    }
    .simulation-main-area {
        flex-direction: column;
        align-items: center; /* Center items when stacked */
        gap: 20px;
    }
    .stats-panel {
        width: 80%; /* Make panels wider when stacked */
        max-width: 400px;
    }
    .visualization-container {
        width: 90%;
        min-height: 400px; /* Reset min-height or adjust as needed */
    }
    /* Ensure canvas scales down if needed */
    #simulationCanvasContainer canvas {
        max-width: 100%;
        height: auto; 
    }
    #combatLogContainer {
        width: 90%;
        height: 180px; /* Slightly smaller log on tablets */
    }
    .advanced-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

/* Mobile Phones */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 15px;
    }
    h1 {
        font-size: 1.5em;
        margin-bottom: 15px;
    }
    .param label {
        flex-basis: 120px; /* Further adjust label width */
    }
     .param input[type="range"] {
        min-width: 80px;
    }
    #startSimulation {
        padding: 10px 20px;
        font-size: 1.1em;
    }
    .donate-button {
        padding: 8px 18px;
        font-size: 1em;
    }
    .stats-panel {
        width: 95%;
    }
    .bar-container label, .bar-container .stat-value {
        font-size: 0.85em;
    }
    .final-stats {
        font-size: 0.9em;
    }
    #combatLogContainer {
        height: 150px; /* Smaller log on mobile */
        font-size: 0.8em;
    }
     #combatLog {
         font-size: 0.9em; /* Adjust log text size slightly */
    }
    .advanced-grid {
        grid-template-columns: 1fr; /* Single column */
    }
    .adv-param input[type="number"] {
        width: 80px;
    }
     .disclaimer {
         font-size: 0.85em;
         padding: 10px;
     }
    .logo {
        width: 100px;
    }
    .overlay-content {
        padding: 20px;
        width: 90%;
    }
     .overlay-content h2 {
         font-size: 1.5em;
     }
     .overlay-content p {
         font-size: 1em;
     }
    .visualization-container {
        min-height: 350px; /* Adjust min height for mobile */
    }
}

#simulationMessage {
    font-size: 1.5em;
    color: #ccc;
    text-align: center;
    margin-top: 20px;
}