body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', system-ui, sans-serif;
    background-color: #0f172a;
    color: #f8fafc;
}

#app {
    width: 100vw;
    height: 100vh;
}

#main-layout {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Simulation Viewport (40% when inspector open) */
#simulation-container {
    flex: 1 1 auto;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #020617;
}

.inspector-open #simulation-container {
    flex: 0 0 40%;
}

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

/* Internal Header for Viewport */
#viewport-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
    z-index: 100;
}

#viewport-header h1 { font-size: 1.1rem; margin: 0; color: #34d399; }
.stats { font-size: 0.85rem; opacity: 0.8; }

#controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 12px;
    display: flex;
    gap: 15px;
    align-items: center;
    pointer-events: auto;
    z-index: 100;
    white-space: nowrap;
}

/* Settings Overlay (Stays left) */
#settings-panel {
    position: absolute;
    left: 20px;
    top: 90px;
    width: 280px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    z-index: 90;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#legend-panel {
    position: absolute;
    left: 20px;
    bottom: 90px;
    width: 240px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 15px;
    z-index: 90;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#legend-panel.collapsed #legend-content {
    display: none;
}

.legend-section { margin-bottom: 12px; }
.legend-section h4 { 
    font-size: 0.75rem; 
    margin: 0 0 8px 0; 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    opacity: 0.5; 
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    margin-bottom: 5px;
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.swatch.algae { background: #34D399; box-shadow: 0 0 8px #34D399; }
.swatch.core { background: #059669; border: 2px solid #34D399; }
.swatch.waste { background: #B45309; }
.swatch.forager { background: rgb(0, 255, 150); }
.swatch.predator { background: rgb(255, 0, 150); }
.swatch.scale { background: #64748b; width: 16px; height: 16px; }
.swatch.focus { border-left: 8px solid white; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-radius: 0; background: none; }
.swatch.hunting { border: 2px solid #EF4444; }
.swatch.mating { border: 2px solid #F472B6; }
.swatch.nursing { border: 2px solid #22D3EE; }
.swatch.vitality { border: 1px solid white; box-shadow: 0 0 5px white; }
.swatch.genealogy { border-radius: 0; height: 2px; width: 15px; background: rgba(52, 211, 153, 0.4); }

#settings-panel.collapsed {
    width: 200px;
    padding: 10px 15px;
}

#settings-panel.collapsed #settings-content {
    display: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1rem;
    margin: 0;
    color: #34d399;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: white;
}

/* Neural Deep Dive (60% when open) */
#inspector-panel {
    width: 60%;
    height: 100%;
    background: #0f172a;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    z-index: 200;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

#inspector-panel.hidden {
    display: none;
}

.inspector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.horizontal-traits {
    display: flex;
    gap: 20px;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 20px;
}

.canvas-wrapper {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

#brain-canvas {
    width: 100%;
    height: 100%;
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
}

.primary-btn {
    width: 100%; background: #34d399; color: #0f172a; border: none; padding: 10px; border-radius: 8px; font-weight: 700; cursor: pointer;
}

.control-group { margin-bottom: 12px; }
.control-group label { display: block; font-size: 0.75rem; opacity: 0.6; margin-bottom: 4px; }
.control-group input { width: 100%; }
.trait-label { opacity: 0.6; font-size: 0.75rem; }
.trait-value { color: #34d399; font-weight: 600; font-size: 0.85rem; }
