/* ==================== ROOT VARIABLES - DARK THEME (DEFAULT) ==================== */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== LIGHT THEME ==================== */
[data-theme="light"] {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #7c3aed;
    --success-color: #059669;
    --error-color: #dc2626;
    --warning-color: #d97706;
    
    --bg-color: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* ==================== GLOBAL STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden;
    transition: var(--transition);
}

[data-theme="dark"] body,
body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

[data-theme="light"] body {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

/* ==================== CONTAINER ==================== */
.container {
    max-width: 900px;
    margin: 0 auto;
    animation: fadeIn 0.6s ease-in;
}

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

/* ==================== HEADER ==================== */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    position: relative;
}

.header-top {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 10px;
}

.theme-toggle,
.sound-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--bg-tertiary);
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-primary);
}

.theme-toggle:hover,
.sound-toggle:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.sound-toggle.muted {
    opacity: 0.5;
}

/* ==================== SVG ICONS ==================== */
.icon {
    flex-shrink: 0;
}

.icon.hidden {
    display: none;
}

.result-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.result-icon-wrapper.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.result-icon {
    width: 28px;
    height: 28px;
}


.header h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* ==================== DIFFICULTY SECTION ==================== */
.difficulty-section {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    animation: slideUp 0.6s ease-out;
}

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

.difficulty-section h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
    color: var(--text-primary);
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.difficulty-btn {
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    padding: 30px 20px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-family: inherit;
}

.difficulty-btn:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.difficulty-indicator {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-bottom: 8px;
}

.difficulty-indicator.easy {
    background: var(--success-color);
    box-shadow: 0 0 12px var(--success-color);
}

.difficulty-indicator.medium {
    background: var(--warning-color);
    box-shadow: 0 0 12px var(--warning-color);
}

.difficulty-indicator.hard {
    background: var(--error-color);
    box-shadow: 0 0 12px var(--error-color);
}

.difficulty-name {
    font-size: 1.4rem;
    font-weight: 700;
}

.difficulty-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* ==================== DURATION SECTION ==================== */
.duration-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid var(--bg-tertiary);
}

.duration-section h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.duration-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.duration-btn {
    padding: 12px 24px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    min-width: 70px;
}

.duration-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

.duration-btn.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

/* ==================== GAME SECTION ==================== */
.game-section {
    animation: slideUp 0.6s ease-out;
}

.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-item {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ==================== TEXT DISPLAY ==================== */
.text-display {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--border-radius-lg);
    margin-bottom: 20px;
    font-size: 1.5rem;
    line-height: 2;
    letter-spacing: 0.5px;
    box-shadow: var(--shadow-md);
    min-height: 200px;
    font-family: 'Courier New', monospace;
}

.text-display .char {
    position: relative;
    transition: var(--transition);
}

.text-display .char.correct {
    color: var(--success-color);
}

.text-display .char.incorrect {
    color: var(--error-color);
    background: rgba(239, 68, 68, 0.1);
}

.text-display .char.current {
    background: var(--primary-color);
    color: var(--bg-color);
    animation: blink 1s infinite;
}

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

/* ==================== INPUT SECTION ==================== */
.input-section {
    margin-bottom: 20px;
}

.text-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 2px solid var(--bg-tertiary);
    border-radius: var(--border-radius);
    padding: 20px;
    font-size: 1.1rem;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    resize: none;
    height: 120px;
    transition: var(--transition);
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.text-input::placeholder {
    color: var(--text-muted);
}

/* ==================== BUTTONS ==================== */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

/* ==================== RESULTS SECTION ==================== */
.results-section {
    animation: slideUp 0.6s ease-out;
}

.results-card {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.results-card h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    color: var(--text-primary);
}

.results-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.result-item {
    background: var(--bg-tertiary);
    padding: 25px;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}


.result-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.result-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.result-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
}

.result-unit {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==================== HIGHSCORES SECTION ==================== */
.highscores-section {
    background: var(--bg-secondary);
    padding: 30px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-top: 30px;
}

.highscores-section h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.8rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.highscores-section h2 .icon {
    color: var(--warning-color);
}

.highscores-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
}

.tab-btn:hover {
    background: var(--bg-secondary);
}

.tab-btn.active {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.highscores-list {
    min-height: 100px;
}

.no-scores {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-style: italic;
}

.score-item {
    background: var(--bg-tertiary);
    padding: 15px 20px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.score-item:hover {
    transform: translateX(5px);
    background: var(--bg-secondary);
}

.score-rank {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 40px;
}

.score-details {
    flex: 1;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.score-detail {
    display: flex;
    flex-direction: column;
}

.score-detail-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-detail-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.score-date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ==================== FOOTER ==================== */
.footer {
    text-align: center;
    margin-top: 50px;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--secondary-color);
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
    display: none !important;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .header-top {
        position: static;
        justify-content: center;
        margin-bottom: 20px;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .difficulty-section {
        padding: 25px;
    }
    
    .difficulty-buttons {
        grid-template-columns: 1fr;
    }
    
    .text-display {
        padding: 25px;
        font-size: 1.2rem;
    }
    
    .stats-bar {
        grid-template-columns: 1fr;
    }
    
    .results-stats {
        grid-template-columns: 1fr;
    }
    
    .result-value {
        font-size: 2rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .duration-buttons {
        gap: 10px;
    }
    
    .duration-btn {
        padding: 10px 18px;
        min-width: 60px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .text-display {
        font-size: 1rem;
        padding: 20px;
    }
    
    .difficulty-section h2,
    .results-card h2,
    .highscores-section h2 {
        font-size: 1.4rem;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    body {
        background: white;
        color: black;
    }
    
    .action-buttons,
    .footer,
    .theme-toggle,
    .sound-toggle {
        display: none;
    }
}
