* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #1a1a1a;
}

#glCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

#fps-counter {
    position: fixed;
    top: 10px;
    right: 10px;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 8px;
    border-radius: 3px;
    user-select: none;
    pointer-events: none;
    z-index: 1000;
}

#control-panel {
    position: fixed;
    top: 10px;
    left: 10px;
    width: 250px;
    max-height: calc(100vh - 20px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 8px;
    font-family: 'Arial', sans-serif;
    font-size: 14px;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

#control-panel.minimized {
    width: auto;
    padding: 12px 16px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #4a7c59;
    padding-bottom: 8px;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.panel-header:hover {
    opacity: 0.8;
}

.panel-content {
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    min-height: 0;
}

/* Custom scrollbar for panel content */
.panel-content::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: #4a7c59;
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: #5a8c69;
}

#control-panel h3 {
    margin: 0;
    font-size: 18px;
    color: #4a7c59;
}

.toggle-button {
    background: #4a7c59;
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-left: 12px;
}

.toggle-button:hover {
    background: #5a8c69;
    transform: scale(1.1);
}

#control-panel h4 {
    margin: 0 0 6px 0;
    font-size: 13px;
    color: #90ee90;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-section,
.controls-section,
.reset-section {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.reset-section {
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 12px;
}

.stats-section {
    font-family: 'Courier New', monospace;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    padding: 2px 0;
}

.stat-label {
    color: #aaa;
    font-size: 13px;
}

.stat-value {
    color: #90ee90;
    font-weight: bold;
    font-size: 14px;
}

.action-button {
    width: 100%;
    padding: 8px;
    margin-bottom: 6px;
    background: #5a8c69;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.action-button:hover {
    background: #6a9c79;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.action-button:active {
    background: #4a7c59;
    transform: translateY(0);
}

.button-group {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.half-width {
    width: calc(50% - 3px);
}

#btn-play-pause {
    font-size: 18px;
    font-weight: bold;
}

.action-button:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
    opacity: 0.5;
}

.action-button:disabled:hover {
    background: #333;
    transform: none;
    box-shadow: none;
}

.speed-control,
.volume-control {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.inline-toggle {
    background: #4a7c59;
    color: white;
    border: none;
    border-radius: 3px;
    min-width: 30px;
    height: 24px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    vertical-align: middle;
    flex-shrink: 0;
}

.inline-toggle:hover {
    background: #5a8c69;
    transform: scale(1.05);
}

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

.control-group label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    color: #ccc;
    font-size: 13px;
}

.control-group label .label-text {
    color: #ccc;
    font-weight: normal;
}

.control-group label .label-text span {
    color: #4a7c59;
    font-weight: bold;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #333;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4a7c59;
    cursor: pointer;
    transition: background 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #5a8c69;
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4a7c59;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
    background: #5a8c69;
}

.reset-button {
    width: 100%;
    padding: 10px;
    background: #4a7c59;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}

.reset-button:hover {
    background: #5a8c69;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.reset-button:active {
    background: #3a6c49;
    transform: translateY(0);
}

/* Checkbox control styling */
.checkbox-control {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.checkbox-control label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: #ccc;
    transition: color 0.2s;
}

.checkbox-control label:hover {
    color: #90ee90;
}

/* Hide default checkbox */
.checkbox-control input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 48px;
    height: 26px;
    background: #333;
    border: 2px solid #4a7c59;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    margin-right: 10px;
    flex-shrink: 0;
}

.checkbox-control input[type="checkbox"]:hover {
    border-color: #5a8c69;
}

/* Toggle slider */
.checkbox-control input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    background: #666;
    transition: all 0.3s ease;
}

/* Checked state */
.checkbox-control input[type="checkbox"]:checked {
    background: #4a7c59;
    border-color: #4a7c59;
}

.checkbox-control input[type="checkbox"]:checked::before {
    left: 24px;
    background: #90ee90;
}

.checkbox-control input[type="checkbox"]:checked:hover {
    background: #5a8c69;
    border-color: #5a8c69;
}

/* Population Graph Container */
#graph-container {
    position: fixed;
    bottom: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    height: 300px;
    background: rgba(0, 0, 0, 0.85);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: block;
    transition: opacity 0.3s ease;
    overflow: auto;
    min-width: 400px;
    min-height: 200px;
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
}

#population-graph {
    width: 100%;
    height: 100%;
}

/* Custom resize handle for bottom-left anchored element */
.graph-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: ne-resize;
    z-index: 1000;
}

.graph-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0px 16px 16px 0px;
    border-color: transparent rgba(74, 124, 89, 0.7) transparent transparent;
}

/* Adjust graph on smaller screens */
@media screen and (max-width: 1024px) {
    #graph-container {
        right: 10px;
        left: 10px;
        width: calc(100vw - 20px);
        height: 250px;
    }
}

@media screen and (max-width: 768px) {
    #graph-container {
        width: calc(100vw - 20px);
        height: 200px;
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
}

/* Extinction Overlay */
.extinction-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 998;
    animation: fadeIn 0.5s ease-in;
    pointer-events: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.extinction-message {
    background: rgba(20, 20, 20, 0.95);
    padding: 40px 60px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 50, 50, 0.5);
    pointer-events: auto;
}

.extinction-message h1 {
    color: #ff6b6b;
    font-size: 48px;
    margin: 0 0 20px 0;
    text-shadow: 0 2px 10px rgba(255, 107, 107, 0.5);
}

.extinction-message p {
    color: #cccccc;
    font-size: 20px;
    margin: 0 0 30px 0;
}

.restart-button {
    padding: 15px 40px;
    background: #4a7c59;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

.restart-button:hover {
    background: #5a8c69;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(74, 124, 89, 0.5);
}

.restart-button:active {
    transform: translateY(0);
}
