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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
    position: relative;
}

.header a:hover {
    opacity: 1 !important;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    font-weight: 700;
}

.timer-display {
    display: flex;
    justify-content: center;
    gap: 40px;
    flex-wrap: wrap;
}

.timer-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.timer-label {
    font-size: 1.1em;
    opacity: 0.9;
}

.timer-value {
    font-size: 2.5em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 10px;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    padding: 30px;
    min-height: 500px;
}

.image-container {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.image-container.active {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.5);
    border: 3px solid #667eea;
}

.image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.image-container.active .overlay {
    opacity: 1;
}

.overlay-content {
    text-align: center;
    color: white;
}

.time-display {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.time-label {
    font-size: 1.5em;
    font-weight: 600;
    opacity: 0.9;
}

.time-value {
    font-size: 4em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.controls {
    padding: 30px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.btn {
    padding: 15px 40px;
    font-size: 1.2em;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
    transform: translateY(-2px);
}

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

.status {
    padding: 10px 20px;
    background: white;
    border-radius: 8px;
    font-size: 1.1em;
    color: #495057;
    min-width: 200px;
    text-align: center;
}

.status.active {
    background: #d4edda;
    color: #155724;
}

.status.error {
    background: #f8d7da;
    color: #721c24;
}

/* Индикатор состояния */
.state-indicator {
    padding: 40px 30px;
    text-align: center;
    background: #f8f9fa;
    border-top: 3px solid #dee2e6;
    border-bottom: 3px solid #dee2e6;
    transition: all 0.5s ease;
}

.state-indicator.state-no-face {
    background: #fff3cd;
    border-color: #ffc107;
    animation: pulse 2s infinite;
}

.state-indicator.state-face-detected {
    background: #d1ecf1;
    border-color: #17a2b8;
}

.state-indicator.state-looking-left {
    background: #d4edda;
    border-color: #28a745;
    animation: glow-left 1.5s infinite;
}

.state-indicator.state-looking-right {
    background: #d4edda;
    border-color: #28a745;
    animation: glow-right 1.5s infinite;
}

.state-icon {
    font-size: 5em;
    margin-bottom: 20px;
    transition: transform 0.3s ease;
    display: inline-block;
}

.state-indicator.state-no-face .state-icon {
    animation: shake 0.5s infinite;
}

.state-indicator.state-face-detected .state-icon {
    animation: bounce 1s infinite;
}

.state-indicator.state-looking-left .state-icon {
    transform: scale(1.2);
    animation: pulse-icon 1s infinite;
}

.state-indicator.state-looking-right .state-icon {
    transform: scale(1.2);
    animation: pulse-icon 1s infinite;
}

.state-text {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 10px;
    color: #212529;
    transition: color 0.3s ease;
}

.state-indicator.state-no-face .state-text {
    color: #856404;
}

.state-indicator.state-face-detected .state-text {
    color: #0c5460;
}

.state-indicator.state-looking-left .state-text,
.state-indicator.state-looking-right .state-text {
    color: #155724;
}

.state-description {
    font-size: 1.3em;
    color: #6c757d;
    font-weight: 500;
}

/* Анимации */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

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

@keyframes pulse-icon {
    0%, 100% {
        transform: scale(1.2);
    }
    50% {
        transform: scale(1.4);
    }
}

@keyframes glow-left {
    0%, 100% {
        box-shadow: 0 0 0 rgba(40, 167, 69, 0);
    }
    50% {
        box-shadow: 0 0 30px rgba(40, 167, 69, 0.5);
    }
}

@keyframes glow-right {
    0%, 100% {
        box-shadow: 0 0 0 rgba(40, 167, 69, 0);
    }
    50% {
        box-shadow: 0 0 30px rgba(40, 167, 69, 0.5);
    }
}

/* Statistics panel */
.statistics-panel {
    padding: 40px 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 3px solid #dee2e6;
}

.statistics-title {
    text-align: center;
    font-size: 2em;
    font-weight: 700;
    color: #212529;
    margin-bottom: 30px;
}

.statistics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.stat-card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.stat-label {
    font-size: 1.1em;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2.5em;
    font-weight: 700;
    color: #212529;
    font-family: 'Courier New', monospace;
    margin-bottom: 5px;
}

.stat-percentage {
    font-size: 1.2em;
    color: #28a745;
    font-weight: 600;
    margin-top: 5px;
}

.stat-description {
    font-size: 0.9em;
    color: #6c757d;
    margin-top: 5px;
    font-style: italic;
}

/* Highlight active stat card */
.stat-card.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.stat-card.active .stat-label,
.stat-card.active .stat-value,
.stat-card.active .stat-percentage,
.stat-card.active .stat-description {
    color: white;
}

/* Chart card styles */
.stat-card-chart {
    grid-column: span 1;
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.chart-container {
    flex: 1;
    min-height: 200px;
    margin: 15px 0;
    position: relative;
}

#comparison-chart {
    max-height: 200px;
}

.winner-display {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid #dee2e6;
}

.winner-label {
    font-size: 0.9em;
    color: #6c757d;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.winner-value {
    font-size: 1.8em;
    font-weight: 700;
    color: #212529;
    margin-bottom: 5px;
    transition: color 0.3s ease;
}

.winner-stats {
    font-size: 0.95em;
    color: #6c757d;
    font-weight: 500;
}

@media (min-width: 768px) {
    .stat-card-chart {
        grid-column: span 2;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .timer-value {
        font-size: 2em;
    }

    .time-value {
        font-size: 3em;
    }

    .state-icon {
        font-size: 3.5em;
    }

    .state-text {
        font-size: 1.8em;
    }

    .state-description {
        font-size: 1.1em;
    }

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

    .statistics-title {
        font-size: 1.5em;
    }

    .stat-value {
        font-size: 2em;
    }
}

