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

.audio-controls select {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9em;
    background: white;
    cursor: pointer;
    min-width: 120px;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.speed-control label {
    font-weight: 600;
    color: #333;
    font-size: 0.85em;
    white-space: nowrap;
}

.speed-control input[type="range"] {
    width: 100px;
}

.speed-control span {
    font-weight: bold;
    color: #667eea;
    font-size: 0.85em;
    min-width: 60px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .audio-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .speed-control {
        justify-content: space-between;
    }
    
    .speed-control input[type="range"] {
        width: 80px;
    }
}

@media (max-width: 480px) {
    .audio-controls select {
        min-width: 100px;
        font-size: 0.8em;
    }
    
    .speed-control {
        padding: 6px 10px;
    }
    
    .speed-control input[type="range"] {
        width: 60px;
    }
}

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

.container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 800px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.2em;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border-left: 4px solid #667eea;
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #333;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
    text-transform: uppercase;
    font-weight: 600;
}

.text-display {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    font-size: 1.3em;
    line-height: 1.6;
    min-height: 150px;
    max-height: 200px;
    overflow-y: auto;
    word-wrap: break-word;
    white-space: pre-wrap;
    text-align: left;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    outline: none;
}

.text-display::-webkit-scrollbar {
    width: 8px;
}

.text-display::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.text-display::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

.text-display::-webkit-scrollbar-thumb:hover {
    background: #5a6fd8;
}

.current-char {
    background: #667eea;
    color: white;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

.correct {
    color: #28a745;
}

.incorrect {
    color: #dc3545;
    text-decoration: underline;
}

.upcoming-text {
    color: #6c757d;
}

.keyboard {
    background: #2c3e50;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 25px;
    overflow: hidden;
    max-width: 100%;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin-bottom: 6px;
    flex-wrap: nowrap;
    min-width: 0;
}

.key {
    background: #34495e;
    color: white;
    padding: 10px 8px;
    margin: 0 2px;
    border-radius: 4px;
    min-width: 40px;
    height: 45px;
    text-align: center;
    font-weight: bold;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    font-size: 0.85em;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 1;
    flex-grow: 0;
}

/* Special keys with different widths */
.key[data-key="Backspace"] {
    min-width: 80px;
    font-size: 0.75em;
}

.key[data-key="Tab"] {
    min-width: 70px;
    font-size: 0.75em;
}

.key[data-key="Caps"] {
    min-width: 85px;
    font-size: 0.75em;
}

.key[data-key="Enter"] {
    min-width: 85px;
    font-size: 0.75em;
}

.key[data-key="Shift"] {
    min-width: 100px;
    font-size: 0.75em;
}

.key[data-key="Space"] {
    min-width: 300px;
    font-size: 0.75em;
}

.key.special-key {
    background: #2c3e50;
}

.key.active {
    background: #667eea;
    transform: scale(1.05);
    box-shadow: 0 0 10px #667eea;
    z-index: 1;
}

.controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

button {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: all 0.3s;
    white-space: nowrap;
    outline: none;
}

button:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

/* Стили для кнопки голоса */
#voiceToggleBtn {
    background: #28a745;
}

#voiceToggleBtn:hover {
    background: #218838;
}

#voiceToggleBtn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

#voiceToggleBtn.voice-active {
    background: #218838;
    box-shadow: 0 0 10px #28a745;
}

#showLeaderboardBtn {
    background: #ffc107;
    color: #212529;
}

#showLeaderboardBtn:hover {
    background: #e0a800;
}

.callsign-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.callsign-selector label {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    font-size: 0.9em;
}

select {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9em;
    background: white;
    cursor: pointer;
    min-width: 80px;
    outline: none;
}

select:focus {
    border-color: #667eea;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 20px;
}

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

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    opacity: 0.7;
}

.modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

/* Leaderboard Styles */
.leaderboard-list {
    margin-top: 15px;
}

.leaderboard-header {
    display: grid;
    grid-template-columns: 60px 1fr 80px 80px 80px;
    gap: 10px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: 60px 1fr 80px 80px 80px;
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    align-items: center;
    transition: background-color 0.2s;
}

.leaderboard-item:hover {
    background-color: #f8f9fa;
}

.leaderboard-item.top-three {
    background: linear-gradient(135deg, #fff9e6, #fff3cd);
    border-radius: 8px;
    margin: 5px 0;
    border: 2px solid #ffd43b;
}

.rank {
    font-weight: bold;
    text-align: center;
}

.name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.accuracy, .wpm, .callsigns {
    text-align: center;
    font-weight: 600;
}

.accuracy {
    color: #28a745;
}

.wpm {
    color: #667eea;
}

.callsigns {
    color: #6c757d;
    font-size: 0.9em;
}

.no-scores {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 40px 20px;
}

/* Score Submission Form */
.score-form {
    margin-top: 20px;
}

.score-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.score-form input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1em;
    margin-bottom: 15px;
    box-sizing: border-box;
}

.score-form input:focus {
    outline: none;
    border-color: #667eea;
}

.score-form button {
    width: 100%;
    background: #28a745;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.score-form button:hover {
    background: #218838;
    transform: translateY(-2px);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .keyboard {
        padding: 10px;
    }
    
    .key {
        padding: 8px 6px;
        min-width: 30px;
        height: 40px;
        font-size: 0.75em;
        margin: 0 1px;
    }
    
    .key[data-key="Backspace"] {
        min-width: 60px;
        font-size: 0.7em;
    }
    
    .key[data-key="Tab"] {
        min-width: 50px;
        font-size: 0.7em;
    }
    
    .key[data-key="Caps"] {
        min-width: 65px;
        font-size: 0.7em;
    }
    
    .key[data-key="Enter"] {
        min-width: 65px;
        font-size: 0.7em;
    }
    
    .key[data-key="Shift"] {
        min-width: 80px;
        font-size: 0.7em;
    }
    
    .key[data-key="Space"] {
        min-width: 200px;
        font-size: 0.7em;
    }
    
    .text-display {
        font-size: 1.1em;
        min-height: 120px;
        max-height: 180px;
        padding: 15px;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .callsign-selector {
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .leaderboard-header,
    .leaderboard-item {
        grid-template-columns: 50px 1fr 70px 70px 70px;
        gap: 8px;
        padding: 10px 12px;
        font-size: 0.85em;
    }
    
    .modal-body {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    
    h1 {
        font-size: 1.6em;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-item {
        padding: 10px;
    }
    
    .stat-value {
        font-size: 1.5em;
    }
    
    .keyboard {
        padding: 8px;
    }
    
    .key {
        padding: 6px 4px;
        min-width: 25px;
        height: 35px;
        font-size: 0.65em;
        margin: 0 1px;
    }
    
    .key[data-key="Backspace"] {
        min-width: 50px;
        font-size: 0.6em;
    }
    
    .key[data-key="Tab"] {
        min-width: 40px;
        font-size: 0.6em;
    }
    
    .key[data-key="Caps"] {
        min-width: 50px;
        font-size: 0.6em;
    }
    
    .key[data-key="Enter"] {
        min-width: 50px;
        font-size: 0.6em;
    }
    
    .key[data-key="Shift"] {
        min-width: 60px;
        font-size: 0.6em;
    }
    
    .key[data-key="Space"] {
        min-width: 150px;
        font-size: 0.6em;
    }
    
    .keyboard-row {
        margin-bottom: 4px;
    }
    
    .callsign-selector {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    .leaderboard-header,
    .leaderboard-item {
        grid-template-columns: 40px 1fr 60px 60px 60px;
        gap: 6px;
        padding: 8px 10px;
        font-size: 0.8em;
    }
    
    .modal-header h2 {
        font-size: 1.3em;
    }
}
.leaderboard-mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.mode-btn {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    flex: 1;
    max-width: 200px;
}

.mode-btn:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.mode-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.score-mode {
    text-align: center;
    font-weight: bold;
    color: #667eea;
    margin: 10px 0;
    font-size: 1.1em;
}

