body {
    margin: 0;
    font-family: sans-serif;
    overflow: hidden;
    background-color: #1a1d21;
    color: #cdd1d5;
    --sidebar-width-desktop: 300px;
    --sidebar-height-mobile: 200px; /* Should this be dynamic? */
    --accent-color: #4CAF50;
    --border-color: #444;
    --font-main: Arial, sans-serif;
}

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

.sidebar {
    background-color: #282c34;
    overflow-y: auto;
    transition: transform 0.3s ease-in-out, width 0.3s ease-in-out, height 0.3s ease-in-out;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.sidebar-content {
    padding: 15px;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-toggle-btn {
    position: fixed;
    z-index: 20;
    padding: 10px 12px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 0 5px 5px 0;
    transition: left 0.3s ease-in-out, top 0.3s ease-in-out;
}

.main-content {
    flex-grow: 1;
    position: relative;
    display: flex;
    overflow: hidden;
}

#mainWorldCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.tile-info-overlay {
    position: absolute;
    top: 10px;
    left: 50px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.9em;
    z-index: 5;
    pointer-events: none;
    white-space: pre-wrap;
}


.control-group {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #444;
}
.control-group:last-child {
    border-bottom: none;
}
.control-group h3 {
    margin-top: 0;
    color: var(--accent-color);
}
.control-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
}
.control-group input[type="number"],
.control-group input[type="range"],
.control-group select,
.control-group button {
    width: calc(100% - 20px);
    padding: 8px 10px;
    margin-bottom: 10px;
    border: 1px solid #555;
    background-color: #333842;
    color: #eee;
    border-radius: 4px;
    box-sizing: border-box;
}
.control-group button {
    cursor: pointer;
    background-color: #555e6d;
}
.control-group button:hover {
    background-color: #667081;
}
#generateWorldsButton {
    background-color: var(--accent-color);
}
#generateWorldsButton:hover {
    background-color: #409043;
}


.structure-toggles, .wire-toggles { margin-top: 15px; }
#structureToggleContainer label, #wireToggleContainer label {
    display: block;
    margin-bottom: 5px;
    cursor: pointer;
}
#structureToggleContainer input[type="checkbox"], #wireToggleContainer input[type="checkbox"] {
    margin-right: 8px;
    width: auto;
}

.info-box {
    background-color: #383c44;
    padding: 10px;
    border-radius: 4px;
    margin-top: 15px;
    font-size: 0.9em;
}
.info-box h4 {
    margin-top: 0;
    margin-bottom: 8px;
    color: var(--accent-color);
    font-size: 1em;
}
.info-box p {
    margin: 4px 0;
    line-height: 1.4;
}
.info-box p span {
    font-weight: bold;
    color: #f0f0f0;
}


.progress-bar-container {
    width: 100%;
    background-color: #555;
    border-radius: 3px;
    height: 10px;
    margin-bottom: 10px;
}
#progressBar {
    width: 0%;
    height: 100%;
    background-color: var(--accent-color);
    border-radius: 3px;
    transition: width 0.3s ease;
}
#logContainer {
    height: 100px;
    overflow-y: auto;
    background-color: #1e1e1e;
    padding: 5px;
    font-size: 0.8em;
    border: 1px solid #444;
    border-radius: 3px;
}


@media (min-width: 769px) {
    .app-container {
        flex-direction: row; /* Sidebar on left, main content on right */
    }
    .sidebar {
        width: var(--sidebar-width-desktop);
        height: 100vh;
        transform: translateX(0);
        transition: transform 0.3s ease-in-out, width 0.3s ease-in-out;
        flex-shrink: 0;
    }
    .sidebar.collapsed {
        transform: translateX(calc(-1 * var(--sidebar-width-desktop)));
        width: 0;
        padding-left: 0;
        padding-right: 0;
        overflow: hidden;
    }
    .sidebar-toggle-btn {
        top: 10px;
        left: var(--sidebar-width-desktop);
        border-radius: 0 5px 5px 0;
    }
    .sidebar-toggle-btn.moved { /* COLLAPSED */
        left: 0px;
    }
    .sidebar.collapsed ~ .sidebar-toggle-btn {
        left: 0px; /* When sidebar is collapsed, button moves to the left edge of the viewport */
    }

}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column; /* Sidebar on top, main content below */
    }
    .main-content {
        flex-grow: 1;
        padding-top: 0px;
        transition: padding-top 0.3s ease-in-out;
        width: 100%;
        overflow: hidden;
    }
    .sidebar {
        width: 100vw;
        height: var(--sidebar-height-mobile);
        max-height: 60vh;
        transition: transform 0.3s ease-in-out, height 0.3s ease-in-out;
        transform: translateY(calc(-100%));
        position: fixed;
        top: 0;
        left: 0;
        overflow: hidden;
        background-color: #282c34;
        z-index: 10;
    }
    .sidebar.open {
        transform: translateY(0);
        overflow-y: auto;
    }
    .sidebar-toggle-btn {
        top: 10px;
        left: 10px;
        border-radius: 5px;
        z-index: 20;
    }
    .app-container.mobile-sidebar-open .main-content {
        padding-top: 28vh; /* Must match .sidebar.open height */
    }

    .tile-info-overlay {
        font-size: 0.8em;
        top: 10px;
    }

}