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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
}

.container {
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 0;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

.title-container {
    text-align: center;
    margin-bottom: 8px;
}

h1 {
    color: #2c3e50;
    margin: 0;
    font-size: 2.2em;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    color: #7f8c8d;
    font-size: 0.9em;
    font-weight: 400;
    letter-spacing: 1px;
    margin-top: 4px;
    text-transform: uppercase;
}

.header-decoration {
    display: flex;
    align-items: center;
    gap: 12px;
}

.decoration-line {
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, #667eea 50%, transparent 100%);
    border-radius: 1px;
}

.decoration-dot {
    width: 6px;
    height: 6px;
    background: #667eea;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.5);
}

.main-content {
    display: flex;
    gap: 20px;
    align-items: stretch;
    flex: 1;
    padding: 0 20px 20px 20px;
    min-height: 0;
    position: relative;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: scaleX(-1);
    flex: 1;
    min-height: 0;
    z-index: 2;
}

#video {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 10px;
    z-index: 1;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

#canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 10px;
    z-index: 2;
    cursor: crosshair;
    transition: opacity 0.3s ease;
}

#templateCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 10px;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#fingerCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 10px;
    z-index: 3;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* 摄像头占位符 */
.camera-placeholder {
    position: absolute;
    top: 0;
    left: 20px;
    right: 180px;
    bottom: 20px;
    background: linear-gradient(135deg, rgba(240, 248, 255, 0.9) 0%, rgba(230, 240, 250, 0.8) 100%);
    border: 2px solid rgba(102, 126, 234, 0.4);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    backdrop-filter: blur(5px);
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.1);
}

.camera-placeholder.content-hidden .placeholder-content {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.placeholder-content {
    text-align: center;
    color: #2c3e50;
    max-width: 300px;
    padding: 20px;
    transition: opacity 0.3s ease;
}

.placeholder-icon {
    font-size: 4em;
    margin-bottom: 20px;
    opacity: 0.7;
}

.placeholder-title {
    font-size: 1.5em;
    font-weight: 600;
    margin-bottom: 10px;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.placeholder-subtitle {
    font-size: 1em;
    color: #7f8c8d;
    margin-bottom: 25px;
    line-height: 1.4;
}

.placeholder-tips {
    text-align: left;
    background: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.tip-item {
    font-size: 0.9em;
    color: #34495e;
    margin-bottom: 8px;
    line-height: 1.3;
}

.tip-item:last-child {
    margin-bottom: 0;
}

.toolbar {
    width: 140px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    align-self: flex-start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 3;
    margin-bottom: 20px;
}

.toolbar-section {
    margin-bottom: 16px;
}

.toolbar-section:last-child {
    margin-bottom: 0;
}

.toolbar-section h4 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
    padding-bottom: 4px;
}

/* 工具按钮 */
.tool-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-btn {
    width: 100%;
    padding: 10px 6px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tool-btn.active {
    border-color: #667eea;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tool-btn:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tool-icon {
    font-size: 18px;
}

/* 基本颜色网格 */
.basic-colors {
    margin-bottom: 15px;
}

.basic-colors label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.color-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    height: 20px;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-btn.active {
    border-color: #667eea;
    border-width: 3px;
    transform: scale(1.15);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.3);
}

/* 工具栏按钮 */
.toolbar-btn {
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toolbar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toolbar-btn:active {
    transform: translateY(0);
}

/* 颜色选择器 */
.color-picker {
    margin-bottom: 15px;
}

.color-picker label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#colorPicker {
    width: 60px;
    height: 30px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

#colorPicker:hover {
    transform: scale(1.1);
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* 画笔大小按钮 */
.brush-size-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.size-btn {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 12px;
    font-weight: 500;
}

.size-btn:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.size-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
}

/* 模板选项 */
.template-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    color: #333;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
}

.checkbox-label span {
    user-select: none;
}

.instructions {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 0;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 500px;
    width: 90%;
    display: none;
    border: 2px solid #667eea;
}

.instructions.show {
    display: block;
}

.instructions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 15px 20px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border-radius: 13px 13px 0 0;
}

.instructions-header h3 {
    margin: 0;
    color: white;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: none;
    box-shadow: none;
}

.instructions ul {
    list-style-type: none;
    padding: 20px;
    margin: 0;
}

.instructions li {
    padding: 8px 0;
    color: #555;
    position: relative;
    padding-left: 25px;
}

.instructions li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
}

/* Templates Modal */
.templates-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 0;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 600px;
    width: 90%;
    display: none;
    border: 2px solid #667eea;
}

.templates-modal.show {
    display: block;
}

.templates-content {
    padding: 0;
}

.templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 15px 20px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border-radius: 13px 13px 0 0;
}

.templates-header h3 {
    margin: 0;
    color: white;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    padding: 20px;
}

.template-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.template-item:hover {
    border-color: #667eea;
    background: #f0f4ff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.template-preview {
    font-size: 40px;
    margin-bottom: 8px;
}

.template-name {
    font-size: 14px;
    color: #333;
    text-align: center;
    font-weight: 500;
}

@media (max-width: 1200px) {
    .main-content {
        flex-direction: column;
        align-items: center;
        padding: 0 10px 10px 10px;
    }
    
    .toolbar {
        width: 100%;
        max-width: 350px;
        margin-top: 10px;
        max-height: none;
    }
    
    .tool-buttons {
        flex-direction: row;
        justify-content: center;
    }
    
    .tool-btn {
        width: 60px;
        height: 60px;
    }
    
    .color-grid {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .brush-size {
        flex-direction: row;
        align-items: center;
    }
    
    #brushSize {
        width: 100px;
        height: 6px;
        writing-mode: horizontal-tb;
        -webkit-appearance: slider-horizontal;
    }
    
    .header {
        padding: 10px 0;
    }
    
    h1 {
        font-size: 1.8em;
        letter-spacing: 2px;
    }
    
    .subtitle {
        font-size: 0.8em;
    }
    
    .decoration-line {
        width: 30px;
    }
    
    .camera-placeholder {
        left: 10px;
        right: 10px;
        bottom: 15px;
    }
    
    .toolbar {
        max-height: calc(100vh - 140px);
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 0 5px 5px 5px;
    }
    
    .toolbar {
        padding: 15px;
    }
    
    .toolbar-section {
        margin-bottom: 15px;
    }
    
    .header {
        padding: 8px 0;
    }
    
    h1 {
        font-size: 1.5em;
        letter-spacing: 1px;
    }
    
    .subtitle {
        font-size: 0.7em;
    }
    
    .decoration-line {
        width: 25px;
    }
    
    .decoration-dot {
        width: 4px;
        height: 4px;
    }
    
    .camera-placeholder {
        left: 5px;
        right: 5px;
        bottom: 10px;
    }
    
    .toolbar {
        max-height: calc(100vh - 120px);
    }
    
    .placeholder-content {
        max-width: 250px;
        padding: 15px;
    }
    
    .placeholder-icon {
        font-size: 3em;
        margin-bottom: 15px;
    }
    
    .placeholder-title {
        font-size: 1.2em;
    }
    
    .placeholder-subtitle {
        font-size: 0.9em;
        margin-bottom: 20px;
    }
    
    .placeholder-tips {
        padding: 12px;
    }
    
    .tip-item {
        font-size: 0.8em;
    }
    
    .instructions {
        width: 95%;
        max-width: none;
    }
}
