/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #f5f5f5;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 5px;
    padding-top: 30px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 800;
    background: linear-gradient(135deg, #1a237e, #0d47a1);
    padding: 5px 10px;
}

main {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.practice-section {
    background: #fff;
    border-radius: 10px;
    padding: 2px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 2px;
}

.typing-area {
    margin: 10px 0px;
    position: relative;
}

.lesson-text {
    font-size: 5.4em;
    line-height: 1.2;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    min-height: 100px;
    background: #e0f3a8;
    cursor: text;
    outline: none;
    font-family: 'Roboto';
    letter-spacing: 0.1em;
    position: relative;
    
    overflow: hidden;
    white-space: nowrap;
    width: 100%;
}

.text-content {
    display: inline-block;
    position: relative;
    transition: transform 0.3s ease-out;
    transform: translateX(0);
    margin-left: 4em; /* ← Add space before first char */
    
}
.space-char {
    display: inline-block;
    width: 0.3em; /* visually bigger space */
}
.lesson-text:focus {
    border-color: #0e71b3;
    box-shadow: 0 0 10px rgba(5, 56, 90, 0.2);
}

.typing-input {
    width: 100%;
    padding: 5px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 1.2em;
    line-height: 0.6;
    resize: vertical;
    min-height: 5px;
    transition: border-color 0.3s;
}

.typing-input:focus {
    border-color: #2196f3;
    outline: none;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.keyboard-section {
    margin-top: 0px;
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 5px;
    background: #e9ecef;
    border-radius: 10px;
    user-select: none;
}

.keyboard-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.key {
    min-width: 40px;
    height: 40px;
    background: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: default;
    transition: all 0.15s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

.key.space {
    width: 400px;
}

.key.backspace,
.key.tab,
.key.caps,
.key.enter,
.key.shift,
.key.ctrl,
.key.alt,
.key.win {
    min-width: 60px;
    font-size: 12px;
}

.key.enter {
    min-width: 90px;
}

.key.shift {
    min-width: 100px;
}

.key.active {
    transform: translateY(2px);
    background: #e3f2fd;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.key.next-key {
    background: rgba(52, 152, 219, 0.1);
    border-color: #3498db;
    animation: keyPulse 1.5s infinite;
}

@keyframes keyPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 152, 219, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(52, 152, 219, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(52, 152, 219, 0);
    }
}

/* Key Connection Styles */
.key-connection {
    position: absolute;
    height: 2px;
    background: transparent;
    transform-origin: left center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.3s ease;
    border-top: 2px dashed #4CAF50;
    z-index: 1;
}

.key-connection.active {
    opacity: 1;
    border-top: 2px solid #4CAF50;
    animation: connectionPulse 1.5s infinite;
}

/* Shift Helper Text */
.shift-helper {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #4CAF50;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
    z-index: 2;
}

.shift-helper.active {
    opacity: 1;
}

.shift-helper:after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #4CAF50;
}

/* Enhanced Key Styles */
.key.next-key {
    background: rgba(76, 175, 80, 0.2);
    border-color: #4CAF50;
    animation: keyPulse 1.5s infinite;
}

.key.shift.next-key {
    animation: shiftKeyPulse 1.5s infinite;
}

/* Animations */
@keyframes connectionPulse {
    0% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.4;
    }
}

@keyframes keyPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

@keyframes shiftKeyPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
        background: rgba(76, 175, 80, 0.2);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
        background: rgba(76, 175, 80, 0.4);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
        background: rgba(76, 175, 80, 0.2);
    }
}

/* Update existing key styles */
.key {
    transition: all 0.3s ease;
}

.key.active {
    transform: translateY(2px);
    box-shadow: 0 1px 1px rgba(0,0,0,0.2);
}

.key.shift {
    position: relative;
}

/* Lesson navigation styles */
.lesson-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 5px;
}

.lesson-numbers {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.lesson-number {
    width: 30px;
    height: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 100;
    color: #2c3e50;
    transition: all 0.2s ease;
}

.lesson-number:hover {
    border-color: #3498db;
    color: #3498db;
}

.lesson-number.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.prev-lesson,
.next-lesson {
    padding: 0.6rem 1.2rem;
    background: #3498db;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.prev-lesson:hover,
.next-lesson:hover {
    background: #2980b9;
}

.prev-lesson:disabled,
.next-lesson:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.7;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 5px 10px;
    }
    
    main {
        margin-top: 30px;
    }
    
    .key {
        width: 40px;
        height: 40px;
        font-size: 1em;
    }
    
    .key[data-key="space"] {
        width: 200px;
    }

    .menu-bar {
        padding: 0.2rem;
    }

    .lesson-numbers {
        gap: 0.25rem;
    }

    .lesson-number {
        width: 35px;
        height: 35px;
        font-size: 0.9rem;
    }

    .controls {
        flex-direction: column;
    }

    #reset-btn,
    #next-lesson-btn {
        width: 100%;
    }
}

/* Header Styles */
h1 {
    color: #333;
    margin-bottom: 15px;
    font-size: 2rem;
}

/* Language and Font Selector Styles */
.language-selector,
.font-selector,
.lesson-selector {
    margin-bottom: 15px;
}

button {
    padding: 8px 16px;
    margin: 0 5px;
    border: none;
    border-radius: 4px;
    background-color: #e0e0e0;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background-color: #d0d0d0;
}

button.active {
    background-color: #2196f3;
    color: white;
}

/* Main content layout */
.practice-area {
    background-color: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

.typing-area textarea {
    width: 100%;
    height: 150px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 1.1rem;
    resize: none;
    margin-bottom: 20px;
}

.typing-area textarea:focus {
    outline: none;
    border-color: #3498db;
}

/* Stats Styles */
.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 5px;
    padding: 5px;
    background-color: #f8f9fa;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stat-item {
    text-align: center;
    padding: 5px 10px;
    border-radius: 5px;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.stat-item span:first-child {
    color: #666;
    margin-right: 5px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-item span:last-child {
    font-size: 1.2rem;
    font-weight: 500;
    color: #2196f3;
}

/* Controls Styles */
.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 5px;
}

#reset-btn,
#next-lesson-btn {
    padding: 0.4rem 1.1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 400;
    transition: all 0.2s ease;
}

#reset-btn {
    background: #e74c3c;
    color: #fff;
}

#next-lesson-btn {
    background: #2ecc71;
    color: #fff;
}

#reset-btn:hover {
    background: #c0392b;
}

#next-lesson-btn:hover {
    background: #27ae60;
}

/* Hand Position Indicator */
.hand-position {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.hand {
    display: flex;
    gap: 5px;
}

.finger {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #bbdefb;
    transition: all 0.3s ease;
}

.finger.active {
    background-color: #2196f3;
    transform: scale(1.2);
}

/* Keyboard Container Styles */
.keyboard-container {
    margin-top: 30px;
    padding: 20px;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Keyboard Layout */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 15px;
    background-color: #e9ecef;
    border-radius: 10px;
    user-select: none;
}

.keyboard-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

/* Key Styles */
.key {
    min-width: 65px;
    height: 35px;
    background-color: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
    padding: 5px;
    position: relative;
    transform-style: preserve-3d;
    transform: translateZ(0);
}

/* Special Keys */
.key.space {
    width: 400px;
}

.key.backspace,
.key.tab,
.key.caps,
.key.enter,
.key.shift,
.key.ctrl,
.key.alt,
.key.win {
    min-width: 60px;
    font-size: 12px;
}

.key.enter {
    min-width: 90px;
}

.key.shift {
    min-width: 100px;
}

/* Finger Color Coding */
.key[data-key="a"],
.key[data-key="q"],
.key[data-key="z"] {
    background-color: #ffcdd2; /* Left pinky */
}

.key[data-key="s"],
.key[data-key="w"],
.key[data-key="x"] {
    background-color: #f8bbd0; /* Left ring */
}

.key[data-key="d"],
.key[data-key="e"],
.key[data-key="c"] {
    background-color: #e1bee7; /* Left middle */
}

.key[data-key="f"],
.key[data-key="r"],
.key[data-key="v"],
.key[data-key="g"],
.key[data-key="t"],
.key[data-key="b"] {
    background-color: #d1c4e9; /* Left index */
}

.key[data-key="j"],
.key[data-key="u"],
.key[data-key="n"],
.key[data-key="h"],
.key[data-key="y"],
.key[data-key="m"] {
    background-color: #bbdefb; /* Right index */
}

.key[data-key="k"],
.key[data-key="i"],
.key[data-key=","] {
    background-color: #b3e5fc; /* Right middle */
}

.key[data-key="l"],
.key[data-key="o"],
.key[data-key="."] {
    background-color: #b2ebf2; /* Right ring */
}

.key[data-key=";"],
.key[data-key="p"],
.key[data-key="/"] {
    background-color: #b2dfdb; /* Right pinky */
}

/* Home Keys */
.key.home-key {
    border-bottom: 3px solid #2196f3;
}

/* Active Key State */
.key.active {
    transform: translateY(4px);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
    background-color: #e3f2fd;
    border-color: #2196f3;
}

/* Next Key to Type Highlight */
.key.next-key {
    animation: pulse 1.5s infinite;
    border-color: #2196f3;
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.5);
    z-index: 1;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 15px rgba(33, 150, 243, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
}

/* Error Highlight */
.key.error {
    animation: shake 0.5s;
    background-color: #ffebee;
    border-color: #f44336;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Character Highlighting in Text Display */
.char {
    display: inline-block;
    padding: 0 2px;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.char.current {
    background-color: #e3f2fd;
    border-bottom: 2px solid #3498db;
    animation: blink 1s infinite;
}

.char.correct {
    color: #27ae60;
    background-color: rgba(39, 174, 96, 0.1);
}

.char.incorrect {
    color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
    text-decoration: underline wavy #e74c3c;
}

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

/* Hand Position Indicator */
.hand-position {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.hand {
    display: flex;
    gap: 5px;
}

.finger {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #bbdefb;
    transition: all 0.3s ease;
}

.finger.active {
    background-color: #2196f3;
    transform: scale(1.2);
}

/* Responsive Keyboard */
@media (max-width: 1200px) {
    .key {
        min-width: 35px;
        height: 35px;
        font-size: 12px;
    }

    .key.space {
        width: 300px;
    }

    .key.backspace,
    .key.tab,
    .key.caps,
    .key.enter,
    .key.shift {
        min-width: 50px;
    }
}

@media (max-width: 768px) {
    .keyboard {
        transform: scale(0.8);
        transform-origin: top center;
    }

    .key.space {
        width: 200px;
    }

    .container {
        padding-top: 140px;
        transform: scale(0.8);
        transform-origin: top center;
    }

    h1 {
        font-size: 2rem;
    }

    .lesson-text {
        font-size: 1.8em;
    }

    .lesson-buttons {
        flex-direction: column;
        align-items: center;
    }

    .lesson-btn {
        width: 100%;
        max-width: 300px;
    }

    .stats {
        flex-direction: column;
        gap: 5px;
    }

    .controls {
        flex-direction: column;
    }

    #reset-btn,
    #next-lesson-btn {
        width: 100%;
    }
}

/* Hindi character specific styles */
.hindi-char {
    font-size: 1.2em;
    padding: 0 2px;
    line-height: 1.8;
}

.hindi-char.current {
    border-bottom: 2px solid #2196f3;
    animation: blink 1s infinite;
}

.hindi-char.correct {
    color: #4caf50;
}

.hindi-char.incorrect {
    color: #f44336;
    text-decoration: wavy underline #f44336;
}

/* Menu Bar Styles */
.menu-bar {
    display: flex;
    gap: 0.06rem;
    padding: 0.085rem;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    border-bottom: 1px solid #2980b9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 600;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.menu-item {
    margin: 0.08rem;
}

.menu-btn {
    padding: 0.2rem 0.3rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 400;
    color: #fff;
    transition: all 0.3s ease;
    min-width: 120px;
    text-align: center;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.menu-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Lesson Navigation */
.lesson-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.lesson-numbers {
    display: flex;
    gap: 0.5rem;
}

.lesson-number {
    width: 2.5rem;
    height: 2.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: #2c3e50;
    transition: all 0.2s ease;
}

.lesson-number:hover {
    border-color: #3498db;
    color: #3498db;
}

.lesson-number.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
    transform: translateY(-1px);
}

.nav-btn {
    padding: 0.6rem 1.2rem;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    color: #2c3e50;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    border-color: #3498db;
    color: #3498db;
}

/* Zoom Controls */
.zoom-btn {
    padding: 0.8rem 1.2rem;
    background: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    color: #2c3e50;
    font-weight: 500;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: #f8f9fa;
    color: #3498db;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive adjustments */
@media (max-width: 668px) {
    .menu-bar {
        padding: 0.2rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    .menu-item {
        margin: 0.15rem;
    }

    .menu-btn {
        min-width: 100px;
        padding: 0.2rem 1rem;
        font-size: 0.9rem;
    }

    .submenu {
        position: fixed;
        top: auto;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 0.25rem;
        width: 90%;
        max-width: 300px;
    }
}