body { background: #2c3e50; }

#builderRoot {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-columns: 64px 1fr 280px;
    grid-template-areas: "toolbar canvas sidebar";
}

/* Canvas area */
#canvasArea {
    grid-area: canvas;
    position: relative;
    overflow: hidden;
    background: #87CEEB;
}
#canvasArea canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }

/* Toolbar */
#toolbar {
    grid-area: toolbar;
    background: #1f2d3d;
    color: #fff;
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    overflow-y: auto;
    border-right: 1px solid #0e1822;
}
#toolbar .tool-btn {
    width: 50px; height: 50px;
    border-radius: 10px;
    background: #2d3e50;
    color: #cbd5e0;
    border: 2px solid transparent;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    padding: 4px;
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.1;
}
#toolbar .tool-btn:hover { background: #3a526b; }
#toolbar .tool-btn.active { border-color: #4ECDC4; background: #3a526b; }
#toolbar .divider { width: 40px; height: 1px; background: #34495e; margin: 4px 0; }

#toolbar .tool-glyph {
    display: block;
    font-size: 22px;
    line-height: 1;
    margin-bottom: 2px;
}

[data-tool-options] {
    display: none;
    background: #2d3e50;
    border-radius: 8px;
    padding: 8px;
    margin-top: 4px;
    width: 50px;
    color: #cbd5e0;
    font-size: 11px;
    text-align: center;
}
[data-tool-options] input[type=color] {
    width: 40px; height: 30px; padding: 0; border: none; background: none; cursor: pointer;
}
[data-tool-options] input[type=range] { width: 100%; }
[data-tool-options] label { display: block; margin: 4px 0; }
[data-tool-options] .place-btn {
    display: block; width: 100%; padding: 6px 0;
    margin: 3px 0;
    border-radius: 6px;
    background: #3a526b; color: #fff;
    border: 2px solid transparent;
    font-size: 10px; cursor: pointer;
    box-shadow: none; text-transform: none; letter-spacing: 0;
}
[data-tool-options] .place-btn:hover { background: #4a6580; }
[data-tool-options] .place-btn.active { border-color: #4ECDC4; }
[data-tool-options] input[type=file] { font-size: 10px; color: #cbd5e0; }
[data-tool-options] .image-status { font-size: 10px; color: #95E1D3; word-break: break-all; }

/* Sidebar */
#sidebar {
    grid-area: sidebar;
    background: #34495e;
    color: #ecf0f1;
    padding: 16px;
    overflow-y: auto;
    border-left: 1px solid #1f2d3d;
    display: flex; flex-direction: column; gap: 12px;
    font-family: sans-serif;
}
#sidebar h2 { font-size: 14px; color: #95E1D3; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; font-family: 'Comic Sans MS', sans-serif; }
#sidebar input[type=text],
#sidebar input[type=number] {
    width: 100%;
    background: #2c3e50;
    border: 1px solid #4a6580;
    color: #fff;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
}
#sidebar input[type=range] { width: 100%; }
#sidebar .row { display: flex; gap: 8px; align-items: center; }
#sidebar .small { font-size: 11px; color: #bdc3c7; }
#sidebar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
#sidebar .actions button {
    flex: 1 1 60px;
    padding: 8px 6px;
    border-radius: 6px;
    font-size: 12px;
    border: none; cursor: pointer;
    box-shadow: none; text-transform: none; letter-spacing: 0;
    font-family: sans-serif;
}
#saveBtn  { background: #4ECDC4; color: #1f2d3d; font-weight: bold; }
#newBtn   { background: #FFE66D; color: #1f2d3d; }
#playBtn  { background: #FF6B6B; color: #fff; }
#refreshList { background: #95A5A6; color: #1f2d3d; }

#mapsList {
    background: #2c3e50;
    border-radius: 6px;
    padding: 6px;
    max-height: 240px;
    overflow-y: auto;
    font-size: 12px;
}
#mapsList .empty { color: #7f8c8d; text-align: center; padding: 12px; }
.map-row {
    display: flex; align-items: center; gap: 4px;
    padding: 6px;
    border-bottom: 1px solid #34495e;
}
.map-row:last-child { border-bottom: none; }
.map-name { flex: 1; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-meta { font-size: 10px; color: #95A5A6; }
.map-row button {
    padding: 4px 8px;
    border: none; border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    box-shadow: none; text-transform: none; letter-spacing: 0;
}
.map-load { background: #4ECDC4; color: #1f2d3d; }
.map-del  { background: #FF6B6B; color: #fff; padding: 4px 8px; }

#statusBar {
    margin-top: auto;
    padding: 6px 8px;
    background: #2c3e50;
    border-radius: 6px;
    font-size: 11px;
    color: #95E1D3;
    min-height: 22px;
}
#statusBar.error { color: #FF6B6B; }

/* Preview overlay */
#previewOverlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
}
#previewOverlay canvas { width: 100%; height: 100%; }
#previewOverlay .close-preview {
    position: absolute;
    top: 16px; right: 16px;
    padding: 8px 18px;
    background: #FF6B6B; color: #fff;
    border: none; border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

@media (max-width: 720px) {
    #builderRoot {
        grid-template-columns: 56px 1fr;
        grid-template-rows: 1fr auto;
        grid-template-areas: "toolbar canvas" "sidebar sidebar";
    }
    #sidebar { max-height: 40vh; }
}
