* {
    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;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
}

h2 {
    text-align: center;
    color: #555;
    margin-bottom: 20px;
    font-size: 22px;
}

/* Time Selection */
#timeSelection {
    padding: 20px 0;
}

.time-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.time-btn {
    padding: 15px 20px;
    font-size: 16px;
    font-weight: bold;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

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

.custom-time {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.custom-time label {
    display: block;
    margin-bottom: 10px;
    color: #555;
    font-weight: 600;
}

.custom-time input {
    width: 200px;
    padding: 10px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-right: 10px;
    outline: none;
}

.custom-time input:focus {
    border-color: #667eea;
}

.custom-time button {
    padding: 10px 25px;
    font-size: 16px;
    font-weight: bold;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
}

.custom-time button:hover {
    background: #218838;
}

/* Practice Screen */
#practiceScreen {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 10px;
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
}

#stats span {
    font-size: 16px;
    font-weight: bold;
    color: #555;
}

#wordDisplay {
    height: 250px;
    padding: 20px;
    background: #fafafa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 18px;
    line-height: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: flex-start;
    flex-shrink: 0;
}

#wordDisplay::-webkit-scrollbar {
    width: 8px;
}

#wordDisplay::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#wordDisplay::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.word {
    padding: 4px 8px;
    border-radius: 5px;
    transition: all 0.2s;
    white-space: nowrap;
    font-size: 17px;
}

.word.current {
    background: #fff3cd;
    font-weight: bold;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.word.correct {
    background: #d4edda;
    color: #155724;
}

.word.incorrect {
    background: #f8d7da;
    color: #721c24;
    text-decoration: line-through;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

#typingInput {
    flex: 1;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 10px;
    outline: none;
}

#typingInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.2);
}

#endBtn {
    padding: 15px 25px;
    font-size: 16px;
    font-weight: bold;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
    white-space: nowrap;
}

#endBtn:hover {
    background: #c82333;
}

/* Results Screen */
#results {
    text-align: center;
    padding: 20px;
}

.result-stats {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 25px;
    margin: 20px 0;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin: 10px 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.result-label {
    font-size: 18px;
    color: #555;
    font-weight: 600;
}

.result-value {
    font-size: 24px;
    color: #667eea;
    font-weight: bold;
}

#restartBtn {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
}

#restartBtn:hover {
    background: #5568d3;
}

/* Landscape mode optimizations */
@media (orientation: landscape) and (max-height: 600px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
        max-height: 95vh;
        overflow-y: auto;
    }
    
    h1 {
        font-size: 20px;
        margin-bottom: 10px;
    }
    
    h2 {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    #stats {
        padding: 10px;
        gap: 5px;
    }
    
    #stats span {
        font-size: 14px;
    }
    
    #wordDisplay {
        height: 180px;
        padding: 15px;
        font-size: 16px;
        line-height: 1.8;
        gap: 8px;
    }
    
    .word {
        font-size: 15px;
        padding: 3px 6px;
    }
    
    #typingInput {
        padding: 10px;
        font-size: 16px;
    }
    
    #endBtn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .time-options {
        gap: 10px;
    }
    
    .time-btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .result-item {
        padding: 10px;
    }
    
    .result-label {
        font-size: 16px;
    }
    
    .result-value {
        font-size: 20px;
    }
}

/* Mobile Portrait */
@media (max-width: 600px) and (orientation: portrait) {
    .container {
        padding: 20px;
    }
    
    #wordDisplay {
        height: 200px;
        font-size: 17px;
        gap: 10px;
    }
    
    .word {
        font-size: 16px;
    }
    
    .time-options {
        grid-template-columns: 1fr 1fr;
    }
    
    .custom-time input {
        width: 150px;
        margin-right: 5px;
        margin-bottom: 10px;
    }
    
    .input-container {
        flex-direction: column;
    }
    
    #endBtn {
        width: 100%;
    }
}

/* Language Selection Styles */
#languageSelection {
    text-align: center;
    padding: 20px 0;
}

.language-buttons {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 30px;
}

.lang-btn {
    padding: 30px 50px;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    font-weight: bold;
    min-width: 200px;
}

.lang-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.lang-btn:active {
    transform: translateY(-2px);
}

/* Hindi Mode Styles - ONLY font changes, NO size changes */
body.hindi-mode #wordDisplay {
    font-family: 'Mangal', 'Noto Sans Devanagari', 'Arial Unicode MS', sans-serif;
}

body.hindi-mode .word {
    font-family: 'Mangal', 'Noto Sans Devanagari', 'Arial Unicode MS', sans-serif;
}

/* Hindi input - keeps EXACT same size as English */
body.hindi-mode #typingInput {
    font-family: 'Mangal', 'Noto Sans Devanagari', 'Arial Unicode MS', sans-serif !important;
}

#typingInput[lang="hi"] {
    font-family: 'Mangal', 'Noto Sans Devanagari', 'Arial Unicode MS', sans-serif !important;
}

/* Back to Language button */
.back-btn {
    position: absolute;
    top: 0px;
    left: 20px;
    padding: 10px 20px;
    font-size: 14px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: 600;
}

.back-btn:hover {
    background: #5a6268;
}

#timeSelection {
    position: relative;
    padding-top: 50px;
}