/* OverFit: the paper-and-ink look of giuseppemuschetta.com, in light and dark. */

:root {
  color-scheme: light;
  --bg: #f8efdf; --paper: #fdf7ec; --paper-2: #f1e4cc; --ink: #1f1b16; --ink-2: #4a4237; --muted: #6f6354;
  --rule: #ddcbac; --grid: #ece0c8; --accent: #1f4a8a; --hl: #c2410c; --good: #0f766e;
  --c0: #1f4a8a; --c1: #c2410c; --c2: #0f766e; /* the three classes: blue, orange, green */
  --t0: #2563eb; --t1: #c2410c; --t2: #0d9488; /* the tints of their regions */
  --tint: .18;
  --shadow: 0 1px 0 rgba(80, 60, 20, .05), 0 10px 28px -18px rgba(80, 60, 20, .35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1013; --paper: #15181d; --paper-2: #1c2027; --ink: #efe9dd; --ink-2: #cfc8ba; --muted: #9a9384;
    --rule: #2a2f37; --grid: #22272f; --accent: #8fb0ff; --hl: #ff8a4c; --good: #34d399;
    --c0: #8fb0ff; --c1: #ff8a4c; --c2: #34d399;
    --t0: #8fb0ff; --t1: #ff8a4c; --t2: #34d399;
    --tint: .17;
    --shadow: 0 10px 28px -18px rgba(0, 0, 0, .8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1013; --paper: #15181d; --paper-2: #1c2027; --ink: #efe9dd; --ink-2: #cfc8ba; --muted: #9a9384;
  --rule: #2a2f37; --grid: #22272f; --accent: #8fb0ff; --hl: #ff8a4c; --good: #34d399;
  --c0: #8fb0ff; --c1: #ff8a4c; --c2: #34d399;
  --t0: #8fb0ff; --t1: #ff8a4c; --t2: #34d399;
  --tint: .17;
  --shadow: 0 10px 28px -18px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.55 Inter, system-ui, sans-serif; }
h1, h2, h3, p, dl, dd, ol { margin: 0; }
[hidden] { display: none !important; }
p, h2, h3, li, .lesson, .verdict, footer span { text-wrap: pretty; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 28px; }

.label { font: 500 .76rem "JetBrains Mono", ui-monospace, monospace; color: var(--muted); letter-spacing: .01em; }
kbd {
  font: 500 .68rem "JetBrains Mono", ui-monospace, monospace; padding: 1px 5px; margin-left: 4px;
  border: 1px solid var(--rule); border-radius: 6px; background: var(--paper-2); color: var(--ink-2);
}
.only-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  kbd, .only-mouse { display: none !important; }
  .only-touch { display: inline; }
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; min-height: 40px;
  border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  font: 500 .92rem Inter, system-ui, sans-serif; cursor: pointer; transition: transform .15s, border-color .15s, background .15s;
}
.btn:hover:not(:disabled) { border-color: var(--ink); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn.primary kbd { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
.btn:focus-visible, .chip:focus-visible, .tile:focus-visible, .icon-btn:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper);
  color: var(--ink-2); font: 500 .82rem Inter, system-ui, sans-serif; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"], .btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip:disabled { opacity: .4; cursor: default; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--rule); background: var(--paper);
  color: var(--ink); font-size: 1.05rem; cursor: pointer; flex: none;
}
.link-btn { border: 0; background: none; padding: 4px 0; color: var(--accent); font: 600 .9rem Inter, system-ui, sans-serif; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* the bar at the top, as on the website */
header.nav { position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
header.nav .wrap { display: flex; align-items: center; gap: 24px; height: 64px; }
.mark { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.mark i { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font: italic 600 1rem Fraunces, Georgia, serif; }
nav.links { display: flex; gap: 4px; margin-left: auto; }
nav.links a { font-size: .9rem; color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 999px; white-space: nowrap; }
nav.links a:hover { background: var(--paper-2); color: var(--ink); }
nav.links .l-short { display: none; }

/* title: centered over the board, exactly as wide as the board */
.brand-block { grid-area: brand; align-self: end; text-align: center; }
.brand h1 { font: 700 2.6rem/1 Fraunces, Georgia, serif; letter-spacing: -.03em; }
.brand h1 em { color: var(--accent); font-style: italic; }
.brand .slogan { margin-top: 6px; font: italic 400 1.2rem/1.3 Fraunces, Georgia, serif; color: var(--muted); }
.intro { margin-top: 10px; color: var(--ink-2); font-size: .97rem; line-height: 1.55; text-wrap: balance; }
.intro b { display: block; color: var(--ink); font-weight: 600; }
.intro a.thesis { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.intro a.thesis:hover { text-decoration-thickness: 2px; }
.head { grid-area: head; align-self: end; display: flex; flex-direction: column; gap: 16px; }
.toggles { display: flex; justify-content: flex-end; gap: 8px; }

/* the game */
.stage {
  max-width: 1160px; margin: 0 auto; padding: 14px 28px 0; display: grid; justify-content: center; align-items: start;
  grid-template-columns: 560px 372px; grid-template-rows: auto 1fr; grid-template-areas: "brand head" "board side"; column-gap: 28px; row-gap: 14px;
}
.stage { scroll-margin-top: 76px; }
.board-col { grid-area: board; }
.side { grid-area: side; }
/* the level's number and name on a line of their own, so a long name never wraps beside the buttons */
.level-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label label" "title nav"; align-items: end; column-gap: 12px; }
.level-bar > div:first-child { display: contents; }
.level-bar #level-no { grid-area: label; }
.level-bar h2 { grid-area: title; font: 600 1.55rem/1.15 Fraunces, Georgia, serif; letter-spacing: -.01em; text-wrap: balance; }
.level-nav { grid-area: nav; display: flex; gap: 6px; }
.level-nav .icon-btn { width: 36px; height: 36px; font-size: .95rem; }
.goal { margin-top: 8px; color: var(--ink-2); min-height: 1.55em; }
.goal b { color: var(--ink); }
.field-wrap { position: relative; width: fit-content; max-width: 100%; }
#field {
  display: block; border-radius: 14px; background: var(--paper); box-shadow: 0 0 0 1px var(--rule), var(--shadow);
  touch-action: none; cursor: crosshair; outline: none; -webkit-tap-highlight-color: transparent;
}
#field.on-cut { cursor: pointer; }
#field:focus-visible { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.tip.touch { transform: translate(-50%, 6px); } /* at the top of the board, never under the page header */
.tip {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(-50%, calc(-100% - 12px));
  padding: 5px 10px; border-radius: 10px; background: var(--ink); color: var(--bg); white-space: nowrap;
  font: 500 .8rem "JetBrains Mono", ui-monospace, monospace; box-shadow: 0 6px 18px -8px rgba(0, 0, 0, .5);
}
.tip.below { transform: translate(-50%, 14px); }
.tip .arrow { opacity: .7; padding: 0 2px; }
.tip.bad { background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--rule); }
.howto { margin-top: 12px; font-size: .95rem; line-height: 1.6; color: var(--ink-2); }
.mini, .board-note { display: none; }
.howto kbd {
  display: inline-block; min-width: 1.7em; margin: 0 2px; padding: 1px 6px; text-align: center; vertical-align: 1px;
  font: 700 .82rem/1.35 "JetBrains Mono", ui-monospace, monospace; color: var(--ink);
  background: var(--paper); border: 1px solid var(--ink-2); border-radius: 6px; box-shadow: 0 2px 0 var(--ink-2);
}

.callout {
  margin-top: 10px; padding: 11px 13px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font: 500 .86rem/1.45 Inter, system-ui, sans-serif; animation: pop .25s ease-out;
}
.callout b { font: italic 600 .98rem Fraunces, Georgia, serif; }

.side { display: flex; flex-direction: column; gap: 14px; }
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.score-row { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 22px; }
.stat .label { display: block; }
.stat b { display: block; font: 600 2.1rem/1.05 "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat b .to { color: var(--muted); font-weight: 400; font-size: .8em; padding: 0 .12em; }
.stat b .better { color: var(--good); }
.stat b .worse { color: var(--hl); }
.stars { font-size: 1.65rem; letter-spacing: .1em; color: var(--hl); line-height: 1.2; white-space: nowrap; }
.stars .off { color: var(--rule); }
.equation { margin-top: 8px; font: 500 .85rem "JetBrains Mono", ui-monospace, monospace; color: var(--ink-2); }
.explain { margin-top: 6px; font-size: .82rem; color: var(--muted); }
.axis-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
.axis-row .label { margin-right: 4px; }
.axis-row .chip { flex: 1 0 auto; padding: 6px 8px; }
.axis-row kbd { margin-left: 5px; }
.axis-row .chip[aria-pressed="true"] kbd { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.actions .btn { padding: 8px 6px; font-size: .86rem; min-height: 38px; }
.note { margin-top: 8px; font-size: .86rem; color: var(--ink-2); }
.note:empty { display: none; }
.note.warn { color: var(--hl); }
.cut-tools { margin-top: 10px; }

.solved-block { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--rule); animation: pop .3s ease-out; }
.solved-head { display: flex; align-items: center; gap: 14px; }
.solved-block .stars { font-size: 1.5rem; }
.stamp {
  display: inline-grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; flex: none;
  border: 3px solid var(--hl); color: var(--hl); font: italic 700 1.35rem Fraunces, Georgia, serif; transform: rotate(-12deg);
  animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1);
}
.verdict { font: 600 1.15rem/1.3 Fraunces, Georgia, serif; }
.lesson { margin-top: 10px; color: var(--ink-2); font-size: .93rem; }
.solved-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.solved-actions #go-next { grid-column: 1 / -1; }
.lab-result > .solved-actions .btn { padding: 8px 6px; font-size: .86rem; white-space: nowrap; }
.lab-result > .solved-actions #relab-btn { grid-column: 1 / -1; }
.lab-result { scroll-margin-top: 72px; }
.board-col .lab-result { margin-top: 12px; }

.tree-card h3 { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; }
.board-col .tree-card, .board-col .lab-chart { margin-top: 16px; }
.tree-card h3 #tree-meta { white-space: nowrap; }
.tree-scroll { margin-top: 10px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tree-svg { display: block; margin: 0 auto; overflow: visible; }
.tree-svg text { font-family: "JetBrains Mono", ui-monospace, monospace; }
.tree-svg .node rect { fill: var(--paper); stroke: var(--rule); stroke-width: 1.2; }
.tree-svg .node text { fill: var(--ink); font-size: 11.5px; font-weight: 600; }
.tree-svg .leaf rect { stroke-width: 1.2; }
.tree-svg .leaf.c0 rect { fill: color-mix(in srgb, var(--c0) 16%, var(--paper)); stroke: var(--c0); }
.tree-svg .leaf.c1 rect { fill: color-mix(in srgb, var(--c1) 16%, var(--paper)); stroke: var(--c1); }
.tree-svg .leaf.c2 rect { fill: color-mix(in srgb, var(--c2) 16%, var(--paper)); stroke: var(--c2); }
.tree-svg .leaf.c0 .shape { fill: var(--c0); }
.tree-svg .leaf.c1 .shape { fill: var(--c1); }
.tree-svg .leaf.c2 .shape { fill: var(--c2); }
.tree-svg .leaf.on rect { stroke: var(--accent); stroke-width: 2.2; }
.tree-svg .leaf text { fill: var(--ink-2); font-size: 10.5px; }
.tree-svg .leaf .wrong { fill: var(--hl); font-weight: 600; }
.tree-svg .edge { stroke: var(--rule); stroke-width: 1.6; fill: none; }
.tree-svg .edge-label { fill: var(--muted); font: italic 500 10.5px Inter, system-ui, sans-serif; }
.tree-svg .on rect { stroke: var(--accent); stroke-width: 2.2; }
.tree-svg .edge.on { stroke: var(--accent); stroke-width: 2.4; }
.tree-svg .dim { opacity: .38; }
.tree-svg .hit { cursor: pointer; }
.tree-svg .grow { animation: grow .22s ease-out; transform-box: fill-box; transform-origin: center top; }
.tree-note { margin-top: 10px; min-height: 2.9em; font-size: .84rem; color: var(--ink-2); }
.tree-note .path { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .8rem; color: var(--ink); }
.tree-note .ok { color: var(--good); font-weight: 600; }
.tree-note .no { color: var(--hl); font-weight: 600; }

/* the sections under the game */
.section { max-width: calc(var(--game-w, 1104px) + 56px); margin: 34px auto 0; padding: 0 28px; scroll-margin-top: 80px; }
.section::before { content: ""; display: block; border-top: 1px solid var(--rule); margin-bottom: 24px; }
.section > h2 { display: flex; align-items: baseline; gap: 12px; }
.section-title { font: 700 2.1rem/1.15 Fraunces, Georgia, serif; letter-spacing: -.02em; color: var(--ink); text-wrap: balance; }
.section-title + .section-lead { margin-top: 10px; }
.section-lead { margin-top: 6px; color: var(--ink-2); max-width: 720px; font-size: .95rem; }
.tiles.level-list { margin-top: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tile {
  width: 100%; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: 12px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink);
  font: inherit; cursor: pointer; transition: transform .15s, border-color .15s;
}
.tile:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--ink); }
.tile:disabled { cursor: default; opacity: .45; }
.tile.current { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tile canvas { width: 44px; height: 44px; border-radius: 7px; background: var(--paper-2); display: block; }
.tile b { display: block; font: 600 .95rem/1.2 Fraunces, Georgia, serif; }
.tile .label { display: block; white-space: nowrap; }
.tile .tile-stars { color: var(--hl); letter-spacing: .08em; font-size: .9rem; white-space: nowrap; }
.tile .tile-stars .off { color: var(--rule); }
.forget-board { margin-top: 8px; font-size: .82rem; }
.levels-foot { margin-top: 14px; display: flex; gap: 18px; flex-wrap: wrap; align-items: baseline; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px 28px; margin-top: 16px; }
.card h3, .built h3 { font: 600 1.05rem/1.25 Fraunces, Georgia, serif; letter-spacing: -.01em; }
.card p, .built p { margin-top: 6px; font-size: .9rem; line-height: 1.6; color: var(--ink-2); }
.built-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px 28px; margin-top: 16px; }
.cite { font-size: .8rem; color: var(--muted); margin-top: 18px; max-width: 900px; }

footer.wrap { position: relative; max-width: calc(var(--game-w, 1104px) + 56px); margin-top: 40px; padding-top: 22px; padding-bottom: 30px; display: flex; justify-content: space-between; gap: 16px; font-size: .85rem; color: var(--muted); }
footer.wrap::before { content: ""; position: absolute; top: 0; left: 28px; right: 28px; border-top: 1px solid var(--rule); }
footer.wrap a { color: var(--accent); text-decoration: none; white-space: nowrap; font-weight: 600; }
footer.wrap a:hover { text-decoration: underline; }

@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes stamp { from { opacity: 0; transform: rotate(-12deg) scale(2.2); } to { opacity: 1; transform: rotate(-12deg) scale(1); } }
@keyframes grow { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 1100px) {
  .built-grid { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "brand" "head" "board" "side"; justify-content: stretch; row-gap: 14px; }
  .brand-block { max-width: 560px; justify-self: center; }
  .toggles { justify-content: center; }
  .field-wrap { margin: 0 auto; }
  .howto { text-align: center; }
  .mini {
    display: flex; align-items: center; gap: 14px; margin: 10px auto 0; max-width: 100%; width: fit-content;
    font: 500 .85rem "JetBrains Mono", ui-monospace, monospace; color: var(--muted);
  }
  .mini b { color: var(--ink); font-size: 1.05rem; }
  .mini b .to { color: var(--muted); font-weight: 400; padding: 0 .1em; }
  .mini b .better { color: var(--good); }
  .mini b .worse { color: var(--hl); }
  .mini .chip { padding: 6px 11px; min-height: 40px; }
  .board-note:not([hidden]) { display: block; margin: 8px auto 0; max-width: 520px; text-align: center; font-size: .86rem; color: var(--ink-2); }
  .board-note .path { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .8rem; color: var(--ink); }
  .board-note .ok { color: var(--good); font-weight: 600; }
  .board-note .no { color: var(--hl); font-weight: 600; }
}
@media (max-width: 720px) {
  .wrap, .stage, .section { padding-left: 16px; padding-right: 16px; }
  header.nav .wrap { gap: 8px; height: 56px; }
  .mark span { font-size: .95rem; }
  nav.links a { padding: 8px 8px; font-size: .86rem; }
  nav.links a.hide-s, nav.links .l-long { display: none; }
  nav.links .l-short { display: inline; }
  .intro { font-size: .93rem; margin-top: 6px; }
  .stage { padding-top: 10px; row-gap: 12px; scroll-margin-top: 62px; }
  .brand h1 { font-size: 1.7rem; }
  .brand .slogan { display: none; }
  .level-nav .icon-btn, .icon-btn { width: 40px; height: 40px; }
  .chip, .actions .btn { min-height: 40px; }
  .link-btn { padding: 10px 0; }
  footer.wrap::before { left: 16px; right: 16px; }
  .level-bar h2 { font-size: 1.3rem; }
  .section-title { font-size: 1.65rem; }
  .goal { margin-top: 4px; font-size: .95rem; }
  .howto { margin-top: 8px; font-size: .82rem; }
  .stat b { font-size: 1.75rem; }
  .cards, .built-grid { grid-template-columns: 1fr; }
  footer.wrap { flex-direction: column; }
}
@media (max-width: 420px) {
  header.nav .wrap { gap: 6px; }
  nav.links a { padding: 8px 6px; }
  .mark span { font-size: .9rem; }
}
@media (max-width: 380px) {
  .mark span { display: none; }
  .actions .btn { font-size: .8rem; padding: 8px 2px; }
  .score-row { gap: 14px; }
}

/* the lab: training points against new data */
.stat b.unknown { color: var(--muted); }
.tests-line { margin-top: 8px; font-size: .84rem; color: var(--muted); }
.lab-actions { display: grid; grid-template-columns: 1.55fr 1fr; gap: 8px; margin-top: 10px; }
.lab-actions .btn { min-height: 44px; }
.lab-actions .primary { font-size: 1rem; }
.lab-result .verdict { margin-top: 10px; }
.lab-chart h3 { margin-bottom: 8px; }
.curve-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--ink-2); margin-bottom: 6px; }
.curve-legend span::before { content: ""; display: inline-block; width: 16px; height: 0; margin-right: 6px; vertical-align: 3px; border-top: 2.5px solid var(--ink-2); }
.curve-legend .k-test::before { border-top-color: var(--accent); }
.curve-legend .k-best::before { border-top: 2px dashed var(--muted); }
.curve-legend .k-dot::before { width: 9px; height: 9px; border: 0; border-radius: 50%; background: var(--hl); vertical-align: 0; }
.curve-svg { display: block; max-width: 100%; height: auto; }
.curve-svg .grid { stroke: var(--grid); stroke-width: 1; }
.curve-svg .tick, .curve-svg .axis { fill: var(--muted); font: 500 10px "JetBrains Mono", ui-monospace, monospace; }
.curve-svg .best { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.curve-svg .best-label { fill: var(--muted); font: italic 500 10.5px Inter, system-ui, sans-serif; }
.curve-svg .train { fill: none; stroke: var(--ink-2); stroke-width: 2.5; stroke-linejoin: round; }
.curve-svg .test { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.curve-svg .gap { stroke: var(--hl); stroke-width: 1.5; stroke-dasharray: 2 3; }
.curve-svg .dot-train, .curve-svg .dot-test { fill: var(--hl); stroke: var(--paper); stroke-width: 1.5; }
.curve-svg .mark { stroke: var(--rule); stroke-width: 1.5; }
.curve-svg .mark-train { fill: none; stroke: var(--ink-2); stroke-width: 2.5; }
.curve-svg .mark-test { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.grow-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 10px; font-size: .86rem; color: var(--ink-2); }
.grow-row input { width: 100%; accent-color: var(--accent); }
.grow-row b { font: 600 .85rem "JetBrains Mono", ui-monospace, monospace; color: var(--ink); min-width: 4.5ch; text-align: right; }
.icon-btn:disabled { opacity: .35; cursor: default; }
body.tested #explain { display: none; }
.lab-chart .leak { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--hl); background: var(--paper-2); border-radius: 0 8px 8px 0; min-height: 0; }
.lab-key { margin-top: 8px; font-size: .84rem; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.lab-key .item { white-space: nowrap; }
.lab-key b { font-weight: 700; color: var(--ink); margin-right: 4px; }
.lab-key .k-old { opacity: .45; }
@media (max-width: 900px) { .lab-key { justify-content: center; } }
@media (max-width: 900px) {
  body:not(.tested) .board-col .grow-row { display: none; }
  .board-col .lab-actions, .board-col .grow-row { margin: 10px auto 0; max-width: 560px; }
  .grow-row { grid-template-columns: 1fr auto; row-gap: 6px; }
  .grow-row > span { grid-column: 1 / -1; }
  .grow-row input { height: 32px; }
}
@media (max-width: 380px) {
  .lab-actions, .solved-actions, .lab-result > .solved-actions { grid-template-columns: 1fr; }
  .score .score-row .label { white-space: nowrap; }
}
.perfect-callout {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--bg);
  font-size: .9rem; line-height: 1.5; animation: pop .25s ease-out;
}
.perfect-callout b { display: block; margin-bottom: 4px; font: italic 600 1.05rem Fraunces, Georgia, serif; }
.perfect-callout .num { font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700; }

/* the small boards of the "How a decision tree works" cards */
.cards > .card { min-width: 0; } /* a wide tree diagram scrolls inside its card, never widens the page */
.card .demo { margin-top: 12px; padding: 12px 10px 10px; border: 1px solid var(--rule); border-radius: 12px; background: var(--paper); }
.demo-stage { display: flex; justify-content: center; }
.demo-board { display: block; touch-action: manipulation; cursor: crosshair; }
.demo-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; }
.demo-controls .btn { padding: 6px 12px; font-size: .84rem; }
.demo-range { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; width: 100%; font-size: .84rem; color: var(--ink-2); }
.demo-range input { width: 100%; accent-color: var(--accent); }
.demo-range b { font: 600 .8rem "JetBrains Mono", ui-monospace, monospace; color: var(--ink); min-width: 4ch; text-align: right; }
.demo-readout { margin-top: 8px; min-height: 3em; font-size: .84rem; line-height: 1.5; color: var(--ink-2); text-align: center; }
.demo-readout b, .demo-readout .num { color: var(--ink); font-weight: 600; }
.demo-readout .num { font-family: "JetBrains Mono", ui-monospace, monospace; }
.demo-tree { margin-top: 8px; overflow-x: auto; }
.demo-tree svg { display: block; margin: 0 auto; }
.demo-chart { margin-top: 8px; }
.demo-chart svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.greedy-score { margin-top: 8px; text-align: center; }
.greedy-score .better { color: var(--good); }
.greedy-score .worse { color: var(--hl); }
.greedy-rank { margin-top: 10px; }
.greedy-rank-title { text-align: center; margin-bottom: 6px; }
.greedy-rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 5px 8px; border: 1px solid transparent; border-radius: 8px; background: none; font: inherit; font-size: .8rem; color: var(--ink-2); text-align: left; cursor: pointer; }
.rank-row:hover, .rank-row.on { border-color: var(--rule); background: var(--paper-2); }
.rank-row.best { color: var(--ink); font-weight: 600; }
.rank-q, .rank-row .num { font-family: "JetBrains Mono", ui-monospace, monospace; white-space: nowrap; }
.rank-row svg { display: block; width: 100%; height: 8px; }
.rank-row .track { fill: var(--paper-2); }
.rank-row .bar { fill: var(--muted); }
.rank-row.best .bar { fill: var(--accent); }
.demo .stopping-note { margin-top: 8px; text-align: center; font-size: .8rem; color: var(--muted); }
/* the last card, alone in its row, takes the whole row: when it is wide enough, its board and controls
   sit on the left and its tree diagram, at full size, on the right */
.cards > .card.wide { grid-column: 1 / -1; container-type: inline-size; }
@container (min-width: 840px) {
  .card.wide .demo { display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: auto auto auto 1fr; grid-template-areas: "stage tree" "controls tree" "readout tree" "note tree"; column-gap: 28px; align-items: start; }
  .card.wide .demo-stage { grid-area: stage; }
  .card.wide .demo-controls { grid-area: controls; }
  .card.wide .demo-readout { grid-area: readout; }
  .card.wide .demo-tree { grid-area: tree; align-self: center; margin-top: 0; }
  .card.wide .stopping-note { grid-area: note; }
}
