* {
    box-sizing: border-box;
}

:root {
    --ink: #172033;
    --muted: #5c667a;
    --paper: #ffffff;
    --bg: #f5f7fb;
    --line: #d9e0ea;
    --nav: #174ea6;
    --nav-dark: #112b5f;
    --accent: #0f766e;
    --accent-soft: #e6f4f1;
    --warn: #9a3412;
    --warn-soft: #fff4e6;
    --fail: #b42318;
    --pass: #137333;
    --code-bg: #101827;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.6;
    overflow-x: hidden;
}

.wrap {
    width: min(1120px, 92%);
    margin: 0 auto;
}

.site-header {
    background: linear-gradient(135deg, var(--nav-dark), #173b7a);
    color: #fff;
    padding: 26px 0;
    text-align: center;
}

.site-header h1 {
    margin: 0;
    font-size: clamp(1.65rem, 3vw, 2.25rem);
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.subtitle {
    margin: 8px 0 0;
    opacity: 0.92;
}

.top-nav {
    background: var(--nav);
    position: sticky;
    top: 0;
    z-index: 20;
}

.nav-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 10px 0;
    scrollbar-width: thin;
}

.top-nav a {
    color: #fff;
    text-decoration: none;
    padding: 9px 12px;
    border-radius: 6px;
    font-weight: 700;
    white-space: nowrap;
}

.top-nav a:hover,
.top-nav a.active {
    background: rgba(255, 255, 255, 0.2);
}

main {
    padding: 24px 0 40px;
}

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(17, 43, 95, 0.07);
    margin: 0 0 22px;
    padding: clamp(18px, 3vw, 26px);
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
    gap: 22px;
    align-items: start;
}

.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.task-box {
    border: 1px solid #c9d7ee;
    background: #edf4ff;
    border-radius: 8px;
    min-height: 250px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
}

.task-box h3 {
    margin: 0;
    font-size: 1.08rem;
}

.task-meta,
.hint,
.intro {
    color: var(--muted);
}

.task-meta {
    font-size: 0.9rem;
    margin: 0;
}

.task-btn,
button,
.secondary-btn {
    border: 0;
    border-radius: 6px;
    background: var(--nav);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 700;
    min-height: 42px;
    padding: 10px 14px;
    text-decoration: none;
}

.task-btn {
    margin-top: auto;
    align-self: flex-start;
}

button:hover,
.task-btn:hover,
.secondary-btn:hover {
    background: #123f8c;
}

.secondary-btn {
    background: #475569;
}

.badge-container {
    position: absolute;
    top: -12px;
    right: 12px;
}

.task-badge,
.level-pill,
.overall-grade {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 9px;
}

.task-badge {
    background: #ecfdf3;
    border: 1px solid #86efac;
    color: #166534;
}

.level-pill {
    background: var(--accent-soft);
    color: #115e59;
}

.instructions-box,
.teacher-note {
    background: #eef4ff;
    border: 1px solid #c9d7ee;
    border-radius: 8px;
    padding: 14px 16px;
}

.teacher-note {
    background: var(--warn-soft);
    border-color: #fed7aa;
}

textarea,
.single-line-input {
    width: 100%;
    border: 1px solid #c9d2df;
    border-radius: 8px;
    font: inherit;
    padding: 12px;
}

textarea {
    min-height: 330px;
    resize: vertical;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.95rem;
    line-height: 1.45;
    background: #fbfdff;
}

.single-line-input {
    margin: 8px 0 12px;
}

code,
pre {
    font-family: Consolas, "Courier New", monospace;
}

code {
    background: #eef2ff;
    border-radius: 4px;
    padding: 2px 5px;
}

pre {
    background: var(--code-bg);
    color: #e6edf7;
    border-radius: 8px;
    overflow-x: auto;
    padding: 14px;
    white-space: pre-wrap;
}

.button-row,
.integrity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.results {
    background: #f8fafc;
    border: 1px solid #dbe5f2;
    border-radius: 8px;
    margin-top: 18px;
    padding: 14px;
}

.result-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.result-list li {
    border-bottom: 1px solid #e7edf5;
    padding: 8px 0;
}

.result-list li:last-child {
    border-bottom: 0;
}

.pass {
    color: var(--pass);
    font-weight: 700;
}

.fail {
    color: var(--fail);
    font-weight: 700;
}

.task-status {
    margin-bottom: 12px;
}

.completion {
    background: #ecfdf3;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    margin-top: 14px;
    padding: 12px;
}

.hidden {
    display: none;
}

.concept-list {
    padding-left: 20px;
    overflow-wrap: anywhere;
}

.concept-list li {
    padding-right: 10px;
}

.score-table {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
}

.score-table th,
.score-table td {
    border: 1px solid #e2e8f0;
    padding: 9px 10px;
    text-align: left;
}

.score-table th {
    background: #eef4ff;
}

.table-wrap {
    overflow-x: auto;
}

.overall-grade {
    background: #e0ecff;
    color: #173b7a;
    min-width: 34px;
    justify-content: center;
}

.certificate-box {
    background: #eff6ff;
    border: 2px solid #bfdbfe;
    border-radius: 8px;
    margin-top: 16px;
    padding: 16px;
}

#certToken,
#verifyTokenInput {
    word-break: break-all;
}

@media (max-width: 820px) {
    .two-column {
        grid-template-columns: 1fr;
    }

    .top-nav {
        position: static;
    }

    textarea {
        min-height: 260px;
    }
}

@media (max-width: 640px) {
    .site-header {
        padding: 22px 0;
    }

    .site-header h1 {
        font-size: 1.3rem;
        line-height: 1.2;
    }

    .nav-links {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .card {
        padding: 16px;
    }

    .concept-list {
        padding-left: 18px;
    }
}

@media print {
    body * {
        visibility: hidden;
    }

    #certificateBox,
    #certificateBox * {
        visibility: visible;
    }

    #certificateBox {
        background: #fff;
        border-color: #000;
        left: 0;
        position: absolute;
        top: 0;
        width: 100%;
    }
}
