:root {
    --bg-primary: #f8f7f4;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0eeeb;
    --border-color: #e0ddd8;
    --border-light: #ebe8e4;
    --text-primary: #2c2c2c;
    --text-secondary: #555555;
    --text-muted: #888888;
    --accent: #1877f2;
    --accent-hover: #1466d0;
    --accent-light: #e7f0fd;
    --success: #2ea44f;
    --success-light: #eafbf0;
    --warning: #d4880f;
    --warning-light: #fef7ea;
    --error: #d03a3a;
    --error-light: #fdeaea;
    --console-bg: #1e1e2e;
    --console-text: #cdd6f4;
    --console-green: #a6e3a1;
    --console-prompt: #89b4fa;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.7;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px 24px;
}

/* ===== HEADER ===== */

header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    margin-bottom: 32px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.tutorial-title {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.lesson-info {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.module, .scene {
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* ===== NARRATIVE SECTION ===== */

.narrative-section {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.scene-title {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.technical-concept {
    background: var(--accent-light);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    border-left: 4px solid var(--accent);
    color: var(--text-primary);
    font-size: 0.95em;
}

.concept-text {
    line-height: 1.8;
}

.concept-text p {
    margin-bottom: 8px;
}

.concept-text p:last-child {
    margin-bottom: 0;
}

.dialogue-container {
    margin: 20px 0;
}

.dialogue-entry {
    margin: 12px 0;
    padding: 14px 18px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-color);
}

.character {
    font-weight: 700;
    color: var(--accent);
    display: inline-block;
    margin-right: 8px;
    font-size: 0.95em;
}

.dialogue-text {
    color: var(--text-primary);
    line-height: 1.8;
}

/* ===== CODE EXAMPLES ===== */

.code-example {
    background: var(--console-bg);
    border-radius: var(--radius-md);
    margin: 20px 0;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.code-header {
    background: #2a2a3e;
    padding: 10px 16px;
    font-weight: 600;
    color: var(--console-prompt);
    font-size: 0.85em;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.code-example pre {
    padding: 16px;
    overflow-x: auto;
}

.code-example code {
    color: var(--console-green);
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 0.9em;
}

/* ===== CHALLENGE SECTION ===== */

.challenge-section {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
    border: 2px solid var(--accent);
    box-shadow: var(--shadow-md);
}

.challenge-title {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 18px;
}

.challenge-task {
    background: var(--bg-tertiary);
    padding: 18px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    line-height: 1.7;
}

.challenge-hint {
    background: var(--warning-light);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--warning);
    margin-bottom: 20px;
    font-size: 0.93em;
    color: var(--text-primary);
}

/* ===== PROGRESSIVE HINT SYSTEM ===== */

.hint-system {
    margin-bottom: 20px;
}

.hint-button,
.solution-button {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.93em;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 8px;
}

.hint-button:hover { border-color: var(--warning); background: var(--warning-light); }
.solution-button:hover { border-color: var(--error); background: var(--error-light); }

.hint-content {
    background: var(--warning-light);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--warning);
    margin-top: 12px;
    margin-bottom: 12px;
    font-size: 0.93em;
    color: var(--text-primary);
}

.surrender-prompt {
    background: var(--bg-tertiary);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-top: 12px;
    margin-bottom: 12px;
    text-align: center;
}

.surrender-prompt p {
    font-size: 1.05em;
    font-weight: 600;
    margin-bottom: 12px;
}

.surrender-yes,
.surrender-no {
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.93em;
    cursor: pointer;
    margin: 0 6px;
    transition: all 0.2s;
}

.surrender-yes {
    background: var(--error);
    color: white;
}
.surrender-yes:hover { background: var(--error); opacity: 0.85; }

.surrender-no {
    background: var(--success);
    color: white;
}
.surrender-no:hover { background: var(--success); opacity: 0.85; }

.solution-content {
    background: var(--error-light);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--error);
    margin-top: 12px;
    margin-bottom: 20px;
}

.solution-content pre {
    background: var(--console-bg);
    color: var(--console-text);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-top: 8px;
    overflow-x: auto;
    font-size: 0.9em;
}

.solution-content code {
    font-family: var(--font-mono);
}

/* ===== INTERACTIVE CONSOLE ===== */

.interactive-console {
    background: var(--console-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: 20px;
    box-shadow: var(--shadow-md);
}

.console-header {
    background: #2a2a3e;
    padding: 10px 16px;
    font-weight: 600;
    color: var(--console-green);
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 0.85em;
}

.console-body {
    padding: 20px;
}

.console-input-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 14px;
}

.console-prompt {
    color: var(--console-prompt);
    margin-right: 10px;
    font-weight: bold;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
}

.console-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--console-text);
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 15px;
    outline: none;
}

.console-input::placeholder {
    color: #585b70;
}

.check-button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    font-family: inherit;
}

.check-button:hover {
    background: var(--accent-hover);
}

.console-output {
    margin-top: 16px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    color: var(--console-text);
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 0.9em;
    min-height: 50px;
    display: none;
}

.console-output.show {
    display: block;
}

.feedback-message {
    margin-top: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    display: none;
    font-size: 0.93em;
}

.feedback-message.success {
    background: var(--success);
    color: white;
    display: block;
}

.feedback-message.error {
    background: var(--error);
    color: white;
    display: block;
}

/* ===== NAVIGATION ===== */

.navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 28px;
}

.nav-button {
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.93em;
}

.nav-button:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ===== BREADCRUMB ===== */

.subtitle {
    color: var(--text-muted);
    font-size: 1.1em;
    margin-top: 6px;
    font-weight: 400;
}

.breadcrumb {
    color: var(--text-muted);
    font-size: 0.88em;
}

.breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ===== HOMEPAGE ===== */

.hero-section {
    text-align: center;
    padding: 48px 24px;
    background: linear-gradient(135deg, var(--accent) 0%, #42a5f5 100%);
    border-radius: var(--radius-lg);
    margin-bottom: 40px;
}

.hero-text h2 {
    font-size: 2.2em;
    color: white;
    margin-bottom: 16px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.hero-text p {
    font-size: 1.1em;
    color: rgba(255, 255, 255, 0.9);
    max-width: 560px;
    margin: 0 auto;
    line-height: 1.7;
}

.section-title {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.tutorials-grid, .lessons-grid {
    margin-bottom: 48px;
}

.tutorial-cards, .lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.tutorial-card, .lesson-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: transform 0.2s, box-shadow 0.2s;
}

.tutorial-card:hover, .lesson-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.tutorial-card.coming-soon {
    opacity: 0.6;
}

.card-header, .lesson-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h4, .lesson-header h4 {
    color: var(--text-primary);
    margin: 0;
    font-weight: 600;
}

.lesson-number {
    background: var(--accent);
    color: white;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78em;
    font-weight: 700;
    white-space: nowrap;
}

.status-badge {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72em;
    font-weight: 700;
}

.status-badge.completed {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.status-badge.coming-soon {
    background: var(--warning-light);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.card-content, .lesson-content {
    padding: 20px;
}

.card-description, .lesson-concept {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 14px;
    font-size: 0.93em;
}

.card-stats {
    display: flex;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.85em;
}

.lesson-preview {
    background: var(--console-bg);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
}

.lesson-preview code {
    color: var(--console-green);
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 0.85em;
}

.card-actions, .lesson-actions {
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
}

.btn-primary {
    background: var(--accent);
    color: white;
    text-decoration: none;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    display: inline-block;
    font-weight: 600;
    font-size: 0.9em;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 10px 24px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9em;
    cursor: not-allowed;
}

/* ===== FEATURES GRID ===== */

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-top: 24px;
}

.feature {
    text-align: center;
    padding: 28px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.feature-icon {
    font-size: 2.5em;
    margin-bottom: 16px;
}

.feature h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-weight: 600;
}

.feature p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.93em;
}

/* ===== TUTORIAL INTRO (menu page) ===== */

.tutorial-intro {
    background: var(--bg-secondary);
    padding: 28px;
    border-radius: var(--radius-lg);
    margin-bottom: 36px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.intro-content h2 {
    color: var(--text-primary);
    margin-bottom: 16px;
    font-weight: 700;
}

.tutorial-meta {
    display: flex;
    gap: 20px;
    color: var(--text-muted);
    align-items: center;
}

.progress-bar {
    background: var(--bg-tertiary);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 16px 0;
    border: 1px solid var(--border-color);
}

.progress-fill {
    background: var(--success);
    height: 100%;
    transition: width 0.3s;
}

.progress-text {
    color: var(--text-muted);
    text-align: center;
    font-size: 0.9em;
}

.tutorial-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.lesson-nav {
    display: flex;
    gap: 10px;
}

/* ===== FOOTER ===== */

footer {
    text-align: center;
    padding: 32px 0;
    margin-top: 48px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.88em;
}

/* ===== LANGUAGE & STYLE SELECTORS ===== */

.lang-selector {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.lang-selector select,
.style-selector select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.85em;
    font-family: inherit;
    cursor: pointer;
}

.style-selector {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* ===== MULTI-LINE TEXTAREA ===== */

.console-textarea {
    width: 100%;
    background: #181825;
    color: var(--console-text);
    border: 1px solid #45475a;
    border-radius: var(--radius-sm);
    padding: 14px;
    font-family: 'Consolas', 'Monaco', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 120px;
    box-sizing: border-box;
}

.console-textarea:focus {
    outline: none;
    border-color: var(--console-prompt);
}

.console-textarea::placeholder {
    color: #585b70;
}

/* ===== MINOR LAYOUT HELPERS ===== */

.lessons-list {
    margin-bottom: 36px;
}

.tutorial-progress {
    margin-bottom: 24px;
}

.lesson-status {
    font-size: 0.85em;
    color: var(--text-muted);
}

.lesson-title {
    font-weight: 600;
    color: var(--text-primary);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .header-content {
        flex-direction: column;
        gap: 12px;
    }

    .tutorial-title {
        font-size: 1.3em;
    }

    .narrative-section, .challenge-section {
        padding: 20px;
    }

    .hero-section {
        padding: 32px 20px;
    }

    .hero-text h2 {
        font-size: 1.7em;
    }

    .hero-text p {
        font-size: 1em;
    }

    .tutorial-cards, .lessons-grid {
        grid-template-columns: 1fr;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .tutorial-navigation {
        flex-direction: column;
        gap: 12px;
    }

    .lesson-nav {
        flex-direction: column;
    }
}
