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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
    color: #333;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
}

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.header h1 {
    font-size: 20px;
    font-weight: 600;
}

.info-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.info-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Main Content */
.main-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.screen.active {
    opacity: 1;
    transform: translateX(0);
}

/* Welcome Screen */
.welcome-content {
    text-align: center;
    padding: 30px;
    max-width: 300px;
}

.welcome-content .icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.welcome-content h2 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #333;
}

.welcome-content p {
    font-size: 16px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 30px;
}

/* Camera Screen */
.camera-container {
    width: 100%;
    height: 100%;
}

.video-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.camera-controls {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    padding: 15px 20px;
    border-radius: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    z-index: 20;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

#video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

#canvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

/* Processing Screen */
.processing-content {
    text-align: center;
    padding: 30px;
}

.processing-content h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #333;
}

.processing-content p {
    font-size: 16px;
    color: #666;
}

/* Result Screen */
.result-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

#resultCanvas {
    flex: 1;
    max-width: 100%;
    max-height: calc(100% - 80px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Error Screen */
.error-content {
    text-align: center;
    padding: 30px;
    max-width: 300px;
}

.error-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.error-content h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #e74c3c;
}

.error-content p {
    font-size: 16px;
    color: #666;
    line-height: 1.5;
    margin-bottom: 30px;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    padding: 15px 30px;
    min-width: 120px;
}

.btn-large {
    padding: 20px 40px;
    font-size: 18px;
    min-width: 200px;
}

.btn-small {
    padding: 10px 20px;
    font-size: 14px;
    min-width: 80px;
}

.btn-capture {
    background: #e74c3c;
    color: white;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    font-size: 24px;
    min-width: auto;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-capture:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #e9ecef;
}

.btn-secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

/* Secondary buttons in camera screen (overlay) */
.camera-controls .btn-secondary {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
}

.camera-controls .btn-secondary:hover {
    background: rgba(255,255,255,0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Loading Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-body ul {
    list-style: none;
    padding: 0;
}

.modal-body li {
    margin-bottom: 12px;
    padding-left: 20px;
    position: relative;
    line-height: 1.5;
}

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

/* Security Notice */
.security-notice {
    position: fixed;
    top: 70px;
    left: 20px;
    right: 20px;
    background: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: 10px;
    font-size: 14px;
    text-align: center;
    border: 1px solid #ffeaa7;
    z-index: 200;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .header {
        padding: 12px 15px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .info-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .welcome-content .icon {
        font-size: 60px;
    }
    
    .welcome-content h2 {
        font-size: 20px;
    }
    
    .btn {
        font-size: 14px;
        padding: 12px 24px;
    }
    
    .btn-large {
        padding: 16px 32px;
        font-size: 16px;
    }
    
    .camera-controls {
        top: 15px;
        padding: 12px 16px;
        gap: 15px;
    }
    
    .btn-capture {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    .result-container {
        padding: 15px;
    }
    
    .result-actions {
        gap: 8px;
    }
    
    .result-actions .btn {
        flex: 1;
        min-width: auto;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .welcome-content {
        padding: 20px;
    }
    
    .welcome-content .icon {
        font-size: 50px;
        margin-bottom: 15px;
    }
    
    .welcome-content h2 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .welcome-content p {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .processing-content {
        padding: 20px;
    }
    
    .error-content {
        padding: 20px;
    }
}