* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 30px;
    max-width: 1200px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 30px;
}

.camera-section {
    position: relative;
}

.camera-container {
    position: relative;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}

#videoElement {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#outputCanvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 250px;
    border: 3px solid #4CAF50;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0.7;
    transition: all 0.3s ease;
}

.face-guide.active {
    border-color: #FF5722;
    box-shadow: 0 0 20px rgba(255, 87, 34, 0.5);
}

.guide-text {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    white-space: nowrap;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
    justify-content: center;
}

.capture-btn {
    background: linear-gradient(45deg, #FF6B6B, #FF8E53);
    color: white;
}

.capture-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.3);
}

.secondary-btn {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.secondary-btn:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
}

.section h3 {
    margin-bottom: 15px;
    color: #343a40;
    font-size: 18px;
}

.background-colors {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.color-option {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.color-option.selected {
    border-color: #007bff;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.3);
}

.color-option.white {
    background: white;
    border: 3px solid #dee2e6;
}

.size-templates {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.size-option {
    padding: 15px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.size-option.selected {
    border-color: #007bff;
    background: #f0f8ff;
}

.size-option h4 {
    margin-bottom: 5px;
    color: #343a40;
}

.size-option p {
    color: #6c757d;
    font-size: 14px;
    margin: 0;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.status.loading {
    background: #fff3cd;
    color: #856404;
}

.status.ready {
    background: #d1edff;
    color: #0c5460;
}

.status.processing {
    background: #f8d7da;
    color: #721c24;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.download-section {
    display: none;
    text-align: center;
}

.download-section.show {
    display: block;
}

.preview-image {
    max-width: 100%;
    border-radius: 10px;
    margin-bottom: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.download-btn {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

.instructions {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
}

.instructions h4 {
    margin-bottom: 10px;
    color: #1976d2;
}

.instructions ul {
    margin-left: 20px;
    color: #424242;
}

.instructions li {
    margin-bottom: 5px;
}

#instruction-heading {
    cursor: pointer;
    user-select: none;
}
.instruction-list {
    transition: all 0.3s ease;
}


@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 20px;
    }

    .background-colors {
        grid-template-columns: repeat(3, 1fr);
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .control-btn {
        width: 100%;
        max-width: 300px;
    }

}