* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0a0a0f;
    color: #fff;
    overflow: hidden;
}

#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#canvas-container canvas {
    display: block;
}

/* Tiny debug panel */
.tp-dfwv {
    position: fixed !important;
    top: 20px !important;
    left: 20px !important;
    width: 340px !important;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    z-index: 1100 !important;
}

/* Config Panel */
#config-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 40px);
    background: rgba(15, 15, 25, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    z-index: 1000;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#config-panel.merged-into-tinypane {
    transform: translateX(calc(100% + 80px));
    opacity: 0;
    pointer-events: none;
}

#config-panel.collapsed {
    transform: translateX(calc(100% - 50px));
}

#config-panel.collapsed .panel-content {
    opacity: 0;
    pointer-events: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.9);
}

#toggle-panel {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background 0.2s;
}

#toggle-panel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.panel-content {
    padding: 16px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    transition: opacity 0.3s ease;
}

.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.config-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.config-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 14px;
}

.config-section h3 span {
    color: rgba(100, 200, 255, 0.8);
    font-weight: 400;
}

.control-group {
    margin-bottom: 14px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.mode-controls {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.mode-controls.active {
    display: block;
}

.conditional-controls {
    margin-top: 8px;
}

.conditional-controls.hidden {
    display: none;
}

.control-group > label {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 6px;
}

.control-group label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

input[type="range"] {
    width: calc(100% - 60px);
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    outline: none;
    vertical-align: middle;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(1.1);
}

.value-display {
    display: inline-block;
    width: 50px;
    text-align: right;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    font-family: 'SF Mono', Monaco, monospace;
}

input[type="color"] {
    -webkit-appearance: none;
    width: 40px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #64c8ff;
    cursor: pointer;
}

select {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    outline: none;
}

select:hover {
    background: rgba(255, 255, 255, 0.15);
}

select option {
    background: #1a1a2e;
    color: #fff;
}

/* Layer List */
#layer-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.layer-item.active {
    border-color: rgba(100, 200, 255, 0.5);
    background: rgba(100, 200, 255, 0.1);
}

.layer-preview {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.layer-info {
    flex: 1;
    min-width: 0;
}

.layer-name {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-particles {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
}

.layer-visibility {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.layer-visibility:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.layer-visibility.hidden {
    color: rgba(255, 255, 255, 0.2);
}

.layer-delete {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: rgba(255, 100, 100, 0.6);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.layer-delete:hover {
    background: rgba(255, 100, 100, 0.15);
    color: rgba(255, 100, 100, 1);
}

/* File Input */
.file-input-wrapper {
    position: relative;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-input-wrapper label {
    display: block;
    padding: 12px 16px;
    background: rgba(100, 200, 255, 0.1);
    border: 1px dashed rgba(100, 200, 255, 0.3);
    border-radius: 8px;
    text-align: center;
    font-size: 12px;
    color: rgba(100, 200, 255, 0.8);
    cursor: pointer;
    transition: all 0.2s;
}

.file-input-wrapper:hover label {
    background: rgba(100, 200, 255, 0.15);
    border-color: rgba(100, 200, 255, 0.5);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 10px 16px;
    margin-top: 10px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

#reset-all {
    background: rgba(255, 100, 100, 0.15);
    color: rgba(255, 150, 150, 0.9);
}

#reset-all:hover {
    background: rgba(255, 100, 100, 0.25);
}

#export-config {
    background: rgba(100, 255, 150, 0.15);
    color: rgba(150, 255, 180, 0.9);
}

#export-config:hover {
    background: rgba(100, 255, 150, 0.25);
}

/* Loading Overlay */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 15, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #64c8ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading p {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

/* Empty State */
.empty-state {
    padding: 30px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 12px;
}

/* Stats */
#stats {
    position: fixed;
    top: 20px;
    left: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    #config-panel {
        width: 280px;
        right: 10px;
        top: 10px;
        max-height: calc(100vh - 20px);
    }
}
