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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-card: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent: #4CAF50;
    --accent-hover: #45a049;
    --border: #dddddd;
    --shadow: rgba(0, 0, 0, 0.1);
    --error: #f44336;
    --success: #4CAF50;
    --warning: #ff9800;
    --info: #2196F3;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-card: #151515;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --accent: #5dff5d;
    --accent-hover: #7bff7b;
    --border: #2a2a2a;
    --shadow: rgba(0, 0, 0, 0.5);
    --error: #ff5252;
    --success: #69f0ae;
    --warning: #ffb74d;
    --info: #64b5f6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background 0.3s, color 0.3s;
    padding-bottom: 2rem;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

header {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 4px 12px var(--shadow);
    margin-bottom: 1.5rem;
    position: relative;
    border: 1px solid var(--border);
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--accent), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

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

.theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    padding: 0.6rem 1.2rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle:hover {
    transform: scale(1.05);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent);
}

.theme-icon {
    font-size: 1.3rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.stat-item {
    background: linear-gradient(135deg, var(--bg-secondary), var(--bg-card));
    padding: 0.6rem 0.3rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.3s;
}

.stat-item:hover {
    transform: translateY(-3px);
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0.1rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--accent), var(--info));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-value.success {
    background: linear-gradient(135deg, var(--success), #81c784);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-value.error {
    background: linear-gradient(135deg, var(--error), #e57373);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.accuracy-bar {
    margin-top: 1rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    height: 25px;
    border: 1px solid var(--border);
    position: relative;
}

.accuracy-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent));
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 0.8rem;
}

.card {
    background: var(--bg-card);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow);
    border: 1px solid var(--border);
}

.section-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.button-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1rem;
}

button {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    padding: 0.8rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--shadow);
    border-color: var(--accent);
}

button.active {
    background: var(--accent);
    color: #000;
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent);
    font-weight: 600;
}

.difficulty-easy { --diff-color: #4CAF50; }
.difficulty-medium { --diff-color: #FF9800; }
.difficulty-hard { --diff-color: #f44336; }
.difficulty-hardcore { --diff-color: #9C27B0; }

button.active.difficulty-easy,
button.active.difficulty-medium,
button.active.difficulty-hard,
button.active.difficulty-hardcore {
    background: var(--diff-color);
    border-color: var(--diff-color);
    color: white;
    box-shadow: 0 0 25px var(--diff-color);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--info));
    color: white;
    border: none;
    font-size: 1.1rem;
    padding: 1rem;
    width: 100%;
    font-weight: 600;
    box-shadow: 0 4px 15px var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px var(--accent);
}

.task-container {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 12px;
    margin: 1rem 0;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
}

.task-text {
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 1rem;
    font-family: 'Courier New', monospace;
    word-wrap: break-word;
    color: var(--text-primary);
}

.solution-section {
    margin-top: 1.5rem;
}

.solution-step {
    background: var(--bg-secondary);
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 10px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--info);
}

.step-title {
    font-weight: bold;
    color: var(--info);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.step-content {
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.answer {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-top: 1rem;
    font-size: 1.3rem;
    text-align: center;
    font-weight: bold;
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.5);
}

.help-box {
    background: var(--bg-secondary);
    border-left: 4px solid var(--warning);
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.help-title {
    color: var(--warning);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 1rem;
}

.evaluation-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 1rem;
}

.btn-correct {
    background: var(--success);
    color: white;
    border: none;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
    font-size: 1rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-correct:hover {
    box-shadow: 0 0 25px var(--success);
}

.btn-incorrect {
    background: var(--error);
    color: white;
    border: none;
    box-shadow: 0 0 15px rgba(244, 67, 54, 0.3);
    font-size: 1rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-incorrect:hover {
    box-shadow: 0 0 25px var(--error);
}

.btn-show {
    background: var(--info);
    color: white;
    border: none;
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.3);
}

.btn-show:hover {
    box-shadow: 0 0 25px var(--info);
}

.btn-back {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
    padding: 0.8rem 1.5rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    transition: all 0.3s;
}

.btn-back:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
}

.hidden {
    display: none;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
}

.badge-easy { background: #4CAF50; color: white; }
.badge-medium { background: #FF9800; color: white; }
.badge-hard { background: #f44336; color: white; }
.badge-hardcore { background: #9C27B0; color: white; }

.motivation-box {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.4);
}

.feedback-message {
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    font-weight: 500;
    text-align: center;
    animation: slideIn 0.3s ease;
}

.feedback-correct {
    background: var(--success);
    color: white;
    box-shadow: 0 0 20px var(--success);
}

.feedback-incorrect {
    background: var(--error);
    color: white;
    box-shadow: 0 0 20px var(--error);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 1rem;
    border: 1px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--info));
    transition: width 0.5s ease;
    box-shadow: 0 0 10px var(--accent);
}

@media (max-width: 600px) {
    h1 { 
        font-size: 1.5rem;
        -webkit-text-fill-color: var(--text-primary);
    }
    .theme-toggle {
        position: static;
        margin-top: 1rem;
        width: 100%;
        justify-content: center;
    }
    .task-text { font-size: 1.1rem; }
    .button-group {
        grid-template-columns: 1fr;
    }
    .stats {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.3rem;
    }
    .stat-item {
        padding: 0.5rem 0.2rem;
    }
    .stat-label {
        font-size: 0.6rem;
        letter-spacing: 0.2px;
    }
    .stat-value {
        font-size: 1.2rem;
    }
}

[data-theme="dark"] .card {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 1px var(--accent);
}

[data-theme="dark"] ::-webkit-scrollbar {
    width: 10px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 5px;
}