:root {
    --bg: #f7f5ef;
    --surface: #fffdfa;
    --text: #1d2730;
    --muted: #5f6b76;
    --border: #d9d3c6;
    --accent: #236c68;
    --accent-dark: #174d4a;
    --accent-soft: #e4f0ee;
    --warning-soft: #fff3cf;
    --task-soft: #eef2f7;
    --example-soft: #f0eadf;
    --error: #a12b2b;
    --shadow: 0 10px 25px rgba(33, 39, 48, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.65;
    overflow-x: hidden;
}

a {
    color: var(--accent-dark);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.2em;
}

a:hover,
a:focus {
    color: #0f3937;
}

.container {
    width: calc(100vw - 32px);
    max-width: 1040px;
    margin: 0 auto;
    padding: 0;
}

.page-content {
    padding-top: 46px;
    padding-bottom: 60px;
}

.intro-section,
.lesson-header {
    margin-bottom: 44px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent-dark);
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p,
li {
    margin-top: 0;
    overflow-wrap: break-word;
}

h1 {
    max-width: 900px;
    margin-bottom: 18px;
    font-size: 3rem;
    line-height: 1.12;
}

h2 {
    margin-bottom: 18px;
    font-size: 2rem;
    line-height: 1.22;
}

h3 {
    margin-bottom: 8px;
    font-size: 1.3rem;
    line-height: 1.3;
}

h4 {
    margin: 20px 0 8px;
    font-size: 1.05rem;
}

.lead {
    max-width: 820px;
    color: var(--muted);
    font-size: 1.25rem;
    line-height: 1.55;
}

.section-block {
    margin: 46px 0;
    max-width: 100%;
}

.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.notice-box,
.lesson-card,
.task-box,
.solution-box,
.plan-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.notice-box {
    margin: 22px 0;
    padding: 24px;
    max-width: 100%;
}

.explanation-box {
    border-left: 6px solid var(--accent);
    background: var(--accent-soft);
}

.example-box {
    border-left: 6px solid #9b7042;
    background: var(--example-soft);
}

.warmup-box {
    border-left: 6px solid #b58b00;
    background: var(--warning-soft);
}

.teacher-note {
    border-left: 6px solid #3f6d9a;
    background: #edf3f8;
}

.deep-dive {
    margin: 46px 0;
    padding: 26px;
    border: 1px solid #b8c9c8;
    border-left: 6px solid #317c78;
    border-radius: 8px;
    background: #eef7f5;
    box-shadow: var(--shadow);
}

.deep-dive h2 {
    margin-bottom: 16px;
    color: var(--accent-dark);
}

.deep-dive-kicker {
    margin-bottom: 8px;
    color: var(--accent-dark);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.advanced-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: -18px 0 34px;
}

.advanced-links a {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-weight: 700;
    text-decoration: none;
}

.advanced-section {
    margin: 24px 0;
    box-shadow: none;
}

.advanced-table {
    margin: 24px 0 32px;
}

.box-kicker,
.task-number,
.status-label {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.definition {
    margin-bottom: 0;
    color: var(--accent-dark);
    font-size: 1.35rem;
    font-weight: 750;
}

.prompt {
    margin: 16px 0 0;
    font-weight: 750;
}

.plain-list,
.notice-box ul,
.notice-box ol,
.task-box ol,
.task-box ul,
.solution-box ol,
.plan-item ul {
    padding-left: 1.45em;
}

.property-list {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.property-item {
    margin: 0;
    box-shadow: none;
}

.code-block-wrap {
    margin: 18px 0;
}

.code-title {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 800;
}

.pseudo-code {
    margin: 0;
    padding: 18px 20px;
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid #c8d0d6;
    border-radius: 8px;
    background: #18242f;
    color: #f4f7f9;
    line-height: 1.55;
}

.pseudo-code code {
    padding: 0;
    background: transparent;
    color: inherit;
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 1rem;
    white-space: pre;
}

.flowchart {
    display: grid;
    gap: 18px;
    max-width: 420px;
    margin: 24px 0;
}

.flow-step {
    position: relative;
    padding: 13px 16px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    background: var(--surface);
    text-align: center;
    font-weight: 750;
}

.flow-step:not(:last-child)::after {
    content: "↓";
    position: absolute;
    left: 50%;
    bottom: -22px;
    transform: translateX(-50%);
    color: var(--accent-dark);
    font-weight: 800;
}

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.course-track {
    margin: 28px 0 36px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 253, 250, 0.72);
}

.algorithm-track {
    border-top: 5px solid var(--accent);
}

.python-track {
    border-top: 5px solid #9b7042;
}

.third-year-track {
    border-top: 5px solid #3f6d9a;
}

.third-year-card .lesson-card-number {
    background: #3f6d9a;
}

.course-track h3 {
    margin-bottom: 0;
}

.course-track-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: -8px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    list-style: none;
}

.course-track-summary::-webkit-details-marker {
    display: none;
}

.course-track-summary::after {
    content: "";
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    margin: 0 6px 6px 0;
    border-right: 3px solid var(--accent-dark);
    border-bottom: 3px solid var(--accent-dark);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.course-track[open] > .course-track-summary::after {
    margin-bottom: -6px;
    transform: rotate(225deg);
}

.course-track-summary:hover h3 {
    color: var(--accent-dark);
}

.course-track-summary:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.course-track-titles {
    flex: 1 1 auto;
    min-width: 0;
}

.course-track-titles .track-kicker {
    display: block;
}

.course-track-count {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
}

.course-track[open] > .course-track-summary {
    margin-bottom: 10px;
}

.programming-world-feature {
    margin: 28px 0 36px;
    padding: 28px;
    border: 1px solid var(--border);
    border-left: 6px solid var(--accent);
    border-radius: 8px;
    background: var(--accent-soft);
    box-shadow: var(--shadow);
}

.programming-world-feature-badge {
    display: inline-block;
    margin-bottom: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface);
    color: var(--accent-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.programming-world-feature p {
    max-width: 62ch;
    color: var(--muted);
}

.programming-world-feature-link {
    display: inline-flex;
    margin-top: 6px;
}

.track-kicker {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.lesson-card {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 16px;
    padding: 20px;
}

.lesson-card-number {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-size: 1.35rem;
    font-weight: 800;
}

.lesson-card h3 a {
    color: var(--text);
    text-decoration: none;
}

.lesson-card h3 a:hover,
.lesson-card h3 a:focus {
    color: var(--accent-dark);
    text-decoration: underline;
}

.lesson-card p {
    margin-bottom: 14px;
    color: var(--muted);
}

.status-label {
    display: inline-block;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.65);
}

.breadcrumb {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 0.95rem;
}

.task-list,
.solution-list,
.year-plan {
    display: grid;
    gap: 18px;
}

.task-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.task-meta .task-number {
    margin-bottom: 0;
}

.difficulty-tag {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
    white-space: nowrap;
}

.difficulty-basic {
    border-color: #9fc1aa;
    background: #edf7f0;
    color: #27593a;
}

.difficulty-medium {
    border-color: #aab8ce;
    background: #eef2f7;
    color: #31485d;
}

.difficulty-challenge {
    border-color: #c9a7a7;
    background: #f7eeee;
    color: #7b3434;
}

.task-box {
    padding: 24px;
    background: var(--task-soft);
    border-left: 6px solid #56677a;
}

.bonus-task {
    border-left-color: #7f5c97;
    background: #f3eef7;
}

.task-box p:last-child,
.solution-box p:last-child,
.notice-box p:last-child,
.plan-item p:last-child {
    margin-bottom: 0;
}

.hint,
.inline-note {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(29, 39, 48, 0.16);
    color: var(--muted);
}

.solutions-section {
    padding-top: 12px;
    border-top: 2px solid var(--border);
}

.primary-button,
.secondary-button {
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
}

.primary-button {
    padding: 10px 18px;
    background: var(--accent);
    color: #ffffff;
}

.primary-button:hover,
.primary-button:focus,
.secondary-button:hover,
.secondary-button:focus {
    background: var(--accent-dark);
    color: #ffffff;
}

.secondary-button {
    padding: 9px 16px;
    background: #31485d;
    color: #ffffff;
}

.js .solution-panel.is-collapsed {
    display: none;
}

.js .reveal-list.is-collapsed {
    display: none;
}

.solution-panel {
    margin-top: 18px;
}

.diagnostic-grid,
.hint-list {
    display: grid;
    gap: 12px;
}

.diagnostic-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
}

.diagnostic-card,
.hint-card {
    margin: 0;
    box-shadow: none;
}

.diagnostic-card {
    background: var(--surface);
}

.diagnostic-card summary,
.hint-card summary {
    cursor: pointer;
    color: var(--accent-dark);
    font-weight: 800;
}

.diagnostic-card[open] summary,
.hint-card[open] summary {
    margin-bottom: 10px;
}

.hint-list {
    margin: 18px 0;
}

.hint-card {
    border-left: 6px solid #b58b00;
    background: var(--warning-soft);
}

.answer-field {
    display: grid;
    gap: 6px;
    font-weight: 750;
}

.answer-field textarea,
.answer-field input[type="text"],
.match-list select,
.ordering-list select {
    width: 100%;
    border: 1px solid #aeb8c1;
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

.match-list select,
.ordering-list select {
    min-height: 44px;
    padding: 8px 11px;
}

.answer-field input[type="text"] {
    min-height: 44px;
    padding: 8px 11px;
}

.field-prompt {
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 650;
}

.third-year-workbench {
    margin-top: 28px;
}

.interactive-intro {
    border-left: 6px solid var(--accent);
    padding-left: 18px;
}

.interactive-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.interactive-card {
    margin: 0;
}

.self-check-card .choice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.choice-row .secondary-button {
    text-align: left;
}

.choice-row .secondary-button.selected {
    outline: 3px solid rgba(35, 108, 104, 0.24);
    background: var(--accent-dark);
    color: #ffffff;
}

.activity-list {
    display: grid;
    gap: 16px;
    margin: 22px 0;
}

.inline-feedback,
.local-save-status,
.submit-message {
    min-height: 1.6em;
    color: var(--muted);
    font-weight: 750;
}

.inline-feedback.is-correct,
.match-list select.is-correct,
.ordering-list select.is-correct,
.submit-message.success {
    color: #1d6c46;
}

.inline-feedback.is-wrong,
.match-list select.is-wrong,
.ordering-list select.is-wrong,
.submit-message.error {
    color: var(--error);
}

.submit-message.pending {
    color: var(--accent-dark);
}

.match-list {
    display: grid;
    gap: 12px;
    margin: 18px 0;
}

.match-list label {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(180px, 1.2fr);
    gap: 12px;
    align-items: center;
    font-weight: 750;
}

.answer-field-list {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.answer-field textarea {
    min-height: 132px;
    padding: 11px 12px;
    resize: vertical;
}

.answer-field textarea.code-textarea {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre;
}

.submit-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
    gap: 18px;
    align-items: start;
}

.submit-summary,
.submit-actions {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    background: var(--surface);
}

.summary-meta {
    display: grid;
    gap: 4px;
    margin-bottom: 14px;
}

.summary-meta p {
    margin: 0;
}

.completion-list {
    display: grid;
    gap: 10px;
    padding: 0;
    list-style: none;
}

.completion-list li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 10px 0;
    border-top: 1px solid rgba(29, 39, 48, 0.12);
}

.completion-list li:first-child {
    border-top: 0;
}

.completion-list strong.done {
    color: #1d6c46;
}

.completion-list strong.missing {
    color: var(--error);
}

.completion-list small {
    grid-column: 1 / -1;
    color: var(--muted);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.88rem;
    line-height: 1.45;
}

.discussion-card-grid,
.role-grid,
.timeline-columns,
.comparison-grid {
    display: grid;
    gap: 16px;
}

.discussion-card-grid,
.comparison-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.discussion-card,
.role-chip,
.vote-options span,
.it-map-branches span {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.68);
}

.discussion-card {
    padding: 18px;
    font-weight: 750;
}

.discussion-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0 28px;
}

.discussion-note {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 253, 250, 0.72);
}

.discussion-note h3 {
    margin-bottom: 6px;
}

.discussion-note p {
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 0.96rem;
}

.discussion-note div {
    min-height: 132px;
    padding: 16px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: rgba(255, 253, 250, 0.55);
    outline: 0;
}

.discussion-note div:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
}

.discussion-note div:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(35, 108, 104, 0.16);
}

.role-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 18px 0 28px;
}

.role-chip,
.it-map-branches span,
.vote-options span {
    padding: 10px 12px;
    font-weight: 750;
}

.role-chip {
    color: var(--text);
    cursor: pointer;
    text-align: left;
}

.role-chip:hover,
.role-chip:focus,
.role-chip.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.it-map {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 16px;
    align-items: start;
    margin: 26px 0;
}

.it-map-root {
    display: grid;
    place-items: center;
    min-height: 72px;
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 800;
}

.it-map-branches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.timeline-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.timeline-card {
    margin: 0;
}

.reveal-list {
    margin-top: 16px;
}

.vote-list,
.discussion-question-list {
    display: grid;
    gap: 18px;
}

.vote-card {
    background: var(--surface);
}

.vote-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 14px 0;
}

.discussion-question-list article {
    padding: 18px 0;
    border-top: 1px solid rgba(29, 39, 48, 0.16);
}

.discussion-question-list article:first-child {
    border-top: 0;
}

.lesson-zero-flow {
    max-width: 520px;
}

.lesson-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.lesson-action-nav {
    margin-top: 18px;
}

.lesson-footer-nav {
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

.button-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.password-form {
    max-width: 560px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.password-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 750;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-row input {
    width: 100%;
    min-height: 44px;
    padding: 8px 11px;
    border: 1px solid #aeb8c1;
    border-radius: 6px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

.form-error {
    margin: 12px 0 0;
    color: var(--error);
    font-weight: 750;
}

.solution-list {
    margin-top: 26px;
}

.solution-box {
    padding: 24px;
    border-left: 6px solid #2f7d51;
    background: #edf7f0;
}

.solution-part + .solution-part {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(29, 39, 48, 0.14);
}

.checklist-list {
    display: grid;
    gap: 9px;
    padding-left: 0;
    list-style: none;
}

.checklist-list li {
    display: grid;
    grid-template-columns: 20px 1fr;
    gap: 10px;
    align-items: start;
}

.checklist-list span {
    width: 18px;
    height: 18px;
    margin-top: 0.32em;
    border: 2px solid var(--accent);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.65);
}

.plan-item {
    padding: 22px;
}

.plan-topic {
    margin-bottom: 10px;
    color: var(--accent-dark);
    font-weight: 800;
}

.method-block + .method-block {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid rgba(29, 39, 48, 0.16);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.lesson-table {
    margin: 18px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    background: #e9e3d8;
    font-weight: 800;
}

tr:last-child td {
    border-bottom: 0;
}

.site-footer {
    padding: 30px 0;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.95rem;
}

code {
    padding: 0.12em 0.3em;
    border-radius: 4px;
    background: #ece7dd;
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.95em;
}

.programming-world {
    --world-ground: #dcedc8;
    --world-ground-dark: #b6d795;
    --world-dirt: #d5b27c;
    --world-wall: #65717a;
    --world-wall-dark: #3f4a52;
    --world-goal: #f6c85f;
    --world-goal-dark: #c9822b;
    --world-grid: #acc894;
    --world-code: #111827;
    --world-player: #37a6b4;
}

.programming-world-intro {
    max-width: 920px;
}

.programming-world-chapter-count {
    margin-left: 6px;
    color: var(--muted);
    font-weight: 700;
    text-transform: none;
}

.programming-world-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    margin: 20px 0 32px;
}

/* The map stays in view while the student scrolls through code and output. */
.programming-world-left {
    position: sticky;
    top: 12px;
}

.programming-world-map-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.programming-world-map-head .eyebrow {
    margin: 0;
}

.programming-world-journey-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 10px;
}

.programming-world-journey-label {
    font-weight: 900;
}

.programming-world-journey-chapters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
}

.programming-world-brief-main h2 {
    margin-bottom: 8px;
}

.programming-world-brief-main p:last-child,
.programming-world-brief-side .programming-world-command-list {
    margin-top: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.programming-world-left,
.programming-world-right {
    min-width: 0;
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.programming-world-badge {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.programming-world-grid {
    display: grid;
    grid-template-columns: repeat(var(--world-columns, 8), minmax(0, 1fr));
    grid-template-rows: repeat(var(--world-rows, 6), minmax(0, 1fr));
    width: min(100%, 620px);
    aspect-ratio: var(--world-columns, 8) / var(--world-rows, 6);
    border: 4px solid #7e9d6d;
    border-radius: 12px;
    overflow: hidden;
    background: #8fbf77;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 14px 30px rgba(54, 70, 46, 0.16);
}

.programming-world-cell {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid rgba(91, 123, 70, 0.35);
    border-bottom: 1px solid rgba(91, 123, 70, 0.35);
    background:
        radial-gradient(circle at 22% 26%, rgba(255, 255, 255, 0.32) 0 8%, transparent 9%),
        radial-gradient(circle at 78% 74%, rgba(104, 142, 74, 0.24) 0 10%, transparent 11%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 45%),
        var(--world-ground);
}

.programming-world-cell.is-start {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent),
        linear-gradient(45deg, var(--world-ground) 0 48%, var(--world-ground-dark) 49% 52%, var(--world-ground) 53%);
}

.programming-world-cell.is-wall {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 35%),
        linear-gradient(45deg, transparent 0 42%, rgba(255, 255, 255, 0.14) 43% 48%, transparent 49%),
        linear-gradient(-45deg, transparent 0 45%, rgba(0, 0, 0, 0.12) 46% 52%, transparent 53%),
        var(--world-wall);
    box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.16);
}

.programming-world-cell.is-goal {
    background:
        radial-gradient(circle at 50% 48%, #fff7bd 0 22%, transparent 23%),
        conic-gradient(from 45deg, var(--world-goal) 0 25%, #f9da88 0 50%, var(--world-goal) 0 75%, #f9da88 0),
        var(--world-goal-dark);
}

.programming-world-cell.is-blocked::after {
    content: "";
    position: absolute;
    inset: 16%;
    border: 3px solid #b42318;
    border-radius: 999px;
    animation: world-blocked-pulse 0.34s ease-in-out;
}

.programming-world-cell.is-robot-hit .programming-world-robot svg {
    animation: world-robot-hit 0.34s ease-in-out;
}

.programming-world-cell.is-complete {
    animation: world-goal-complete 0.75s ease-in-out;
}

.programming-world-robot {
    position: relative;
    z-index: 2;
    display: block;
    width: 84%;
    height: 84%;
    filter: drop-shadow(0 4px 5px rgba(29, 39, 48, 0.28));
    transition: transform 0.18s ease;
}

.programming-world-robot svg {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.programming-world-flag {
    position: absolute;
    inset: 6%;
    z-index: 1;
    pointer-events: none;
}

.programming-world-flag svg {
    display: block;
    width: 100%;
    height: 100%;
}

.programming-world-cell.is-goal:has(.programming-world-robot) .programming-world-flag {
    opacity: 0.55;
}

/* Trail of the cells the robot has walked through. */
.programming-world-cell.is-visited:not(.is-goal)::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle, rgba(18, 60, 66, 0.32) 0 11%, transparent 12%),
        rgba(55, 166, 180, 0.2);
    pointer-events: none;
}

.programming-world-grid.is-celebrating .programming-world-robot svg {
    animation: world-robot-celebrate 0.6s ease-in-out 2;
}

.programming-world-grid.is-celebrating .programming-world-cell.is-goal {
    animation: world-goal-complete 0.6s ease-in-out 2;
}

.programming-world-brief {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    gap: 8px 28px;
    margin-top: 16px;
    padding: 16px 20px;
    border: 1px solid #d7dfcd;
    border-radius: 8px;
    background: #fbfdf8;
}

.programming-world-brief h2 {
    margin-bottom: 8px;
}

.programming-world-hint {
    margin-top: 14px;
}

.programming-world-hint summary {
    cursor: pointer;
    font-weight: 900;
}

.programming-world-next[hidden] {
    display: none;
}

.programming-world-robot.direction-north {
    transform: rotate(-90deg);
}

.programming-world-robot.direction-east {
    transform: rotate(0deg);
}

.programming-world-robot.direction-south {
    transform: rotate(90deg);
}

.programming-world-robot.direction-west {
    transform: rotate(180deg);
}

.programming-world-legend,
.programming-world-command-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

/* Icon toolbar above the editor; every button has a title and a label. */
.programming-world-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.programming-world-controls svg {
    width: 20px;
    height: 20px;
    flex: none;
}

.programming-world-run {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.programming-world-icon-button {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.programming-world-icon-button:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.programming-world-icon-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.programming-world-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.world-legend-tile {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1px solid var(--world-grid);
    border-radius: 4px;
    background: var(--world-ground);
}

.world-legend-tile.is-wall {
    background: var(--world-wall);
}

.world-legend-tile.is-goal {
    background: var(--world-goal);
}

.world-legend-tile.is-robot {
    background: var(--world-player);
}

.world-legend-tile.is-visited {
    background:
        radial-gradient(circle, rgba(18, 60, 66, 0.32) 0 14%, transparent 15%),
        #c3e3cd;
}

.programming-world-editor-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    margin-bottom: 8px;
}

.programming-world-editor-label {
    color: var(--text);
    font-weight: 800;
}

.programming-world-editor-keys {
    color: var(--muted);
    font-size: 0.8rem;
}

.programming-world-editor-wrap {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid #2b3643;
    border-radius: 8px;
    background: var(--world-code);
}

.programming-world-gutter {
    display: flex;
    flex-direction: column;
    min-width: 2.6em;
    padding: 16px 8px 16px 10px;
    overflow: hidden;
    border-right: 1px solid #2b3643;
    background: #0b111c;
    color: #6b7a90;
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.95rem;
    line-height: 22px;
    text-align: right;
    user-select: none;
}

.programming-world-gutter span {
    display: block;
    flex: none;
    height: 22px;
}

.programming-world-gutter .is-active {
    color: #fde68a;
    font-weight: 800;
}

.programming-world-gutter .is-error {
    color: #fca5a5;
    font-weight: 800;
}

.programming-world-editor-area {
    position: relative;
    min-width: 0;
}

.programming-world-line-highlight {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 0;
    border-left: 3px solid #fbbf24;
    background: rgba(251, 191, 36, 0.16);
    pointer-events: none;
    transition: transform 0.08s linear;
}

.programming-world-line-highlight.is-error {
    border-left-color: #f87171;
    background: rgba(248, 113, 113, 0.2);
}

.programming-world-editor {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 240px;
    resize: vertical;
    margin: 0;
    padding: 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #e5f3ff;
    caret-color: #fde68a;
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.95rem;
    line-height: 22px;
    tab-size: 4;
    white-space: pre;
}

.programming-world-editor:focus {
    outline: none;
}

.programming-world-editor-wrap:focus-within {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.programming-world-editor.is-busy {
    color: #b9c7d8;
}

.programming-world-speed {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.programming-world-speed input {
    width: 90px;
    accent-color: var(--accent);
}

.programming-world-speed output {
    min-width: 5.5em;
    color: var(--text);
    font-weight: 800;
}

.programming-world-status-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    margin-top: 16px;
}

.programming-world-status-row .programming-world-status {
    flex: 1 1 260px;
    margin-top: 0;
}

.programming-world-status-row .programming-world-next {
    flex: none;
}

.programming-world-description {
    color: var(--muted);
}

.programming-world-star-goal {
    margin: 8px 0 0;
    padding: 6px 10px;
    border-radius: 8px;
    background: #fff7db;
    color: #7a4b00;
    font-size: 0.9rem;
    font-weight: 700;
}

.programming-world-hints {
    margin-top: 14px;
}

.programming-world-hint-list {
    display: grid;
    gap: 8px;
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
}

.programming-world-hint-list li {
    padding: 10px 12px;
    border-left: 4px solid var(--accent);
    border-radius: 6px;
    background: var(--accent-soft);
}

.programming-world-hint-list strong {
    display: block;
    margin-bottom: 4px;
    color: var(--accent-dark);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.programming-world-hint-list p,
.programming-world-hint-list pre {
    margin: 0;
}

.programming-world-hint-list pre {
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

.programming-world-hint-button[hidden] {
    display: none;
}

.programming-world-status {
    margin-top: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
    font-weight: 800;
}

.programming-world-status.is-success {
    border-color: #8cc7a3;
    background: #edf8f0;
    color: #14532d;
    animation: world-status-pop 0.35s ease-out;
}

.programming-world-status.is-error {
    border-color: #e6aaa6;
    background: #fff1f0;
    color: var(--error);
}

.programming-world-console {
    margin-top: 16px;
}

.programming-world-console pre {
    min-height: 92px;
    max-height: 190px;
    margin: 0;
    overflow: auto;
    padding: 14px;
    border: 1px solid #d4dde7;
    border-radius: 8px;
    background: #f8fafc;
    color: #1f2937;
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.9rem;
}

.programming-world-command-list code {
    font-size: 1rem;
    font-weight: 800;
}

.programming-world-examples,
.programming-world-policy {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.programming-world-cheatsheet {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.programming-world-cheat {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.programming-world-cheat code {
    font-size: 1rem;
    font-weight: 800;
}

.programming-world-cheat p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

/* Journey: one dot per mission, grouped by chapter. */
.programming-world-journey {
    display: block;
    margin: 20px 0 0;
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.programming-world-journey-chapter {
    display: grid;
    gap: 6px;
}

.programming-world-journey-title {
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.programming-world-journey-dots {
    display: flex;
    gap: 6px;
}

.programming-world-journey-dot {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 2px solid #c9d6bd;
    border-radius: 999px;
    background: #ffffff;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
}

.programming-world-journey-dot:hover {
    border-color: var(--accent);
    color: var(--accent-dark);
}

.programming-world-journey-dot.is-complete {
    border-color: #3f9d63;
    background: #3f9d63;
    color: #ffffff;
}

.programming-world-journey-dot.has-star::after {
    content: "⭐";
    position: absolute;
    top: -9px;
    right: -9px;
    font-size: 0.8rem;
}

.programming-world-journey-dot.is-dimmed {
    opacity: 0.4;
}

.programming-world-focus {
    margin: 20px 0 0;
    padding: 10px 14px;
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: 800;
}

.programming-world-focus[hidden] {
    display: none;
}

.programming-world-journey-dot.is-next {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.programming-world-journey-dot.is-active {
    border-color: var(--accent-dark);
    box-shadow: 0 0 0 3px var(--accent);
}

.programming-world-journey-dot.is-active:not(.is-complete) {
    background: var(--accent-soft);
    color: var(--accent-dark);
}

/* Main map and the hidden variant maps after a run. */
.programming-world-maps {
    margin-top: 18px;
}

.programming-world-maps h3 {
    margin-bottom: 4px;
    font-size: 1rem;
}

.programming-world-maps-note {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.programming-world-map-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.programming-world-map-thumb {
    display: grid;
    grid-template-columns: auto auto;
    justify-items: start;
    align-items: center;
    gap: 6px 8px;
    padding: 8px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.programming-world-map-thumb:disabled {
    cursor: default;
}

.programming-world-map-thumb.is-active {
    border-color: var(--accent-dark);
}

.programming-world-map-thumb.is-passed .programming-world-map-mark {
    background: #3f9d63;
    color: #ffffff;
}

.programming-world-map-thumb.is-failed .programming-world-map-mark {
    background: #b42318;
    color: #ffffff;
}

.programming-world-mini {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(var(--world-columns, 8), var(--mini-cell, 7px));
    grid-auto-rows: var(--mini-cell, 7px);
    gap: 1px;
    padding: 2px;
    border-radius: 4px;
    background: #7e9d6d;
}

.programming-world-mini i {
    background: var(--world-ground);
}

.programming-world-mini i.is-wall {
    background: var(--world-wall);
}

.programming-world-mini i.is-goal {
    background: #e5484d;
}

.programming-world-mini i.is-start {
    background: var(--world-player);
}

.programming-world-mini.is-hidden {
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    width: 64px;
    height: 48px;
    color: #ffffff;
    font-size: 1.3rem;
    font-weight: 900;
}

.programming-world-map-label {
    font-size: 0.85rem;
    font-weight: 800;
}

.programming-world-map-mark {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 0.8rem;
    font-weight: 900;
}

.programming-world-examples .notice-box,
.programming-world-policy .notice-box {
    margin: 0;
}

.programming-world-examples pre {
    margin-bottom: 14px;
}

@keyframes world-blocked-pulse {
    0% {
        opacity: 0.2;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes world-robot-hit {
    0%,
    100% {
        transform: translateX(0);
    }

    35% {
        transform: translateX(-8%);
    }

    70% {
        transform: translateX(8%);
    }
}

@keyframes world-robot-celebrate {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.22);
    }
}

@keyframes world-status-pop {
    0% {
        transform: scale(0.97);
    }

    60% {
        transform: scale(1.015);
    }

    100% {
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .programming-world-robot,
    .programming-world-line-highlight {
        transition: none;
    }

    .programming-world-grid.is-celebrating .programming-world-robot svg,
    .programming-world-grid.is-celebrating .programming-world-cell.is-goal,
    .programming-world-cell.is-robot-hit .programming-world-robot svg,
    .programming-world-cell.is-blocked::after,
    .programming-world-status.is-success {
        animation: none;
    }
}

@keyframes world-goal-complete {
    0% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.35);
    }

    100% {
        filter: brightness(1);
    }
}

@media (max-width: 760px) {
    body {
        font-size: 17px;
    }

    .container {
        width: auto;
        max-width: none;
        margin-left: 16px;
        margin-right: 16px;
    }

    .page-content {
        padding-top: 32px;
    }

    h1 {
        font-size: 2rem;
        overflow-wrap: anywhere;
    }

    h2 {
        font-size: 1.65rem;
    }

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

    .discussion-card-grid,
    .discussion-board,
    .role-grid,
    .timeline-columns,
    .comparison-grid,
    .diagnostic-grid,
    .interactive-grid,
    .programming-world-shell,
    .programming-world-examples,
    .programming-world-policy,
    .submit-layout {
        grid-template-columns: 1fr;
    }

    .match-list label,
    .completion-list li {
        grid-template-columns: 1fr;
    }

    .discussion-board div {
        min-height: 90px;
    }

    .it-map {
        grid-template-columns: 1fr;
    }

    .course-track {
        padding: 18px;
    }

    .lesson-card {
        grid-template-columns: 44px 1fr;
        padding: 17px;
    }

    .lesson-card-number {
        width: 44px;
        height: 44px;
    }

    .course-track {
        padding: 18px;
    }

    .notice-box,
    .deep-dive,
    .task-box,
    .solution-box,
    .plan-item,
    .programming-world-feature {
        min-width: 0;
        padding: 18px;
    }

    .task-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .form-row {
        flex-direction: column;
    }

    .pseudo-code,
    .table-wrap {
        width: 100%;
        min-width: 0;
    }

    .pseudo-code {
        padding: 16px;
    }

    .pseudo-code code {
        font-size: 0.92rem;
    }

    .programming-world-left,
    .programming-world-right {
        padding: 18px;
    }

    .programming-world-grid {
        width: 100%;
    }

    .programming-world-journey {
        padding: 12px;
    }

    .programming-world-speed {
        margin-left: 0;
    }

    .programming-world-journey-dot {
        width: 30px;
        height: 30px;
    }

    .programming-world-editor-keys {
        display: none;
    }
}

/* Map and code side by side need room; below that they stack. */
/* Touch keys above the editor (script.js renderKeys): only where there is
   no physical keyboard, as one scrollable row. */
.programming-world-keys {
    display: none;
}

@media (hover: none) and (pointer: coarse) {
    .programming-world-editor-keys {
        display: none;
    }

    .programming-world-keys {
        display: flex;
        gap: 6px;
        margin: 0 -2px 8px;
        padding: 2px 2px 6px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }

    .programming-world-keys::-webkit-scrollbar {
        display: none;
    }
}

.programming-world-key {
    flex: none;
    min-width: 44px;
    min-height: 40px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: Consolas, "Liberation Mono", monospace;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}

.programming-world-key:active {
    background: var(--accent-soft);
    border-color: var(--accent);
}

@media (max-width: 980px) {
    .programming-world-shell,
    .programming-world-brief {
        grid-template-columns: minmax(0, 1fr);
    }

    .programming-world-left {
        position: static;
        scroll-margin-top: 76px;
    }

    /* The status sits right under the toolbar, so after "Spustit" (which
       scrolls to the map) the result is in view together with the map. */
    .programming-world-right {
        display: flex;
        flex-direction: column;
    }

    .programming-world-controls {
        order: 1;
    }

    .programming-world-status-row {
        order: 2;
        margin: 0 0 14px;
    }

    .programming-world-editor-head {
        order: 3;
    }

    .programming-world-keys {
        order: 4;
    }

    .programming-world-editor-wrap {
        order: 5;
    }

    .programming-world-console {
        order: 6;
    }
}

@media (max-width: 760px) {
    /* The eyebrow goes above the heading instead of squeezing it. */
    .section-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .programming-world-left,
    .programming-world-right {
        padding: 14px;
    }

    .programming-world-brief {
        padding: 14px;
    }

    .programming-world-run {
        flex: 1 1 auto;
        justify-content: center;
    }

    .programming-world-speed {
        flex: 1 1 100%;
        margin-left: 0;
    }

    .programming-world-speed input {
        flex: 1 1 auto;
    }

    .programming-world-legend {
        gap: 6px 12px;
        margin-top: 12px;
    }

    .programming-world-legend span {
        font-size: 0.82rem;
    }

    /* 16px or more: phones do not zoom the page when the editor gets focus. */
    .programming-world-editor,
    .programming-world-gutter {
        font-size: 16px;
    }

    .programming-world-editor {
        min-height: 200px;
        padding: 16px 12px;
    }

    .programming-world-status-row .programming-world-status {
        flex-basis: 100%;
    }

    .programming-world-status-row .programming-world-next {
        flex: 1 1 100%;
    }
}
