* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #404040;
}

#canvas-container {
    width: 100%;
    height: 100%;
    touch-action: none; /* Prevent default touch behaviors */
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI Overlay */
#ui-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Top UI Buttons */
.ui-button {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ui-button:active {
    background: rgba(0, 0, 0, 0.8);
}

#menu-button {
    top: 20px;
    left: 20px;
}

#help-button {
    top: 20px;
    right: 20px;
}

/* Component Drawer */
#component-drawer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 17%;
    background: #0b354d;
    border-radius: 20px 20px 0 0;
    pointer-events: auto;
    transition: transform 0.3s ease-out;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

#component-drawer.drawer-closed {
    transform: translateY(calc(100% - 60px));
}

#component-drawer.drawer-open {
    transform: translateY(0);
}

/* Drawer Toggle Button */
.drawer-toggle {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}

.drawer-toggle:active {
    background: rgba(255, 255, 255, 0.2);
}

.drawer-toggle svg {
    transition: transform 0.3s;
}

#component-drawer.drawer-open .drawer-toggle svg {
    transform: rotate(180deg);
}

/* Drawer Content */
.drawer-content {
    width: 100%;
    height: calc(100% - 20px);
    margin-top: 20px;
    overflow: hidden;
}

.drawer-scroll {
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    display: flex;
    gap: 20px;
    padding: 0 20px 20px 20px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep functionality */
.drawer-scroll::-webkit-scrollbar {
    display: none;
}

.drawer-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Drawer Item */
.drawer-item {
    flex-shrink: 0;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}

.drawer-item:active {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(0.95);
}

.drawer-item.unavailable {
    opacity: 0.3;
    pointer-events: none;
}

.drawer-item canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.drawer-item-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    font-size: 12px;
    text-align: center;
    display: none;
}

/* Inspect Mode Overlay */
.inspect-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    pointer-events: auto;
    transition: opacity 0.3s;
}

.inspect-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#inspect-canvas {
    position: absolute;
    border-radius: 10px;
    cursor: grab;
    transition: all 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#inspect-canvas:active {
    cursor: grabbing;
}

.inspect-label {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 32px;
    font-weight: bold;
    text-align: center;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s 0.3s;
}

.inspect-description {
    position: absolute;
    bottom: 55px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
    font-weight: normal;
    text-align: center;
    padding: 8px 20px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.3s 0.3s;
    max-width: 80%;
}

.inspect-overlay:not(.hidden) .inspect-label {
    opacity: 1;
}

.inspect-overlay:not(.hidden) .inspect-description {
    opacity: 1;
}