/* =============================================================
   EVOLUTION — Biopunk Laboratory Aesthetic
   Fullscreen living ecosystem
   ============================================================= */

/* ---------- CUSTOM FONTS ----------
   Fonts are loaded via <link> in index.html head (preferred over @import
   so downloads start earlier and don't block CSS parsing). */

/* ---------- CSS VARIABLES ---------- */
:root {
    --font-display: 'Orbitron', sans-serif;
    --font-mono: 'Space Mono', monospace;
    --font-body: 'Exo 2', sans-serif;

    /* Core Palette */
    --petri-dark: #0a0d08;
    --petri-deep: #050704;
    --substrate: #0d120a;

    /* Bioluminescent Colors */
    --bio-green: #39ff14;
    --bio-green-dim: rgba(57, 255, 20, 0.6);
    --bio-blue: #00f5d4;
    --bio-cyan: #00e5ff;
    --warning-amber: #ffbe0b;
    --organic-pink: #ff006e;
    --organic-purple: #9d4edd;

    /* Translucent Membranes */
    --membrane: rgba(57, 255, 20, 0.08);
    --membrane-strong: rgba(57, 255, 20, 0.15);

    /* Text */
    --text-primary: #e0ffe0;
    --text-secondary: #9cc69b;
    --text-muted: #6b8a6b;
    --text-dim: #3d5a3d;

    /* Effects */
    --glow-green: 0 0 30px rgba(57, 255, 20, 0.4);
    --panel-bg: rgba(8, 12, 10, 0.78);
    --panel-border: rgba(101, 255, 190, 0.15);
    --panel-shadow:
        0 30px 80px rgba(0, 0, 0, 0.42),
        0 0 0 1px rgba(101, 255, 190, 0.05),
        0 0 40px rgba(0, 245, 212, 0.08);
}

/* ---------- RESET & BASE ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background:
        radial-gradient(circle at top, rgba(8, 68, 46, 0.35), transparent 38%),
        radial-gradient(circle at 82% 18%, rgba(0, 229, 255, 0.12), transparent 24%),
        linear-gradient(180deg, #040705 0%, #08100c 48%, #050704 100%);
    color: var(--text-primary);
    position: relative;
    letter-spacing: 0.01em;
}

/* ---------- AMBIENT BACKGROUND ---------- */
.ambient-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.substrate-texture {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(57, 255, 20, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 80%, rgba(0, 245, 212, 0.02) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 50%, var(--substrate) 0%, var(--petri-deep) 100%);
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(57, 255, 20, 0.3) 0%, transparent 70%);
    animation: float linear infinite;
    opacity: 0;
}

@keyframes float {
    0% {
        transform: translateY(100vh) scale(0.5);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translateY(-100px) scale(1.2);
        opacity: 0;
    }
}

.particle:nth-child(1) {
    left: 10%;
    width: 4px;
    height: 4px;
    animation-duration: 25s;
    animation-delay: 0s;
}

.particle:nth-child(2) {
    left: 25%;
    width: 6px;
    height: 6px;
    animation-duration: 30s;
    animation-delay: 5s;
}

.particle:nth-child(3) {
    left: 40%;
    width: 3px;
    height: 3px;
    animation-duration: 22s;
    animation-delay: 2s;
}

.particle:nth-child(4) {
    left: 55%;
    width: 5px;
    height: 5px;
    animation-duration: 28s;
    animation-delay: 8s;
}

.particle:nth-child(5) {
    left: 70%;
    width: 4px;
    height: 4px;
    animation-duration: 26s;
    animation-delay: 3s;
}

.particle:nth-child(6) {
    left: 85%;
    width: 7px;
    height: 7px;
    animation-duration: 32s;
    animation-delay: 6s;
}

.particle:nth-child(7) {
    left: 15%;
    width: 3px;
    height: 3px;
    animation-duration: 20s;
    animation-delay: 10s;
}

.particle:nth-child(8) {
    left: 60%;
    width: 5px;
    height: 5px;
    animation-duration: 24s;
    animation-delay: 4s;
}

/* ---------- FULLSCREEN CANVAS ---------- */
#evoCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    cursor: crosshair;
    background: var(--petri-dark);
}

/* ---------- FLOATING CONTROL PANEL ---------- */
.control-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 260px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

/* Panel Header */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(10, 13, 8, 0.9);
    border: 1px solid rgba(57, 255, 20, 0.15);
    border-radius: 16px;
    backdrop-filter: blur(12px);
}

.panel-header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--bio-green);
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h1 i {
    font-size: 1.2rem;
}

.header-actions {
    display: flex;
    gap: 6px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 8px;
    background: rgba(57, 255, 20, 0.05);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(57, 255, 20, 0.15);
    border-color: var(--bio-green-dim);
    color: var(--bio-green);
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.2);
}

.icon-btn i {
    font-size: 1rem;
}

/* Panel Sections */
.panel-section {
    background: rgba(10, 13, 8, 0.85);
    border: 1px solid rgba(57, 255, 20, 0.1);
    border-radius: 14px;
    padding: 11px 14px;
    backdrop-filter: blur(10px);
}

.panel-section h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin: 0 0 7px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.panel-section h3 i {
    font-size: 0.85rem;
    color: var(--bio-green-dim);
}

/* Blob buttons */
.btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.blob-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 7px 6px;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.1) 0%, rgba(57, 255, 20, 0.04) 100%);
    color: var(--text-primary);
    border: 1px solid rgba(57, 255, 20, 0.2);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.blob-btn i {
    font-size: 0.8rem;
}

.blob-btn:hover {
    transform: scale(1.02);
    border-color: var(--bio-green-dim);
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.2);
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.18) 0%, rgba(57, 255, 20, 0.08) 100%);
}

.blob-btn:active {
    transform: scale(0.98);
}

.blob-btn.primary {
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.2) 0%, rgba(57, 255, 20, 0.08) 100%);
    border-color: rgba(57, 255, 20, 0.35);
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.12);
    grid-column: 1 / -1;
}

.blob-btn.primary:hover {
    box-shadow: 0 0 25px rgba(57, 255, 20, 0.3);
}

.blob-btn.running {
    background: linear-gradient(135deg, rgba(255, 0, 110, 0.2) 0%, rgba(255, 0, 110, 0.08) 100%);
    border-color: rgba(255, 0, 110, 0.4);
    box-shadow: 0 0 15px rgba(255, 0, 110, 0.2);
}

/* Sliders */
.slider-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.slider-item label {
    font-size: 0.58rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    justify-content: space-between;
    line-height: 1.2;
}

.slider-item label span {
    color: var(--bio-green);
    font-weight: 700;
}

.slider-item input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    margin: 2px 0;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--membrane) 0%, rgba(57, 255, 20, 0.2) 100%);
    outline: none;
    cursor: pointer;
}

.slider-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--bio-green);
    box-shadow: 0 0 8px var(--bio-green);
    cursor: pointer;
    transition: transform 0.2s ease;
}

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

.slider-item input[type="range"]::-moz-range-thumb {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--bio-green);
    box-shadow: 0 0 10px var(--bio-green);
    cursor: pointer;
    border: none;
}

/* Checkbox */
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.65rem;
    color: var(--text-muted);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.checkbox-item input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(57, 255, 20, 0.3);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.checkbox-item input[type="checkbox"]:checked {
    background: rgba(57, 255, 20, 0.2);
    border-color: var(--bio-green);
}

.checkbox-item input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--bio-green);
    font-size: 0.6rem;
}

/* Select */
.select-item select {
    width: 100%;
    padding: 6px 10px;
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    background: rgba(57, 255, 20, 0.05);
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    margin-top: 6px;
}

.select-item select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Metrics Section */
.metrics-section {
    padding: 10px 14px;
}

.metric-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(57, 255, 20, 0.05);
}

.metric-row:last-child {
    border-bottom: none;
}

.metric-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bio-green);
    box-shadow: 0 0 8px var(--bio-green);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.metric-icon.energy {
    background: var(--bio-blue);
    box-shadow: 0 0 8px var(--bio-blue);
}

.metric-icon.food {
    background: var(--bio-cyan);
    box-shadow: 0 0 8px var(--bio-cyan);
}

.metric-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    flex: 1;
}

.metric-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--bio-green);
    min-width: 35px;
    text-align: right;
}

.metric-value.energy {
    color: var(--bio-blue);
}

.metric-value.food {
    color: var(--bio-cyan);
}

/* ---------- LAB NOTES (Event Log) ---------- */
.lab-notes {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 280px;
    max-height: 180px;
    background: rgba(10, 13, 8, 0.9);
    border: 1px solid rgba(57, 255, 20, 0.12);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    overflow: hidden;
    z-index: 50;
}

.lab-notes-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid rgba(57, 255, 20, 0.08);
    display: flex;
    align-items: center;
    gap: 6px;
}

.lab-notes-header i {
    font-size: 0.8rem;
}

.lab-notes-content {
    max-height: 140px;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.log-entry {
    font-size: 0.65rem;
    padding: 3px 6px;
    border-left: 2px solid transparent;
    color: var(--text-muted);
    animation: typeIn 0.3s ease-out;
}

@keyframes typeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.log-entry.system {
    color: var(--text-dim);
    font-style: italic;
}

.log-entry.birth {
    border-left-color: var(--bio-green);
    color: #a8ffb0;
}

.log-entry.death {
    border-left-color: var(--text-dim);
    color: #666;
}

.log-entry.kill {
    border-left-color: var(--warning-amber);
    color: #ffe4a8;
}

.log-entry.mate {
    border-left-color: var(--organic-pink);
    color: #ffb0d0;
}

.log-entry .id {
    color: var(--bio-cyan);
    font-weight: 700;
}

/* ---------- MODAL STYLES ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 7, 4, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: linear-gradient(135deg, rgba(13, 18, 10, 0.98) 0%, rgba(10, 13, 8, 0.98) 100%);
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 20px;
    width: 90%;
    max-width: 540px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow:
        0 0 60px rgba(57, 255, 20, 0.1),
        0 30px 80px rgba(0, 0, 0, 0.5);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(57, 255, 20, 0.1);
}

.modal-header h2 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--bio-green);
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 0 0 20px rgba(57, 255, 20, 0.4);
}

.modal-header h2 i {
    font-size: 1.3rem;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255, 0, 110, 0.1);
    border-color: rgba(255, 0, 110, 0.4);
    color: var(--organic-pink);
}

.modal-close i {
    font-size: 1.1rem;
}

.modal-content {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(85vh - 80px);
    line-height: 1.6;
}

.modal-content h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.modal-content h4 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: var(--bio-green);
    margin: 20px 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-content h4 i {
    font-size: 1rem;
    opacity: 0.8;
}

.modal-content p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.modal-content ul {
    padding-left: 20px;
    margin-bottom: 10px;
}

.modal-content li {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.modal-content li strong {
    color: var(--text-primary);
}

.modal-content .highlight-cyan {
    color: var(--bio-cyan);
    font-weight: 700;
}

.modal-content .highlight-amber {
    color: var(--warning-amber);
    font-weight: 700;
}

/* Hotkeys Grid */
.hotkeys-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 12px 0;
}

.hotkey {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(57, 255, 20, 0.05);
    border-radius: 8px;
    font-size: 0.75rem;
}

.hotkey kbd {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    padding: 4px 8px;
    background: rgba(57, 255, 20, 0.15);
    border: 1px solid rgba(57, 255, 20, 0.25);
    border-radius: 4px;
    color: var(--bio-green);
}

.hotkey span {
    color: var(--text-muted);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
    .control-panel {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 50vh;
        border-radius: 20px 20px 0 0;
        padding: 12px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .panel-header {
        width: 100%;
        order: -1;
    }

    .panel-section {
        flex: 1;
        min-width: 140px;
    }

    .lab-notes {
        display: none;
    }

    .modal {
        max-width: 95%;
        max-height: 80vh;
    }
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(57, 255, 20, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(57, 255, 20, 0.4);
}

/* ---------- AGENT INFO PANEL ---------- */
.agent-info-panel {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    width: 380px;
    max-height: 85vh;
    background: rgba(10, 13, 8, 0.95);
    border: 1px solid rgba(57, 255, 20, 0.25);
    border-radius: 16px;
    backdrop-filter: blur(15px);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 0 40px rgba(57, 255, 20, 0.15),
        0 20px 60px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.agent-info-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

.agent-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: rgba(57, 255, 20, 0.05);
    border-bottom: 1px solid rgba(57, 255, 20, 0.12);
}

.agent-info-header h3 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--bio-green);
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 0 15px rgba(57, 255, 20, 0.5);
}

.agent-info-header h3 i {
    font-size: 1.1rem;
}

.agent-info-close {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.agent-info-close:hover {
    background: rgba(255, 0, 110, 0.15);
    border-color: rgba(255, 0, 110, 0.5);
    color: var(--organic-pink);
}

.agent-info-content {
    padding: 16px;
    overflow-y: auto;
    max-height: calc(85vh - 60px);
}

/* DNA Section */
.dna-section {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(57, 255, 20, 0.1);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 16px;
}

.dna-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.dna-sequence {
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: var(--bio-cyan);
    word-break: break-all;
    line-height: 1.6;
    letter-spacing: 0.05em;
    background: rgba(0, 245, 212, 0.05);
    padding: 8px;
    border-radius: 6px;
}

.dna-sequence .base-A { color: #ff6b6b; }
.dna-sequence .base-T { color: #4ecdc4; }
.dna-sequence .base-G { color: #ffe66d; }
.dna-sequence .base-C { color: #95e1d3; }
.dna-sequence .dna-separator { color: var(--text-dim); opacity: 0.5; }

/* Trait Groups */
.trait-group {
    background: rgba(57, 255, 20, 0.03);
    border: 1px solid rgba(57, 255, 20, 0.08);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

.trait-group-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--bio-green);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(57, 255, 20, 0.1);
}

.trait-group-title i {
    font-size: 0.85rem;
    opacity: 0.8;
}

.trait-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.75rem;
}

.trait-row:not(:last-child) {
    border-bottom: 1px solid rgba(57, 255, 20, 0.05);
}

.trait-label {
    color: var(--text-muted);
}

.trait-value {
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
}

.trait-value.energy {
    color: var(--bio-blue);
}

.trait-value.aggression {
    color: var(--warning-amber);
}

.trait-value.male {
    color: #5599ff;
}

.trait-value.female {
    color: #ff77aa;
}

.trait-value.ready {
    color: var(--bio-green);
}

.trait-value.not-ready {
    color: #888;
}

.trait-value.bonus {
    color: var(--bio-cyan);
    font-weight: 600;
}

.color-preview {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-left: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 8px currentColor;
}

/* Organs List */
.organs-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.organ-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-size: 0.7rem;
}

.organ-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.9rem;
}

.organ-icon.tentacle { background: rgba(157, 78, 221, 0.2); color: var(--organic-purple); }
.organ-icon.tail { background: rgba(0, 245, 212, 0.2); color: var(--bio-blue); }
.organ-icon.cilia { background: rgba(57, 255, 20, 0.2); color: var(--bio-green); }
.organ-icon.spine { background: rgba(255, 190, 11, 0.2); color: var(--warning-amber); }
.organ-icon.flagellum { background: rgba(255, 0, 110, 0.2); color: var(--organic-pink); }

.organ-name {
    flex: 1;
    color: var(--text-primary);
    font-weight: 600;
}

.organ-stats {
    color: var(--text-muted);
    font-size: 0.65rem;
}

.no-organs {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.7rem;
    padding: 10px;
    text-align: center;
}

/* Selected agent highlight */
.agent-selected-marker {
    position: absolute;
    pointer-events: none;
    border: 2px solid var(--bio-green);
    border-radius: 50%;
    animation: selectedPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 20px var(--bio-green);
}

@keyframes selectedPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.4; }
}

/* Responsive for agent panel */
@media (max-width: 768px) {
    .agent-info-panel {
        width: 95%;
        max-width: 380px;
        top: 10px;
    }
}

/* ---------- ADVANCED SETTINGS MODAL ---------- */
.modal-wide {
    max-width: 900px;
    width: 95%;
}

.settings-content {
    padding: 0 !important;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.settings-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(57, 255, 20, 0.1);
}

.settings-section h3 {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--bio-green);
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(57, 255, 20, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section h3 i {
    font-size: 1rem;
}

.setting-item {
    margin-bottom: 14px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.setting-value {
    font-family: var(--font-mono);
    color: var(--bio-cyan);
    font-weight: 600;
    background: rgba(0, 245, 212, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    min-width: 50px;
    text-align: center;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(57, 255, 20, 0.15);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--bio-green);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 8px var(--bio-green);
    transition: all 0.2s ease;
}

.setting-item input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px var(--bio-green);
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--bio-green);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px var(--bio-green);
}

.setting-hint {
    display: block;
    font-size: 0.62rem;
    color: var(--text-dim);
    margin-top: 4px;
    font-style: italic;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(57, 255, 20, 0.15);
    background: rgba(0, 0, 0, 0.2);
}

.settings-actions .blob-btn {
    padding: 10px 20px;
    font-size: 0.75rem;
}

/* Responsive for settings modal */
@media (max-width: 768px) {
    .modal-wide {
        max-width: 100%;
        width: 100%;
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        max-height: 50vh;
        padding: 12px;
        gap: 12px;
    }

    .settings-section {
        padding: 12px;
    }

    .settings-actions {
        flex-direction: column;
    }

    .settings-actions .blob-btn {
        width: 100%;
    }
}

/* ---------- TEACHER MODE: FORMULAS OVERLAY ---------- */
.formulas-overlay {
    position: fixed;
    top: 20px;
    left: 20px;
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: 40;
    pointer-events: none;
    max-width: 280px;
}

.formulas-overlay.active {
    display: flex;
}

.formula-card {
    background: rgba(10, 13, 8, 0.92);
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 10px;
    padding: 10px 14px;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 20px rgba(57, 255, 20, 0.1);
}

.formula-card h4 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bio-green);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.formula-card h4 i {
    font-size: 0.85rem;
    opacity: 0.8;
}

.formula {
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    color: var(--bio-cyan);
    background: rgba(0, 245, 212, 0.08);
    padding: 6px 10px;
    border-radius: 6px;
    line-height: 1.5;
    white-space: nowrap;
    overflow-x: auto;
}

.formula-values {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: italic;
}

.formula-values span {
    color: var(--bio-green);
    font-weight: 600;
}

/* ---------- TEACHER MODE: GRAPHS PANEL ---------- */
.graphs-panel {
    position: fixed;
    bottom: 20px;
    left: 300px;
    right: 300px;
    display: none;
    flex-direction: column;
    gap: 8px;
    z-index: 40;
    background: rgba(5, 7, 4, 0.85);
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 12px;
    padding: 8px;
    backdrop-filter: blur(10px);
}

.graphs-panel.active {
    display: flex;
}

.graphs-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bio-green);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(57, 255, 20, 0.15);
    margin-bottom: 4px;
}

.graphs-panel .graphs-content {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.graph-container {
    background: rgba(10, 13, 8, 0.92);
    border: 1px solid rgba(57, 255, 20, 0.15);
    border-radius: 10px;
    padding: 8px 10px;
    backdrop-filter: blur(8px);
    width: 160px;
}

.graph-container h4 {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.graph-container h4 i {
    font-size: 0.75rem;
    color: var(--bio-green-dim);
}

.graph-container canvas {
    width: 100%;
    height: 60px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
}

/* ---------- TEACHER MODE: STEP EXPLANATION ---------- */
.step-explanation {
    position: fixed;
    /* Placed above `.lab-notes` so the two panels don't overlap in the
       bottom-left corner. Users can still drag either one elsewhere. */
    bottom: 220px;
    left: 20px;
    display: none;
    flex-direction: column;
    width: 260px;
    background: rgba(10, 13, 8, 0.95);
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    z-index: 45;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(57, 255, 20, 0.1);
}

.step-explanation.active {
    display: flex;
}

.step-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--bio-green);
    padding: 10px 14px;
    background: rgba(57, 255, 20, 0.08);
    border-bottom: 1px solid rgba(57, 255, 20, 0.1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-header i {
    font-size: 0.9rem;
}

.step-content {
    padding: 12px 14px;
    max-height: 300px;
    overflow-y: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.step-content .step-event {
    padding: 4px 0;
    border-bottom: 1px solid rgba(57, 255, 20, 0.05);
}

.step-content .step-event:last-child {
    border-bottom: none;
}

.step-content .step-event.birth {
    color: #a8ffb0;
}

.step-content .step-event.death {
    color: #888;
}

.step-content .step-event.hunt {
    color: #ffe4a8;
}

.step-content .step-event.mate {
    color: #ffb0d0;
}

.step-content .step-event.eat {
    color: var(--bio-cyan);
}

.step-content .step-stat {
    color: var(--text-primary);
    font-weight: 600;
}

/* ---------- DIVERSITY PANEL ---------- */
.diversity-panel {
    position: fixed;
    top: 20px;
    left: 300px;
    display: none;
    flex-direction: column;
    width: 200px;
    background: rgba(10, 13, 8, 0.95);
    border: 1px solid rgba(57, 255, 20, 0.2);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    z-index: 40;
    overflow: hidden;
    box-shadow: 0 0 25px rgba(57, 255, 20, 0.1);
}

.diversity-panel.active {
    display: flex;
}

.diversity-header {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--bio-green);
    padding: 10px 12px;
    background: rgba(57, 255, 20, 0.08);
    border-bottom: 1px solid rgba(57, 255, 20, 0.1);
    display: flex;
    align-items: center;
    gap: 6px;
}

.diversity-header i {
    font-size: 0.85rem;
}

.diversity-content {
    padding: 10px 12px;
}

.diversity-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.68rem;
}

.diversity-label {
    color: var(--text-muted);
}

.diversity-value {
    font-family: 'Orbitron', sans-serif;
    font-weight: 600;
    color: var(--bio-cyan);
}

.diversity-value.aggression {
    color: var(--warning-amber);
}

.diversity-shapes-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.3);
}

.diversity-shapes-bar .shape-segment {
    height: 100%;
    transition: width 0.3s ease;
}

.diversity-shapes-bar .shape-segment:nth-child(1) { background: #ff6b6b; } /* amoeba */
.diversity-shapes-bar .shape-segment:nth-child(2) { background: #4ecdc4; } /* coccus */
.diversity-shapes-bar .shape-segment:nth-child(3) { background: #ffe66d; } /* bacillus */
.diversity-shapes-bar .shape-segment:nth-child(4) { background: #95e1d3; } /* spirillum */
.diversity-shapes-bar .shape-segment:nth-child(5) { background: #a8e6cf; } /* paramecium */
.diversity-shapes-bar .shape-segment:nth-child(6) { background: #dcd6f7; } /* diatom */

/* ---------- NEURAL NETWORK VISUALIZATION ---------- */
.nn-visualization {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--membrane-strong);
    border-radius: 8px;
    padding: 8px;
    margin: 8px 0;
}

.nn-visualization canvas {
    width: 100%;
    height: auto;
    display: block;
}

.nn-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.nn-weight-count {
    color: var(--bio-cyan);
}

.nn-architecture {
    font-family: 'Space Mono', monospace;
    color: var(--bio-green-dim);
}

/* NN Node colors */
.nn-node-input { fill: #4ecdc4; }
.nn-node-hidden { fill: #ffe66d; }
.nn-node-output { fill: #ff6b6b; }
.nn-connection-positive { stroke: rgba(57, 255, 20, 0.5); }
.nn-connection-negative { stroke: rgba(255, 0, 110, 0.5); }

/* NN DNA Section in DNA display */
.nn-dna-section {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed var(--membrane);
    font-size: 0.65rem;
}

.nn-dna-label {
    color: var(--bio-cyan);
    font-weight: bold;
}

.nn-dna-value {
    font-family: 'Space Mono', monospace;
    color: var(--text-muted);
    word-break: break-all;
    letter-spacing: 1px;
}

/* Neural Network Description in Instructions Modal */
.nn-description {
    background: rgba(0, 245, 212, 0.05);
    border: 1px solid rgba(0, 245, 212, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
}

.nn-description h5 {
    color: var(--bio-cyan);
    font-size: 0.85rem;
    margin: 12px 0 6px 0;
    font-weight: 600;
}

.nn-description h5:first-child {
    margin-top: 0;
}

.nn-description ul {
    margin: 4px 0;
    padding-left: 20px;
}

.nn-description ul ul {
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.nn-description code {
    background: rgba(57, 255, 20, 0.15);
    color: var(--bio-green);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
}

/* ---------- LIVE NEURAL NETWORK PANEL ---------- */
.live-nn-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    background: rgba(5, 7, 4, 0.95);
    border: 1px solid rgba(0, 245, 212, 0.3);
    border-radius: 14px;
    backdrop-filter: blur(15px);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 0 40px rgba(0, 245, 212, 0.2),
        0 15px 50px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.live-nn-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.live-nn-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(0, 245, 212, 0.12), rgba(57, 255, 20, 0.08));
    border-bottom: 1px solid rgba(0, 245, 212, 0.2);
}

.live-nn-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bio-cyan);
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-nn-agent {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    color: var(--bio-green);
    background: rgba(57, 255, 20, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid rgba(57, 255, 20, 0.2);
}

.live-nn-close {
    width: 24px;
    height: 24px;
    border: 1px solid rgba(0, 245, 212, 0.2);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.live-nn-close:hover {
    background: rgba(255, 0, 110, 0.15);
    border-color: rgba(255, 0, 110, 0.5);
    color: var(--organic-pink);
}

/* Section titles */
.nn-section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    padding: 8px 12px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nn-section-title i {
    color: var(--bio-cyan);
    font-size: 0.7rem;
}

/* State Section */
.nn-state-section {
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(0, 245, 212, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nn-state-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bio-green);
    padding: 4px 10px;
    background: rgba(57, 255, 20, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(57, 255, 20, 0.2);
    transition: all 0.3s ease;
}

.nn-state-indicator i {
    font-size: 1rem;
}

.nn-state-indicator.hungry {
    color: var(--warning-amber);
    background: rgba(255, 190, 11, 0.15);
    border-color: rgba(255, 190, 11, 0.3);
}

.nn-state-indicator.fleeing {
    color: var(--organic-pink);
    background: rgba(255, 0, 110, 0.15);
    border-color: rgba(255, 0, 110, 0.3);
    animation: pulseAlert 0.5s ease infinite;
}

.nn-state-indicator.hunting {
    color: #ff6b6b;
    background: rgba(255, 107, 107, 0.15);
    border-color: rgba(255, 107, 107, 0.3);
}

.nn-state-indicator.mating {
    color: #ff69b4;
    background: rgba(255, 105, 180, 0.15);
    border-color: rgba(255, 105, 180, 0.3);
    animation: pulseHeart 1s ease infinite;
}

@keyframes pulseAlert {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 0, 110, 0.3); }
    50% { box-shadow: 0 0 15px rgba(255, 0, 110, 0.6); }
}

@keyframes pulseHeart {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.nn-state-details {
    display: flex;
    gap: 8px;
}

.nn-energy-badge, .nn-age-badge {
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nn-energy-badge {
    background: rgba(255, 190, 11, 0.1);
    color: var(--warning-amber);
    border: 1px solid rgba(255, 190, 11, 0.2);
}

.nn-energy-badge.low {
    animation: pulseLow 0.8s ease infinite;
    background: rgba(255, 0, 110, 0.15);
    color: var(--organic-pink);
    border-color: rgba(255, 0, 110, 0.3);
}

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

.nn-age-badge {
    background: rgba(0, 245, 212, 0.1);
    color: var(--bio-cyan);
    border: 1px solid rgba(0, 245, 212, 0.2);
}

/* Sensors Section */
.nn-sensors-section {
    border-bottom: 1px solid rgba(0, 245, 212, 0.1);
}

.nn-sensors-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 4px 12px 10px;
}

.nn-sensor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 4px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.nn-sensor.active {
    background: rgba(57, 255, 20, 0.1);
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.2);
}

.nn-sensor-icon {
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.nn-sensor.active .nn-sensor-icon {
    color: var(--bio-green);
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.8);
}

#sensorFood.active .nn-sensor-icon { color: var(--bio-green); }
#sensorMate.active .nn-sensor-icon { color: #ff69b4; text-shadow: 0 0 8px rgba(255, 105, 180, 0.8); }
#sensorThreat.active .nn-sensor-icon { color: var(--organic-pink); text-shadow: 0 0 8px rgba(255, 0, 110, 0.8); }
#sensorCrowd.active .nn-sensor-icon { color: var(--bio-cyan); text-shadow: 0 0 8px rgba(0, 245, 212, 0.8); }

.nn-sensor-bar {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 2px;
    overflow: hidden;
}

.nn-sensor-fill {
    height: 100%;
    width: 0%;
    background: var(--bio-green);
    border-radius: 2px;
    transition: width 0.15s ease-out, background 0.2s ease;
}

#sensorMateFill { background: #ff69b4; }
#sensorThreatFill { background: var(--organic-pink); }
#sensorCrowdFill { background: var(--bio-cyan); }

.nn-sensor-value {
    font-family: 'Space Mono', monospace;
    font-size: 0.55rem;
    color: var(--text-dim);
}

/* Brain Section */
.nn-brain-section {
    border-bottom: 1px solid rgba(0, 245, 212, 0.1);
}

.nn-brain-section canvas {
    width: 100%;
    height: 160px;
    display: block;
}

/* Decisions Section */
.nn-decisions-section {
    border-bottom: 1px solid rgba(0, 245, 212, 0.1);
}

.nn-decisions-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 12px 10px;
}

.nn-decision {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nn-decision-label {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    color: var(--text-muted);
    width: 70px;
    flex-shrink: 0;
}

.nn-decision-bar {
    flex: 1;
    height: 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.nn-decision-bar.turn-bar {
    background: linear-gradient(90deg,
        rgba(255, 0, 110, 0.2) 0%,
        rgba(0, 0, 0, 0.4) 45%,
        rgba(0, 0, 0, 0.4) 55%,
        rgba(57, 255, 20, 0.2) 100%);
}

.nn-decision-center {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-50%);
}

.nn-decision-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--bio-cyan), var(--bio-green));
    border-radius: 5px;
    width: 0%;
    transition: all 0.15s ease-out;
    box-shadow: 0 0 8px rgba(0, 245, 212, 0.5);
}

.turn-bar .nn-decision-fill {
    position: absolute;
    left: 50%;
    width: 0%;
    transition: all 0.15s ease-out;
}

.turn-bar .nn-decision-fill.left {
    background: linear-gradient(90deg, var(--organic-pink), var(--warning-amber));
    transform: translateX(-100%);
    border-radius: 5px 0 0 5px;
}

.turn-bar .nn-decision-fill.right {
    background: linear-gradient(90deg, var(--bio-cyan), var(--bio-green));
    border-radius: 0 5px 5px 0;
}

.aggro-bar .nn-decision-fill {
    background: linear-gradient(90deg, var(--warning-amber), #ff6b6b);
}

.mate-bar .nn-decision-fill {
    background: linear-gradient(90deg, #ff69b4, #ff1493);
}

.nn-decision-value {
    font-family: 'Space Mono', monospace;
    font-size: 0.6rem;
    color: var(--text-muted);
    width: 32px;
    text-align: right;
}

.nn-decision-icon {
    font-size: 0.9rem;
    color: var(--text-muted);
    width: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.nn-decision-icon.left {
    color: var(--organic-pink);
    transform: rotate(-90deg);
}

.nn-decision-icon.right {
    color: var(--bio-green);
    transform: rotate(90deg);
}

.nn-decision-icon.straight {
    color: var(--bio-cyan);
}

/* Thought Bubble */
.nn-thought-section {
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.15);
}

.nn-thought-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.08), rgba(0, 245, 212, 0.05));
    border: 1px solid rgba(57, 255, 20, 0.15);
    border-radius: 12px 12px 12px 4px;
    font-family: 'Space Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-secondary);
    position: relative;
}

.nn-thought-bubble::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 8px;
    width: 8px;
    height: 8px;
    background: rgba(57, 255, 20, 0.08);
    border: 1px solid rgba(57, 255, 20, 0.15);
    border-top: none;
    border-right: none;
    border-radius: 0 0 0 6px;
    transform: skewY(-10deg);
}

.nn-thought-bubble i {
    color: var(--bio-green);
    font-size: 1rem;
    animation: thinkPulse 2s ease infinite;
}

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

.live-nn-hint {
    padding: 6px 12px 8px;
    font-size: 0.55rem;
    color: var(--text-dim);
    text-align: center;
    font-style: italic;
}

/* Impulse animation keyframes */
@keyframes synapseFlash {
    0% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1.2); }
    100% { opacity: 0; transform: scale(0.5); }
}

.synapse-impulse {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--bio-cyan);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--bio-cyan);
    animation: synapseFlash 0.3s ease-out forwards;
    pointer-events: none;
}

/* ---------- FORMULAS HANDLE ---------- */
.formulas-handle {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 8px 12px;
    margin-bottom: 8px;
    background: rgba(57, 255, 20, 0.06);
    border: 1px solid rgba(57, 255, 20, 0.12);
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.formulas-handle i {
    color: var(--bio-green-dim);
    font-size: 0.85rem;
}

/* ---------- DRAGGABLE PANELS ---------- */
.draggable {
    cursor: default;
}

.draggable.dragging {
    user-select: none;
    transition: none !important;
}

.drag-handle {
    cursor: grab;
    user-select: none;
}

.drag-handle:active,
.draggable.dragging .drag-handle {
    cursor: grabbing;
}

/* Drag indicator icon */
.drag-handle::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2339ff14' stroke-width='2'%3E%3Cpath d='M12 2L12 22M2 12L22 12M7 7L12 2L17 7M17 17L12 22L7 17M2 12L7 7M22 12L17 7M2 12L7 17M22 12L17 17'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.4;
    transition: opacity 0.2s;
    vertical-align: middle;
}

.drag-handle:hover::before {
    opacity: 0.8;
}

/* Panel position reset when draggable (override transform centering) */
.draggable.has-position {
    transform: none !important;
}

.draggable.has-position.active {
    transform: none !important;
}

/* ---------- ADDITIONAL INFO: RESPONSIVE ---------- */
@media (max-width: 768px) {
    .formulas-overlay,
    .graphs-panel,
    .step-explanation,
    .diversity-panel {
        display: none !important;
    }
}
/* ---------- ACCESSIBILITY: REDUCED MOTION ---------- */
/* Respect user preference for reduced motion (vestibular disorders, migraine, etc.) */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .particle {
        display: none;
    }
}

/* ---------- ACCESSIBILITY: FOCUS INDICATORS ---------- */
/* Restore visible focus ring for keyboard navigation (WCAG 2.4.7).
   Uses :focus-visible so mouse clicks don't show the ring. */
.slider-item input[type="range"]:focus-visible,
.setting-item input[type="range"]:focus-visible,
.select-item select:focus-visible,
.blob-btn:focus-visible,
.icon-btn:focus-visible,
.modal-close:focus-visible,
.agent-info-close:focus-visible,
.live-nn-close:focus-visible,
.checkbox-item input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--bio-green);
    outline-offset: 2px;
    box-shadow: 0 0 8px rgba(57, 255, 20, 0.6);
}

/* ---------- VISUAL REFRESH: MICROSCOPE HUD ---------- */
body::before,
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
}

body::before {
    z-index: 2;
    background:
        repeating-linear-gradient(
            180deg,
            rgba(255, 255, 255, 0) 0,
            rgba(255, 255, 255, 0) 3px,
            rgba(57, 255, 20, 0.015) 4px
        );
    opacity: 0.28;
    mix-blend-mode: screen;
}

body::after {
    z-index: 3;
    background:
        radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 48%, rgba(0, 0, 0, 0.34) 100%),
        linear-gradient(90deg, rgba(0, 245, 212, 0.03), transparent 18%, transparent 82%, rgba(57, 255, 20, 0.03));
}

.ambient-layer {
    z-index: 0;
}

.ambient-grid,
.ambient-rings,
.ambient-vignette {
    position: absolute;
    inset: 0;
}

.ambient-grid {
    background-image:
        linear-gradient(rgba(0, 245, 212, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 245, 212, 0.05) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 85%);
    opacity: 0.22;
}

.ambient-rings {
    background:
        radial-gradient(circle at 18% 14%, rgba(0, 245, 212, 0.16), transparent 20%),
        radial-gradient(circle at 80% 78%, rgba(57, 255, 20, 0.14), transparent 24%),
        radial-gradient(circle at 50% 50%, rgba(0, 229, 255, 0.08), transparent 30%);
    filter: blur(36px);
    opacity: 0.8;
}

.ambient-vignette {
    box-shadow:
        inset 0 0 180px rgba(0, 0, 0, 0.72),
        inset 0 0 40px rgba(0, 245, 212, 0.06);
}

.substrate-texture {
    background:
        radial-gradient(ellipse at 20% 16%, rgba(57, 255, 20, 0.08) 0%, transparent 36%),
        radial-gradient(ellipse at 74% 22%, rgba(0, 245, 212, 0.06) 0%, transparent 26%),
        radial-gradient(ellipse at 60% 80%, rgba(157, 78, 221, 0.05) 0%, transparent 22%),
        radial-gradient(ellipse at 50% 50%, rgba(13, 18, 10, 0.7) 0%, var(--petri-deep) 100%);
}

#evoCanvas {
    background:
        radial-gradient(circle at 50% 50%, rgba(8, 12, 10, 0.25), rgba(5, 7, 4, 0.92)),
        var(--petri-dark);
    filter: saturate(1.06) contrast(1.04);
}

.control-panel {
    top: 8px;
    right: 10px;
    width: 318px;
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
    gap: 6px;
    z-index: 60;
    padding-bottom: 0;
    padding-right: 4px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    min-height: 0;
}

.control-panel::-webkit-scrollbar {
    width: 8px;
}

.control-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 999px;
}

.control-panel::-webkit-scrollbar-thumb {
    background: rgba(57, 255, 20, 0.3);
    border-radius: 999px;
}

.panel-header,
.panel-section,
.lab-notes,
.graphs-panel,
.diversity-panel,
.step-explanation,
.live-nn-panel,
.agent-info-panel,
.formula-card,
.formulas-handle,
.modal {
    background:
        linear-gradient(180deg, rgba(10, 16, 13, 0.62) 0%, rgba(6, 10, 8, 0.5) 100%);
    border: 1px solid rgba(101, 255, 190, 0.12);
    box-shadow:
        0 12px 36px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(101, 255, 190, 0.03),
        0 0 24px rgba(0, 245, 212, 0.04);
    backdrop-filter: blur(14px) saturate(120%);
}

.panel-header {
    display: block;
    padding: 6px 12px 7px;
    border-radius: 14px;
    background:
        radial-gradient(circle at top left, rgba(57, 255, 20, 0.08), transparent 42%),
        linear-gradient(145deg, rgba(12, 20, 15, 0.64) 0%, rgba(7, 11, 9, 0.52) 100%);
}

.panel-heading {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.panel-kicker {
    font-family: var(--font-display);
    font-size: 0.48rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(0, 245, 212, 0.78);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    line-height: 1.2;
}

.panel-header h1 {
    font-family: var(--font-display);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    margin: 0;
    line-height: 1.2;
}
.panel-header h1 i {
    font-size: 0.95rem;
    margin-right: 4px;
    vertical-align: -1px;
}

.panel-subtitle {
    display: none;
}

.header-actions {
    display: grid;
    grid-template-columns: repeat(3, 30px);
    gap: 6px;
    flex-shrink: 0;
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(0, 245, 212, 0.12);
    color: rgba(224, 255, 224, 0.68);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.icon-btn:hover {
    background: rgba(0, 245, 212, 0.12);
    border-color: rgba(0, 245, 212, 0.4);
    color: var(--bio-cyan);
    transform: translateY(-1px);
}

.panel-section {
    position: relative;
    overflow: hidden;
    padding: 9px 11px;
    border-radius: 16px;
}

.panel-section::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent 40%);
    opacity: 0.32;
    pointer-events: none;
}

.panel-section > * {
    position: relative;
    z-index: 1;
}

.panel-section h3 {
    margin-bottom: 8px;
    font-family: var(--font-display);
    font-size: 0.56rem;
    letter-spacing: 0.14em;
    color: rgba(202, 255, 216, 0.62);
}

.panel-section-hero {
    display: grid;
    gap: 4px;
    border-color: rgba(0, 245, 212, 0.22);
    background:
        radial-gradient(circle at top right, rgba(0, 245, 212, 0.08), transparent 34%),
        linear-gradient(160deg, rgba(7, 20, 16, 0.58) 0%, rgba(7, 10, 9, 0.48) 100%);
}

.status-strip {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 0;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 0;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(101, 255, 190, 0.12);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(224, 255, 224, 0.76);
    font-size: 0.66rem;
    letter-spacing: 0.03em;
    justify-content: center;
    white-space: nowrap;
}

.status-chip i {
    color: var(--bio-cyan);
    font-size: 0.78rem;
}

.status-chip span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning-amber);
    box-shadow: 0 0 10px rgba(255, 190, 11, 0.45);
}

.status-chip-live.is-running .status-dot {
    background: var(--bio-green);
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.6);
    animation: pulse-dot 1.8s ease-in-out infinite;
}

.status-chip-live.is-running {
    color: #d9ffe2;
    border-color: rgba(57, 255, 20, 0.34);
    background: rgba(57, 255, 20, 0.09);
}

.status-chip-live.is-paused {
    border-color: rgba(255, 190, 11, 0.26);
    background: rgba(255, 190, 11, 0.08);
}

.hero-copy {
    display: none;
}

.hero-spectrum {
    display: none;
}

.hero-spectrum span {
    display: block;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(0, 245, 212, 0.9), rgba(57, 255, 20, 0.15));
    box-shadow: 0 0 14px rgba(0, 245, 212, 0.16);
}

.hero-spectrum span:nth-child(1) { height: 22%; }
.hero-spectrum span:nth-child(2) { height: 48%; }
.hero-spectrum span:nth-child(3) { height: 78%; }
.hero-spectrum span:nth-child(4) { height: 56%; }
.hero-spectrum span:nth-child(5) { height: 92%; }
.hero-spectrum span:nth-child(6) { height: 36%; }

body[data-sim-state='running'] .panel-section-hero {
    box-shadow:
        0 12px 36px rgba(0, 0, 0, 0.22),
        0 0 0 1px rgba(101, 255, 190, 0.03),
        0 0 24px rgba(57, 255, 20, 0.06);
}

.btn-group {
    gap: 4px;
}

.blob-btn {
    min-height: 26px;
    padding: 4px 6px;
    border-radius: 10px;
    font-family: var(--font-display);
    font-size: 0.55rem;
    letter-spacing: 0.06em;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
        linear-gradient(135deg, rgba(57, 255, 20, 0.08), rgba(0, 245, 212, 0.04));
    border: 1px solid rgba(101, 255, 190, 0.12);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 6px 16px rgba(0, 0, 0, 0.14);
}

.blob-btn i {
    font-size: 0.7rem;
}

.blob-btn:hover {
    transform: translateY(-1px);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03)),
        linear-gradient(135deg, rgba(57, 255, 20, 0.16), rgba(0, 245, 212, 0.1));
}

.blob-btn.primary {
    min-height: 30px;
    border-radius: 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
        linear-gradient(135deg, rgba(57, 255, 20, 0.18), rgba(0, 245, 212, 0.08));
    border-color: rgba(57, 255, 20, 0.24);
}

.blob-btn.running {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
        linear-gradient(135deg, rgba(255, 0, 110, 0.28), rgba(255, 190, 11, 0.14));
    border-color: rgba(255, 0, 110, 0.32);
}

.slider-item {
    gap: 6px;
}

.slider-group {
    gap: 8px;
}

.slider-item label,
.checkbox-item,
.select-item select,
.setting-item label,
.setting-hint,
.metric-meta,
.modal-content p,
.modal-content li {
    font-family: var(--font-body);
}

.slider-item label {
    font-size: 0.6rem;
    letter-spacing: 0.08em;
    color: rgba(202, 255, 216, 0.62);
}

.slider-item input[type="range"],
.setting-item input[type="range"] {
    height: 5px;
    background: linear-gradient(90deg, rgba(0, 245, 212, 0.14), rgba(57, 255, 20, 0.08));
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}

.slider-item input[type="range"]::-webkit-slider-thumb,
.setting-item input[type="range"]::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
    background: linear-gradient(180deg, #c9ffe5 0%, #39ff14 100%);
    box-shadow: 0 0 0 4px rgba(57, 255, 20, 0.1), 0 0 16px rgba(57, 255, 20, 0.45);
}

.slider-item input[type="range"]::-moz-range-thumb,
.setting-item input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: linear-gradient(180deg, #c9ffe5 0%, #39ff14 100%);
    box-shadow: 0 0 0 4px rgba(57, 255, 20, 0.1), 0 0 16px rgba(57, 255, 20, 0.45);
}

.checkbox-item {
    min-height: 30px;
    padding: 5px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: rgba(224, 255, 224, 0.72);
    font-size: 0.6rem;
    letter-spacing: 0.05em;
    transition: background 0.2s ease, transform 0.2s ease;
}

.checkbox-item:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(1px);
}

.checkbox-item + .checkbox-item {
    margin-top: 4px;
}

.toggle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.toggle-grid .checkbox-item + .checkbox-item {
    margin-top: 0;
}

.select-item select {
    min-height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(0, 245, 212, 0.14);
    font-size: 0.64rem;
}

.metrics-section {
    padding: 9px 11px;
}

.metrics-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.metrics-heading h3 {
    margin: 0;
}

.metrics-caption {
    font-size: 0.52rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(0, 245, 212, 0.56);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
}

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid rgba(101, 255, 190, 0.1);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)),
        rgba(7, 10, 9, 0.42);
}

.metric-card::after {
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 2px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(0, 245, 212, 0.85), rgba(57, 255, 20, 0.1));
}

.metric-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.metric-label {
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(202, 255, 216, 0.58);
}

.metric-value {
    min-width: 0;
    text-align: left;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.92rem;
    line-height: 1;
}

.metric-meta {
    margin-top: 3px;
    color: rgba(224, 255, 224, 0.56);
    font-size: 0.54rem;
}

.metric-bar {
    margin-top: 5px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    overflow: hidden;
}

.metric-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    transition: width 0.35s ease;
    box-shadow: 0 0 12px currentColor;
}

.metric-card-population .metric-bar span {
    color: var(--bio-green);
    background: linear-gradient(90deg, rgba(57, 255, 20, 0.52), rgba(57, 255, 20, 0.95));
}

.metric-card-energy .metric-bar span {
    color: var(--bio-cyan);
    background: linear-gradient(90deg, rgba(0, 229, 255, 0.45), rgba(0, 245, 212, 0.95));
}

.metric-card-food .metric-bar span {
    color: var(--warning-amber);
    background: linear-gradient(90deg, rgba(255, 190, 11, 0.45), rgba(255, 190, 11, 0.92));
}

.lab-notes {
    bottom: 10px;
    left: 10px;
    width: 240px;
    max-height: 170px;
    border-radius: 14px;
}

.lab-notes-content {
    max-height: 118px;
}

.panel-section-morphology .checkbox-item {
    margin-bottom: 4px;
}

.morphology-select[hidden] {
    display: none !important;
}

.lab-notes-header,
.graphs-header,
.diversity-header,
.step-header,
.live-nn-header,
.agent-info-header,
.formulas-handle {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border-bottom: 1px solid rgba(101, 255, 190, 0.08);
    color: rgba(202, 255, 216, 0.82);
}

.formulas-handle {
    margin-bottom: 0;
}

.formula-card {
    border-radius: 16px;
}

.graphs-panel {
    bottom: 10px;
    left: 330px;
    right: 330px;
    border-radius: 14px;
    padding: 8px;
}

.graph-container {
    width: 168px;
    border-radius: 10px;
    background: rgba(7, 10, 9, 0.48);
}

.diversity-panel {
    top: 10px;
    left: 330px;
    width: 210px;
    border-radius: 14px;
}

.diversity-content,
.agent-info-content,
.lab-notes-content,
.step-content {
    font-family: var(--font-body);
}

.step-explanation {
    bottom: 190px;
    left: 10px;
    width: 250px;
    border-radius: 14px;
}

.modal {
    border-radius: 28px;
}

.modal-header {
    padding: 20px 24px;
    background:
        radial-gradient(circle at top left, rgba(57, 255, 20, 0.12), transparent 42%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.modal-content {
    font-size: 0.96rem;
}

.modal-content p,
.modal-content li {
    color: rgba(224, 255, 224, 0.78);
}

.modal-content code,
.formula,
.dna-sequence,
.nn-architecture,
.nn-dna-value {
    font-family: var(--font-mono);
}

.agent-info-panel,
.live-nn-panel {
    border-radius: 20px;
}

.live-nn-hint,
.formula-values,
.metric-meta,
.step-content,
.nn-description ul ul,
.organ-stats {
    color: rgba(224, 255, 224, 0.6);
}

@media (max-width: 1180px) {
    .graphs-panel {
        left: 24px;
        right: 24px;
    }

    .diversity-panel {
        left: 24px;
        top: 120px;
    }
}

@media (max-width: 768px) {
    body::before {
        opacity: 0.16;
    }

    .ambient-grid,
    .ambient-rings {
        opacity: 0.35;
    }

    .control-panel {
        left: 12px;
        right: 12px;
        bottom: 12px;
        top: auto;
        width: auto;
        max-height: calc(100vh - 24px);
        gap: 10px;
        padding: 0;
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .panel-header,
    .panel-section {
        border-radius: 18px;
    }

    .panel-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 12px;
        padding: 14px 16px;
    }

    .header-actions {
        grid-template-columns: repeat(3, 36px);
        gap: 6px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        border-radius: 12px;
    }

    .panel-subtitle {
        max-width: none;
        font-size: 0.76rem;
        line-height: 1.35;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .status-strip {
        flex-direction: row;
        gap: 6px;
    }

    .status-chip {
        min-width: 0;
        flex: 1 1 0;
        justify-content: center;
        white-space: nowrap;
    }

    .status-chip span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .hero-copy {
        display: none;
    }

    .hero-spectrum {
        display: none;
    }

    .panel-section-hero,
    .metrics-section {
        width: 100%;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .metric-card {
        padding: 12px;
    }

    .metric-card-food {
        grid-column: 1 / -1;
    }

    .metric-value {
        font-size: 1.15rem;
    }

    .lab-notes {
        display: none;
    }
}

@media (max-width: 520px) {
    .control-panel {
        left: 10px;
        right: 10px;
        bottom: 10px;
        max-height: calc(100vh - 20px);
        padding: 0;
        gap: 8px;
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .panel-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 10px 12px;
        padding: 14px;
    }

    .panel-heading {
        gap: 4px;
    }

    .panel-kicker {
        font-size: 0.52rem;
        letter-spacing: 0.14em;
    }

    .panel-header h1 {
        font-size: 1rem;
        gap: 6px;
    }

    .panel-header h1 i {
        font-size: 1rem;
    }

    .header-actions {
        grid-template-columns: repeat(3, 34px);
        gap: 6px;
    }

    .icon-btn {
        width: 34px;
        height: 34px;
        border-radius: 12px;
    }

    .panel-subtitle {
        max-width: none;
        font-size: 0.72rem;
        line-height: 1.32;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .panel-section,
    .metrics-section {
        padding: 12px 14px;
        border-radius: 16px;
    }

    .panel-section h3 {
        margin-bottom: 8px;
        font-size: 0.58rem;
        letter-spacing: 0.14em;
    }

    .panel-section-hero {
        display: grid;
        gap: 10px;
    }

    .status-strip {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 6px;
        margin-bottom: 0;
    }

    .status-chip {
        min-width: 0;
        flex: 1 1 0;
        justify-content: center;
        padding: 6px 9px;
        font-size: 0.66rem;
        white-space: nowrap;
    }

    .status-chip span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .hero-copy {
        display: none;
    }

    .hero-spectrum {
        display: none;
    }

    .btn-group {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .blob-btn,
    .blob-btn.primary {
        min-height: 42px;
        padding: 10px 8px;
        border-radius: 16px;
        font-size: 0.62rem;
        letter-spacing: 0.08em;
    }

    .blob-btn.primary {
        grid-column: 1 / -1;
    }

    .slider-group {
        gap: 10px;
    }

    .slider-item label {
        font-size: 0.64rem;
        letter-spacing: 0.08em;
    }

    .checkbox-item {
        min-height: 34px;
        padding: 8px 10px;
        border-radius: 10px;
        font-size: 0.68rem;
        letter-spacing: 0.04em;
    }

    .select-item select {
        min-height: 36px;
        font-size: 0.7rem;
    }

    .metrics-heading {
        align-items: center;
        margin-bottom: 10px;
    }

    .metrics-caption {
        font-size: 0.54rem;
        letter-spacing: 0.12em;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .metric-card {
        padding: 12px;
        border-radius: 14px;
    }

    .metric-card-food {
        grid-column: 1 / -1;
    }

    .metric-card-top {
        margin-bottom: 8px;
    }

    .metric-label {
        font-size: 0.52rem;
        letter-spacing: 0.12em;
    }

    .metric-value {
        font-size: 1.1rem;
    }

    .metric-meta {
        margin-top: 4px;
        font-size: 0.64rem;
    }

    .metric-bar {
        margin-top: 8px;
        height: 5px;
    }
}

/* ---------- COOKIE / ANALYTICS CONSENT BANNER ---------- */
.cookie-consent {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 560px;
    width: calc(100% - 40px);
    z-index: 9999;
    background: rgba(10, 13, 8, 0.95);
    border: 1px solid rgba(57, 255, 20, 0.25);
    border-radius: 14px;
    padding: 16px 20px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(57, 255, 20, 0.08);
    color: var(--text-primary);
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    animation: cookieFadeIn 0.4s ease-out;
}

@keyframes cookieFadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.cookie-consent-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bio-green);
    margin-bottom: 8px;
}

.cookie-consent-text {
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 12px;
}

.cookie-consent-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.cookie-consent-btn {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 16px;
    border-radius: 18px;
    border: 1px solid rgba(57, 255, 20, 0.25);
    background: rgba(57, 255, 20, 0.06);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.cookie-consent-btn:hover {
    background: rgba(57, 255, 20, 0.14);
    border-color: var(--bio-green-dim);
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.2);
}

.cookie-consent-accept {
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.22) 0%, rgba(57, 255, 20, 0.1) 100%);
    border-color: rgba(57, 255, 20, 0.45);
}

.cookie-consent-reject {
    color: var(--text-muted);
}

/* === Ecosystem Presets === */
.presets-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    padding: 10px 14px;
    border: 1px solid rgba(0, 245, 212, 0.18);
    border-radius: 10px;
    background: rgba(0, 245, 212, 0.04);
}
.presets-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--bio-cyan);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 6px;
}
.preset-btn {
    font-size: 0.72rem;
    padding: 6px 12px;
    border-radius: 14px;
}
.preset-btn.active {
    border-color: var(--bio-green);
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.35);
}

/* === Eco-tools status line === */
.eco-status {
    margin-top: 8px;
    min-height: 16px;
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    color: var(--bio-cyan);
    text-align: center;
    opacity: 0.85;
}
.eco-status.active {
    color: var(--warning-amber);
    animation: eco-pulse 1.2s ease-in-out infinite;
}
@keyframes eco-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}
/* Canvas cursor when awaiting meteorite target */
canvas#evoCanvas.cursor-target {
    cursor: crosshair;
}
/* Ice-age visual tint overlay */
.ice-age-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(100, 180, 255, 0.18) 100%);
    z-index: 3;
    animation: ice-shimmer 4s ease-in-out infinite;
}
@keyframes ice-shimmer {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1.0; }
}

/* === Milestone events — stand out in the event log === */
.log-entry.milestone {
    background: linear-gradient(
        90deg,
        rgba(255, 190, 11, 0.18) 0%,
        rgba(255, 190, 11, 0.04) 100%
    );
    border-left: 3px solid var(--warning-amber);
    padding-left: 8px;
    font-weight: 600;
    color: var(--warning-amber);
}
.log-entry.milestone i {
    color: var(--warning-amber);
    margin-right: 4px;
}

/* === Pedigree in agent-info panel === */
.pedigree-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid rgba(0, 245, 212, 0.15);
    border-radius: 6px;
    background: rgba(0, 245, 212, 0.04);
}
.pedigree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
}
.pedigree-label {
    color: var(--text-muted);
    min-width: 60px;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.pedigree-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
}
.pedigree-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-family: 'Space Mono', monospace;
    font-size: 0.65rem;
    color: #000;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.pedigree-chip:hover {
    transform: scale(1.08);
    box-shadow: 0 0 8px rgba(57, 255, 20, 0.5);
}
.pedigree-chip.dead {
    background: rgba(120, 120, 120, 0.3);
    color: var(--text-muted);
    cursor: default;
}

/* === Pedigree tree modal === */
.pedigree-modal-agent {
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    color: var(--bio-cyan);
    margin-left: 6px;
}
.pedigree-tree-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    max-height: 70vh;
    overflow-y: auto;
}
.ped-level {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 0;
}
.ped-level-label {
    min-width: 120px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.ped-level-root .ped-level-label {
    color: var(--bio-green);
}
.ped-level-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
    justify-content: center;
}
.ped-node {
    padding: 6px 12px;
    border-radius: 16px;
    font-family: 'Space Mono', monospace;
    font-size: 0.72rem;
    color: #0a0d08;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border: 1.5px solid transparent;
}
.ped-node:hover {
    transform: scale(1.1);
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.45);
}
.ped-node.root {
    transform: scale(1.25);
    border-color: var(--bio-green);
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.7);
    cursor: default;
}
.ped-node.dead {
    cursor: default;
    color: var(--text-muted);
    opacity: 0.6;
}
.ped-node.dead:hover {
    transform: none;
    box-shadow: none;
}
.pedigree-tree-btn {
    margin-top: 8px;
    font-size: 0.7rem;
    padding: 6px 12px;
    width: 100%;
}
.pedigree-empty {
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    font-family: 'Space Mono', monospace;
}

/* === Effects overlay canvas === */
.effects-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 2;
}

/* === Floating preset toolbar (top-centre) === */
.preset-toolbar {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(10, 13, 8, 0.68);
    border: 1px solid rgba(0, 245, 212, 0.22);
    border-radius: 26px;
    backdrop-filter: blur(10px);
    z-index: 4;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
}
.preset-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.68rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    background: rgba(57, 255, 20, 0.04);
    border: 1px solid rgba(57, 255, 20, 0.18);
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.18s ease;
}
.preset-chip:hover {
    background: rgba(57, 255, 20, 0.14);
    border-color: var(--bio-green-dim);
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.28);
}
.preset-chip.active {
    background: linear-gradient(135deg, rgba(57, 255, 20, 0.26) 0%, rgba(57, 255, 20, 0.12) 100%);
    border-color: var(--bio-green);
    color: var(--bio-green);
    box-shadow: 0 0 18px rgba(57, 255, 20, 0.45);
}
.preset-chip i {
    font-size: 1rem;
}
@media (max-width: 820px) {
    .preset-toolbar { padding: 6px; gap: 4px; }
    .preset-chip { padding: 5px 8px; }
    .preset-chip span { display: none; }    /* icons-only on narrow viewports */
}

/* === Section-action button (inline in section header) === */
.section-action-btn {
    margin-left: auto;               /* push to the right end of the flex h3 */
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bio-cyan);
    background: rgba(0, 245, 212, 0.08);
    border: 1px solid rgba(0, 245, 212, 0.28);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.18s ease;
}
.section-action-btn i {
    font-size: 0.72rem;
}
.section-action-btn:hover {
    background: rgba(0, 245, 212, 0.18);
    border-color: var(--bio-cyan);
    box-shadow: 0 0 12px rgba(0, 245, 212, 0.32);
}

/* === Custom preset chip (synthetic; disabled until user tweaks params) === */
.preset-chip-custom {
    opacity: 0.3;
    cursor: default;
    border-style: dashed;
}
.preset-chip-custom.active {
    opacity: 1;
    background: linear-gradient(135deg, rgba(255, 190, 11, 0.22) 0%, rgba(255, 190, 11, 0.08) 100%);
    border-color: var(--warning-amber);
    color: var(--warning-amber);
    box-shadow: 0 0 16px rgba(255, 190, 11, 0.38);
}

/* === Header version — tiny unobtrusive text, no background === */
.panel-version {
    display: inline-block;
    margin-left: 6px;
    font-family: 'Space Mono', monospace;
    font-size: 0.55rem;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-transform: none;
    vertical-align: middle;
    opacity: 0.7;
}

/* === Header action row (Описание / Инструкция) — compact === */
.header-actions-row {
    display: flex;
    gap: 6px;
    margin: -2px 0 10px 0;
}
.header-action-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: unset;
}
.header-action-btn i {
    font-size: 0.75rem;
}

/* === Stronger visual separation for the Morphology section === */
.panel-section-morphology {
    margin-top: 4px;
}
.panel-section-morphology::before {
    content: '';
    display: block;
    height: 1px;
    margin: -8px -4px 10px;
    background: linear-gradient(90deg, transparent, rgba(57, 255, 20, 0.18), transparent);
}

/* "+ Еда" still stands alone on row 3 of the Simulation group; span it
 * across both columns. Вторжение and Вирус now pair up on their own
 * row so neither needs to span any more. */
.btn-group #evoFood {
    grid-column: 1 / -1;
}

/* Keep long labels inside their buttons */
.blob-btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Inline slider row: LABEL  [======range======]  VALUE === */
.slider-item-inline {
    display: grid !important;
    grid-template-columns: 72px 1fr 34px;
    align-items: center;
    gap: 8px;
}
.slider-item-inline label {
    display: block;
    margin: 0;
    font-size: 0.57rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.1;
}
.slider-item-inline input[type="range"] {
    margin: 0;
}
.slider-item-inline .slider-val {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.62rem;
    color: var(--bio-green);
    text-align: right;
}

/* === Small checkbox variant for the eco-panel toggle === */
.checkbox-item-sm {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 0;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}
.checkbox-item-sm input[type="checkbox"] {
    width: 12px;
    height: 12px;
    accent-color: var(--bio-green);
    cursor: pointer;
}
.checkbox-item-sm:hover {
    color: var(--bio-green);
}
