:root {
    --primary: #4F46E5;
    --accent: #00DCF0;
    --accent-green: #00E0C0;
    --success: #10B981;
    --error: #EF4444;
    --bg-dark: #0A0F1C;
    --bg-card: #111827;
    --text-light: #F9FAFB;
    --glass-bg: rgba(17, 24, 39, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 500px;
    height: 100dvh;
    position: relative;
    background-color: var(--bg-dark);
}

.hidden {
    display: none !important;
}

/* ==================== WELCOME SCREEN ==================== */
.welcome-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2.5rem 2rem;
    background: radial-gradient(ellipse at 50% 20%, rgba(0, 220, 240, 0.08) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 80%, rgba(79, 70, 229, 0.06) 0%, transparent 50%),
                var(--bg-dark);
    animation: fadeIn 0.6s ease-out;
}

.welcome-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

/* Brand Logo */
.brand-logo {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.logo-icon {
    animation: float 3s ease-in-out infinite;
}

.brand-name {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 0.95rem;
    font-weight: 300;
    opacity: 0.6;
}

.brand-sub a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    opacity: 1;
}

.brand-sub a:hover {
    text-decoration: underline;
}

/* Welcome Info */
.welcome-info {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tagline {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.6;
    opacity: 0.75;
    max-width: 340px;
}

.features {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 0.85rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 400;
    color: rgba(255,255,255,0.8);
    transition: all 0.3s ease;
}

.feature-item:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(0, 220, 240, 0.2);
}

.feature-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

/* Start Button */
.btn-start {
    background: linear-gradient(135deg, var(--accent), var(--accent-green));
    color: #0A0F1C;
    font-size: 1.15rem;
    font-weight: 800;
    padding: 1.1rem 2rem;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    transition: all 0.2s ease;
    box-shadow: 0 4px 25px rgba(0, 220, 240, 0.25);
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 35px rgba(0, 220, 240, 0.35);
}

.btn-start:active {
    transform: scale(0.97);
}

.btn-icon {
    font-size: 1.3rem;
}

.disclaimer {
    font-size: 0.72rem;
    opacity: 0.35;
    text-align: center;
    margin-top: -1rem;
}

/* ==================== CAMERA SCREEN ==================== */
.camera-screen {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #000;
    animation: fadeIn 0.4s ease-out;
}

.camera-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 5;
    transform: scaleX(-1);
}

.overlay-elements {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 2rem 1.5rem;
    pointer-events: none;
}

/* Status Box Glassmorphism */
.status-box {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.status-box h2 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
    transition: color 0.3s ease;
}

.status-box p {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* Tracking States */
.state-error h2 { color: var(--error); }
.state-success h2 { color: var(--success); }

/* Face Guide (Corners) */
.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 65%;
    aspect-ratio: 3/4;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.face-guide .corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border-color: white;
    border-style: solid;
    transition: border-color 0.3s ease;
}

.face-guide.aligned .corner {
    border-color: var(--success);
    opacity: 1;
}

.corner.top-left { top: 0; left: 0; border-width: 4px 0 0 4px; border-top-left-radius: 20px; }
.corner.top-right { top: 0; right: 0; border-width: 4px 4px 0 0; border-top-right-radius: 20px; }
.corner.bottom-left { bottom: 0; left: 0; border-width: 0 0 4px 4px; border-bottom-left-radius: 20px; }
.corner.bottom-right { bottom: 0; right: 0; border-width: 0 4px 4px 0; border-bottom-right-radius: 20px; }

/* Requirements Badges */
.requirements {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    position: absolute;
    bottom: 12%;
    left: 50%;
    transform: translateX(-50%);
    width: 95%;
    pointer-events: none;
}

.badge {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    padding: 0.35rem 0.7rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.badge.met {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
    color: var(--success);
}

/* Countdown Animation */
.countdown-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

.number {
    font-size: 8rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    animation: popIn 1s infinite alternate;
}

.ring {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 6px solid transparent;
    border-top-color: var(--success);
    border-bottom-color: var(--success);
    animation: spin 1.5s linear infinite;
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.4);
}

/* Modal */
.modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
    z-index: 50;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    pointer-events: auto;
}

.modal-content {
    background: #1F2937;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    width: 100%;
    border: 1px solid rgba(255,255,255,0.1);
}

.modal-content img {
    width: 100%;
    border-radius: 12px;
    margin: 1.5rem 0;
    transform: scaleX(-1);
}

.btn {
    background: linear-gradient(135deg, var(--primary), #818CF8);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:active {
    transform: scale(0.96);
}

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

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(1.1); opacity: 1; }
}

@keyframes fadeIn {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
}

/* Flash effect for capture */
.flash {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: white;
    z-index: 100;
    pointer-events: none;
    animation: flashAnim 0.8s ease-out;
}

@keyframes flashAnim {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ==================== READY ANIMATION ==================== */
.ready-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 18;
    gap: 1rem;
    animation: readyPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ready-circle {
    width: 100px;
    height: 100px;
}

.ready-check {
    width: 100px;
    height: 100px;
    filter: drop-shadow(0 0 15px rgba(16, 185, 129, 0.6));
}

.ready-check-circle {
    stroke: var(--success);
    stroke-width: 2.5;
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    animation: drawCircle 0.6s ease-out forwards;
}

.ready-check-path {
    stroke: var(--success);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: drawCheck 0.3s 0.4s ease-out forwards;
}

.ready-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--success);
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
    animation: readyTextFade 0.3s 0.5s ease-out forwards;
    opacity: 0;
}

@keyframes drawCircle {
    to { stroke-dashoffset: 0; }
}

@keyframes drawCheck {
    to { stroke-dashoffset: 0; }
}

@keyframes readyPop {
    0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes readyTextFade {
    to { opacity: 1; }
}
