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

body {
    background: #0e120a;
    color: #c8c0a8;
    font-family: 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Toolbar ── */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(20,24,16,0.98);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    z-index: 100;
    flex-shrink: 0;
    gap: 8px;
}
.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
}
.toolbar-center { flex: 1; justify-content: center; }
.toolbar label { font-size: 11px; color: #888; white-space: nowrap; }
.toolbar input[type="text"], .toolbar select {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: #ddd;
    padding: 3px 8px;
    font-size: 12px;
}
.toolbar input[type="text"] { width: 140px; }
.toolbar select { width: 100px; }
.toolbar input[type="checkbox"] { accent-color: #7ab83a; }

.separator {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.1);
    margin: 0 4px;
}

.btn-back {
    text-decoration: none;
    color: #e8d480;
    font-weight: 700;
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid rgba(220,160,40,0.3);
    border-radius: 4px;
    background: rgba(220,160,40,0.08);
    transition: all 0.2s;
}
.btn-back:hover { background: rgba(220,160,40,0.2); }

.tb-btn {
    padding: 4px 10px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    color: #c8c0a8;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.tb-btn:hover { background: rgba(255,255,255,0.12); }
.tb-btn-primary { border-color: rgba(120,180,60,0.3); color: #a8d860; }
.tb-btn-primary:hover { background: rgba(120,180,60,0.15); }
.tb-btn-accent { border-color: rgba(220,160,40,0.4); color: #e8d480; }
.tb-btn-accent:hover { background: rgba(220,160,40,0.15); }

.tb-btn-sm {
    width: 26px; height: 26px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    color: #c8c0a8;
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.tb-btn-sm:hover { background: rgba(255,255,255,0.12); }

#zoomLevel { font-size: 12px; min-width: 40px; text-align: center; }

/* ── Main layout ── */
.editor-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.panel {
    width: 200px;
    flex-shrink: 0;
    background: rgba(16,20,12,0.98);
    border-right: 1px solid rgba(255,255,255,0.06);
    overflow-y: auto;
    padding: 10px;
}
.panel:last-child {
    border-right: none;
    border-left: 1px solid rgba(255,255,255,0.06);
}
.panel h3 {
    font-size: 11px;
    letter-spacing: 2px;
    color: #888;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* ── Tool buttons ── */
.tool-group { margin-bottom: 12px; }
.tool-group-title {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.tool-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: none;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}
.tool-btn:hover { background: rgba(255,255,255,0.06); color: #ddd; }
.tool-btn.selected {
    background: rgba(120,180,60,0.12);
    border-color: rgba(120,180,60,0.3);
    color: #c8e8a0;
}

.tool-icon {
    width: 18px; height: 18px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}
.tile-empty { background: #a89860; border: 1px solid #8a7a50; }
.tile-grass { background: #6a9a2e; border: 1px solid #4a7a1a; }
.tile-road { background: #c4a858; border: 1px solid #aa9040; position: relative; }
.tile-road::after { content: ''; position: absolute; top: 4px; bottom: 4px; left: 6px; right: 6px; border-left: 2px solid #b89848; border-right: 2px solid #b89848; }
.tile-wall { background: #6b5335; border: 1px solid #4a3820; }
.tile-destr { background: #c2a059; border: 1px dashed #8b6914; }
.tile-house { background: #7a6a5a; border: 1px solid #5a4a3a; position: relative; }
.tile-house::after { content: ''; position: absolute; top: 1px; left: 2px; right: 2px; height: 5px; background: #9a4a3a; border-radius: 1px; }
.tile-bush { background: #3a7a2a; border: 1px solid #2a5a1a; border-radius: 50%; }

.obj-fence-h {
    background: #8a7050;
    border: 1px solid #6a5030;
    border-radius: 2px;
    position: relative;
}
.obj-fence-h::after {
    content: '';
    position: absolute;
    top: 50%; left: 3px; right: 3px;
    height: 2px;
    background: #b09060;
    transform: translateY(-50%);
}
.obj-fence-v {
    background: #8a7050;
    border: 1px solid #6a5030;
    border-radius: 2px;
    position: relative;
}
.obj-fence-v::after {
    content: '';
    position: absolute;
    left: 50%; top: 3px; bottom: 3px;
    width: 2px;
    background: #b09060;
    transform: translateX(-50%);
}
.obj-barrel {
    background: radial-gradient(circle, #5a4020 40%, #7a5a3a 100%);
    border: 1px solid #5a4020;
    border-radius: 50%;
}
.obj-crate {
    background: #9a8050;
    border: 1px solid #7a6030;
    position: relative;
}
.obj-crate::after {
    content: '×';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    line-height: 1;
    color: #6a5030;
}
.obj-tree {
    background: radial-gradient(circle, #2a5a18 30%, #3a7a2a 100%);
    border: 1px solid #2a5a18;
    border-radius: 50%;
}

.obj-spawn { background: #ffdd44; border-radius: 50%; border: 2px solid #aa9922; }
.obj-spawn-r { background: #ff5555; border-radius: 50%; border: 2px solid #aa2222; }
.obj-spawn-b { background: #5588ff; border-radius: 50%; border: 2px solid #2255aa; }
.obj-spawn-g { background: #55cc55; border-radius: 50%; border: 2px solid #228822; }
.obj-capture { background: #fff; border: 2px solid #aaa; position: relative; }
.obj-capture::after {
    content: '⚑';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
}
.obj-bonus { background: linear-gradient(135deg, #44cc44, #228822); border-radius: 3px; border: 1px solid #116611; }
.obj-gold { background: linear-gradient(135deg, #ffdd44, #cc9900); border-radius: 3px; border: 1px solid #aa7700; }
.obj-turret-r { background: radial-gradient(circle, #ff5555 40%, #882222 100%); border-radius: 50%; border: 2px solid #aa3333; position: relative; }
.obj-turret-r::after { content: '⊕'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 11px; color: #fff; }
.obj-turret-b { background: radial-gradient(circle, #5588ff 40%, #223388 100%); border-radius: 50%; border: 2px solid #3355aa; position: relative; }
.obj-turret-b::after { content: '⊕'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 11px; color: #fff; }

.mode-btn { font-size: 12px; }

.brush-row {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.brush-row input[type="range"] { flex: 1; accent-color: #7ab83a; min-width: 60px; }
#brushSizeVal { font-size: 12px; min-width: 16px; text-align: center; }

.shape-btn {
    width: 26px; height: 26px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    background: none;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    padding: 0;
}
.shape-btn:hover { background: rgba(255,255,255,0.06); }
.shape-btn.selected {
    background: rgba(120,180,60,0.12);
    border-color: rgba(120,180,60,0.3);
    color: #c8e8a0;
}

/* ── Canvas area ── */
.canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0a0d08;
    cursor: crosshair;
}
#editorCanvas {
    position: absolute;
    top: 0; left: 0;
}
.canvas-info {
    position: absolute;
    bottom: 8px; left: 8px;
    background: rgba(0,0,0,0.7);
    color: #aaa;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    pointer-events: none;
}

/* ── Right panel ── */
.prop-group {
    margin-bottom: 12px;
}
.prop-group label {
    display: block;
    font-size: 11px;
    color: #888;
    margin: 4px 0 2px;
}
.prop-group input[type="number"] {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: #ddd;
    padding: 4px 8px;
    font-size: 12px;
}

.stats { font-size: 12px; line-height: 1.8; }
.stats span { color: #e8d480; font-weight: 700; }

.validation { font-size: 11px; line-height: 1.6; }
.valid-ok { color: #6a6; }
.valid-err { color: #d44; }
.valid-warn { color: #da4; }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal {
    background: rgba(14,18,10,0.98);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 20px 28px;
    min-width: 360px;
    max-width: 500px;
    max-height: 70vh;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
}
.modal h3 {
    font-size: 16px;
    color: #e8d480;
    margin-bottom: 12px;
    letter-spacing: 1px;
}
.modal label {
    display: block;
    font-size: 12px;
    color: #888;
    margin: 8px 0 3px;
}
.modal input, .modal select {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: #ddd;
    padding: 6px 10px;
    font-size: 13px;
}
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}
.modal-list {
    max-height: 300px;
    overflow-y: auto;
}
.modal-list .map-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.15s;
}
.modal-list .map-item:hover {
    background: rgba(120,180,60,0.08);
    border-color: rgba(120,180,60,0.2);
}
.map-item-name { font-size: 13px; color: #ddd; }
.map-item-meta { font-size: 11px; color: #666; }

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 50px; right: 16px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.toast {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    animation: toastIn 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.success { background: rgba(60,140,40,0.9); color: #fff; }
.toast.error { background: rgba(180,40,30,0.9); color: #fff; }
.toast.info { background: rgba(40,80,160,0.9); color: #fff; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================================
 * ── Bush size flyout ── */
.tool-btn[data-tool="bush"] { position: relative; padding-right: 18px; }
.bush-flyout-arrow {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 10px;
    pointer-events: none;
}
.tool-btn[data-tool="bush"]:hover .bush-flyout-arrow { color: #c8e8a0; }

.tool-flyout {
    display: none;
    position: fixed;
    z-index: 150;
    background: rgba(20,24,16,0.98);
    border: 1px solid rgba(120,180,60,0.4);
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    min-width: 180px;
}
.tool-flyout.open { display: block; }
.flyout-title {
    font-size: 11px;
    color: #c8e8a0;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
    text-align: center;
}
.flyout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}
.size-btn {
    background: rgba(40,46,30,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 5px;
    padding: 8px 6px;
    color: #c8c0a8;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.size-btn:hover { background: rgba(120,180,60,0.12); border-color: rgba(120,180,60,0.4); }
.size-btn.selected {
    background: rgba(120,180,60,0.18);
    border-color: rgba(120,180,60,0.6);
    color: #c8e8a0;
}
.size-preview {
    display: block;
    background: radial-gradient(ellipse at 35% 30%, #5a8838, #2a5818 70%);
    border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.size-preview.size-1 { width: 16px; height: 16px; }
.size-preview.size-2 { width: 22px; height: 22px; }
.size-preview.size-3 { width: 28px; height: 28px; }
.size-label { font-size: 10px; letter-spacing: 0.5px; font-weight: 600; }

/* ============================================================
 * ── Status bar ── */
.status-bar {
    height: 26px;
    background: rgba(14,18,10,0.98);
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 14px;
    font-size: 11px;
    color: #888;
    flex-shrink: 0;
}
.sb-section { display: flex; align-items: center; gap: 5px; padding: 0 4px; }
.sb-label { color: #6a6a5a; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.sb-value { color: #e8d480; font-weight: 600; }
.sb-mono { font-family: 'Courier New', monospace; color: #88aacc; }
.sb-spacer { flex: 1; }
.sb-section-bush .sb-value { color: #88dd66; }
.sb-help-btn {
    background: transparent;
    border: 1px solid rgba(220,160,40,0.3);
    color: #e8d480;
    padding: 2px 10px;
    font-size: 10px;
    border-radius: 3px;
    cursor: pointer;
    letter-spacing: 0.5px;
}
.sb-help-btn:hover { background: rgba(220,160,40,0.12); border-color: rgba(220,160,40,0.6); }

/* ============================================================
 * ── Quick-help bubble ── */
.quick-help {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20,24,16,0.98);
    border: 1px solid rgba(220,160,40,0.4);
    border-radius: 8px;
    padding: 18px 24px;
    box-shadow: 0 6px 30px rgba(0,0,0,0.6);
    z-index: 250;
    min-width: 320px;
}
.quick-help.visible { display: block; }
.quick-help .qh-title {
    font-size: 13px;
    color: #e8d480;
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}
.quick-help .qh-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 12px;
    font-size: 12px;
}
.quick-help kbd {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 3px;
    padding: 2px 6px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #ffe890;
    min-width: 36px;
    text-align: center;
}
.quick-help span { color: #c8c0a8; }
