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

body {
    overflow: hidden;
    font-family: 'Courier New', monospace;
    background: #000;
    margin: 0;
    padding: 0;
}

/* Splash Screen */
#splashScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100000;
    opacity: 1;
    transition: opacity 1s ease-out;
}

#splashScreen.fade-out {
    opacity: 0;
    pointer-events: none;
}

#splashScreen.hidden {
    display: none;
}

#splashLogo {
    max-width: 400px;
    max-height: 400px;
    width: 80%;
    height: auto;
    object-fit: contain;
    animation: logoFadeIn 1s ease-out;
    margin-bottom: 40px;
}

@keyframes logoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

#passwordForm {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    animation: formFadeIn 1s ease-out 0.5s both;
}

@keyframes formFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#passwordInput {
    width: 300px;
    padding: 12px 20px;
    font-size: 16px;
    background: rgba(42, 42, 62, 0.9);
    border: 2px solid #4a9eff;
    border-radius: 8px;
    color: #fff;
    text-align: center;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: all 0.3s ease;
}

#passwordInput:focus {
    border-color: #6ab0ff;
    box-shadow: 0 0 20px rgba(74, 158, 255, 0.4);
}

#passwordInput::placeholder {
    color: #888;
}

#passwordSubmit {
    width: 300px;
    padding: 12px 20px;
    font-size: 16px;
    background: #4a9eff;
    border: 2px solid #6ab0ff;
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    transition: all 0.3s ease;
}

#passwordSubmit:hover {
    background: #6ab0ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(74, 158, 255, 0.5);
}

#passwordSubmit:active {
    transform: translateY(0);
}

#passwordError {
    color: #ff4444;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    min-height: 20px;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

#controlPanel {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px;
    height: 100vh;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-left: 2px solid #2a2a3e;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
    box-shadow: -2px 0 10px rgba(0,0,0,0.5);
}

#controlPanel.collapsed {
    transform: translateX(calc(100% - 50px));
}

#panelToggle {
    position: fixed;
    left: 0;
    top: 0;
    width: 140px;
    height: 50px;
    background: #2a2a3e;
    border: 2px solid #4a9eff;
    border-radius: 0 0 8px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 10000;
    user-select: none;
    padding: 0 10px;
    text-align: center;
}

#panelToggle:hover {
    background: #4a9eff;
}

#blueprintsToggle {
    position: fixed;
    left: 140px;
    top: 0;
    width: 50px;
    height: 50px;
    background: #2a2a3e;
    border: 2px solid #667eea;
    border-left: none;
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 10000;
    user-select: none;
}

#blueprintsToggle:hover {
    background: #667eea;
}

#settingsToggle {
    position: fixed;
    left: 190px;
    top: 0;
    width: 50px;
    height: 50px;
    background: #2a2a3e;
    border: 2px solid #4a9eff;
    border-left: none;
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    transition: all 0.3s ease;
    z-index: 10000;
    user-select: none;
}

#settingsToggle:hover {
    background: #4a9eff;
}

#settingsModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    justify-content: center;
    align-items: flex-start;
    padding-top: 80px;
}

.settings-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 30px;
    border-radius: 12px;
    border: 2px solid #4a9eff;
    max-width: 500px;
    width: 90%;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Стили скроллбара для настроек */
.settings-content::-webkit-scrollbar {
    width: 10px;
}

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

.settings-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4a9eff 0%, #667eea 100%);
    border-radius: 5px;
    transition: background 0.3s;
}

.settings-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6ab0ff 0%, #764ba2 100%);
}

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

.setting-item label {
    display: block;
    color: #ccc;
    font-size: 13px;
    margin-bottom: 8px;
}

.setting-item input[type="color"] {
    width: 100%;
    height: 45px;
    cursor: pointer;
}

.setting-item input[type="range"] {
    width: 100%;
}

#controlPanel.collapsed .control-section,
#controlPanel.collapsed h2 {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#controlPanel .control-section,
#controlPanel h2 {
    opacity: 1;
    transition: opacity 0.3s ease 0.1s;
}

#controlPanel h2 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 20px;
    text-align: center;
    text-transform: uppercase;
}

.control-section {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(15, 15, 30, 0.5);
    border-radius: 8px;
    border: 1px solid #2a2a3e;
}

.control-section label {
    display: block;
    color: #fff;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.control-section textarea,
.control-section input {
    width: 100%;
    padding: 10px;
    background: #0f0f1e;
    border: 2px solid #2a2a3e;
    border-radius: 4px;
    color: #fff;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.control-section textarea {
    min-height: 120px;
}

.control-section textarea:focus,
.control-section input:focus {
    outline: none;
    border-color: #4a9eff;
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preset-item {
    padding: 10px;
    background: #0f0f1e;
    border: 2px solid #2a2a3e;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-item:hover {
    border-color: #4a9eff;
    background: #1a1a2e;
}

.preset-item.selected {
    border-color: #4a9eff;
    background: #1a2a4e;
}

.preset-color {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
    border: 2px solid #2a2a3e;
}

.preset-name {
    color: #fff;
    font-size: 12px;
    display: inline-block;
    vertical-align: middle;
}

.preset-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    margin-left: 5px;
    color: #fff;
}

.badge-glow {
    background: #ffa500;
}

.badge-glass {
    background: #4a9eff;
}

#gameContainer {
    width: 100vw;
    height: 100vh;
    position: relative;
    background: #000;
}

#gameCanvas {
    width: 100%;
    height: 100%;
}

#ui {
    position: absolute;
    top: 20px;
    right: 370px;
    color: white;
    font-size: 14px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    transition: right 0.3s ease;
}

body.panel-collapsed #ui {
    right: 70px;
}

body.game-mode #ui {
    display: none;
}

#fpsCounter {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #4a9eff;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: bold;
    pointer-events: none;
    font-family: 'Courier New', monospace;
}

#instructions {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    text-align: center;
    font-size: 12px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    max-width: calc(100% - 400px);
    transition: max-width 0.3s ease;
}

body.panel-collapsed #instructions {
    max-width: calc(100% - 100px);
}

.button {
    padding: 8px 16px;
    background: #2a2a3e;
    border: 2px solid #4a9eff;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    margin-top: 10px;
    transition: all 0.2s;
}

.button:hover {
    background: #4a9eff;
}

#loadEditorModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1000;
}

#loadEditorModal[style*="flex"] {
    display: flex !important;
    justify-content: center;
    align-items: center;
}

#loadEditorModal .modal-content {
    background: #1a1a2e;
    padding: 30px;
    border-radius: 8px;
    border: 2px solid #4a9eff;
    max-width: 500px;
    width: 90%;
}

#loadEditorModal input[type="file"] {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    background: #0f0f1e;
    border: 2px solid #2a2a3e;
    border-radius: 4px;
    color: #fff;
}


/* Настройки */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: #2a2a3e;
    outline: none;
    border-radius: 5px;
    height: 6px;
    cursor: pointer;
}

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

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

input[type="color"] {
    border: 2px solid #2a2a3e;
    border-radius: 5px;
    background: #0f0f1e;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

/* ========== BLUEPRINTS SYSTEM ========== */
#blueprintsModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0a0a14;
    z-index: 20000;
    display: flex;
    flex-direction: column;
}

#blueprintsContainer {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Меню нодов слева */
#blueprintsMenu {
    width: 250px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-right: 2px solid #2a2a3e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.blueprints-menu-header {
    padding: 15px;
    border-bottom: 2px solid #2a2a3e;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.blueprints-menu-header h3 {
    color: #fff;
    font-size: 16px;
    margin: 0;
}

.blueprints-close-btn {
    background: #2a2a3e;
    border: 2px solid #4a9eff;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.blueprints-close-btn:hover {
    background: #ef4444;
    border-color: #ef4444;
}

.blueprints-menu-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.node-category {
    margin-bottom: 20px;
}

.node-category-title {
    color: #4a9eff;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #2a2a3e;
}

.node-item {
    padding: 10px;
    background: #0f0f1e;
    border: 2px solid #2a2a3e;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    user-select: none;
}

.node-item:hover {
    border-color: #4a9eff;
    background: #1a1a2e;
    transform: translateX(5px);
}

.node-item:active {
    cursor: grabbing;
}

.node-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.node-name {
    color: #fff;
    font-size: 12px;
    flex: 1;
}

/* Canvas для нодов */
#blueprintsCanvas {
    flex: 1;
    position: relative;
    background: #0f0f1e;
    background-image: 
        linear-gradient(rgba(74, 158, 255, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 158, 255, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    overflow: hidden;
    cursor: default;
}

#blueprintsCanvas.panning {
    cursor: grabbing;
}

#blueprintsCanvas.pan-ready {
    cursor: grab;
}

#blueprintsConnections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connection-line {
    stroke: #4a9eff;
    stroke-width: 2;
    fill: none;
    pointer-events: stroke;
}

.connection-line:hover {
    stroke: #6ab0ff;
    stroke-width: 3;
}

/* Ноды на canvas */
.blueprint-node {
    position: absolute;
    min-width: 200px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border: 2px solid #2a2a3e;
    border-radius: 8px;
    cursor: move;
    user-select: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

.blueprint-node.selected {
    border-color: #4a9eff;
    box-shadow: 0 0 20px rgba(74, 158, 255, 0.5);
}

.blueprint-node-header {
    padding: 10px 15px;
    background: rgba(15, 15, 30, 0.5);
    border-bottom: 1px solid #2a2a3e;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: move;
}

.blueprint-node-icon {
    font-size: 16px;
}

.blueprint-node-title {
    color: #fff;
    font-size: 13px;
    font-weight: bold;
    flex: 1;
}

.blueprint-node-close {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s;
}

.blueprint-node-close:hover {
    background: #ef4444;
    color: #fff;
}

.blueprint-node-body {
    padding: 10px;
}

.blueprint-node-inputs,
.blueprint-node-outputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.node-port {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px;
    border-radius: 4px;
    transition: background 0.2s;
}

.node-port:hover {
    background: rgba(74, 158, 255, 0.1);
}

.node-port-input {
    flex-direction: row;
}

.node-port-output {
    flex-direction: row-reverse;
}

.port-circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #4a9eff;
    background: #1a1a2e;
    cursor: crosshair;
    transition: all 0.2s;
    flex-shrink: 0;
}

.port-circle:hover {
    background: #4a9eff;
    transform: scale(1.3);
}

.port-circle.input {
    border-color: #4ade80;
}

.port-circle.input:hover {
    background: #4ade80;
}

.port-circle.output {
    border-color: #4a9eff;
}

.port-label {
    color: #ccc;
    font-size: 11px;
    flex: 1;
}

.node-port-input .port-label {
    text-align: left;
}

.node-port-output .port-label {
    text-align: right;
}

/* Textarea для текстовых нодов */
.blueprint-node-textarea-container {
    margin-top: 10px;
    margin-bottom: 5px;
}

.blueprint-node-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    background: rgba(15, 15, 30, 0.8);
    border: 1px solid #2a2a3e;
    border-radius: 4px;
    color: #fff;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.blueprint-node-textarea:focus {
    border-color: #4a9eff;
    box-shadow: 0 0 8px rgba(74, 158, 255, 0.3);
}

.blueprint-node-textarea::placeholder {
    color: #666;
}

/* Скроллбар для меню */
.blueprints-menu-content::-webkit-scrollbar {
    width: 8px;
}

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

.blueprints-menu-content::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4a9eff 0%, #667eea 100%);
    border-radius: 4px;
}

.blueprints-menu-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6ab0ff 0%, #764ba2 100%);
}

/* Контекстное меню для создания нодов */
#blueprintsContextMenu {
    font-family: 'Courier New', monospace;
}

.context-menu-category {
    margin-bottom: 15px;
}

.context-menu-category-title {
    color: #4a9eff;
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid #2a2a3e;
}

.context-menu-item {
    padding: 8px 10px;
    background: #0f0f1e;
    border: 1px solid #2a2a3e;
    border-radius: 4px;
    margin-bottom: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.context-menu-item:hover {
    background: #1a1a2e;
    border-color: #4a9eff;
    transform: translateX(3px);
}

/* Скроллбар для контекстного меню */
#blueprintsContextMenu::-webkit-scrollbar {
    width: 8px;
}

#blueprintsContextMenu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#blueprintsContextMenu::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #4a9eff 0%, #667eea 100%);
    border-radius: 4px;
}

#blueprintsContextMenu::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #6ab0ff 0%, #764ba2 100%);
}
