/* === TYPING SPEED GAME STYLES === */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.game-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* === HEADER === */
.game-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6366f1;
    text-decoration: none;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    transform: translateX(-5px);
}

.game-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 12px;
}

.game-header h1 i {
    color: #3b82f6;
}

.game-stats {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(99, 102, 241, 0.1);
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 600;
    color: #374151;
}

.stat i {
    color: #6366f1;
}

/* === MAIN CONTENT === */
.game-main {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

.game-controls {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #64748b, #475569);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(100, 116, 139, 0.3);
}

.mode-select,
.duration-select,
.difficulty-select {
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-select:focus,
.duration-select:focus,
.difficulty-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* === TYPING AREA === */
.typing-area-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: relative;
}

.typing-stats-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 10px;
    border-left: 4px solid #3b82f6;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-label {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 500;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1f2937;
}

/* === TYPING DISPLAY === */
.typing-display {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    min-height: 120px;
    position: relative;
    overflow: hidden;
}

.text-to-type {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #374151;
    letter-spacing: 0.5px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.char {
    position: relative;
    transition: all 0.2s ease;
}

.char.correct {
    background: rgba(34, 197, 94, 0.2);
    color: #059669;
}

.char.incorrect {
    background: rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

.char.current {
    background: #3b82f6;
    color: white;
    animation: blink 1s infinite;
}

.char.pending {
    color: #9ca3af;
}

/* === TYPING INPUT === */
.typing-input-container {
    position: relative;
}

.typing-input {
    width: 100%;
    min-height: 120px;
    padding: 20px;
    border: 2px solid #e5e7eb;
    border-radius: 15px;
    font-size: 1.1rem;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
    resize: vertical;
    background: white;
    transition: all 0.3s ease;
}

.typing-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.typing-input:disabled {
    background: #f3f4f6;
    cursor: not-allowed;
    opacity: 0.7;
}

.input-feedback {
    margin-top: 15px;
    padding: 12px;
    background: rgba(34, 197, 94, 0.05);
    border-radius: 8px;
    border-left: 3px solid #10b981;
}

.feedback-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: #065f46;
}

.feedback-item i {
    color: #10b981;
}

/* === GAME OVERLAY === */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.game-overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    color: white;
    padding: 40px;
    max-width: 500px;
}

.overlay-content h2 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: #3b82f6;
}

.overlay-content p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

.overlay-stats {
    margin: 30px 0;
    padding: 25px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.result-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #3b82f6;
}

.result-label {
    font-size: 0.9rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.performance-rating {
    text-align: center;
    margin-top: 20px;
}

.rating-badge {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.rating-badge.excellent {
    background: linear-gradient(135deg, #10b981, #059669);
}

.rating-badge.good {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.rating-badge.average {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.rating-badge.poor {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.rating-description {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* === SIDEBAR === */
.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.leaderboard-panel,
.tips-panel,
.keyboard-layout {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.leaderboard-panel h3,
.tips-panel h3,
.keyboard-layout h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    color: #1f2937;
    font-size: 1.2rem;
}

.leaderboard-panel h3 i {
    color: #f59e0b;
}

.tips-panel h3 i {
    color: #10b981;
}

.keyboard-layout h3 i {
    color: #3b82f6;
}

/* === LEADERBOARD === */
.leaderboard-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: #3b82f6;
    color: white;
}

.leaderboard-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 8px;
    font-size: 0.9rem;
}

.rank {
    font-weight: 600;
    color: #3b82f6;
}

.score {
    font-weight: 600;
    color: #374151;
}

.date {
    color: #6b7280;
    font-size: 0.8rem;
}

/* === TIPS === */
.tip-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: rgba(16, 185, 129, 0.05);
    border-radius: 8px;
    border-left: 3px solid #10b981;
}

.tip-item i {
    color: #10b981;
    margin-top: 2px;
    flex-shrink: 0;
}

.tip-item span {
    font-size: 0.9rem;
    line-height: 1.4;
    color: #374151;
}

/* === KEYBOARD VISUAL === */
.keyboard-visual {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.keyboard-row {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.key {
    min-width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.key.active {
    background: #3b82f6;
    color: white;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.space-key {
    min-width: 120px;
    font-size: 0.7rem;
}

/* === ANIMATIONS === */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes typeCorrect {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); background: rgba(34, 197, 94, 0.3); }
    100% { transform: scale(1); }
}

@keyframes typeIncorrect {
    0% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
    100% { transform: translateX(0); }
}

.char.typed-correct {
    animation: typeCorrect 0.3s ease-out;
}

.char.typed-incorrect {
    animation: typeIncorrect 0.3s ease-out;
}

.btn:active {
    transform: scale(0.95);
}

.stat-value.updating {
    animation: pulse 0.5s ease-in-out;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 1024px) {
    .game-main {
        grid-template-columns: 1fr;
    }
    
    .game-sidebar {
        order: -1;
        flex-direction: row;
        overflow-x: auto;
    }
    
    .leaderboard-panel,
    .tips-panel,
    .keyboard-layout {
        min-width: 280px;
    }
}

@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .game-stats {
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .game-controls {
        justify-content: center;
        flex-direction: column;
        gap: 10px;
    }
    
    .game-header h1 {
        font-size: 1.5rem;
    }
    
    .typing-stats-bar {
        flex-direction: column;
        gap: 15px;
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .game-sidebar {
        flex-direction: column;
    }
    
    .text-to-type {
        font-size: 1rem;
    }
    
    .typing-input {
        font-size: 1rem;
        min-height: 100px;
    }
}

@media (max-width: 480px) {
    .typing-area-container {
        padding: 20px;
    }
    
    .overlay-content {
        padding: 20px;
    }
    
    .overlay-content h2 {
        font-size: 2rem;
    }
    
    .results-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .result-value {
        font-size: 2rem;
    }
    
    .keyboard-row {
        gap: 3px;
    }
    
    .key {
        min-width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }
    
    .space-key {
        min-width: 100px;
    }
}

/* === GAME STATES === */
.game-paused .typing-input {
    filter: blur(3px);
    pointer-events: none;
}

.game-complete .overlay-content {
    animation: pulse 1s ease-in-out;
}

/* === PRINT STYLES === */
@media print {
    .game-container {
        background: white;
        color: black;
    }
    
    .game-sidebar,
    .game-controls {
        display: none;
    }
}