body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: sans-serif;
}

#editor-container {
    width: 100%;
    height: 100%;
    /* Gradient from dark blue up high to light blue down low */
    background: linear-gradient(to bottom, #009dff, #9fb6e0);
}

#left-panel {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 260px;
    background: #222;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
    z-index: 20;
}

#left-panel.closed {
    transform: translateX(-100%);
}

#toggle-left-panel {
    position: absolute;
    right: -30px;
    top: 10px;
    width: 30px;
    height: 40px;
    background: #222;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 0 5px 5px 0;
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

#left-panel-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 100%;
    box-sizing: border-box;
    padding: 10px;
    gap: 0;
}

.left-split-section {
    display: flex;
    flex-direction: column;
    min-height: 80px;
    overflow: hidden;
}

#left-properties-section {
    flex: 1 1 58%;
}

#left-layers-section {
    flex: 1 1 42%;
}

#left-panel-divider {
    height: 8px;
    margin: 8px 0;
    border-radius: 6px;
    background: linear-gradient(to right, #30353d, #48515c, #30353d);
    cursor: row-resize;
    flex: 0 0 auto;
}

.left-section-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    background: #1d1d1d;
    border: 1px solid #343434;
    border-radius: 8px;
    padding: 8px;
}

.layer-toolbar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.layer-toolbar .tool-btn {
    width: 100%;
}

#layers-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.layer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: #2a2a2a;
    border: 1px solid transparent;
    color: #e9eef4;
    cursor: pointer;
}

.layer-row.active {
    border-color: #00ffcc;
    background: #1f3331;
}

.layer-row.dragging {
    opacity: 0.55;
}

.layer-row.drop-before {
    box-shadow: inset 0 2px 0 #00ffcc;
}

.layer-row.drop-after {
    box-shadow: inset 0 -2px 0 #00ffcc;
}

.layer-name {
    font-size: 13px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.layer-main {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
}

.layer-overlay-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(115, 210, 255, 0.2);
    color: #73d2ff;
    border: 1px solid rgba(115, 210, 255, 0.8);
    flex: 0 0 auto;
    font-size: 11px;
}

.layer-name-input {
    flex: 1 1 auto;
    min-width: 0;
    background: #1a1a1a;
    color: #e9eef4;
    border: 1px solid #00ffcc;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 13px;
}

.layer-hide-btn {
    border: none;
    background: #3a3a3a;
    color: #dce4ef;
    width: 28px;
    height: 28px;
    border-radius: 5px;
    cursor: pointer;
}

.layer-hide-btn:hover {
    background: #505050;
}

.layer-context-menu {
    position: fixed;
    z-index: 100100;
    min-width: 180px;
    background: rgba(18, 24, 30, 0.97);
    border: 1px solid rgba(130, 221, 255, 0.38);
    border-radius: 8px;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.44);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.layer-context-menu button {
    border: none;
    background: transparent;
    color: #d9e9f4;
    border-radius: 6px;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
}

.layer-context-menu button:hover {
    background: rgba(116, 206, 255, 0.2);
}

.layer-context-menu button.convert-only {
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    margin-top: 4px;
    padding-top: 9px;
}

.overlay-convert-panel {
    position: fixed;
    left: 50%;
    top: 14px;
    transform: translateX(-50%);
    z-index: 100090;
    min-width: 420px;
    max-width: min(86vw, 620px);
    background: rgba(14, 20, 26, 0.96);
    border: 1px solid rgba(115, 210, 255, 0.48);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
    padding: 12px 14px;
    color: #dbe9f4;
    font-family: 'Segoe UI', Tahoma, sans-serif;
}

.overlay-convert-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8ccce8;
    margin-bottom: 10px;
    font-weight: 700;
}

.overlay-convert-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
}

.overlay-convert-row label {
    min-width: 76px;
    font-size: 12px;
    color: #bfd5e3;
}

#overlay-convert-resolution {
    flex: 1;
}

#overlay-convert-resolution-value {
    min-width: 44px;
    text-align: right;
    font-size: 12px;
    color: #ecf8ff;
    font-weight: 700;
}

.overlay-convert-row.meta-row {
    justify-content: space-between;
    color: #9ec7de;
    font-size: 12px;
}

.overlay-convert-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.overlay-convert-actions button {
    border: 1px solid #4f6778;
    background: #22303b;
    color: #def0fb;
    border-radius: 6px;
    padding: 7px 12px;
    cursor: pointer;
    font-weight: 600;
}

.overlay-convert-actions button:hover {
    background: #2f4250;
}

#overlay-convert-apply {
    border-color: #2f8cb8;
    background: #145577;
}

#overlay-convert-apply:hover {
    background: #1b6791;
}

canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#right-panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 220px;
    background: #222;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 5px rgba(0,0,0,0.5);
    overflow-y: auto;
}

#right-panel.closed {
    transform: translateX(100%);
}

#toggle-panel {
    position: absolute;
    left: -30px;
    top: 10px;
    width: 30px;
    height: 40px;
    background: #222;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px 0 0 5px;
    box-shadow: -2px 0 5px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-content {
    display: flex;
    flex-direction: column;
    padding: 10px 8px;
    align-items: center;
    height: 100%;
    min-height: 100%;
    box-sizing: border-box;
}

.sidebar-section {
    width: 100%;
    margin-bottom: 10px;
}

.section-title {
    color: #cfd4da;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 8px 4px;
}

.toolbar {
    display: grid;
    grid-template-columns: repeat(4, 40px);
    justify-content: center;
    gap: 10px;
}

.object-count-display {
    width: 190px;
    margin: 0 0 10px 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: #2b2f35;
    border: 1px solid #3e4650;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
}

.object-count-label {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #aeb7c2;
    font-weight: 700;
}

.object-count-value {
    font-size: 15px;
    color: #e8edf3;
    font-weight: 800;
}

.object-count-display.warn .object-count-value {
    color: #ffa341;
}

.object-count-display.danger .object-count-value {
    color: #ff5c5c;
}

.tool-btn, #export-btn {
    width: 40px;
    height: 40px;
    font-size: 20px;
    border: 2px solid transparent;
    background: #444;
    color: white;
    cursor: pointer;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.tool-btn:hover, #export-btn:hover {
    background: #555;
}

.tool-btn.active {
    border-color: #00ffcc;
    background: #333;
}

#export-modal, #settings-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#image-overlay-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#export-modal.hidden, #settings-modal.hidden, #image-overlay-modal.hidden, #layer-context-menu.hidden, #overlay-convert-panel.hidden {
    display: none;
}

.modal-content {
    background: #333;
    color: white;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.modal-content h3 {
    margin: 0;
}

#json-output {
    width: 100%;
    height: 300px;
    font-family: monospace;
    resize: none;
    background: #222;
    color: #00ffcc;
    border: 1px solid #555;
    padding: 10px;
    box-sizing: border-box;
}

#close-modal, #close-settings-modal {
    align-self: flex-end;
    padding: 8px 16px;
    background: #555;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#close-modal:hover, #close-settings-modal:hover {
    background: #666;
}

#settings-modal label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
}

#settings-modal input {
    background: #222;
    color: #00ffcc;
    border: 1px solid #555;
    padding: 5px;
    border-radius: 4px;
}

.image-overlay-content {
    max-width: 520px;
}

.image-overlay-subtitle {
    margin: 0;
    color: #b8c2cf;
    font-size: 14px;
}

#image-overlay-dropzone {
    min-height: 150px;
    border: 2px dashed #4b5969;
    border-radius: 10px;
    background: #252a30;
    color: #d8e5f2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    text-align: center;
    padding: 18px;
}

#image-overlay-dropzone i {
    font-size: 28px;
    color: #73d2ff;
}

#image-overlay-dropzone:hover,
#image-overlay-dropzone.drag-over,
#image-overlay-dropzone:focus {
    border-color: #73d2ff;
    background: #263440;
    outline: none;
}

.image-overlay-actions {
    display: flex;
    justify-content: flex-end;
}

#image-overlay-cancel-btn {
    padding: 8px 16px;
    background: #555;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#image-overlay-cancel-btn:hover {
    background: #666;
}

/* Properties Panel (inside left panel) */
#properties-panel {
    background: #2a2a2a;
    padding: 8px;
    border-radius: 8px;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

#properties-panel.closed {
    display: none;
}

#properties-panel label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 14px;
    font-weight: bold;
}

#prop-blockColor {
    background: transparent;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    width: 40px;
    height: 30px;
}

.prop-color-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#prop-color-picker-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2e2e2e;
    color: #d7f8f0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#prop-color-picker-btn:hover {
    background: #3a3a3a;
}

#prop-color-picker-btn.active {
    border-color: #73d2ff;
    color: #73d2ff;
    background: #1f2a33;
}

#properties-fields {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
}

#movement-details {
    border: 1px solid #404040;
    border-radius: 6px;
    padding: 6px;
    background: #252525;
}

#movement-details summary {
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    font-weight: bold;
    color: #cfd4da;
}

#movement-fields {
    display: flex;
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

#properties-fields input[type="number"],
#properties-fields select,
#movement-fields input[type="number"],
#movement-fields select {
    background: #222;
    color: #00ffcc;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 4px 6px;
    width: 86px;
}

#properties-fields input[type="checkbox"],
#movement-fields input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #00ffcc;
}

#mobile-notice {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #121212;
    z-index: 99999;
    color: white;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: center;
    padding: 30px;
}

#mobile-notice i {
    font-size: 6rem;
    color: #ff4444;
    margin-bottom: 25px;
}

#mobile-notice h2 {
    font-size: 2rem;
    margin-bottom: 15px;
    margin-top: 0;
}

#mobile-notice p {
    font-size: 1.2rem;
    line-height: 1.5;
    color: #ccc;
    max-width: 400px;
}

@media (max-width: 900px) and (pointer: coarse), (max-width: 600px) {
    #mobile-notice {
        display: flex;
    }
    #editor-container, #right-panel, #left-panel, #tutorial-btn, .bottom-tools, #properties-panel {
        display: none !important;
    }
}
