@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-green: #8FD14F;
    --secondary-green: #7AB83C;
    --light-green: #E8F5E0;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --background: #F8FBF6;
    --white: #ffffff;
    --error-red: #E74C3C;
    --shadow: 0 4px 12px rgba(143, 209, 79, 0.15);
    --shadow-lg: 0 8px 24px rgba(143, 209, 79, 0.2);
}

body {
    font-family: 'Fredoka', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #F0F8EA 0%, #E3F2D3 50%, #D6ECC2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-primary);
}

.container {
    width: 100%;
    max-width: 1000px;
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    text-align: center;
    margin-bottom: 35px;
}

header h1 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 4px;
    color: var(--primary-green);
    margin-bottom: 8px;
    text-transform: uppercase;
}

header h2 {
    font-size: 52px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    font-family: 'Fredoka', sans-serif;
}

.stats-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-bottom: 35px;
    flex-wrap: wrap;
    position: relative;
}

.timer-circle {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--white) 0%, var(--light-green) 100%);
    border: 5px solid var(--primary-green);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.timer-circle.warning {
    border-color: #f59e0b;
    animation: pulse 1s infinite;
}

.timer-circle.danger {
    border-color: var(--error-red);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.timer-value {
    font-size: 46px;
    font-weight: 700;
    color: var(--primary-green);
    font-family: 'Fredoka', sans-serif;
}

.timer-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.stat-item {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 18px 28px;
    border-radius: 16px;
    text-align: center;
    box-shadow: var(--shadow);
    min-width: 110px;
    border: 2px solid rgba(143, 209, 79, 0.2);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-green);
}

.stat-value {
    font-size: 38px;
    font-weight: 700;
    color: var(--primary-green);
    margin-bottom: 5px;
    font-family: 'Fredoka', sans-serif;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.reset-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(143, 209, 79, 0.3);
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--primary-green);
}

.reset-btn:hover {
    background: var(--primary-green);
    color: var(--white);
    transform: translateY(-50%) rotate(180deg);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-green);
}

.typing-area {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 45px;
    box-shadow: var(--shadow-lg);
    position: relative;
    border: 2px solid rgba(143, 209, 79, 0.2);
    transition: all 0.3s ease;
}

.typing-area:hover {
    border-color: rgba(143, 209, 79, 0.4);
}

.words-display {
    font-size: 36px;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 30px;
    min-height: 200px;
    font-family: 'Space Mono', 'Courier New', monospace;
    font-weight: 700;
    user-select: none;
    overflow: hidden;
    letter-spacing: 2px;
    word-break: keep-all;
    overflow-wrap: normal;
    white-space: normal;
}

.word {
    display: inline-block;
    margin: 0;
    position: relative;
    white-space: nowrap;
}

.word .letter {
    display: inline-block;
    position: relative;
}

.word .letter.correct {
    color: var(--text-primary);
    background: rgba(143, 209, 79, 0.3);
    border-radius: 4px;
    padding: 2px 4px;
}

.word .letter.incorrect {
    color: var(--text-primary);
    background: rgba(231, 76, 60, 0.3);
    border-radius: 4px;
    padding: 2px 4px;
}

.word .letter.current {
    background: rgba(127, 140, 141, 0.3);
    color: var(--text-primary);
    border-radius: 4px;
    padding: 2px 4px;
    position: relative;
}

.word .letter.current::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text-primary);
    animation: cursorBlink 1s infinite;
}

.letter.space.correct {
    background: rgba(143, 209, 79, 0.3);
    border-radius: 4px;
    padding: 2px 8px;
}

.letter.space.incorrect {
    background: rgba(231, 76, 60, 0.3);
    border-radius: 4px;
    padding: 2px 8px;
}

.letter.space.current {
    background: rgba(127, 140, 141, 0.3);
    border-radius: 4px;
    padding: 2px 8px;
    position: relative;
}

.letter.space.current::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--text-primary);
    animation: cursorBlink 1s infinite;
}

@keyframes cursorBlink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

.typing-input {
    width: 100%;
    padding: 14px 24px;
    font-size: 32px;
    border: 3px solid var(--light-green);
    border-radius: 12px;
    outline: none;
    resize: none;
    font-family: 'Space Mono', 'Courier New', monospace;
    font-weight: 700;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    height: 60px;
    line-height: 32px;
    color: var(--text-primary);
    background: var(--white);
    position: relative;
    overflow-x: hidden;
    overflow-y: hidden;
    white-space: nowrap;
}

.typing-input:focus {
    border-color: var(--primary-green);
    box-shadow: 0 0 0 4px rgba(143, 209, 79, 0.2);
}

.typing-input:disabled {
    background: var(--background);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 50px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(143, 209, 79, 0.3);
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s ease;
    border: 2px solid rgba(143, 209, 79, 0.3);
}

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

.modal-content h2 {
    font-size: 36px;
    color: var(--primary-green);
    margin-bottom: 30px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 700;
}

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

.result-item {
    flex: 1;
    min-width: 100px;
}

.result-value {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary-green);
    margin-bottom: 10px;
    font-family: 'Fredoka', sans-serif;
}

.result-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.try-again-btn {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 100%);
    color: var(--white);
    border: none;
    padding: 16px 45px;
    font-size: 18px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Fredoka', sans-serif;
    box-shadow: var(--shadow);
}

.try-again-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(143, 209, 79, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    header h2 {
        font-size: 40px;
    }

    .stats-container {
        gap: 20px;
    }

    .timer-circle {
        width: 110px;
        height: 110px;
    }

    .timer-value {
        font-size: 36px;
    }

    .stats {
        gap: 15px;
        justify-content: center;
    }

    .stat-item {
        padding: 15px 22px;
        min-width: 100px;
    }

    .stat-value {
        font-size: 32px;
    }

    .reset-btn {
        position: static;
        transform: none;
        margin-top: 10px;
    }

    .reset-btn:hover {
        transform: rotate(180deg);
    }

    .typing-area {
        padding: 30px;
    }

    .words-display {
        font-size: 28px;
        min-height: 180px;
        letter-spacing: 1px;
    }

    .typing-input {
        font-size: 24px;
        height: 60px;
        padding: 18px 18px;
        line-height: 24px;
        letter-spacing: 1px;
    }

    .modal-content {
        padding: 35px;
    }

    .modal-content h2 {
        font-size: 28px;
    }

    .result-value {
        font-size: 38px;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 13px;
    }

    header h2 {
        font-size: 32px;
    }

    .timer-circle {
        width: 95px;
        height: 95px;
    }

    .timer-value {
        font-size: 30px;
    }

    .stat-item {
        padding: 12px 18px;
        min-width: 85px;
    }

    .stat-value {
        font-size: 26px;
    }

    .stat-label {
        font-size: 10px;
    }

    .typing-area {
        padding: 25px;
    }

    .words-display {
        font-size: 22px;
        min-height: 150px;
        letter-spacing: 1px;
    }

    .typing-input {
        font-size: 18px;
        padding: 18.5px 16px;
        line-height: 18px;
        height: 55px;
        letter-spacing: 1px;
    }

    .modal-content {
        padding: 28px;
    }

    .result-value {
        font-size: 32px;
    }

    .try-again-btn {
        padding: 14px 35px;
        font-size: 16px;
    }
}
