:root {
    --bg-main: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-box: #1a2333;
    --accent-orange: #f97316;
    --accent-gold: #f59e0b;
    --border-gold: #d97706;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --border-thick: 10px;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

html { 
    scroll-behavior: smooth; 
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* === БОКОВАЯ ПАНЕЛЬ (ОГЛАВЛЕНИЕ) === */
.sidebar { 
    width: 320px; 
    background-color: var(--bg-sidebar); 
    border-right: 1px solid #334155; 
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    flex-shrink: 0; 
}

.sidebar-header { 
    padding: 20px; 
    border-bottom: 1px solid #334155; 
}

.back-btn { 
    color: var(--accent-orange); 
    text-decoration: none; 
    font-weight: bold; 
    font-size: 18px; 
    margin-bottom: 10px; 
    display: inline-block; 
    transition: color 0.2s;
}

.back-btn:hover { 
    color: var(--accent-gold); 
}

.sidebar-title { 
    font-family: 'Neucha', sans-serif; 
    font-size: 28px; 
    color: #ffffff; 
    letter-spacing: 1px; 
}

.toc-container { 
    padding: 20px 10px 30px 20px; 
    overflow-y: auto; 
    flex-grow: 1; 
}

.toc-container::-webkit-scrollbar { 
    width: 6px; 
}

.toc-container::-webkit-scrollbar-thumb {
    background-color: #475569;
    border-radius: 3px;
}

.toc-list { 
    list-style: none; 
    padding-left: 0; 
}

.toc-list a { 
    display: block; 
    color: var(--text-muted); 
    text-decoration: none; 
    padding: 6px 0; 
    font-size: 16px; 
    transition: color 0.2s, padding-left 0.2s; 
}

.toc-list a:hover { 
    color: var(--accent-gold); 
    padding-left: 4px; 
}

.level-1, .level-1-1 { 
    font-weight: 600; 
    margin-top: 15px; 
    color: #ffffff !important; 
    font-size: 18px; 
}

.level-1:hover { 
    color: var(--accent-orange) !important; 
}

.level-2 { 
    margin-left: 20px; 
    font-size: 16px; 
}

/* === ОСНОВНАЯ ОБЛАСТЬ (КОНТЕНТ) === */
.content-area { 
    flex-grow: 1; 
    padding: 40px 60px; 
    overflow-y: auto; 
    height: 100%;
}

.content-area::-webkit-scrollbar { 
    width: 8px; 
}

.content-area::-webkit-scrollbar-thumb {
    background-color: #334155;
    border-radius: 4px;
}

h1 {
    font-family: 'Neucha', sans-serif;
    font-size: 48px;
    color: var(--accent-orange);
    border-bottom: 2px solid #334155;
    padding-bottom: 10px;
    margin-bottom: 30px;
}

/* === КОНСТРУКТОР СПРАЙТОВ === */
.constructor-box {
    display: flex;
    flex-direction: row;
    background-color: var(--bg-box);
    border: var(--border-thick) solid var(--accent-gold);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 60px rgba(249, 115, 22, 0.3);
    max-width: 1080px;
    width: 100%;
}

.left-column {
    display: flex;
    flex-direction: column;
    flex: 0 0 250px;
    background-color: var(--bg-box);
    border-right: var(--border-thick) solid var(--accent-gold);
}

.left-panel {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.option-group {
    padding: 15px;
    border-bottom: var(--border-thick) solid var(--accent-gold);
}

.option-group:last-child {
    border-bottom: none;
}

.option-label {
    color: var(--accent-gold);
    font-size: 28px;
    font-family: 'Neucha', sans-serif;
    margin-bottom: 8px;
    display: block;
}

.option-select {
    background-color: #0c1426;
    color: var(--text-main);
    padding: 8px;
    font-size: 16px;
    width: 100%;
    border: 1px solid #334155;
    border-radius: 4px;
}

.option-select:disabled { 
    opacity: 0.6; 
    cursor: not-allowed;
}

.accessory-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 16px;
}

.code-btn {
    background: #1a2333;
    color: white;
    border: none;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    border-top: var(--border-thick) solid var(--accent-gold);
    transition: background-color 0.2s;
}

.code-btn:hover:not(:disabled) { 
    background: var(--accent-orange); 
}

.code-btn:disabled { 
    background: #475569; 
    cursor: not-allowed; 
}

.right-column {
    flex: 1;
    background: #1a2333;
    display: flex;
    flex-direction: column;
}

.preview-area {
    flex: 1;
    min-height: 500px;
    background-color: #1a2333;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sprite-layers {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    object-position: bottom center;
    image-rendering: crisp-edges;
    pointer-events: none;
}

#layer-accessory-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: clamp(18px, 4vw, 26px);
    text-align: center;
    padding: 20px;
    z-index: 1;
}

/* === ЭЛЕМЕНТЫ ДЛЯ МОБИЛЬНОГО МЕНЮ === */
.mobile-menu-btn, .sidebar-overlay {
    display: none;
}

/* === АДАПТИВНОСТЬ (МОБИЛЬНАЯ ВЕРСИЯ) === */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 1000;
        background-color: var(--accent-orange);
        color: #ffffff;
        border: none;
        padding: 12px 20px;
        border-radius: 50px;
        font-weight: bold;
        font-size: 16px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
        cursor: pointer;
        transition: transform 0.2s, background-color 0.2s;
    }

    .mobile-menu-btn:active { 
        transform: scale(0.95); 
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        box-shadow: 4px 0 15px rgba(0,0,0,0.5);
    }

    .sidebar.active { 
        transform: translateX(0); 
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.6);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease-in-out;
    }

    .sidebar-overlay.active {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .content-area {
        padding: 20px 16px 80px 16px;
        height: auto;
        overflow-y: visible;
    }

    h1 {
        font-size: 34px;
        margin-bottom: 20px;
    }

    .constructor-box {
        flex-direction: column-reverse; /* На мобильных превью будет сверху, а выпадающие списки — снизу */
    }

    .left-column {
        flex: none;
        width: 100%;
        border-right: none;
        border-top: var(--border-thick) solid var(--accent-gold);
    }

    .preview-area {
        min-height: 50vh;
    }
}