:root {
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --panel-bg: rgba(0, 0, 0, 0.7);
    --accent-color: #00ffcc;
    --prey-color: #00ff00;
    --predator-color: #ff0000;
    --ui-border-radius: 10px;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

canvas#simulation-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Allow clicks to pass through to canvas */
}

#stats-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--panel-bg);
    padding: 10px;
    border-radius: var(--ui-border-radius);
    pointer-events: auto;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-row {
    margin: 5px 0;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
}

.label {
    font-weight: bold;
    margin-right: 10px;
}

.prey-color { color: var(--prey-color); }
.predator-color { color: var(--predator-color); }

#graph-canvas {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    margin-bottom: 5px;
    width: 300px;
    height: 100px;
}

#toggle-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--panel-bg);
    border: none;
    color: white;
    font-size: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    z-index: 100;
}

#toggle-controls:hover {
    transform: rotate(90deg);
}

#controls-panel {
    position: absolute;
    top: 70px;
    right: 20px;
    background: var(--panel-bg);
    padding: 20px;
    border-radius: var(--ui-border-radius);
    pointer-events: auto;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 250px;
    max-height: 80vh;
    overflow-y: auto;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#controls-panel.hidden {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

h2, h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 5px;
}

h3 {
    margin-top: 15px;
    font-size: 14px;
    color: #aaa;
}

.control-group {
    margin-bottom: 10px;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 5px;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.2);
    height: 4px;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.button-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

button {
    flex: 1;
    padding: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

button:hover {
    background: rgba(255, 255, 255, 0.2);
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: auto;
    cursor: pointer;
}

#start-screen h1 {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: 0 0 10px var(--accent-color);
}

#start-screen p {
    font-size: 24px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

@media (max-width: 600px) {
    #stats-panel {
        left: 10px;
        right: 10px;
        top: 10px;
        width: auto;
    }

    #graph-canvas {
        width: 100%;
    }

    #controls-panel {
        top: 150px; /* Below stats */
        left: 10px;
        right: 10px;
        width: auto;
    }
}
