@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700;800&display=swap');

:root {
    --bg-base: #0b0f19;
    --panel-bg: #111827;
    --cyan-neon: #38bdf8;
    --purple-neon: #a855f7;
    --amber-neon: #f59e0b;
    --rose-neon: #f43f5e;
    --emerald-neon: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-base);
    color: #f1f5f9;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
}

/* ОСНОВНЕ ПОЛОТНО СИМУЛЯЦІЇ (НА ВЕСЬ ЕКРАН) */
#env {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: calc(100vh - 56px);
    overflow: hidden;
    background: #000000;
}

#env-canvas {
    position: relative;
    top: 0px;
    left: 0px;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: crosshair;
}

/* ВІКНО КОНСТРУКТОРА В РЕДАКТОРІ (195x195) */
#editor-env {
    width: 195px !important;
    height: 195px !important;
    min-width: 195px !important;
    min-height: 195px !important;
    position: relative;
    display: block;
    margin: 0 auto;
    background: #0e1318;
    border-radius: 8px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#editor-canvas {
    width: 195px !important;
    height: 195px !important;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: pointer;
	transition: transform 0.15s ease;
}

/* ПЛАВАЮЧІ HUD-БЛОКИ */
.hud-floating-bar {
    position: fixed;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(51, 65, 85, 0.85);
    border-radius: 18px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(2, 132, 199, 0.15);
    z-index: 30;
}

/* НИЖНЯ ПАНЕЛЬ ШВИДКИХ КНОПОК */
.hot-controls {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(51, 65, 85, 0.85);
    border-radius: 20px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7), 0 0 15px rgba(2, 132, 199, 0.25);
    z-index: 30;
}

.hot-controls button,
.cad-tool-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.hot-controls button:hover,
.cad-tool-btn:hover {
    background: #334155;
    color: #38bdf8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
}

.hot-controls button.selected,
.cad-tool-btn.selected {
    background: #0284c7 !important;
    border-color: #38bdf8 !important;
    color: #ffffff !important;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.6);
}

.top-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    cursor: pointer;
}
.top-icon-btn:hover {
    background: #334155;
    color: var(--cyan-neon);
    transform: translateY(-1px);
}

.cad-action-btn {
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid #374151;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    cursor: pointer;
}

.hud-circle-btn {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: #1e293b;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    cursor: pointer;
}
.hud-circle-btn:hover {
    background: #334155;
    color: var(--cyan-neon);
}

/* БОКОВІ КНОПКИ (РЕЙКА СПРАВА) */
.side-tab-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #162032;
    border: 1px solid #293548;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.side-tab-btn:hover {
    background: #223049;
    border-color: var(--cyan-neon);
    transform: scale(1.06);
}
.side-tab-btn.active {
    background: #0f2b48 !important;
    border-color: #0284c7 !important;
    box-shadow: 0 0 14px rgba(2, 132, 199, 0.6) !important;
}

.side-tab-btn .tab-tooltip {
    position: absolute;
    right: 52px;
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    border: 1px solid #334155;
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 60;
}
.side-tab-btn:hover .tab-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(-4px);
}

/* 6 ВИСУВНИХ ПАНЕЛЕЙ (CYBER DRAWERS) */
.cyber-drawer {
    position: fixed;
    right: 48px;
    top: 56px;
    bottom: 0;
    width: 340px;
    background: #111827;
    border-left: 1px solid #1e293b;
    display: none;
    flex-direction: column;
    z-50;
    box-shadow: -15px 0 45px rgba(0, 0, 0, 0.85);
}

@media (min-width: 640px) {
    .cyber-drawer {
        width: 380px;
        right: 56px;
    }
}

.cyber-drawer.drawer-open {
    display: flex !important;
}

.drawer-header {
    padding: 14px 16px;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    shrink-0;
}
.drawer-title {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.drawer-close-btn {
    color: #94a3b8;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.15s;
}
.drawer-close-btn:hover {
    color: #ffffff;
    background: #1e293b;
}

.drawer-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* ФОРМИ ТА ЕЛЕМЕНТИ */
.cyber-input {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 8px 10px;
    color: #f8fafc;
    font-size: 12px;
    outline: none;
    transition: border-color 0.15s;
}
.cyber-input:focus {
    border-color: #0284c7;
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.3);
}

.cyber-checkbox {
    width: 15px;
    height: 15px;
    accent-color: #0284c7;
    cursor: pointer;
}

.cell-desc-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
}
.cell-color-mouth { background: #deb14d; }
.cell-color-producer { background: #15de59; }
.cell-color-mover { background: #60d4ff; }
.cell-color-killer { background: #f82380; }
.cell-color-armor { background: #7230db; }
.cell-color-eye { background: #b6c1ea; }
.cell-color-food { background: #2f7ab7; }
.cell-color-wall { background: #ffffff; }

.cell-btn {
    padding: 8px 6px;
    border-radius: 10px;
    background: #0f172a;
    border: 1px solid #1e293b;
    font-size: 11px;
    font-weight: 700;
    color: #e2e8f0;
    cursor: pointer;
}
.cell-btn:hover {
    border-color: #0284c7;
    background: #1e293b;
}

.mode-select-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.mode-select-btn:hover {
    background: #1e293b;
    color: #38bdf8;
}
.mode-select-btn.active {
    background: #0c4a6e;
    border-color: #0284c7;
    color: #38bdf8;
    box-shadow: 0 0 12px rgba(2, 132, 199, 0.4);
}

.stat-box {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-label {
    font-size: 10px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
}
.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 800;
}

#headless-notification {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #38bdf8;
    font-size: 90px;
    z-index: 25;
}

/* МОДАЛЬНЕ ВІКНО СПІЛЬНОТИ (COMMUNITY CREATIONS) */
.load-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 860px;
    background: #111827;
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.95), 0 0 40px rgba(2, 132, 199, 0.35);
    z-index: 70;
    display: none;
}

.list-container {
    overflow-y: auto;
    padding-right: 6px;
}

.list-item {
    cursor: pointer;
    padding: 9px 12px;
    border-radius: 10px;
    background: #1e293b;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
    transition: all 0.15s ease;
    border: 1px solid #334155;
    display: block;
}

.list-item:hover {
    background: #0c4a6e;
    border-color: #38bdf8;
    color: #ffffff;
    transform: translateX(4px);
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.brain-editor-window {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92%;
    max-width: 780px;
    max-height: 85vh;
    overflow-y: auto;
    background: #111827;
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.9), 0 0 30px rgba(168, 85, 247, 0.3);
    z-index: 80;
    display: none;
}
.brain-editor-window h2 {
    font-size: 16px;
    font-weight: 800;
    color: #c084fc;
    margin-bottom: 8px;
}
.brain-editor-btn {
    background: #2e1065;
    border: 1px solid #7e22ce;
    color: #e9d5ff;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
#close-brain-editor {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #0b0f19; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }



/* Окуляр мікроскопа */
#eyepiece-overlay {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    background: radial-gradient(circle at center, transparent 41%, rgba(3, 7, 15, 0.72) 45%, rgba(3, 7, 15, 0.96) 53%);
}

/* Вибір кольору столу та масштабу */
.table-color-swatch {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    border: 2px solid #334155;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}
.table-color-swatch:hover {
    transform: scale(1.1);
}
.table-color-swatch.active {
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

.table-scale-btn {
    padding: 5px 0;
    border-radius: 8px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s;
}
.table-scale-btn:hover {
    color: #fff;
    border-color: #38bdf8;
}
.table-scale-btn.active {
    background: #0284c7;
    border-color: #38bdf8;
    color: #fff;
    box-shadow: 0 0 10px rgba(2, 132, 199, 0.45);
}

/* Чіткий вигляд кнопок органел у редакторі */
.cell-type.cell-btn {
    border-width: 2px;
    transition: all 0.15s ease;
    color: #f8fafc;
}
.cell-type.cell-btn.selected-cell-brush {
    box-shadow: 0 0 12px rgba(250, 204, 21, 0.55);
    border-color: #facc15 !important;
    transform: translateY(-1px);
}

/* Таблиця редактора мозку */
.brain-editor-window table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 14px;
    font-size: 12px;
}
.brain-editor-window th, .brain-editor-window td {
    border: 1px solid #1e293b;
    padding: 5px 8px;
    text-align: left;
}
.brain-editor-window th {
    background: #0f172a;
    color: #38bdf8;
}
.brain-editor-window select {
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 3px 6px;
}
.decision-map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
}
.remove-state-btn {
    background: #7f1d1d;
    color: #fecaca;
    border: none;
    border-radius: 6px;
    padding: 2px 8px;
    cursor: pointer;
}