:root {
    --primary-color: #E53935;
    --secondary-color: #FFD600;
    --green-color: #4CAF50;
    --blue-color: #2196F3;
    --light-red: #FFCDD2;
    --light-yellow: #FFF9C4;
    --dark-red: #C62828;
    --text-color: #333;
    --bg-color: #FFFDE7;
    --normal-bg: #FFFFFF;
    --disabled-bg: #f5f5f5;
    --pink-color: #E91E63;
    --header-gradient-start: #FFD600;
    --header-gradient-end: #4CAF50;
    --header-text: white;
}

.typing-tutor-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 15px;
    background-color: var(--bg-color);
    color: var(--text-color);
    max-width: 100%;
}

.typing-tutor-container h1 {
    background: linear-gradient(135deg, var(--header-gradient-start), var(--header-gradient-end));
    color: var(--header-text);
    text-align: center;
    margin-bottom: 25px;
    font-size: 1.8rem;
    padding: 18px 0;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.typing-tutor-card {
    background-color: var(--normal-bg);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border: 1px solid var(--light-red);
    position: relative;
}

#referenceText {
    white-space: pre-wrap;
    line-height: 2;
    font-size: 1.1rem;
    height: 200px;
    overflow-y: hidden;
    padding: 15px;
    border: 2px solid var(--light-yellow);
    border-radius: 8px;
    background-color: var(--normal-bg);
    margin-bottom: 15px;
    position: relative;
    scroll-behavior: smooth;
    text-align: justify;
    text-justify: inter-word;
    display: block;
}

#referenceText span {
    position: relative;
    display: inline;
    line-height: 2;
    transition: all 0.1s ease;
}

#userInput {
    width: 100%;
    height: 150px;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid var(--light-red);
    border-radius: 8px;
    resize: none;
    margin-bottom: 15px;
    background-color: var(--normal-bg);
    text-align: justify;
    text-justify: inter-word;
}

#userInput:disabled {
    background-color: var(--disabled-bg);
    cursor: not-allowed;
}

#userInput:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(229, 57, 53, 0.2);
}

.typing-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.typing-controls button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.3s;
    flex: 1;
    min-width: 140px;
    font-weight: bold;
}

#startBtn {
    background-color: var(--green-color);
    color: white;
}

#startBtn.running {
    background-color: var(--primary-color);
}

#startBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#startBtn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#resetBtn {
    background-color: var(--secondary-color);
    color: #333;
}

#resetBtn:hover:not(:disabled) {
    background-color: var(--blue-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#resetBtn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#nextBtn {
    background-color: var(--blue-color);
    color: white;
    min-width: 120px;
    flex: none;
}

#prevBtn {
    background-color: var(--pink-color);
    color: white;
    min-width: 120px;
    flex: none;
}

#nextBtn:hover:not(:disabled),
#prevBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#nextBtn:active:not(:disabled),
#prevBtn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#setTimerBtn {
    background-color: #607D8B;
    color: white;
    min-width: 120px;
}

.timer-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
}

.timer {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    background-color: var(--light-yellow);
    padding: 12px 30px;
    border-radius: 50px;
    display: inline-block;
    min-width: 140px;
    text-align: center;
}

.stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.stat-box {
    background-color: var(--light-yellow);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--secondary-color);
}

.stat-title {
    font-size: 0.9rem;
    color: var(--dark-red);
    margin-bottom: 5px;
    font-weight: bold;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.current-char {
    background-color: var(--secondary-color);
    border-radius: 2px;
    position: relative;
    z-index: 2;
}

.correct {
    color: #388E3C;
}

.incorrect {
    color: var(--primary-color);
    text-decoration: underline;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
}

.checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
}

.language-selector {
    margin-bottom: 15px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.language-option {
    padding: 8px 16px;
    border-radius: 5px;
    border: 2px solid var(--light-red);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.language-option.selected {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--dark-red);
}

.language-option:hover:not(.selected) {
    background-color: var(--light-yellow);
}

.part-info {
    text-align: center;
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--dark-red);
}

.time-up-message {
    text-align: center;
    color: var(--primary-color);
    font-weight: bold;
    margin-bottom: 15px;
    font-size: 1.2rem;
    display: none;
}

.time-input-container {
    display: flex;
    align-items: center;
    gap: 5px;
}

#timeInput {
    width: 60px;
    height: 40px;
    padding: 5px;
    font-size: 1.1rem;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 5px;
}

/* Scrollbar styling for reference text (optional) */
#referenceText::-webkit-scrollbar {
    width: 6px;
}

#referenceText::-webkit-scrollbar-track {
    background: var(--light-yellow);
    border-radius: 3px;
}

#referenceText::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 3px;
}

#referenceText::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

@media (min-width: 768px) {
    .typing-tutor-container {
        max-width: 100%;
        padding: 20px;
    }
    
    #referenceText, #userInput {
        height: 250px;
    }
    
    .stats-container {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .typing-controls button {
        min-width: 160px;
        padding: 14px 28px;
    }
    
    .timer {
        font-size: 2.2rem;
        min-width: 160px;
        padding: 14px 35px;
    }
}

@media (max-width: 480px) {
    .typing-controls {
        flex-direction: column;
    }
    
    .typing-controls button {
        width: 100%;
    }
    
    .checkbox-container {
        width: 100%;
        justify-content: center;
    }
    
    .timer {
        font-size: 1.8rem;
        padding: 10px 20px;
    }
    
    #referenceText, #userInput {
        height: 180px;
    }
}