* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Poppins', sans-serif;
    user-select: none;
}

:root {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --element-bg: #334155;
    --element-border: rgba(255, 255, 255, 0.1);
    --element-hover: #475569;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden; /* Prevent scrolling the body */
    width: 100vw;
    height: 100vh;
}

#game-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Canvas Area */
#canvas {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle at 50% 50%, #1e293b 0%, #0f172a 100%);
}

#controls {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 100;
}

#controls button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
    font-weight: 500;
}

#controls button:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

#canvas-items-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let empty space pass clicks */
}

/* Sidebar Area */
#sidebar {
    width: 350px;
    background-color: var(--sidebar-bg);
    border-left: 1px solid var(--element-border);
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 15px rgba(0,0,0,0.3);
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--element-border);
    background: rgba(30, 41, 59, 0.95);
    position: sticky;
    top: 0;
    z-index: 2;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 5px;
    background: -webkit-linear-gradient(45deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stats {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

#search-input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--element-border);
    background: var(--bg-color);
    color: white;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--accent);
}

#inventory-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 10px;
}

/* Custom Scrollbar */
#inventory-list::-webkit-scrollbar {
    width: 8px;
}
#inventory-list::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}
#inventory-list::-webkit-scrollbar-thumb {
    background: var(--element-bg);
    border-radius: 4px;
}
#inventory-list::-webkit-scrollbar-thumb:hover {
    background: var(--element-hover);
}

/* Element Styling */
.element-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--element-bg);
    border: 1px solid var(--element-border);
    padding: 8px 14px;
    border-radius: 20px;
    cursor: grab;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
    pointer-events: auto; /* Re-enable pointer events inside canvas-items */
}

.element-item:hover {
    background: var(--element-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.element-item:active {
    cursor: grabbing;
}

.element-item.canvas-item {
    position: absolute;
    margin: 0;
    transform: translate(-50%, -50%); /* Center on mouse */
    /* Give z-index to elements that are dragged later */
}

/* Animations */
@keyframes pop-in {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    70% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

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

.element-item.anim-pop {
    animation: pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.element-item.anim-discover {
    animation: discover 0.6s ease;
}

@keyframes shake {
    0%, 100% { transform: translate(-50%, -50%); }
    25% { transform: translate(calc(-50% - 5px), -50%); }
    50% { transform: translate(calc(-50% + 5px), -50%); }
    75% { transform: translate(calc(-50% - 5px), -50%); }
}

.element-item.anim-shake {
    animation: shake 0.3s ease;
}

/* Confetti container (if needed later) */
.particle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    z-index: 1000;
}

@keyframes pulse-loading {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 0.7; transform: translate(-50%, -50%) scale(0.9); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.element-item.loading {
    animation: pulse-loading 1s infinite ease-in-out;
    pointer-events: none;
    border-color: #a78bfa;
    box-shadow: 0 0 15px rgba(167, 139, 250, 0.6);
}
