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

:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --bg-light: #f8fafc;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

/* Main Content */
.main {
    flex: 1;
    padding: 16px;
}

.section {
    margin-bottom: 20px;
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.status-card {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 16px 8px;
    text-align: center;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
}

.status-card.success {
    border-color: var(--success);
    background: #ecfdf5;
}

.status-card.error {
    border-color: var(--error);
    background: #fef2f2;
}

.status-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.status-text {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 4px;
}

.status-badge {
    font-size: 1.2rem;
}

/* Video Wrapper */
.video-wrapper {
    position: relative;
    width: 100%;
    background: black;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#video-preview {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 4/3;
    object-fit: cover;
}

.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 260px;
    border: 3px solid transparent;
    border-radius: 50%;
    transition: border-color 0.3s ease;
    pointer-events: none;
}

.face-guide.active {
    border-color: rgba(16, 185, 129, 0.6);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.action-prompt {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    display: none;
    backdrop-filter: blur(10px);
}

.action-prompt.active {
    display: block;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-5px); }
}

.timer-display {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    backdrop-filter: blur(10px);
}

.timer-display.active {
    display: flex;
}

/* Instructions */
#instructions-section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: var(--text-dark);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.action-item {
    background: var(--bg-light);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.95rem;
    border: 1px solid var(--border);
}

.hint {
    font-size: 0.85rem;
    color: var(--text-light);
    text-align: center;
    padding: 8px;
    background: #fef3c7;
    border-radius: 8px;
    border-left: 3px solid var(--warning);
}

/* Result Section */
.result-icon {
    font-size: 4rem;
    text-align: center;
    margin-bottom: 16px;
}

#result-section {
    text-align: center;
    padding: 24px;
    background: var(--bg-light);
    border-radius: 12px;
}

#result-section.success {
    background: #ecfdf5;
    border: 2px solid var(--success);
}

#result-section.error {
    background: #fef2f2;
    border: 2px solid var(--error);
}

#result-title {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: var(--text-dark);
}

#result-message {
    color: var(--text-light);
    margin-bottom: 12px;
}

.upload-status {
    font-size: 0.9rem;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    margin-top: 12px;
}

/* Error Section */
.error-section {
    background: #fef2f2;
    border: 2px solid var(--error);
    border-radius: 12px;
    padding: 20px;
}

.error-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 12px;
}

.error-section h3 {
    color: var(--error);
    margin-bottom: 8px;
}

.error-section p {
    color: var(--text-dark);
    margin-bottom: 12px;
}

.error-solutions {
    background: white;
    padding: 12px;
    border-radius: 8px;
    margin-top: 12px;
}

.error-solutions ol {
    margin-left: 20px;
    margin-top: 8px;
}

.error-solutions li {
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-dark);
}

/* Controls */
.controls {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    flex: 1;
    max-width: 280px;
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
    color: white;
}

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

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

/* Footer */
.footer {
    padding: 16px;
    text-align: center;
    background: var(--bg-light);
    border-top: 1px solid var(--border);
}

.footer p {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* Responsive */
@media (max-width: 480px) {
    .header h1 {
        font-size: 1.25rem;
    }

    .main {
        padding: 12px;
    }

    .status-icon {
        font-size: 1.5rem;
    }

    .status-text {
        font-size: 0.75rem;
    }

    .action-prompt {
        font-size: 1rem;
        padding: 10px 20px;
    }

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

    .btn {
        font-size: 1rem;
        padding: 14px 24px;
    }

    .face-guide {
        width: 160px;
        height: 220px;
    }
}

@media (min-width: 600px) {
    .app {
        margin-top: 20px;
        margin-bottom: 20px;
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
        overflow: hidden;
    }

    .header {
        border-radius: 0;
    }
}

/* Download Section */
.download-section {
    margin-top: 20px;
    padding: 15px;
    background: #f0f9ff;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
}

.download-section .btn {
    width: 100%;
    max-width: none;
}

.download-section .btn:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

/* Hidden utility */
.hidden {
    display: none !important;
}
