:root {
  --bg: #0b0b24;
  --panel: rgb(22 22 56 / 0.88);
  --panel-2: #23235a;
  --border: #35357a;
  --text: #e6e4ff;
  --muted: #a3a1d6;
  --term-bg: rgb(8 8 26 / 0.94);
  --gold: #ffd166;
  --accent: #6aa8ff;
  --ok: #7fe0a0;
  --warn: #ffd166;
  --err: #ff7a90;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --script: "Snell Roundhand", "Apple Chancery", "Lucida Calligraphy", "Brush Script MT", cursive;
}
body[data-track="intermediate"] { --accent: #ffb547; }
body[data-track="advanced"] { --accent: #b88cff; }
body[data-track="impossible"] { --accent: #7dff9a; }
body[data-track="unfair"] { --accent: #ff6b6b; }
body[data-track="sandbox"] { --accent: #ff8fd0; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 120%, #3b1f6e 0%, #1a1446 45%, var(--bg) 80%) fixed;
  color: var(--text);
  font: 15px/1.5 var(--sans);
  display: flex;
  flex-direction: column;
}

/* Twinkling starfield behind everything */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 25% 70%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 40% 35%, #fff8d6 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 58%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 82% 28%, #fff8d6 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 80%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 5% 90%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 33% 5%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 75% 90%, #fff8d6 50%, transparent 51%);
  background-size: 420px 420px;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.45; } to { opacity: 1; } }

code, kbd { font-family: var(--mono); font-size: 0.9em; }
code { background: var(--panel-2); padding: 0.05em 0.35em; border-radius: 4px; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.35em; background: var(--panel); }
button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45em 0.9em;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}
button:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 35%, transparent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); color: #12102e; border-color: var(--accent); font-weight: 700; }
button.secondary { background: transparent; }

/* ---------------------------------------------------------------- header */
.topbar {
  /* Its backdrop-filter makes it a stacking context; lift the whole bar so its dropdown menus sit above
     the track tabs below instead of under them. */
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgb(15 15 44 / 0.75);
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.75rem; }
.logo {
  font-size: 1.7rem;
  width: 2.8rem; height: 2.8rem;
  display: grid; place-items: center;
  border: 2px solid var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 16px rgb(255 209 102 / 0.45);
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-3px) rotate(-8deg); } }
.brand h1 {
  margin: 0;
  font: 700 1.75rem/1 var(--script);
  color: var(--gold);
  text-shadow: 0 0 14px rgb(255 209 102 / 0.4);
  white-space: nowrap;
}
.brand h1 span { font: 800 1.3rem var(--mono); color: var(--accent); text-shadow: none; }
.tagline { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.85rem; font-style: italic; }
.modules { display: flex; gap: 0.3rem; flex: 1; justify-content: center; flex-wrap: wrap; }

/* Category menus in the top bar */
.cat { position: relative; }
.cat-btn { border-radius: 999px; padding: 0.3em 0.75em; font-size: 0.9rem; white-space: nowrap; }
.cat-btn.current { background: var(--gold); color: #12102e; border-color: var(--gold); font-weight: 700; }
.cat-btn[aria-expanded="true"] { border-color: var(--gold); box-shadow: 0 0 12px rgb(255 209 102 / 0.35); }
.cat-btn .caret { font-size: 0.75em; opacity: 0.8; }
.cat-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  min-width: 300px; max-width: min(420px, 90vw);
  display: grid; gap: 2px; padding: 0.35rem;
  background: #1c1a4a; border: 1px solid var(--gold); border-radius: 12px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.5);
}
.cat-item {
  display: grid; grid-template-columns: 1.8rem 1fr auto; align-items: center; gap: 0.6rem;
  text-align: left; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 0.45rem 0.6rem;
}
.cat-item:hover, .cat-item:focus-visible { background: var(--panel-2); border-color: var(--border); outline: none; transform: none; box-shadow: none; }
.cat-item[aria-checked="true"] { border-color: var(--gold); }
.ci-emoji { font-size: 1.25rem; text-align: center; }
.ci-text { display: grid; }
.ci-name { font-weight: 700; }
.ci-blurb { color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.ci-prog { font: 600 0.8rem var(--mono); color: var(--gold); white-space: nowrap; }
.card-cat { grid-column: 1 / -1; margin: 0.6rem 0 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.prog-cat { margin: 1.4rem 0 0; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
@media (max-width: 1500px) { .tagline, .cat-current { display: none; } .brand h1 { font-size: 1.5rem; } .brand h1 span { font-size: 1.1rem; } }
.modules button[aria-pressed="true"] { background: var(--gold); color: #12102e; border-color: var(--gold); font-weight: 700; }
.modules .progress, .tracks .progress { opacity: 0.75; font-size: 0.8em; margin-left: 0.2em; }

/* Track tabs + mode toggles under the header */
.subbar {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgb(15 15 44 / 0.55);
}
.tracks { display: flex; gap: 0.35rem; flex: 1; flex-wrap: wrap; }
.tracks button { border-radius: 8px; padding: 0.3em 0.85em; font-size: 0.92rem; }
.tracks button[aria-pressed="true"] { background: var(--track-accent, var(--accent)); color: #12102e; border-color: var(--track-accent, var(--accent)); font-weight: 700; }
.modes { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.modes .mode { font-size: 0.85rem; padding: 0.3em 0.75em; border-radius: 999px; background: transparent; }
.modes .mode[aria-pressed="true"] { background: color-mix(in srgb, #ff7a5c 25%, var(--panel-2)); border-color: #ff7a5c; color: #ffd2c4; font-weight: 700; }
.score { display: flex; align-items: center; gap: 0.5rem; font-family: var(--mono); }
.score-label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.score-value { font-size: 1.35rem; font-weight: 800; color: var(--gold); min-width: 3ch; text-align: right; text-shadow: 0 0 10px rgb(255 209 102 / 0.5); }
.score-value.bump { animation: bump 0.6s ease-out; }
.score-value.negative { color: var(--err); text-shadow: 0 0 10px rgb(255 122 144 / 0.5); }
@keyframes bump { 30% { transform: scale(1.45); } }
.icon-btn { width: 2rem; height: 2rem; padding: 0; border-radius: 50%; }

/* ---------------------------------------------------------------- layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 410px) 1fr;
  gap: 1rem;
  padding: 1rem 1.25rem;
  min-height: 0;
}
@media (max-width: 900px) {
  html, body { height: auto; }
  .topbar { justify-content: space-between; }
  .modules { order: 3; flex-basis: 100%; }
  .layout { grid-template-columns: 1fr; padding: 0.75rem; }
  .mission { overflow: visible; }
  .terminal { min-height: 70vh; }
}

/* --------------------------------------------------------------- mission */
.mission {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.level-strip { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.level-strip button {
  width: 1.95rem; height: 1.95rem; padding: 0;
  font: 600 0.85rem var(--mono);
  border-radius: 50%;
}
.level-strip button.done { background: color-mix(in srgb, var(--gold) 22%, var(--panel-2)); border-color: var(--gold); color: var(--gold); }
.level-strip li { position: relative; }
.level-strip button[aria-current="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.level-strip button[data-grade]::after {
  content: attr(data-grade);
  position: absolute; top: -0.45rem; right: -0.35rem;
  font: 800 0.6rem/1 var(--mono);
  background: var(--gold); color: #12102e;
  border-radius: 999px; padding: 0.15rem 0.28rem;
}
.rank { color: var(--accent); font: 700 0.75rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 0.4rem; }
.mission h2 { margin: 0; font-size: 1.4rem; }
.mission h3 { margin: 0 0 0.3rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.story { margin: 0; color: #d3d0f5; }
.objective {
  background: color-mix(in srgb, var(--accent) 12%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-left: 4px solid var(--accent);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
}
.objective p { margin: 0; font-weight: 600; line-height: 1.7; }
/* Exact names and text the player must type */
.objective code, .story code, .hints code {
  background: #0e0d2c;
  color: var(--gold);
  border: 1px dashed color-mix(in srgb, var(--gold) 60%, transparent);
  padding: 0.05em 0.4em;
  white-space: nowrap;
  font-weight: 700;
}
.story code, .hints code { border-style: solid; border-color: transparent; font-weight: 600; }
.teaches dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.75rem; font-size: 0.9rem; }
.teaches dt { font-family: var(--mono); color: var(--accent); white-space: nowrap; }
.teaches dd { margin: 0; color: #d3d0f5; }
.hints ol { margin: 0; padding-left: 1.3rem; color: var(--warn); font-size: 0.92rem; }
.hints li + li { margin-top: 0.25rem; }
.hints ol:empty { display: none; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.5rem; }
#hint-cost { color: var(--muted); font-size: 0.8em; }

/* -------------------------------------------------------------- terminal */
.terminal {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--term-bg);
  min-height: 0;
  box-shadow: 0 10px 50px rgb(0 0 0 / 0.45), 0 0 0 1px rgb(255 209 102 / 0.06);
}
.chrome {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f57; } .dot.yellow { background: #febc2e; } .dot.green { background: #28c840; }
.chrome-title { flex: 1; text-align: center; font: 0.8rem var(--mono); color: var(--muted); margin-right: 3rem; }
.screen {
  flex: 1;
  overflow-y: auto;
  padding: 0.8rem 1rem 1.5rem;
  font: 14px/1.5 var(--mono);
  cursor: text;
  min-height: 300px;
}
.output { white-space: pre-wrap; word-break: break-word; }
.output .line-cmd .ps { color: var(--ok); }
.output .stderr { color: var(--err); }
.output .stderr-info { color: var(--muted); }
.output .sys { color: var(--muted); }
.output .banner { color: var(--accent); font-weight: 700; }
.output .success {
  color: var(--gold);
  border: 1px solid var(--gold);
  background: rgb(255 209 102 / 0.08);
  box-shadow: 0 0 18px rgb(255 209 102 / 0.25);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  margin: 0.5rem 0;
  display: block;
  font-weight: 700;
  animation: glow 1.2s ease-out;
}
@keyframes glow { from { box-shadow: 0 0 40px rgb(255 209 102 / 0.8); } }
.output .nudge { color: var(--warn); }
.output .options { color: var(--muted); }
.input-line { display: flex; gap: 0.6ch; align-items: baseline; }
.prompt { color: var(--ok); white-space: nowrap; }
#cmd {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
  caret-color: var(--gold);
  padding: 0;
  min-width: 0;
}

/* Report card */
.output .report-head { color: var(--text); font-weight: 700; margin-top: 0.2rem; }
.output .report { color: #c9c6ee; }
.output .note-plus { color: var(--ok); }
.output .note-minus { color: #ffb0a0; }
.output .note-tip { color: #9fd6ff; }

/* Hardcore: no sidebar, no hints. The terminal takes the whole stage. */
body.hardcore .mission { display: none; }
body.hardcore .layout { grid-template-columns: 1fr; }
body.hardcore .terminal { box-shadow: 0 0 0 1px rgb(255 122 92 / 0.45), 0 10px 50px rgb(255 90 60 / 0.15); }

/* ------------------------------------------------------------------- vim */
.chrome-btn { padding: 0.15em 0.6em; font-size: 0.8rem; }
.vimview .chrome-title { margin-right: 0.5rem; }
.vim-editor {
  font: 14px/1.5 var(--mono);
  padding: 0.6rem 0 0;
  outline: none;
  cursor: text;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
}
.vim-editor:focus-visible, .vim-editor:focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); }
.vim-lines { min-height: 14lh; }
.vl { display: flex; white-space: pre; }
.vl .gutter { width: 3.5ch; padding-right: 1ch; text-align: right; color: #5c5a99; flex: none; user-select: none; }
.vl.tilde .txt { color: #4b4a85; }
.vl .cur { background: var(--gold); color: #12102e; }
.vim-editor:not(:focus) .vl .cur { background: transparent; outline: 1px solid var(--gold); color: inherit; }
.vl .cur-bar { box-shadow: inset 2px 0 0 var(--gold); }
.vl .sel { background: rgb(150 140 255 / 0.35); }
.vim-status {
  display: flex; gap: 1rem; padding: 0.15rem 0.8rem;
  background: var(--panel-2); color: var(--muted); font-size: 0.85rem;
}
.vs-mode { color: var(--gold); font-weight: 700; min-width: 12ch; }
.vs-pending { flex: 1; text-align: right; color: var(--text); }
.vs-pos { white-space: nowrap; }
.vim-cmdline { padding: 0.15rem 0.8rem 0.35rem; min-height: 1.6em; white-space: pre; }
.vim-cmdline.err { color: var(--err); }
.vim-feed { flex: 1; overflow-y: auto; padding: 0.6rem 1rem 1rem; font: 13.5px/1.45 var(--mono); min-height: 140px; }

/* ANSI colours emitted by the shell when writing to the screen */
.a-1 { font-weight: 700; }
.a-31 { color: #ff7a90; }
.a-32 { color: #7fe0a0; }
.a-34 { color: #7fb4ff; }
.a-35 { color: #e29bff; }
.a-36 { color: #6fe6dc; }
.a-95 { color: var(--gold); }
.a-30 { color: #0b0b24; }
.a-42 { background: #3fbf6a; color: #0b0b24; }

/* --------------------------------------------------------------- footer */
.footer {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; justify-content: center;
  padding: 0.5rem 1rem 0.8rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* --------------------------------------------------------------- dialog */
dialog {
  max-width: 780px;
  width: calc(100% - 2rem);
  background: linear-gradient(180deg, #24205e, #16153f);
  color: var(--text);
  border: 1px solid var(--gold);
  border-radius: 18px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 0 60px rgb(255 209 102 / 0.2);
}
dialog::backdrop { background: rgb(5 5 20 / 0.75); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 0.5rem; text-align: center; font: 700 2.2rem/1.1 var(--script); color: var(--gold); }
.welcome-hero { text-align: center; font-size: 3rem; line-height: 1; animation: bob 3s ease-in-out infinite; }
dialog form { text-align: right; margin-top: 1rem; }
.track-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.track-card {
  text-align: left;
  display: flex; flex-direction: column; gap: 0.35rem;
  padding: 0.9rem;
  border-radius: 12px;
  border-top: 3px solid var(--card-accent);
}
.track-card .emoji { font-size: 1.8rem; line-height: 1; }
.track-card strong { font-size: 1.05rem; color: var(--card-accent); }
.track-card span { color: var(--muted); font-size: 0.88rem; }
.track-card:hover { border-color: var(--card-accent) !important; }

/* ------------------------------------------------------ fairy godmother */
.fairy-btn { border-color: #c9a6ff; }
.fairy-btn:hover:not(:disabled) { border-color: #e2ccff; box-shadow: 0 0 14px rgb(201 166 255 / 0.45); }
dialog.fairy { max-width: 860px; max-height: 88vh; overflow-y: auto; border-color: #c9a6ff; box-shadow: 0 0 60px rgb(201 166 255 / 0.3); }
dialog.fairy h2 { color: #e2ccff; }
.fg-step { margin: 1rem 0; padding: 0.8rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: rgb(10 10 34 / 0.55); }
.fg-cmd { display: flex; align-items: baseline; gap: 0.6rem; }
.fg-cmd code { font-size: 1rem; background: transparent; padding: 0; white-space: pre-wrap; word-break: break-word; color: var(--gold); }
.fg-num { font: 700 0.75rem var(--mono); color: #12102e; background: #c9a6ff; border-radius: 999px; padding: 0.1rem 0.45rem; }
.fg-summary { margin: 0.4rem 0 0.2rem; color: var(--text); }
.fg-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0.6rem 0; font-family: var(--mono); }
.fg-chip { padding: 0.15rem 0.45rem; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-2); white-space: pre; cursor: default; }
.fg-parts { margin: 0; display: grid; gap: 2px; }
.fg-part { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: 0.75rem; padding: 0.3rem 0.4rem; border-radius: 6px; }
.fg-part dt { display: flex; flex-direction: column; gap: 0.1rem; }
.fg-part dt code { background: transparent; padding: 0; white-space: pre-wrap; word-break: break-word; }
.fg-kind { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.fg-part dd { margin: 0; color: #d3d0f5; }
.fg-chip.lit, .fg-part.lit { outline: 1px solid #c9a6ff; background: rgb(201 166 255 / 0.14); }
.fg-inner { margin: 0.5rem 0 0.2rem; padding: 0.5rem 0.7rem; border-style: dashed; background: rgb(201 166 255 / 0.06); }
.fg-inner .fg-cmd code { font-size: 0.9rem; }
.fg-subparts { margin: 0.35rem 0 0; padding-left: 1rem; font-size: 0.9rem; color: var(--muted); }
.fg-subparts code { background: transparent; padding: 0; }
.fg-why { margin-top: 1rem; padding: 0.8rem 1rem; border-left: 4px solid var(--gold); background: rgb(255 209 102 / 0.07); border-radius: 0 10px 10px 0; }
.fg-why h3 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.fg-why p { margin: 0; }
.fg-warn { font-size: 1.05rem; }
.fg-confirm, .fairy-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }
/* Colour by kind: what a piece IS (command, flag, plumbing, expansion) */
.k-command, .k-subcommand, .k-keyword { color: var(--gold); }
.k-flag { color: #7fb4ff; }
.k-pipe, .k-operator, .k-redirect { color: #e29bff; }
.k-glob, .k-var, .k-quote, .k-value { color: #7fe0a0; }
.k-assign, .k-key { color: #6fe6dc; }
.k-comment { color: var(--muted); }
.cell.helped { border-color: #c9a6ff; color: #e2ccff; }

/* -------------------------------------------------------- opt-in dialog */
dialog.optin { max-width: 520px; border-color: #ff7a5c; box-shadow: 0 0 60px rgb(255 90 60 / 0.25); }
dialog.optin h2 { color: #ffb39e; }
.optin-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* ------------------------------------------------------ progress dialog */
dialog.progress-dialog { max-width: 980px; max-height: 88vh; overflow-y: auto; }
dialog.progress-dialog h2 { font-size: 2rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; margin: 0.5rem 0 1rem; }
.tile { background: rgb(10 10 34 / 0.6); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.9rem; }
.tile-label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.tile-value { font: 800 2.2rem/1.1 var(--sans); color: var(--text); margin-top: 0.2rem; font-variant-numeric: tabular-nums; }
.tile-value small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.tile-sub { color: var(--muted); font-size: 0.8rem; }
.prog-section { margin-top: 1.1rem; }
.prog-section h3 { margin: 0 0 0.45rem; font-size: 0.95rem; }
.muted { color: var(--muted); font-weight: 400; }
/* Meters: one hue, track is the same hue at low strength. */
.meter { height: 8px; border-radius: 4px; background: rgb(255 209 102 / 0.16); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--gold); }
.prog-module > .meter { margin-bottom: 0.5rem; }
.prog-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.prog-table th { text-align: left; font-weight: 600; padding: 0.3rem 0.6rem 0.3rem 0; white-space: nowrap; width: 1%; }
.prog-table td { padding: 0.3rem 0.4rem; vertical-align: middle; }
.prog-count { color: var(--muted); font-variant-numeric: tabular-nums; width: 1%; white-space: nowrap; }
.prog-meter { width: 120px; }
.cells { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.cell {
  width: 1.8rem; height: 1.8rem; padding: 0; display: inline-grid; place-items: center;
  font: 700 0.75rem var(--mono); border-radius: 6px; color: var(--muted);
}
.cell.done { background: color-mix(in srgb, var(--gold) 22%, var(--panel-2)); border-color: var(--gold); color: var(--gold); }
.cell.locked { border: 1px dashed var(--border); opacity: 0.6; font-size: 0.7rem; }
.grade-bars { display: grid; gap: 4px; max-width: 560px; }
.gb-row { display: grid; grid-template-columns: 1.6rem 15rem 1fr 2.5rem; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.gb-letter { font: 800 0.95rem var(--mono); color: var(--text); }
.gb-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gb-track { height: 12px; border-radius: 0 4px 4px 0; position: relative; }
.gb-fill { position: absolute; inset: 0 auto 0 0; background: var(--gold); border-radius: 0 4px 4px 0; }
.gb-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.recent { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.3rem; font-size: 0.9rem; }
.recent li { display: grid; grid-template-columns: 1fr auto 11rem; gap: 0.75rem; align-items: center; }
.grade-chip { font: 800 0.8rem var(--mono); background: var(--gold); color: #12102e; border-radius: 999px; padding: 0.05rem 0.5rem; }
.progress-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 1.25rem; }
.progress-actions .spacer { flex: 1; }
button.danger { color: #ffb0a0; border-color: #7a3540; }

/* ----------------------------------------------------------- celebration */
.celebration { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.spark {
  position: absolute;
  font-size: var(--size, 18px);
  color: var(--c, var(--gold));
  text-shadow: 0 0 8px currentColor;
  animation: burst var(--dur, 1.3s) cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
@keyframes burst {
  0% { transform: translate(0, 0) scale(0.3) rotate(0deg); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1) rotate(var(--rot, 180deg)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sky, .logo, .welcome-hero, .score-value.bump, .output .success { animation: none; }
  .celebration { display: none; }
}
