@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;700&display=swap');

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

body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 1.5rem;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #444;
}

.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 1.5rem;
    background-color: #f9f9f9;
    padding: 1rem;
    border-radius: 5px;
}

.stat {
    text-align: center;
}

.typing-area {
    margin-bottom: 1.5rem;
    position: relative;
}

.text-display {
    background-color: #f9f9f9;
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 1rem;
    min-height: 100px;
    font-size: 1.2rem;
    line-height: 1.8;
}

.text-display .correct {
    color: #28a745;
}

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

.text-display .current {
    background-color: #ffc10726;
}

.text-input {
    width: 100%;
    height: 120px;
    padding: 1rem;
    font-size: 1.2rem;
    border: 2px solid #ddd;
    border-radius: 5px;
    resize: none;
    font-family: 'Vazirmatn', sans-serif;
}

.text-input:focus {
    outline: none;
    border-color: #4e9af1;
}

.completion-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(76, 175, 80, 0.9);
    color: white;
    padding: 1rem 2rem;
    border-radius: 5px;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.completion-message.warning-message {
    background-color: rgba(244, 67, 54, 0.9);
    animation: shake 0.5s ease;
}

.completion-message.show-message {
    opacity: 1;
    animation: bounce 0.5s ease;
}

.completion-message.warning-message.show-message {
    opacity: 1;
    animation: shake 0.5s ease;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translate(-50%, -50%);
    }

    40% {
        transform: translate(-50%, -60%);
    }

    60% {
        transform: translate(-50%, -55%);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translate(-50%, -50%);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translate(-52%, -50%);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translate(-48%, -50%);
    }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

button {
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    transition: all 0.2s;
}

#start-btn {
    background-color: #4CAF50;
    color: white;
}

#reset-btn {
    background-color: #f44336;
    color: white;
}

#next-btn {
    background-color: #2196F3;
    color: white;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

button:hover:not(:disabled) {
    opacity: 0.9;
}

/* Keyboard Styles */
.keyboard-container {
    margin-top: 1.5rem;
    background-color: #f0f0f0;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.key {
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 0 0.2rem;
    padding: 0.7rem 0.8rem;
    font-size: 1.1rem;
    min-width: 2.2rem;
    text-align: center;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.1s ease;
}

.key:hover {
    background-color: #f9f9f9;
}

.key:active,
.key.active {
    background-color: #e0f7fa;
    transform: translateY(2px);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.key.highlight {
    background-color: rgba(33, 150, 243, 0.3);
    border-color: #2196F3;
}

.space-key {
    min-width: 10rem;
    padding: 0.7rem 2rem;
    margin-top: 0.4rem;
}

.keyboard-toggle {
    text-align: center;
    margin-top: 1rem;
}

#toggle-keyboard {
    background-color: #9e9e9e;
    color: white;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
}

@media (max-width: 600px) {
    .container {
        margin: 1rem;
        padding: 1rem;
    }

    .stats {
        flex-direction: column;
        gap: 0.5rem;
    }

    .key {
        padding: 0.5rem 0.6rem;
        font-size: 0.9rem;
        min-width: 1.8rem;
    }

    .keyboard-row {
        flex-wrap: wrap;
    }

    .space-key {
        min-width: 8rem;
    }
}