* {
    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;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

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

h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 10px;
    font-size: 2.5em;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    gap: 20px;
}

.stat-box {
    background: #f8f9fa;
    padding: 15px 25px;
    border-radius: 10px;
    text-align: center;
    flex: 1;
}

.stat-label {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

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

#textDisplay {
    background: #f8f9fa;
    padding: 30px;
    border-radius: 10px;
    font-size: 1.3em;
    line-height: 1.8;
    margin-bottom: 20px;
    user-select: none;
    letter-spacing: 1px;
}

.char {
    position: relative;
}

.char.correct {
    color: #28a745;
}

.char.incorrect {
    color: #dc3545;
    background: #ffe6e6;
}

.char.current {
    background: #667eea;
    color: white;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

#inputBox {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    border: 3px solid #667eea;
    border-radius: 10px;
    outline: none;
    margin-bottom: 20px;
    font-family: inherit;
}

#inputBox:disabled {
    background: #e9ecef;
    cursor: not-allowed;
}

.buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

button {
    padding: 12px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

#restartBtn {
    background: #667eea;
    color: white;
}

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

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

.result-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

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

.result-content h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.result-stats {
    margin: 20px 0;
}

.result-stat {
    margin: 15px 0;
    font-size: 1.2em;
}

.result-stat span {
    font-weight: bold;
    color: #667eea;
    font-size: 1.5em;
}

#closeResult {
    background: #28a745;
    color: white;
    margin-top: 20px;
}

#closeResult:hover {
    background: #218838;
}

.instruction {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-style: italic;
}

@media (max-width: 480px) {
    body {
        align-items: flex-start;
        padding: 8px;
    }

    .container {
        padding: 20px 12px;
        border-radius: 14px;
    }

    h1 {
        font-size: 1.7em;
    }

    .subtitle,
    .stats {
        margin-bottom: 20px;
    }

    .stats {
        gap: 8px;
    }

    .stat-box {
        min-width: 0;
        padding: 10px 4px;
    }

    .stat-label {
        font-size: 0.72em;
        overflow-wrap: anywhere;
    }

    .stat-value {
        font-size: 1.4em;
    }

    #textDisplay {
        padding: 16px;
        font-size: 1em;
    }

    button {
        min-height: 44px;
    }
}
