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

body {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%);
    color: white;
    font-family: 'Segoe UI', system-ui, sans-serif;
    overflow: hidden;
    min-height: 100vh;
}

/* ===== Floating Header ===== */
.floating-header {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 30px;
    background: rgba(15, 15, 26, 0.8);
    backdrop-filter: blur(20px);
    padding: 12px 24px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-icon {
    font-size: 24px;
}

.brand-text {
    font-family: 'Permanent Marker', cursive;
    font-size: 20px;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 20px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
}

.back-link:hover {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.1);
}

/* ===== Floating Toolbar ===== */
.floating-toolbar {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(20px);
    padding: 12px 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Custom scrollbar for toolbar */
.floating-toolbar::-webkit-scrollbar {
    width: 4px;
}

.floating-toolbar::-webkit-scrollbar-track {
    background: transparent;
}

.floating-toolbar::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.3);
    border-radius: 2px;
}

.floating-toolbar::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 165, 250, 0.5);
}

.floating-toolbar.collapsed {
    transform: translateY(-50%) translateX(-120%);
    opacity: 0;
    pointer-events: none;
}

.toolbar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.toolbar-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 2px;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.toolbar-btn:hover {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
    transform: scale(1.05);
}

.toolbar-btn:active {
    transform: scale(0.95);
}

.toolbar-btn.active {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.toolbar-btn.accent {
    background: rgba(244, 63, 94, 0.2);
    color: #f43f5e;
}

.toolbar-btn.accent:hover {
    background: rgba(244, 63, 94, 0.3);
}

.toolbar-btn.accent.active {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: white;
}

/* Sound Reactive Button */
#toggleSoundReactive.active {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    animation: pulse-glow 1.5s ease-in-out infinite;
}

/* Bloom Button */
#toggleBloom.active {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a2e;
    box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    }

    50% {
        box-shadow: 0 4px 25px rgba(139, 92, 246, 0.7);
    }
}

.toolbar-divider {
    width: 26px;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 2px 0;
}

/* Toolbar Slider */
.toolbar-slider {
    width: 30px;
    height: 50px;
    -webkit-appearance: slider-vertical;
    appearance: slider-vertical;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
}

.toolbar-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}

.slider-value {
    font-size: 10px;
    color: #60a5fa;
    font-weight: 600;
}

/* Toolbar Dropdown */
.toolbar-dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    left: 46px;
    top: 0;
    z-index: 2000;
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 6px;
    min-width: 120px;
    max-height: 280px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Custom scrollbar for dropdown */
.dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.dropdown-menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb {
    background: rgba(96, 165, 250, 0.3);
    border-radius: 3px;
}

.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(96, 165, 250, 0.5);
}

.toolbar-dropdown:hover .dropdown-menu,
.dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.7);
    text-align: left;
    font-size: 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: rgba(96, 165, 250, 0.1);
    color: #60a5fa;
}

.dropdown-item.active {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

/* Toolbar Toggle Button */
.toolbar-toggle {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 15, 26, 0.9);
    backdrop-filter: blur(20px);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
}

.toolbar-toggle.visible {
    opacity: 1;
    pointer-events: all;
}

.toolbar-toggle:hover {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

/* ===== Help Panel ===== */
.help-panel {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%) translateX(120%);
    z-index: 1000;
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(20px);
    padding: 0;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    width: 260px;
    opacity: 0;
    transition: all 0.3s ease;
}

.help-panel.visible {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
    color: #60a5fa;
}

.help-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.help-close:hover {
    color: white;
}

.help-content {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.help-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-group-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
}

.help-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
}

kbd {
    display: inline-block;
    padding: 3px 7px;
    font-size: 11px;
    font-family: 'SF Mono', 'Consolas', monospace;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #a78bfa;
}

.help-footer {
    padding: 12px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
}

.help-footer i {
    margin-right: 6px;
}

/* ===== Canvas Container ===== */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: all;
}

canvas {
    display: block;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

/* ===== Modal Styles ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: linear-gradient(135deg, rgba(15, 15, 26, 0.98), rgba(26, 26, 46, 0.98));
    margin: 5% auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.3s ease;
    overflow: hidden;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.6);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(244, 63, 94, 0.2);
    color: #f43f5e;
}

.modal-header {
    padding: 30px 30px 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.modal-header h2 {
    font-family: 'Permanent Marker', cursive;
    font-size: 28px;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-body {
    padding: 30px;
}

.modal-body p {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.7;
    margin-bottom: 20px;
    font-size: 15px;
}

.modal-body h3 {
    color: #60a5fa;
    font-size: 16px;
    margin: 25px 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-body h3 i {
    font-size: 14px;
    opacity: 0.7;
}

.modal-body ul {
    list-style: none;
    padding: 0;
}

.modal-body li {
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
    line-height: 1.6;
}

.modal-body li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 14px;
    width: 6px;
    height: 6px;
    background: #a78bfa;
    border-radius: 50%;
}

.modal-note {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-top: 20px;
}

.modal-note i {
    color: #fbbf24;
    font-size: 18px;
    margin-top: 2px;
}

.modal-note span {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1.6;
}

/* Close button fallback */
.close {
    display: none;
}

/* ===== Responsive Design ===== */
@media screen and (max-width: 768px) {
    .floating-header {
        top: 10px;
        padding: 10px 16px;
        gap: 15px;
    }

    .brand-text {
        font-size: 16px;
    }

    .back-link span {
        display: none;
    }

    .floating-toolbar {
        left: 10px;
        padding: 10px 6px;
    }

    .toolbar-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .toolbar-slider {
        height: 40px;
    }

    .help-panel {
        width: calc(100% - 40px);
        right: 20px;
        max-height: 60vh;
        overflow-y: auto;
    }

    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
}

@media screen and (max-width: 480px) {
    .floating-header {
        padding: 8px 12px;
    }

    .brand-icon {
        font-size: 20px;
    }

    .brand-text {
        font-size: 14px;
    }

    .floating-toolbar {
        left: 10px;
        right: auto;
        top: 80px;
        bottom: auto;
        transform: none;
        flex-direction: column;
        max-width: none;
    }

    .floating-toolbar.collapsed {
        transform: translateX(-120%);
    }

    .toolbar-section {
        flex-direction: column;
    }

    .toolbar-btn {
        width: 30px;
        height: 30px;
        font-size: 11px;
    }

    .toolbar-divider {
        width: 24px;
        height: 1px;
        margin: 2px 0;
    }

    .toolbar-slider {
        width: 24px;
        height: 35px;
        -webkit-appearance: slider-vertical;
        appearance: slider-vertical;
    }

    .toolbar-label {
        font-size: 8px;
    }

    .dropdown-menu {
        left: 40px;
        right: auto;
        top: 0;
        bottom: auto;
        transform: translateX(-10px);
    }

    .toolbar-dropdown:hover .dropdown-menu {
        transform: translateX(0);
    }

    .toolbar-toggle {
        left: 10px;
        right: auto;
        top: 80px;
        bottom: auto;
        transform: none;
    }
}

/* ===== Legacy support - hide old elements ===== */
.toggle-ui-btn,
.content-wrapper,
.top-nav,
.controls-panel,
.instructions {
    display: none !important;
}