* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #0f172a;
    color: #f8fafc;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.app-container {
    background: #1e293b;
    width: 100%;
    max-width: 750px;
    padding: 35px;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    border: 1px solid #334155;
    position: relative;
}

header {
    text-align: center;
    margin-bottom: 25px;
}

header h1 {
    font-size: 1.8rem;
    color: #f8fafc;
    margin-bottom: 6px;
}

header p {
    color: #94a3b8;
    font-size: 0.9rem;
}

.dashboard {
    display: flex;
    justify-content: space-around;
    margin-bottom: 25px;
    background: #0f172a;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #334155;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #38bdf8;
}

.text-display {
    background-color: #0f172a;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #334155;
    font-size: 1.25rem;
    line-height: 1.8;
    letter-spacing: 0.5px;
    min-height: 120px;
    margin-bottom: 20px;
    user-select: none;
    word-break: break-word;
    direction: rtl;
}

.text-display span {
    position: relative;
    transition: color 0.1s ease;
}

.text-display span.correct {
    color: #4ade80;
}

.text-display span.incorrect {
    color: #f87171;
    background-color: rgba(248, 113, 113, 0.2);
    border-radius: 2px;
}

.text-display span.current {
    border-bottom: 3px solid #38bdf8;
}

.input-area {
    margin-bottom: 20px;
}

textarea {
    width: 100%;
    background-color: #0f172a;
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 15px;
    color: #f8fafc;
    font-size: 1.1rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s ease;
    direction: rtl;
}

textarea:focus {
    border-color: #38bdf8;
}

textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.controls {
    display: flex;
    justify-content: center;
}

#restartBtn, #modalRestartBtn {
    background-color: #38bdf8;
    color: #0f172a;
    border: none;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#restartBtn:hover, #modalRestartBtn:hover {
    background-color: #0284c7;
    color: #ffffff;
    transform: translateY(-2px);
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(5px);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #1e293b;
    border: 1px solid #334155;
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    width: 85%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    color: #4ade80;
    margin-bottom: 20px;
}

.final-stats {
    text-align: right;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 1.05rem;
}

.final-stats strong {
    color: #38bdf8;
}