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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    /* Prevent pull-to-refresh and bounce on mobile */
    overscroll-behavior: none;
    touch-action: none;
    /* Handle notched phones */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

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

#fluidCanvas {
    z-index: 2;
}

.start-overlay {
    position: fixed;
    top: 60%;
    left: 50%;
    transform: translate(-50%, 0);
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    z-index: 50;
    pointer-events: none;
}

.start-overlay p {
    margin: 0;
    font-size: clamp(24px, 6vw, 48px);
    font-weight: 300;
}

.start-overlay .hint {
    font-size: clamp(14px, 3vw, 24px);
    margin-top: 16px;
    opacity: 0.6;
}

.settings {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    left: max(20px, env(safe-area-inset-left));
    background: rgba(40, 40, 40, 0.95);
    padding: 16px;
    border-radius: 12px;
    color: #fff;
    width: 242px;
    max-height: calc(100vh - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    scrollbar-gutter: stable;
    transition: opacity 0.3s ease;
    z-index: 100;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.settings::-webkit-scrollbar {
    width: 6px;
}

.settings::-webkit-scrollbar-track {
    background: transparent;
}

.settings::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

.settings::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.settings.hidden {
    opacity: 0;
    pointer-events: none;
}

.settings h2 {
    position: sticky;
    top: -16px;
    background: rgba(40, 40, 40, 0.95);
    margin: -16px -16px 16px -16px;
    padding: 20px 16px 16px 16px;
    font-size: 18px;
    font-weight: 600;
    z-index: 1;
}

.setting-group {
    margin-bottom: 10px;
}

.setting-section {
    margin-left: -16px;
    margin-right: -16px;
    padding: 8px 16px 8px 16px;
    margin-bottom: 8px;
}

.setting-section:first-child {
    margin-top: -16px;
}

.setting-header {
    margin: 0 0 12px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #555;
}

.setting-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1.1px;
}

.setting-group label {
    display: block;
    margin-bottom: 2px;
    font-size: 14px;
    color: #999;
}

.label-unit {
    font-size: 0.85em;
    opacity: 0.5;
    font-weight: normal;
}

.setting-group input[type="number"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #555;
    border-radius: 6px;
    background: #333;
    color: #fff;
    font-size: 14px;
}

.setting-group input[type="number"]:focus,
.setting-group select:focus {
    outline: none;
    border-color: #888;
}

.setting-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #555;
    border-radius: 6px;
    background: #333;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.setting-group #musicSelect {
    background: #444;
}

.setting-group .toggle-btn {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #2a2a2a;
    color: #888;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.setting-group .toggle-btn:hover {
    background: #333;
}

.setting-group .toggle-btn[data-checked="true"] {
    background: #3d6fa8;
    border-color: #5080b8;
    color: #fff;
}

.setting-group #audioEnabled[data-checked="true"] {
    background: linear-gradient(135deg, #3d6fa8 0%, #8b4d9e 100%);
    border-color: #6a5dad;
}

.setting-group #glowEnabled[data-checked="true"] {
    background: linear-gradient(135deg, #5890d8 0%, #78b8f8 100%);
    border-color: #70a8e8;
}

.setting-group .toggle-btn .toggle-state {
    font-weight: 600;
}

.setting-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #555;
    cursor: pointer;
    -webkit-appearance: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    cursor: pointer;
}

.color-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.setting-group input[type="color"] {
    width: 50px;
    height: 36px;
    border: 1px solid #555;
    border-radius: 6px;
    background: #333;
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}

.hex-input {
    flex: 1;
    min-width: 0;
    padding: 6px 6px;
    border: 1px solid #555;
    border-radius: 6px;
    background: #333;
    color: #999;
    font-size: 12px;
    font-family: monospace;
}

.hex-input:focus {
    outline: none;
    border-color: #888;
}

.copy-btn {
    width: 44px;
    padding: 6px 0;
    border: 1px solid #555;
    border-radius: 6px;
    background: #444;
    color: #999;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
    text-align: center;
}

.copy-btn:hover {
    background: #555;
}

.copy-btn:active {
    background: #666;
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

.setting-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.reset-settings-btn {
    width: 100%;
    margin-top: 16px;
    padding: 10px;
    border: 1px solid rgba(139, 69, 69, 0.4);
    border-radius: 6px;
    background: rgba(90, 40, 40, 0.3);
    color: rgba(255, 150, 150, 0.7);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-settings-btn:hover {
    background: rgba(120, 50, 50, 0.4);
    border-color: rgba(180, 90, 90, 0.6);
    color: rgba(255, 170, 170, 0.9);
}

.reset-settings-btn:active {
    background: rgba(100, 45, 45, 0.5);
}

.audio-btn,
.play-pause-btn {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Order from right: mute, play, music */
.audio-btn {
    right: max(20px, env(safe-area-inset-right));
}

.play-pause-btn {
    right: calc(max(20px, env(safe-area-inset-right)) + 60px);
}

.music-picker {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    right: calc(max(20px, env(safe-area-inset-right)) + 120px);
    z-index: 100;
}

.music-picker-label {
    height: 50px;
    padding: 0 24px;
    border: none;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 280px;
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.music-picker-label:hover {
    background: rgba(255, 255, 255, 0.3);
}

.music-picker-dropdown {
    position: absolute;
    bottom: 60px;
    right: 0;
    min-width: 280px;
    max-height: 350px;
    overflow-y: auto;
    background: rgba(30, 30, 40, 0.95);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    padding: 8px 0;
    scrollbar-width: auto;
    scrollbar-color: rgba(255, 255, 255, 0.3) rgba(80, 80, 90, 0.3);
}

.music-picker-dropdown::-webkit-scrollbar {
    width: 12px;
}

.music-picker-dropdown::-webkit-scrollbar-track {
    background: rgba(80, 80, 90, 0.5);
    border-radius: 6px;
    margin: 8px 4px;
}

.music-picker-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    border: 2px solid rgba(80, 80, 90, 0.5);
}

.music-picker-dropdown::-webkit-scrollbar-thumb:hover {
    background: #fff;
}

.music-picker-dropdown.hidden {
    display: none;
}

.music-picker-dropdown .category {
    padding: 10px 14px 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.music-picker-dropdown .track {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #fff;
    transition: background 0.15s;
}

.music-picker-dropdown .track:hover {
    background: rgba(255, 255, 255, 0.1);
}

.music-picker-dropdown .track.selected {
    background: rgba(100, 150, 255, 0.3);
}

.music-picker-dropdown .track.none-option {
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 4px;
}

.audio-btn:hover,
.play-pause-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Pulse animation for play button on first load */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(86, 97, 250, 0.7);
        transform: scale(1);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(86, 97, 250, 0);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(86, 97, 250, 0);
        transform: scale(1);
    }
}

.play-pause-btn.pulse {
    animation: pulse 1.5s ease-out infinite;
}

.trail-options.hidden,
.ripple-options.hidden,
.trail-advanced-options.hidden,
.reverb-options.hidden,
.music-volume-control.hidden,
.tone-options.hidden,
.trail-show.hidden {
    display: none;
}

/* Custom color picker */
.color-swatch-btn {
    width: 36px;
    height: 36px;
    border: 2px solid #555;
    border-radius: 6px;
    cursor: pointer;
    flex-shrink: 0;
}

.color-swatch-btn:hover {
    border-color: #888;
}

.color-popup {
    position: fixed;
    background: rgba(30, 30, 30, 0.98);
    border: 1px solid #555;
    border-radius: 10px;
    padding: 12px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.color-popup.hidden {
    display: none;
}

.color-wheel {
    display: block;
    cursor: crosshair;
    border-radius: 50%;
}

.color-lightness {
    margin-top: 10px;
}

.color-lightness input[type="range"] {
    width: 100%;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, #000, #888, #fff);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.color-lightness input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #333;
    cursor: pointer;
}

