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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.container {
    max-width: 90vw;
    max-height: 90vh;
    width: 100%;
    margin: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    text-align: center;
    margin-bottom: 15px;
    padding: 12px;
    background: linear-gradient(135deg, #0066cc 0%, #004c99 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,102,204,0.3);
    flex-shrink: 0;
}

header h1 {
    color: white;
    margin-bottom: 6px;
    font-size: 20px;
    font-weight: 600;
}

header p {
    color: rgba(255,255,255,0.9);
    font-size: 12px;
    margin: 0;
}

main {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex: 1;
    min-height: 0;
}

.left-column,
.right-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    min-height: 0;
}

.left-column {
    order: 1;
}

.right-column {
    order: 2;
}

.upload-section,
.edit-section,
.output-section {
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    flex-shrink: 1;
}

.preview-section {
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border: 1px solid rgba(255,255,255,0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 400px;
}

.upload-section:hover,
.preview-section:hover,
.edit-section:hover,
.output-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.upload-section h2,
.preview-section h2,
.edit-section h2,
.output-section h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
    flex-shrink: 0;
}

.upload-options {
    display: flex;
    justify-content: center;
}

.option {
    width: 100%;
    max-width: 300px;
}

input[type="file"] {
    display: none;
}

label,
button {
    display: block;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #0066cc 0%, #004c99 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,102,204,0.3);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

label:hover,
button:hover {
    background: linear-gradient(135deg, #0052a3 0%, #003d7a 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,102,204,0.4);
}

label:active,
button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,102,204,0.3);
}

.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-height: 350px;
    border: 3px dashed #0066cc;
    border-radius: 10px;
    background: rgba(245, 247, 250, 0.5);
    transition: all 0.3s ease;
    overflow: hidden;
}

.preview-container img,
.preview-container canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-container:hover {
    border-color: #004c99;
    background: rgba(245, 247, 250, 0.8);
}

#previewCanvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.bg-color-section,
.size-section {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.bg-color-section h3,
.size-section h3 {
    margin-bottom: 12px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

.color-options {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.color-btn {
    width: 60px;
    height: 60px;
    border: 3px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.color-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.color-btn.blue {
    background: #0066cc;
}

.color-btn.white {
    background: #ffffff;
    border: 3px solid #333;
    color: #333;
    text-shadow: none;
}

.color-btn.red {
    background: #cc0000;
}

.color-btn.active {
    border: 4px solid #333;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#sizeSelect {
    width: 100%;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

#sizeSelect:hover {
    border-color: #0066cc;
    box-shadow: 0 2px 8px rgba(0,102,204,0.1);
}

.output-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: auto;
}

.output-buttons button {
    flex: 1;
    max-width: 180px;
    padding: 12px;
    font-size: 14px;
}

footer {
    text-align: center;
    padding: 12px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-top: 15px;
    flex-shrink: 0;
}

footer p {
    color: #555;
    font-size: 10px;
    margin: 0;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .upload-options {
        flex-direction: column;
    }
    
    .color-options {
        justify-content: center;
    }
    
    .output-buttons {
        flex-direction: column;
    }
}

#video {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    background-color: #000;
}

.capture-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: rgba(0,0,0,0.5);
}

.capture-overlay button {
    width: 200px;
    margin: 10px;
}

.capture-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 400px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

/* 加载状态 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    font-size: 18px;
    color: #0066cc;
}

.loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0066cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 错误提示 */
.error {
    background-color: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    text-align: center;
}

/* 成功提示 */
.success {
    background-color: #e8f5e8;
    color: #2e7d32;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    text-align: center;
}

/* 按钮选中状态 */
.color-btn.active {
    border: 3px solid #333;
    transform: scale(1.1);
}