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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(to bottom right, #f8f9fa, #e9ecef);
    color: #212529;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #495057;
    font-weight: 600;
}

.mode-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 10px 20px;
    border: 2px solid #0d6efd;
    background: #fff;
    color: #0d6efd;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: #e7f1ff;
}

.mode-btn.active {
    background: #0d6efd;
    color: #fff;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.video-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    aspect-ratio: 4/3;
    background: #fff;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #dee2e6;
}

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

#canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: scaleX(-1);
}

.counter {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 10px;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #dee2e6;
}

.counter .label {
    display: block;
    font-size: 0.8rem;
    color: #6c757d;
    opacity: 0.9;
}

.counter .count {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #495057;
}

.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn.primary {
    background: #0d6efd;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn.primary:hover {
    background: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:not(.primary) {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.btn:not(.primary):hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

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

.status {
    text-align: center;
    padding: 10px 20px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    font-size: 0.9rem;
    color: #6c757d;
}

.status.error {
    background: #f8d7da;
    border-color: #f5c2c7;
    color: #842029;
}

.status.success {
    background: #d1e7dd;
    border-color: #badbcc;
    color: #0f5132;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .mode-btn {
        padding: 8px 15px;
        font-size: 0.8rem;
    }

    .video-container {
        border-radius: 10px;
    }

    .counter {
        padding: 10px 15px;
    }

    .counter .count {
        font-size: 1.5rem;
    }
}
