
:root {
    --bg-dark: #0f0f0f;
    --bg-sidebar: #1a1a1a;
    --bg-item: #252525;
    --accent: #00ff00;
    --text-main: #e0e0e0;
    --text-dim: #888;
    --border: #333;
    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
    user-select: none; 
    -webkit-user-select: none;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Fredoka', sans-serif;
    overflow: hidden;
}

#editor-interface {
    display: flex;
    width: 100%;
    height: 100vh;
}

#sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0,0,0,0.5);
    z-index: 100;
}

#viewport {
    flex-grow: 1;
    position: relative;
    background-color: #000;
    cursor: crosshair;
}

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

.sidebar-header {
    padding: 15px;
    background: #222;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.2rem;
    color: var(--accent);
}

#tile-container {
    flex-grow: 1;
    overflow-y: overlay;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: min-content;
    gap: 8px;
}

.palette-item {
    background: var(--bg-item);
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.palette-item:hover {
    background: #333;
    transform: translateY(-2px);
}

.palette-item.selected {
    background: #2a3a2a;
    border-color: var(--accent);
}

.palette-item img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: contain;
    pointer-events: none;
}

.tile-label {
    margin-top: 5px;
    font-size: 10px;
    color: var(--text-dim);
    text-align: center;
    word-break: break-all;
    line-height: 1.1;
}

#controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.85);
    padding: 12px 20px;
    border-radius: 30px;
    display: flex;
    gap: 15px;
    align-items: center;
    border: 1px solid var(--border);
    backdrop-filter: blur(5px);
}

.btn {
    background: #333;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.2s;
}

.btn:hover { background: #444; }

.btn-primary {
    background: var(--accent);
    color: black;
}

.btn-primary:hover { background: #00cc00; }

#map-info {
    font-size: 12px;
    color: var(--text-dim);
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.hidden { display: none !important; }

#setup-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-sidebar);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 320px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--text-dim);
}

.input-group input {
    width: 100%;
    padding: 8px;
    background: #111;
    border: 1px solid var(--border);
    color: white;
    border-radius: 4px;
}

#visit-counter {
    position: fixed;
    top: 10px;
    right: 10px;
    font-size: 11px;
    font-family: 'Fredoka', sans-serif;
    color: #ffffff;
    opacity: 0.3;
    z-index: 9999;
    pointer-events: none;
}
