  /* ── SITE TOKENS ───────────────────────────────────── */
  :root {
    --green:      #4fc431;
    --green-dark: #3aad1f;
    --bg:         #0f1620;
    --bg2:        #18202e;
    --bg3:        #222c3c;
    --text:       #e8edf4;
    --text-muted: #8fa0b8;
    --border:     #2a3547;
    --radius:     16px;
    --mono:       'JetBrains Mono', monospace;
    --sans:       'DM Sans', sans-serif;
    /* quiz accent colours */
    --accent:     #00ff88;
    --amber:      #ffb347;
    --amber-dim:  #3a2800;
    --blue:       #4fc3f7;
    --blue-dim:   #0c2d40;
    --red:        #ff6b6b;
    --red-dim:    #3a0d0d;
    --green-dim:  #0d4a2b;
    --violet:     #b58aff;
    --violet-dim: #241a3a;
    --teal:       #5eead4;
    --teal-dim:   #0d2e2a;
  }

  [data-theme="light"] {
    --bg:         #dde4ef;
    --bg2:        #eaf0f8;
    --bg3:        #d0d9e8;
    --text:       #0f1a2e;
    --text-muted: #3d5070;
    --border:     #b0bdd0;
    --green:      #2d8a14;
    --green-dark: #1f6b0d;
    --accent:     #00cc66;
    --green-dim:  #d4edda;
    --red-dim:    #fde8e8;
    --blue-dim:   #dbeeff;
    --amber-dim:  #fff3cd;
    --violet-dim: #ece0ff;
    --teal-dim:   #d7f7f0;
  }

  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
  }

  /* ── Binary rain ───────────────────────────────────── */
  #rain-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.06;
    z-index: 0;
  }

  /* ── NAV ───────────────────────────────────────────── */
  nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(15,22,32,0.92);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    display: flex;
    align-items: center;
    height: 64px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    gap: 16px;
    flex-shrink: 0;
  }
  [data-theme="light"] nav { background: rgba(234,240,248,0.95); }

  .nav-back {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
  }
  .nav-back:hover { color: var(--green); border-color: var(--green); }

  .nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
  }
  .nav-logo img { height: 32px; width: auto; }
  .nav-brand { font-family: var(--mono); font-size: 0.82rem; color: var(--green); font-weight: 700; }

  .nav-title {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .theme-btn {
    background: var(--bg3);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: 0.2s;
    line-height: 1;
    flex-shrink: 0;
  }
  .theme-btn:hover { color: var(--text); }

  /* ── PAGE WRAPPER ──────────────────────────────────── */
  .wrapper {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 24px 56px;
    flex: 1;
    width: 100%;
  }

  /* ── HEADER ─────────────────────────────────────────── */
  header { text-align: center; margin-bottom: 2.5rem; }

  .page-label {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--green);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    border: 1px solid var(--green);
    padding: 0.2em 0.8em;
    border-radius: 6px;
    margin-bottom: 1rem;
  }

  h1 {
    font-family: var(--mono);
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1.2;
  }
  h1 span { color: var(--green); }

  .subtitle { margin-top: 0.5rem; color: var(--text-muted); font-size: 0.9rem; }

  /* ── TOPIC PILLS ─────────────────────────────────────── */
  .topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 1rem;
  }
  .pill {
    font-family: var(--mono);
    font-size: 0.7rem;
    padding: 0.25em 0.75em;
    border-radius: 100px;
    background: var(--bg2);
    border: 1px solid var(--border);
    color: var(--text-muted);
  }

  /* ── PROGRESS ────────────────────────────────────────── */
  .progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-family: var(--mono);
  }
  .progress-bar-wrap {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 4px;
    height: 6px;
    margin-bottom: 2rem;
    overflow: hidden;
  }
  .progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--blue));
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
  }

  /* ── QUESTION CARD ───────────────────────────────────── */
  .card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.75rem;
    margin-bottom: 1.25rem;
    animation: slideIn 0.3s ease;
  }
  @keyframes slideIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── BADGE ───────────────────────────────────────────── */
  .card-badge {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.2em 0.7em;
    border-radius: 6px;
    margin-bottom: 0.9rem;
  }
  .badge-sets          { background: var(--blue-dim);   color: var(--blue);   border: 1px solid var(--blue); }
  .badge-empty         { background: var(--amber-dim);  color: var(--amber);  border: 1px solid var(--amber); }
  .badge-comprehension { background: var(--green-dim);  color: var(--accent); border: 1px solid var(--accent); }
  .badge-strings       { background: var(--red-dim);    color: var(--red);    border: 1px solid var(--red); }
  .badge-finite        { background: var(--violet-dim); color: var(--violet); border: 1px solid var(--violet); }
  .badge-cartesian     { background: var(--teal-dim);   color: var(--teal);   border: 1px solid var(--teal); }

  .question-text {
    font-size: 1rem;
    line-height: 1.65;
    margin-bottom: 1.1rem;
    color: var(--text);
  }

  /* ── DATA BLOCKS ─────────────────────────────────────── */
  .data-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.1rem;
    font-family: var(--mono);
    font-size: 0.9rem;
    line-height: 1.9;
  }
  .data-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
  .data-label { color: var(--text-muted); min-width: 5rem; }
  .bits { color: var(--blue); letter-spacing: 0.05em; }
  .highlight { color: var(--amber); }

  /* ── SUB-PARTS ───────────────────────────────────────── */
  .subpart-list { display: flex; flex-direction: column; gap: 0.65rem; }
  .subpart-row {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    padding: 0.6rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
  }
  .subpart-label { font-family: var(--mono); font-size: 0.88rem; color: var(--text); min-width: 2rem; }
  .subpart-prompt { font-family: var(--mono); font-size: 0.88rem; color: var(--blue); flex: 1; min-width: 8rem; }

  /* ── CHECKLIST ───────────────────────────────────────── */
  .checklist { display: flex; flex-direction: column; gap: 0.5rem; }
  .check-row {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.55rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 0.92rem;
    cursor: pointer;
  }
  .check-row input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--blue); cursor: pointer; }

  /* ── INPUTS ──────────────────────────────────────────── */
  .answer-row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
  .answer-label { font-size: 0.85rem; color: var(--text-muted); min-width: 5rem; }

  input[type="text"], select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
    outline: none;
    transition: border-color 0.2s;
  }
  input[type="text"]:focus, select:focus { border-color: var(--blue); }
  input.correct   { border-color: var(--green) !important; background: var(--green-dim); }
  input.incorrect { border-color: var(--red)   !important; background: var(--red-dim); }
  select { cursor: pointer; }
  input.wide { width: 100%; max-width: 22rem; }

  /* ── BUTTONS ─────────────────────────────────────────── */
  .btn {
    font-family: var(--sans);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.55rem 1.25rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
  }
  .btn-check   { background: var(--blue);  color: #000; }
  .btn-check:hover { filter: brightness(1.15); }
  .btn-next    { background: #4fc431; color: #000; }
  .btn-next:hover { background: #3aad1f; }
  .btn-restart { background: transparent; color: var(--text); border: 1px solid var(--border); }
  .btn-restart:hover { border-color: var(--blue); color: var(--blue); }

  .action-row { display: flex; gap: 0.75rem; margin-top: 1.1rem; flex-wrap: wrap; }

  /* ── FEEDBACK ────────────────────────────────────────── */
  .feedback {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.6;
    display: none;
  }
  .feedback.show { display: block; }
  .feedback.correct-fb   { background: var(--green-dim); border: 1px solid var(--green); color: var(--accent); }
  .feedback.incorrect-fb { background: var(--red-dim);   border: 1px solid var(--red);   color: #ffaaaa; }
  .feedback strong { color: var(--text); }
  .fb-mono { font-family: var(--mono); color: var(--amber); }

  /* ── HINT ────────────────────────────────────────────── */
  .hint-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-family: var(--sans);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0;
    margin-top: 0.6rem;
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .hint-toggle:hover { color: var(--blue); }
  .hint-box {
    display: none;
    background: var(--bg);
    border-left: 3px solid var(--amber);
    padding: 0.75rem 1rem;
    margin-top: 0.6rem;
    border-radius: 0 8px 8px 0;
    font-size: 0.83rem;
    color: var(--text-muted);
    line-height: 1.7;
    font-family: var(--mono);
  }
  .hint-box.open { display: block; }

  /* ── SCORE SCREEN ────────────────────────────────────── */
  #score-screen { display: none; text-align: center; animation: slideIn 0.4s ease; }
  #score-screen.show { display: block; }

  .score-ring { width: 130px; height: 130px; margin: 0 auto 1.5rem; }
  .score-ring svg { width: 100%; height: 100%; }

  .score-number { font-family: var(--mono); font-size: 2.5rem; font-weight: 700; }
  .score-number.great { color: var(--green); }
  .score-number.ok    { color: var(--amber); }
  .score-number.poor  { color: var(--red); }

  .score-label { color: var(--text-muted); margin-bottom: 2rem; }

  .score-breakdown {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: left;
    margin-bottom: 1.5rem;
  }
  .score-breakdown h3 {
    font-family: var(--mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--green);
    margin-bottom: 0.75rem;
  }
  .score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
  }
  .score-row:last-child { border-bottom: none; }
  .score-tick  { color: var(--green); font-family: var(--mono); }
  .score-cross { color: var(--red);   font-family: var(--mono); }

  /* ── FOOTER ──────────────────────────────────────────── */
  footer {
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 28px 32px;
    text-align: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
  }
  footer p { font-family: var(--mono); font-size: 0.78rem; color: var(--text-muted); }
  footer span { color: var(--green); }

  @media (max-width: 500px) {
    h1 { font-size: 1.3rem; }
    nav { padding: 0 16px; }
    .nav-title { display: none; }
  }
