:root {
    --primary: #8B5CF6;
    --secondary: #A78BFA;
    --accent: #EC4899;
    --bg: #0F0A2A;
    --text: #F8FAFC;
    --grass-light: #4ADE80;
    --grass-dark: #22C55E;
    --sand: #FCD34D;
    --water: #3B82F6;
    --wall: #475569;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 800px; /* Limit width on large screens for better gameplay */
    margin: 0 auto;
    background-color: #1a163a; /* Slightly lighter than bg for the play area */
    box-shadow: 0 0 40px rgba(139, 92, 246, 0.1);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* HUD */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.hud-item {
    background: rgba(15, 10, 42, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 10px 15px;
    border-radius: var(--radius);
    text-align: center;
    min-width: 80px;
}

.hud-item .label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--secondary);
    margin-bottom: 4px;
}

.hud-item span:not(.label) {
    font-size: 20px;
    font-weight: bold;
    color: var(--text);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 10, 42, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

h1 {
    font-size: 48px;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
}

h2 {
    font-size: 36px;
    margin-bottom: 20px;
    color: var(--accent);
}

.accent {
    color: var(--accent);
    text-shadow: 0 0 20px rgba(236, 72, 153, 0.5);
}

p {
    font-size: 18px;
    color: var(--secondary);
    margin-bottom: 30px;
    text-align: center;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 250px;
}

button {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

button:active {
    transform: translateY(1px);
}

/* Editor UI */
.hidden {
    display: none !important;
}

#editor-ui {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    z-index: 15;
}

.editor-panel {
    background: rgba(15, 10, 42, 0.9);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 15px;
    backdrop-filter: blur(10px);
}

.editor-panel h3 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--secondary);
}

.tool-grid, .action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}

.action-grid {
    margin-bottom: 0;
    grid-template-columns: repeat(4, 1fr);
}

.editor-panel button {
    padding: 8px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

.editor-panel button.active {
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

#editor-message {
    text-align: center;
    margin-top: 10px;
    color: var(--accent);
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 0 5px var(--bg);
}

@media (max-width: 600px) {
    #hud {
        top: 10px; left: 10px; right: 10px;
    }
    .hud-item {
        padding: 5px 10px;
        min-width: 60px;
    }
    .hud-item span:not(.label) {
        font-size: 16px;
    }
    h1 { font-size: 36px; }
}
