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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    color: #e0e0e0;
    overflow-x: hidden;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 15px 0;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5em;
    background: linear-gradient(90deg, #ff69b4, #9b59b6, #3498db, #2ecc71, #f1c40f, #e74c3c);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rainbow 3s linear infinite;
    text-shadow: 0 0 30px rgba(255, 105, 180, 0.3);
}

@keyframes rainbow {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.subtitle {
    font-size: 1.2em;
    color: #b8a9c9;
    margin-top: 5px;
}

.main-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* 工具栏样式 */
.toolbar {
    width: 250px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-section:last-child {
    border-bottom: none;
}

.tool-section h3 {
    font-size: 0.95em;
    margin-bottom: 10px;
    color: #c0a0ff;
}

/* 图片上传 */
.image-upload {
    text-align: center;
}

.image-upload input[type="file"] {
    display: none;
}

.upload-btn {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #6b5ce7, #4d96ff);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(107, 92, 231, 0.4);
}

.upload-hint {
    font-size: 0.75em;
    color: #888;
    margin-top: 5px;
}

/* 颜色面板 */
.color-palette {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 10px;
}

.color-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

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

.custom-color label {
    font-size: 0.85em;
    color: #b8a9c9;
}

.custom-color input[type="color"] {
    width: 50px;
    height: 30px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background: transparent;
}

/* 滑块样式 */
.brush-size, .effect-intensity {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #9b59b6, #3498db);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.5);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.brush-size span, .effect-intensity span {
    min-width: 25px;
    text-align: center;
    font-weight: bold;
    color: #d4a5f5;
}

/* 下拉选择 */
select {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9em;
    cursor: pointer;
    outline: none;
}

select:hover, select:focus {
    border-color: #9b59b6;
}

select option {
    background: #1a1a2e;
    color: #e0e0e0;
}

/* 按钮样式 */
.tools, .actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-btn, .action-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tool-btn:hover, .action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.tool-btn.active {
    background: linear-gradient(135deg, #9b59b6, #3498db);
    border-color: transparent;
}

.tool-btn.danger {
    background: rgba(231, 76, 60, 0.3);
    border-color: rgba(231, 76, 60, 0.5);
}

.tool-btn.danger:hover {
    background: rgba(231, 76, 60, 0.5);
}

.action-btn {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.3), rgba(52, 152, 219, 0.3));
    border-color: rgba(155, 89, 182, 0.3);
}

.action-btn:hover {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.5), rgba(52, 152, 219, 0.5));
}

/* 画布容器 */
.canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#sandCanvas {
    background: #1a1a2e;
    border-radius: 15px;
    cursor: crosshair;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: block;
}

.canvas-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 10px 20px;
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.85em;
    color: #b8a9c9;
}

/* 预设图案面板 */
.presets {
    width: 180px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.presets h3 {
    font-size: 1em;
    margin-bottom: 12px;
    color: #d4a5f5;
    text-align: center;
}

.preset-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.preset-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.preset-btn.active {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.4), rgba(52, 152, 219, 0.4));
    border-color: #9b59b6;
}

.preset-icon {
    font-size: 1.5em;
}

.canvas-settings {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.canvas-settings label {
    font-size: 0.85em;
    color: #b8a9c9;
}

.canvas-settings input[type="color"] {
    width: 100%;
    height: 35px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
    }

    .toolbar, .presets {
        width: 100%;
    }

    .toolbar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .tool-section {
        margin-bottom: 10px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }

    .toolbar {
        grid-template-columns: 1fr;
    }

    #sandCanvas {
        max-width: 100%;
    }
}

/* 动画效果 */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}