/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a1a;
    color: #ffffff;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

body.light-theme {
    background-color: #f5f5f5;
    color: #333333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

h1 {
    color: #4a9eff;
}

.controls button {
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 8px 16px;
    margin-left: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.controls button:hover {
    background-color: #555;
}

/* Editor section */
.editor-section {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.sidebar {
    width: 250px;
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    transition: background-color 0.3s;
}

body.light-theme .sidebar {
    background-color: #e0e0e0;
}

.sidebar h3 {
    margin-bottom: 10px;
    color: #4a9eff;
}

.obstacle-palette {
    margin-bottom: 20px;
}

.obstacle-item {
    padding: 10px;
    margin-bottom: 5px;
    background-color: #333;
    border-radius: 4px;
    cursor: grab;
    user-select: none;
}

.obstacle-item:hover {
    background-color: #444;
}

.level-properties label {
    display: block;
    margin-bottom: 10px;
}

.level-properties input {
    width: 100%;
    padding: 5px;
    background-color: #333;
    border: 1px solid #555;
    color: #fff;
    border-radius: 4px;
}

.patterns button {
    display: block;
    width: 100%;
    padding: 8px;
    margin-bottom: 5px;
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.patterns button:hover {
    background-color: #555;
}

/* Grid container */
.grid-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #2a2a2a;
    border-radius: 8px;
    padding: 20px;
    transition: background-color 0.3s;
}

body.light-theme .grid-container {
    background-color: #e0e0e0;
}

#grid {
    display: grid;
    gap: 2px;
    background-color: #333;
    border-radius: 4px;
    padding: 10px;
}

/* Tiles */
.tile {
    width: 40px;
    height: 40px;
    background-color: #444;
    border: 1px solid #555;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
}

.tile:hover {
    background-color: #555;
}

.tile.on {
    background-color: #4a9eff;
}

.tile.off {
    background-color: #222;
}

body.light-theme .tile.on {
    background-color: #1e90ff;
}

body.light-theme .tile.off {
    background-color: #ddd;
}

.tile.obstacle.block {
    background-color: #ff4444;
    color: #fff;
    font-weight: bold;
}

.tile.obstacle.portal {
    background-color: #9c27b0;
    color: #fff;
    font-weight: bold;
}

.tile.obstacle.portal.off {
    background-color: #666;
    color: #ccc;
}

.tile.ripple {
    animation: ripple 0.5s ease-out;
}

@keyframes ripple {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); background-color: #ffff00; }
    100% { transform: scale(1); }
}

/* Preview section */
.preview-section {
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

#preview {
    font-family: monospace;
    white-space: pre;
    background-color: #1a1a1a;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
}

/* Validation feedback */
.validation-feedback {
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
}

#feedback {
    color: #ffeb3b;
}

/* Responsive */
@media (max-width: 768px) {
    .editor-section {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .tile {
        width: 30px;
        height: 30px;
    }
}