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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    max-width: 800px;
    width: 90%;
    min-height: 600px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    justify-content: flex-start;
}

.logo {
    height: 60px;
    width: auto;
}

h1 {
    color: #4a5568;
    font-family: 'Alfa Slab One', cursive;
    font-size: 2.5rem;
    font-weight: 400;
    background: linear-gradient(45deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.difficulty-selector label {
    font-weight: 600;
    color: #4a5568;
}

.difficulty-selector select {
    padding: 0.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #4a5568;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.difficulty-selector select:focus {
    outline: none;
    border-color: #667eea;
}

/* Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.875rem;
    color: #718096;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #4a5568;
}

/* Word Display */
.word-display {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: #f7fafc;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.current-word {
    font-size: 3rem;
    font-weight: 700;
    color: #4a5568;
    letter-spacing: 2px;
    transition: all 0.3s ease;
    position: relative;
}

.current-word.correct {
    color: #48bb78;
    transform: scale(1.1);
}

.current-word.incorrect {
    color: #f56565;
    animation: shake 0.5s ease-in-out;
}

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

/* Letter highlighting for real-time feedback */
.letter {
    position: relative;
    transition: all 0.2s ease;
}

.letter.correct {
    color: #48bb78;
    background: rgba(72, 187, 120, 0.1);
}

.letter.incorrect {
    color: #f56565;
    background: rgba(245, 101, 101, 0.1);
}

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

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

/* Input Section */
.input-section {
    margin-bottom: 2rem;
}

.word-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.25rem;
    border: 3px solid #e2e8f0;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
    background: white;
    color: #4a5568;
}

.word-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.word-input:disabled {
    background: #f7fafc;
    cursor: not-allowed;
}

.word-input.correct {
    border-color: #48bb78;
    background: rgba(72, 187, 120, 0.05);
}

.word-input.incorrect {
    border-color: #f56565;
    background: rgba(245, 101, 101, 0.05);
}

/* Controls */
.controls {
    text-align: center;
    margin-bottom: 2rem;
}

.btn {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    transform: translateY(0);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-2px);
}

/* Progress Bar */
.progress-container {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(45deg, #667eea, #764ba2);
    width: 0%;
    transition: width 1s linear;
    border-radius: 4px;
}

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

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    animation: slideIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.modal-content h2 {
    color: #4a5568;
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 12px;
}

.final-stat {
    text-align: center;
}

.final-stat-label {
    display: block;
    font-size: 0.875rem;
    color: #718096;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.final-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #4a5568;
}

.high-score {
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    color: #744210;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-weight: 700;
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.crown {
    font-size: 1.5rem;
    margin-right: 0.5rem;
}

.personal-best {
    color: #718096;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
        width: 95%;
    }

    h1 {
        font-size: 2rem;
    }

    header {
        flex-direction: column;
        text-align: center;
    }

    .header-content {
        justify-content: center;
    }

    .logo {
        height: 50px;
    }

    .current-word {
        font-size: 2rem;
    }

    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .final-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .word-input {
        font-size: 1.125rem;
    }

    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        margin: 0.25rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    .current-word {
        font-size: 1.5rem;
    }

    .stats-bar {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .final-stats {
        grid-template-columns: 1fr;
    }

    .word-input {
        font-size: 1rem;
        padding: 0.875rem;
    }
}

/* Time Bonus Notification */
.time-bonus {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(45deg, #48bb78, #38a169);
    color: white;
    padding: 1rem 2rem;
    border-radius: 25px;
    font-size: 1.25rem;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(72, 187, 120, 0.3);
    z-index: 1001;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: bonusPop 0.5s ease;
}

@keyframes bonusPop {
    0% {
        transform: translateX(-50%) scale(0.8);
    }
    50% {
        transform: translateX(-50%) scale(1.1);
    }
    100% {
        transform: translateX(-50%) scale(1);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .container {
        border: 3px solid #000;
    }
    
    .btn-primary {
        background: #000;
        color: #fff;
        border: 2px solid #000;
    }
    
    .word-input:focus {
        border-color: #000;
        box-shadow: 0 0 0 3px #000;
    }
}
