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

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252540;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent: #ff6b35;
    --accent-hover: #ff8c5a;
    --success: #4caf50;
    --border: #333355;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--accent), #f4d03f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

nav {
    display: flex;
    gap: 1rem;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s;
}

nav a:hover,
nav a.active {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

main {
    display: flex;
    flex: 1;
    padding: 1rem;
    gap: 1rem;
}

#game-container {
    flex: 1;
    position: relative;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: crosshair;
    max-width: 100%;
    max-height: calc(100vh - 150px);
}

#loading {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    inset: 0;
    font-size: 1.2rem;
    color: var(--accent);
}

#loading.hidden {
    display: none;
}

#controls {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#toolbar,
#settings,
#actions,
#stats,
#instructions {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}

h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

#material-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.material-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.material-btn:hover {
    border-color: var(--accent);
}

.material-btn.active {
    border-color: var(--accent);
    background: rgba(255, 107, 53, 0.2);
}

.color-preview {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.erase-btn {
    grid-column: span 2;
}

.setting {
    margin-bottom: 0.75rem;
}

.setting:last-child {
    margin-bottom: 0;
}

.setting label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

input[type="range"] {
    width: 100%;
    margin-top: 0.5rem;
    accent-color: var(--accent);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

#actions {
    display: flex;
    gap: 0.5rem;
}

#actions button {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

#actions button:hover {
    background: var(--accent);
    border-color: var(--accent);
}

#stats p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

#stats span {
    color: var(--accent);
    font-weight: bold;
}

#instructions ul {
    list-style: none;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

#instructions li {
    margin-bottom: 0.4rem;
}

#instructions strong {
    color: var(--text-primary);
}

footer {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

/* About page styles */
.about-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

.about-content h2 {
    color: var(--accent);
    margin-bottom: 1rem;
    margin-top: 2rem;
}

.about-content h2:first-child {
    margin-top: 0;
}

.about-content p {
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.about-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.about-content li {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.about-content code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.about-content pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.about-content pre code {
    background: transparent;
    padding: 0;
}

.stack-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 20px;
    margin: 0.25rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.stack-badge.rust {
    border-color: #dea584;
    color: #dea584;
}

.stack-badge.wasm {
    border-color: #654ff0;
    color: #654ff0;
}

.stack-badge.js {
    border-color: #f7df1e;
    color: #f7df1e;
}

.stack-badge.bun {
    border-color: #fbf0df;
    color: #fbf0df;
}

.stack-badge.cloudflare {
    border-color: #f38020;
    color: #f38020;
}

/* Responsive */
@media (max-width: 900px) {
    main {
        flex-direction: column;
    }

    #controls {
        width: 100%;
    }

    #material-buttons {
        grid-template-columns: repeat(4, 1fr);
    }

    .erase-btn {
        grid-column: span 1;
    }
}

@media (max-width: 600px) {
    header {
        flex-direction: column;
        gap: 0.5rem;
    }

    #material-buttons {
        grid-template-columns: repeat(3, 1fr);
    }
}
