* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #0d0d14;
    font-family: 'Crimson Pro', serif;
}

#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    cursor: crosshair;
}

#toolPalette {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 100;
    transition: opacity 0.3s ease;
}

.tool-hub {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: rgba(255, 200, 87, 0.8);
}

.tool-hub:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.05);
}

.tool-hub svg {
    width: 20px;
    height: 20px;
}

.tool-item {
    position: absolute;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: rgba(255, 255, 255, 0.6);
    left: 6px;
    bottom: 6px;
}

.tool-item svg {
    width: 20px;
    height: 20px;
}

.tool-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
}

.tool-item.active {
    background: rgba(255, 200, 87, 0.2);
    border-color: rgba(255, 200, 87, 0.4);
    color: #ffc857;
    box-shadow: 0 0 20px rgba(255, 200, 87, 0.3);
}

#toolPalette.open .tool-item {
    opacity: 1;
    pointer-events: auto;
}

#toolPalette.open .tool-item:nth-child(2) { transform: translate(0, -70px); }
#toolPalette.open .tool-item:nth-child(3) { transform: translate(50px, -50px); }
#toolPalette.open .tool-item:nth-child(4) { transform: translate(70px, 0); }
#toolPalette.open .tool-item:nth-child(5) { transform: translate(50px, 50px); }
#toolPalette.open .tool-item:nth-child(6) { transform: translate(0, 70px); }
#toolPalette.open .tool-item:nth-child(7) { transform: translate(-50px, 50px); }

#brushSizeSelector {
    position: fixed;
    bottom: 120px;
    left: 30px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 99;
}

#brushSizeSelector.visible {
    opacity: 1;
    pointer-events: auto;
}

.size-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.size-option::after {
    content: '';
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
}

.size-option[data-size="4"]::after { width: 4px; height: 4px; }
.size-option[data-size="12"]::after { width: 10px; height: 10px; }
.size-option[data-size="24"]::after { width: 16px; height: 16px; }
.size-option[data-size="48"]::after { width: 24px; height: 24px; }

.size-option:hover {
    background: rgba(255, 255, 255, 0.15);
}

.size-option.active {
    border-color: #ffc857;
    box-shadow: 0 0 15px rgba(255, 200, 87, 0.4);
}

#colorWheel {
    position: fixed;
    bottom: 100px;
    left: 100px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    z-index: 99;
}

#colorWheel.visible {
    opacity: 1;
    pointer-events: auto;
}

#colorCanvas {
    border-radius: 50%;
    cursor: crosshair;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

#recentColors {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.recent-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s ease;
}

.recent-color:hover {
    transform: scale(1.2);
}

#modeToggle {
    position: fixed;
    top: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    z-index: 100;
}

#modeToggle svg {
    width: 24px;
    height: 24px;
}

#modeToggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

#modeToggle.active {
    background: rgba(78, 205, 196, 0.2);
    border-color: rgba(78, 205, 196, 0.4);
    color: #4ecdc4;
    box-shadow: 0 0 25px rgba(78, 205, 196, 0.3);
}

#saveBtn {
    position: fixed;
    top: 30px;
    right: 95px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
    z-index: 100;
}

#saveBtn svg {
    width: 22px;
    height: 22px;
}

#saveBtn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

#saveBtn.saved {
    background: rgba(255, 200, 87, 0.3);
    border-color: rgba(255, 200, 87, 0.5);
    color: #ffc857;
    transform: scale(1.1);
}

#galleryStrip {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    background: rgba(13, 13, 20, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 90;
    overflow: hidden;
}

#galleryStrip.open {
    height: 140px;
}

#galleryContent {
    display: flex;
    gap: 16px;
    padding: 20px 30px;
    overflow-x: auto;
    scrollbar-width: none;
}

#galleryContent::-webkit-scrollbar {
    display: none;
}

.gallery-thumb {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    border-radius: 12px;
    background-size: cover;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
}

.gallery-thumb:hover {
    transform: scale(1.05);
    border-color: rgba(255, 200, 87, 0.4);
}

#galleryHandle {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px 3px 0 0;
    cursor: pointer;
    z-index: 91;
    transition: background 0.2s ease;
}

#galleryHandle:hover {
    background: rgba(255, 255, 255, 0.25);
}

#footer {
    position: fixed;
    bottom: 10px;
    right: 15px;
    z-index: 50;
    opacity: 0.15;
    transition: opacity 0.3s ease;
}

#footer:hover {
    opacity: 0.5;
}

#footer a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 12px;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    #toolPalette {
        bottom: 20px;
        left: 20px;
    }
    
    .tool-hub {
        width: 50px;
        height: 50px;
    }
    
    .tool-item {
        width: 40px;
        height: 40px;
    }
    
    #toolPalette.open .tool-item:nth-child(2) { transform: translate(0, -60px); }
    #toolPalette.open .tool-item:nth-child(3) { transform: translate(42px, -42px); }
    #toolPalette.open .tool-item:nth-child(4) { transform: translate(60px, 0); }
    #toolPalette.open .tool-item:nth-child(5) { transform: translate(42px, 42px); }
    #toolPalette.open .tool-item:nth-child(6) { transform: translate(0, 60px); }
    #toolPalette.open .tool-item:nth-child(7) { transform: translate(-42px, 42px); }
    
    #modeToggle, #saveBtn {
        width: 44px;
        height: 44px;
        top: 20px;
    }
    
    #modeToggle {
        right: 20px;
    }
    
    #saveBtn {
        right: 75px;
    }
    
    #colorWheel {
        left: 50%;
        transform: translateX(-50%);
        bottom: 150px;
    }
    
    #brushSizeSelector {
        left: 80px;
        bottom: 20px;
        flex-direction: row;
    }
    
    .gallery-thumb {
        width: 80px;
        height: 80px;
    }
    
    #galleryStrip.open {
        height: 120px;
    }
}