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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

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

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

header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #667eea;
}

.difficulty-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.difficulty-label {
    font-size: 0.95em;
    font-weight: 600;
    color: #555;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.difficulty-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 8px 18px;
    border-radius: 999px;
    border: 2px solid #667eea;
    background: transparent;
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.difficulty-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
    transform: translateY(-1px);
}

.difficulty-btn.active {
    background: linear-gradient(90deg, #667eea, #764ba2);
    color: #fff;
    box-shadow: 0 10px 20px rgba(118, 75, 162, 0.35);
}

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

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
}

.level-info {
    text-align: center;
    margin-bottom: 30px;
}

.level-info h2 {
    color: #333;
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e0e0e0;
    border-radius: 5px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

.level-description {
    color: #666;
    font-style: italic;
}

.game-area {
    margin: 30px 0;
}

.text-display {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 30px;
    font-size: 1.5em;
    line-height: 1.8;
    min-height: 120px;
    margin-bottom: 20px;
    font-family: 'Courier New', monospace;
}

.typed {
    color: #28a745;
}

.current {
    background: #667eea;
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.remaining {
    color: #666;
}

.input-area {
    margin-bottom: 30px;
}

#typing-input {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.3s;
    font-family: 'Courier New', monospace;
}

#typing-input:focus {
    border-color: #667eea;
}

#typing-input.correct {
    border-color: #28a745;
}

#typing-input.error {
    border-color: #dc3545;
}

#typing-input.completed {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.keyboard-display {
    background: #2c3e50;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 8px;
}

.key {
    background: #34495e;
    color: white;
    border: 2px solid #2c3e50;
    border-radius: 5px;
    padding: 10px 15px;
    font-size: 0.9em;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
    transition: all 0.2s;
    cursor: default;
}

.key.active {
    background: #667eea;
    border-color: #667eea;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.key.next {
    background: #f39c12;
    border-color: #f39c12;
    animation: glow 1s infinite;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px rgba(243, 156, 18, 0.5); }
    50% { box-shadow: 0 0 15px rgba(243, 156, 18, 0.8); }
}

.key.correct {
    background: #27ae60;
}

.key.error {
    background: #e74c3c;
}

.key.space {
    min-width: 200px;
}

.key.shift {
    min-width: 80px;
}

.key.enter {
    min-width: 100px;
}

.key.backspace {
    min-width: 80px;
}

.completion-message {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 15px;
    padding: 30px;
    margin: 30px 0;
    text-align: center;
    color: white;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.completion-content h3 {
    color: white;
    font-size: 2em;
    margin-bottom: 20px;
}

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

.completion-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.completion-label {
    font-size: 1em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.completion-value {
    font-size: 2.5em;
    font-weight: bold;
}

.completion-status {
    font-size: 1.2em;
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    font-weight: bold;
}

.completion-status.success {
    background: rgba(40, 167, 69, 0.3);
}

.completion-status.warning {
    background: rgba(255, 193, 7, 0.3);
}

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

.btn {
    padding: 12px 30px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.btn-primary {
    background: #667eea;
    color: white;
}

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

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

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

.level-selector {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #e0e0e0;
}

.level-selector h3 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-width: 800px;
    margin: 0 auto;
}

.level-card {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.level-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e9ecef;
}

.level-card.completed {
    background: #d4edda;
    border-color: #28a745;
}

.level-card.active {
    background: #cfe2ff;
    border-color: #667eea;
    font-weight: bold;
}

.level-card h4 {
    margin-bottom: 5px;
    color: #333;
}

.level-card .level-stats {
    font-size: 0.8em;
    color: #666;
    margin-top: 5px;
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 1.8em;
    }

    .difficulty-control {
        gap: 8px;
    }

    .difficulty-btn {
        padding: 6px 14px;
        font-size: 0.9em;
    }

    .text-display {
        font-size: 1.2em;
        padding: 20px;
    }

    .stats-bar {
        gap: 20px;
    }

    .key {
        padding: 8px 10px;
        font-size: 0.8em;
        min-width: 35px;
    }

    .levels-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

