:root {
    --primary-color: #4a5568;
    --secondary-color: #667eea;
    --accent-color: #48bb78;
    --error-color: #f56565;
    --bg-color: #f7fafc;
    --text-color: #2d3748;
    --card-bg: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
}

[data-theme="dark"] {
    --primary-color: #e2e8f0;
    --secondary-color: #9f7aea;
    --accent-color: #68d391;
    --error-color: #fc8181;
    --bg-color: #1a202c;
    --text-color: #e2e8f0;
    --card-bg: #2d3748;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.logo {
    font-size: 2.5rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.tagline {
    font-size: 1.2rem;
    color: var(--secondary-color);
}

main {
    flex: 1;
}

.setup-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow);
    max-width: 600px;
    margin: 0 auto;
}

.setup-steps {
    margin: 30px 0;
}

.step {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
}

.step-number {
    width: 40px;
    height: 40px;
    background: var(--secondary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.start-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-weight: 600;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(72, 187, 120, 0.3);
}

.practice-section {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.hidden {
    display: none !important;
}

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

.stat {
    background: var(--card-bg);
    padding: 20px 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.text-display {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.target-text {
    font-size: 1.5rem;
    margin-bottom: 20px;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

.target-text .correct {
    color: var(--accent-color);
}

.target-text .incorrect {
    color: var(--error-color);
    background: rgba(245, 101, 101, 0.2);
}

.target-text .current {
    background: var(--secondary-color);
    color: white;
    padding: 2px 4px;
    border-radius: 4px;
}

.typed-text {
    font-size: 1.2rem;
    color: var(--secondary-color);
    min-height: 30px;
    font-family: 'Courier New', monospace;
}

.camera-view {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    max-width: 800px;
    margin: 0 auto;
}

#video {
    width: 100%;
    height: auto;
    display: block;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.virtual-keyboard {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: var(--border-radius);
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
    width: 90%;
    max-width: 600px;
}

.key {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px;
    text-align: center;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.key.active {
    background: var(--accent-color);
    transform: scale(1.1);
}

.key.pressed {
    background: var(--secondary-color);
    animation: keyPress 0.3s ease;
}

@keyframes keyPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

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

.control-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: var(--primary-color);
    transform: translateY(-2px);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 500px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.settings-group {
    margin-bottom: 20px;
}

.settings-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--secondary-color);
}

.settings-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--secondary-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 1rem;
}

.close-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: var(--border-radius);
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
}

footer {
    text-align: center;
    padding: 30px 0;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .stats {
        gap: 20px;
    }
    
    .stat {
        padding: 15px 20px;
    }
    
    .virtual-keyboard {
        padding: 10px;
        gap: 3px;
    }
    
    .key {
        padding: 8px 4px;
        font-size: 0.8rem;
    }
}