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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    background: #000;
    position: relative;
    width: 100vw;
    height: 100vh;
}

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

.controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.controls:hover {
    background: rgba(255, 255, 255, 0.15);
}

.control-btn {
    width: 45px;
    height: 45px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    position: relative;
    overflow: hidden;
    transform: translateZ(0); /* Force hardware acceleration */
    backface-visibility: hidden; /* Prevent flickering */
}

.control-btn:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.2s ease, height 0.2s ease;
    pointer-events: none;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.control-btn:hover:before {
    width: 100%;
    height: 100%;
}

.control-btn:active {
    transform: translateZ(0) scale(0.95);
}

.control-btn svg {
    width: 20px;
    height: 20px;
    z-index: 1;
    position: relative;
    pointer-events: none; /* Prevent SVG from interfering with hover */
}

body.hide-controls .controls {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(100px);
}

body:not(.hide-controls) .controls {
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
}

.control-btn.active {
    animation: pulse 1s ease-in-out infinite;
    background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 600px) {
    .controls {
        bottom: 20px;
        padding: 12px;
        gap: 10px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
    }
    
    .control-btn svg {
        width: 18px;
        height: 18px;
    }
}

:-webkit-full-screen {
    width: 100%;
    height: 100%;
}

:-moz-full-screen {
    width: 100%;
    height: 100%;
}

:fullscreen {
    width: 100%;
    height: 100%;
}

.fade-transition {
    animation: fadeIn 1.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}