/* Tokens follow hjalli.com (warm paper / warm dark) plus the post's own signal colours. */
.ttt {
  --font-heading: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --bg: #FAF9F6; --bg2: #F0EFEC; --card: #FFFFFF;
  --text: #1A1A1A; --text2: #5C5C5C; --text3: #8A8A8A;
  --line: #E2E0DC; --accent: #B45A2B;
  --pos: #23955A; --neg: #E0592A; --orange: #E0772E; --purple: #5B2A86;
  --x: #2B2B33; --o: #5B2A86; --grid: #D9D5CF;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ttt {
    --bg: #161618; --bg2: #26262C; --card: #1E1E22;
    --text: #E8E6E1; --text2: #A3A09A; --text3: #6E6B66;
    --line: #2E2E34; --accent: #D4845A;
    --pos: #4CC07F; --neg: #F27547; --orange: #F08A3E; --purple: #B48AE6;
    --x: #E8E6E1; --o: #B48AE6; --grid: #3A3A42;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.35);
  }
}
[data-theme="dark"] .ttt {
  --bg: #161618; --bg2: #26262C; --card: #1E1E22;
  --text: #E8E6E1; --text2: #A3A09A; --text3: #6E6B66;
  --line: #2E2E34; --accent: #D4845A;
  --pos: #4CC07F; --neg: #F27547; --orange: #F08A3E; --purple: #B48AE6;
  --x: #E8E6E1; --o: #B48AE6; --grid: #3A3A42;
}

.ttt *, .ttt *::before, .ttt *::after { box-sizing: border-box; margin: 0; padding: 0; }
.ttt { -webkit-font-smoothing: antialiased; touch-action: manipulation; }
.ttt { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 1.0625rem; line-height: 1.65; }
.ttt-main { padding: 0 16px 6rem; }
.ttt .intro, .ttt .prose, .ttt .foot { max-width: 42rem; margin: 0 auto; }
.ttt .intro { padding: 4.5rem 0 1.5rem; }
.ttt .kicker { font-size: .8125rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: .75rem; }
.ttt h1 { font-family: var(--font-heading); font-weight: 600; font-size: clamp(2.1rem, 6vw, 3.25rem); line-height: 1.1; letter-spacing: -.01em; }
.ttt .dek { font-size: 1.25rem; line-height: 1.5; color: var(--text2); margin-top: 1rem; }
.ttt .prose p, .ttt .prose ul { margin: 0 0 1.1rem; }
.ttt .prose h2 { font-family: var(--font-heading); font-weight: 600; font-size: 1.6rem; line-height: 1.2; margin: 3rem 0 .9rem; }
.ttt .prose h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: .4rem; }
.ttt .prose em { font-style: normal; font-weight: 500; }
.ttt .lesson { border-left: 3px solid var(--orange); padding: .2rem 0 .2rem 1.1rem; margin: 1.5rem 0; }
.ttt .lesson p { margin-bottom: .7rem; }
.ttt .numbers { list-style: none; }
.ttt .numbers li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.ttt .numbers strong { font-family: var(--font-heading); font-size: 1.35rem; font-weight: 600; margin-right: .4rem; }
.ttt .foot { color: var(--text3); font-size: .875rem; padding-top: 2rem; }

/* ---------- controls ---------- */
.ttt button, .ttt select { font: inherit; color: inherit; }
.ttt button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: .45rem .95rem; font-size: .875rem; font-weight: 500; transition: background .15s, border-color .15s, filter .15s; }
.ttt button:hover { border-color: var(--text3); }
.ttt button.primary { background: var(--purple); border-color: var(--purple); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ttt button.primary { color: #161618; } }
[data-theme="dark"] .ttt button.primary { color: #161618; }
.ttt button.primary:hover { filter: brightness(1.08); }
.ttt button.primary.running { background: transparent; color: var(--purple); }
.ttt button.ghost { background: transparent; }
.ttt button.small { padding: .3rem .8rem; font-size: .8125rem; }
.ttt button.try { background: transparent; border-color: var(--orange); color: var(--orange); font-weight: 600; }
.ttt .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--card); }
.ttt .seg button { border: 0; background: transparent; padding: .3rem .8rem; color: var(--text2); }
.ttt .seg button.on { background: var(--bg2); color: var(--text); font-weight: 600; }
.ttt .seg.small button { padding: .28rem .65rem; font-size: .8125rem; }
.ttt .toggle { font-size: .875rem; display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; color: var(--text2); }
.ttt .toggle input { accent-color: var(--purple); width: 15px; height: 15px; }

/* ---------- widget frames ---------- */
.ttt .widget { max-width: 42rem; margin: 1.75rem auto 2.25rem; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; }
.ttt .widget.narrow { max-width: 25rem; }
.ttt .widget.wide { max-width: 56rem; }
.ttt .lab-host { max-width: 64rem; scroll-margin-top: 16px; }
@media (max-width: 560px) { .ttt .widget { padding: 14px; border-radius: 14px; } }
@media (max-width: 560px) { .ttt .cx .cx-m.perfect::after { top: auto; bottom: 21px; right: 7px; } } /* beside the rating, clear of the little board */
.ttt .vx-note { display: block; min-height: 2.8em; }
.ttt .track i.on { outline: 2px solid var(--text); outline-offset: -1px; z-index: 1; }

/* ---------- board ---------- */
.ttt .bw-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ttt .tally { display: flex; gap: 12px; font-size: .75rem; color: var(--text3); }
.ttt .tally b { font-family: var(--font-heading); font-size: 1rem; color: var(--text); font-weight: 600; margin-right: 2px; font-variant-numeric: tabular-nums; }
.ttt .bw-board { position: relative; width: 100%; max-width: 300px; aspect-ratio: 1; margin: 18px auto 8px; }
.ttt .bw-board .grid { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
/* grid lines drawn as rounded bars, not cell borders */
.ttt .bw-board .grid::before, .ttt .bw-board .grid::after { content: ''; position: absolute; pointer-events: none; }
.ttt .bw-board .grid::before { left: 33.333%; right: 33.333%; top: 2%; bottom: 2%; border-left: 3px solid var(--grid); border-right: 3px solid var(--grid); margin: 0 -1.5px; border-radius: 2px; }
.ttt .bw-board .grid::after { top: 33.333%; bottom: 33.333%; left: 2%; right: 2%; border-top: 3px solid var(--grid); border-bottom: 3px solid var(--grid); margin: -1.5px 0; border-radius: 2px; }
.ttt .cell { position: relative; border: 0; border-radius: 12px; background: transparent; padding: 0; display: block; transition: background .15s; }
.ttt .cell:hover { border-color: transparent; }
.ttt .cell.playable { cursor: pointer; }
.ttt .cell.playable:hover { background: color-mix(in srgb, var(--bg2) 70%, transparent); }
.ttt .cell .heat, .ttt .cell .piece, .ttt .cell .val { position: absolute; inset: 0; pointer-events: none; }
.ttt .cell .heat { inset: 6%; border-radius: 50%; transition: background .3s; }
.ttt .cell .val { top: auto; bottom: 9%; text-align: center; font-family: var(--font-mono); font-size: .75rem; color: var(--text2); }
.ttt .cell.best .heat { box-shadow: inset 0 0 0 2px var(--purple); }
.ttt .cell.best .val { color: var(--text); font-weight: 600; }
.ttt .cell.dim .piece { opacity: .28; transition: opacity .4s .3s; }
.ttt .cell.last .piece::after { content: ''; position: absolute; left: 50%; bottom: 8%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--text3); }
.ttt .pc { width: 100%; height: 100%; display: block; fill: none; stroke-linecap: round; stroke-width: 9; }
.ttt .pc.x { stroke: var(--x); } .ttt .pc.o { stroke: var(--o); }
.ttt .pc.new path { animation: draw .18s ease-out backwards; }
.ttt .pc.new path.d2 { animation-delay: .14s; }
.ttt .pc.new circle { animation: draw .32s ease-out backwards; }
.ttt .pc.ghost { opacity: .18; }
@keyframes draw { from { stroke-dasharray: 0 1; } to { stroke-dasharray: 1 0; } }
.ttt .winline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ttt .winline line { stroke: var(--orange); stroke-width: 10; stroke-linecap: round; opacity: 0; }
.ttt .winline.show line { opacity: .9; animation: draw .45s .25s ease-out backwards; }
.ttt .winline.done line { animation: none; }
@media (prefers-reduced-motion: reduce) { .ttt .pc.new path, .ttt .pc.new circle, .ttt .winline.show line { animation: none; } }
.ttt .bw-status { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 2.2rem; }
.ttt .bw-status .msg { font-weight: 500; }
.ttt .bw .toggle { display: flex; justify-content: center; margin-top: 6px; }

/* ---------- inputs ---------- */
.ttt .iw { display: grid; grid-template-columns: auto auto 1fr; gap: 14px 18px; align-items: center; }
.ttt .iw-board { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 170px; text-align: center; } /* fixed, so a new caption never shifts the row */
.ttt .iw-board .grid { width: 150px; height: 150px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.ttt .iw-board .cell { background: var(--bg2); border-radius: 8px; cursor: pointer; }
.ttt .iw-board .cell:hover { background: color-mix(in srgb, var(--bg2) 60%, var(--line)); }
.ttt .iw-board .piece { position: absolute; inset: 0; }
.ttt .iw small, .ttt .iw-strip small { color: var(--text3); font-size: .75rem; }
.ttt .iw-arrow { color: var(--text3); font-size: 1.4rem; }
.ttt .iw-planes { display: flex; gap: 18px; flex-wrap: wrap; }
.ttt .plane { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ttt .pgrid { display: grid; grid-template-columns: repeat(3, 30px); grid-auto-rows: 30px; gap: 3px; font-family: var(--font-mono); font-size: .85rem; }
.ttt .pgrid span, .ttt .strip span { display: flex; align-items: center; justify-content: center; background: var(--bg2); border-radius: 5px; color: var(--text3); }
.ttt .pgrid span.one, .ttt .strip span.one { background: var(--purple); color: #fff; font-weight: 600; }
.ttt .iw-strip { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; }
.ttt .strip { display: grid; grid-template-columns: repeat(18, 1fr); gap: 3px; font-family: var(--font-mono); font-size: .75rem; }
.ttt .strip span { height: 26px; }
.ttt .strip span.gap { margin-left: 6px; }
@media (max-width: 560px) {
  .ttt .iw { grid-template-columns: 1fr; justify-items: center; }
  .ttt .iw-arrow { transform: rotate(90deg); }
  .ttt .strip span { height: 22px; font-size: .65rem; }
}

/* ---------- network ---------- */
.ttt .nw-cap { font-size: .8125rem; color: var(--text2); line-height: 1.3; min-height: 1.3em; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* one line, always */
@media (max-width: 560px) { .ttt .nw-cap { white-space: normal; min-height: 2.6em; } } /* two lines, always, on a phone */
.ttt .nw-wrap { position: relative; }
.ttt .nw canvas { width: 100%; display: block; }
.ttt .legend { font-size: .75rem; color: var(--text3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.ttt .legend-note { margin-left: auto; }
.ttt .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.ttt .sw.pos { background: var(--pos); } .ttt .sw.neg { background: var(--neg); }

/* ---------- tooltips ---------- */
.ttt .tip { position: absolute; z-index: 5; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.14); padding: 9px 11px; font-size: .8125rem; line-height: 1.45; max-width: 280px; color: var(--text); }
.ttt .tip .muted, .ttt .muted { color: var(--text3); }
.ttt .tipglyph { display: block; width: 250px; height: 94px; margin: 8px 0 2px; }
.ttt .tipsub { display: grid; grid-template-columns: 130px 120px; font-size: .7rem; color: var(--text3); margin-bottom: 6px; }

/* ---------- training ---------- */
.ttt .tw-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ttt .counter { display: flex; flex-direction: column; line-height: 1.1; min-width: 7rem; }
.ttt .counter .g { font-family: var(--font-heading); font-size: 2rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.ttt .counter small, .ttt .latest small { color: var(--text3); font-size: .75rem; }
.ttt .tw-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; flex: 1; }
.ttt .latest { display: flex; align-items: center; gap: 8px; }
.ttt .mini { display: grid; grid-template-columns: repeat(3, 14px); grid-template-rows: repeat(3, 14px); gap: 2px; }
.ttt .mini div { background: var(--bg2); border-radius: 2px; font-size: 10px; line-height: 14px; text-align: center; font-weight: 700; }
.ttt .mini .x { color: var(--x); } .ttt .mini .o { color: var(--o); } .ttt .mini .rnd { opacity: .4; }
.ttt .verdict { margin-top: 12px; font-size: .9375rem; color: var(--text2); line-height: 1.5; min-height: 3em; } /* two lines, always: the longest verdict fits */
@media (max-width: 560px) { .ttt .verdict { min-height: 6.1em; } } /* three on a phone */
.ttt .verdict strong { color: var(--text); }
@media (max-width: 560px) {
  .ttt .tw-row { gap: 12px; }
  .ttt .counter { flex-direction: row; align-items: baseline; gap: 8px; min-width: 0; }
  .ttt .tw-buttons { flex-basis: 100%; }
  .ttt .tw-buttons .primary { flex-basis: 100%; }
}

/* ---------- settings ---------- */
.ttt .sw-settings { margin-top: 14px; font-size: .875rem; }
.ttt .sw-settings summary { cursor: pointer; color: var(--text2); font-weight: 500; }
.ttt .sw-settings .cfg { color: var(--text3); font-weight: 400; margin-left: .3rem; }
.ttt .settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 10px; }
.ttt .sw-settings label { display: flex; flex-direction: column; gap: 4px; color: var(--text2); font-size: .8125rem; }
.ttt .sw-settings select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .5rem; font-size: .8125rem; max-width: 100%; }
.ttt .settings-note { color: var(--text3); font-size: .8125rem; margin-top: 8px; }

/* ---------- charts ---------- */
.ttt .cw { display: grid; grid-template-columns: repeat(var(--n, 1), minmax(0, 1fr)); gap: 18px; }
@media (max-width: 760px) { .ttt .cw { grid-template-columns: 1fr; } }
.ttt .cw figure { min-width: 0; }
.ttt .cw figcaption { font-size: .8125rem; font-weight: 600; }
.ttt .cw figcaption small { display: block; font-weight: 400; color: var(--text3); }
.ttt .cwrap { position: relative; }
.ttt .cw canvas { width: 100%; height: 140px; display: block; margin-top: 6px; cursor: crosshair; }
.ttt .widget[data-charts="lost"] canvas { height: 170px; }

/* ---------- lab ---------- */
.ttt .lab-top { display: grid; grid-template-columns: minmax(250px, 320px) 1fr; gap: 26px; align-items: start; }
@media (max-width: 760px) { .ttt .lab-top { grid-template-columns: 1fr; } }
.ttt .lab-train { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.ttt .lab-train .cw { margin-top: 18px; }

/* ---------- chips + mini boards (the watched position) ---------- */
.ttt .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ttt .chip { padding: .2rem .65rem; font-size: .75rem; color: var(--text2); background: transparent; }
.ttt .chip.on { background: var(--purple); border-color: var(--purple); color: #fff; font-weight: 600; }
.ttt .mb { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; width: 72px; aspect-ratio: 1; }
.ttt .mb > div { background: var(--bg2); border-radius: 4px; position: relative; }
.ttt .mb > div.hi { background: color-mix(in srgb, var(--purple) 22%, var(--bg2)); box-shadow: inset 0 0 0 1.5px var(--purple); }
.ttt .mb.click > div.free { cursor: pointer; }
.ttt .mb.click > div.free:hover { background: color-mix(in srgb, var(--bg2) 60%, var(--line)); }
.ttt .mb .pc { stroke-width: 11; }

/* ---------- explainers ---------- */
.ttt .xh { display: flex; gap: 14px; align-items: flex-start; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.ttt .xh-text { flex: 1; min-width: 0; }
.ttt .xh-what { font-size: .875rem; color: var(--text2); margin-bottom: 8px; }
.ttt .xh-what b { color: var(--text); }
.ttt .xsel { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; font-size: .875rem; margin-bottom: 14px; }
.ttt .xsel .xnum { min-width: 1.6em; text-align: center; font-variant-numeric: tabular-nums; }
.ttt .xsel .xof { margin-right: 4px; }
.ttt .xsel .chip { margin-left: 2px; }
.ttt .xsel canvas.xid { width: 46px; height: 22px; margin: 0 4px; }
.ttt .xsel .dot.xid { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); margin: 0 4px; }
.ttt .xsel .prev, .ttt .xsel .next { padding: .15rem .6rem; font-size: 1rem; line-height: 1.2; }
.ttt .xbtns { display: flex; gap: 6px; margin-left: auto; }
.ttt .pos { color: var(--pos); } .ttt .neg { color: var(--neg); }
.ttt b.pos, .ttt b.neg, .ttt .big { font-weight: 600; }
.ttt .nx { display: grid; grid-template-columns: auto auto auto auto auto auto auto auto; gap: 6px 8px; align-items: center; justify-content: start; font-family: var(--font-mono); font-size: .72rem; }
.ttt .nx > small { font-family: var(--font-body); font-size: .68rem; color: var(--text3); text-align: center; }
.ttt .nx-lab { font-family: var(--font-body); font-size: .8125rem; display: flex; flex-direction: column; line-height: 1.25; padding-right: 4px; }
.ttt .nx-lab small { color: var(--text3); font-size: .7rem; }
.ttt .g3 { display: grid; grid-template-columns: repeat(3, 30px); grid-auto-rows: 24px; gap: 2px; }
.ttt .g3 span { display: flex; align-items: center; justify-content: center; background: var(--bg2); border-radius: 4px; color: var(--text3); }
.ttt .g3.in span.one { background: var(--purple); color: #fff; font-weight: 600; }
.ttt .g3.wt span { color: var(--text); }
.ttt .g3.pr span { background: transparent; border: 1px solid var(--line); }
.ttt .g3.pr span.pos, .ttt .g3.pr span.neg { font-weight: 600; border-color: currentColor; }
.ttt .g3.pr span.off { color: var(--line); }
.ttt .op { color: var(--text3); font-family: var(--font-body); }
.ttt .nx-sum { font-weight: 600; font-size: .8125rem; }
.ttt .xeq { display: flex; align-items: center; justify-content: space-evenly; gap: 28px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); font-size: .875rem; }
.ttt .xsum { font-family: var(--font-mono); font-size: .8125rem; }
.ttt .xsq { display: flex; align-items: center; gap: 18px; }
.ttt .xsq > div, .ttt .xtile { display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.ttt .xsq small, .ttt .xtile small { color: var(--text3); font-size: .7rem; text-align: center; }
.ttt .big { font-family: var(--font-mono); font-size: 1.25rem; margin: 2px 0; }
.ttt .tanh .ax { stroke: var(--line); } .ttt .tanh .cv { fill: none; stroke: var(--text2); stroke-width: 1.5; }
.ttt .tanh .gd { stroke: var(--text3); stroke-dasharray: 2 2; } .ttt .tanh .tl { font: 9px var(--font-body); fill: var(--text3); }
.ttt canvas.tile { width: 56px; height: 27px; display: block; }
.ttt .xtile canvas.tile { width: 92px; height: 45px; margin-bottom: 4px; }
.ttt .xtile .dot { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); margin-bottom: 4px; }
.ttt .l2 { display: grid; grid-template-columns: auto auto auto auto auto auto 1fr; gap: 5px 10px; align-items: center; font-family: var(--font-mono); font-size: .75rem; }
.ttt .l2-h, .ttt .l2-r { display: contents; }
.ttt .l2-scroll { max-height: 300px; overflow-y: auto; padding-right: 4px; }
.ttt .l2-h span { font-family: var(--font-body); font-size: .68rem; color: var(--text3); position: sticky; top: 0; z-index: 1; background: var(--card); padding: 4px 0; align-self: stretch; }
.ttt .l2-n { display: flex; align-items: center; gap: 6px; color: var(--text3); }
.ttt .l2-r.rest .l2-n { font-family: var(--font-body); font-size: .75rem; }
.ttt .bar { position: relative; height: 10px; background: var(--bg2); border-radius: 3px; min-width: 60px; }
.ttt .bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.ttt .bar i.pos, .ttt .track i.pos { background: var(--pos); } .ttt .bar i.neg, .ttt .track i.neg { background: var(--neg); }
.ttt .vx { display: grid; grid-template-columns: 9rem 1fr; gap: 8px 12px; align-items: center; font-size: .8125rem; }
.ttt .vx-r { display: contents; }
.ttt .vx-l { display: flex; justify-content: space-between; gap: 8px; color: var(--text2); }
.ttt .vx-l b { font-family: var(--font-mono); }
.ttt .vx > small { grid-column: 1 / -1; font-size: .75rem; }
.ttt .track { position: relative; height: 18px; background: var(--bg2); border-radius: 4px; }
.ttt .track::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; border-left: 1px solid var(--text3); }
.ttt .track i { position: absolute; top: 2px; bottom: 2px; border-right: 1px solid var(--card); }
.ttt .track i:hover { filter: brightness(1.15); }
.ttt .vx-r.total .track i.res { background: var(--purple); border: 0; border-radius: 3px; }
.ttt .vx-r.total .vx-l { color: var(--text); font-weight: 600; }
.ttt .meter { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.ttt .mt { position: relative; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--neg), var(--bg2) 50%, var(--pos)); }
.ttt .mt i { position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--text); }
.ttt .mt-l { display: flex; justify-content: space-between; font-size: .7rem; color: var(--text3); line-height: 1.2; margin-top: 5px; }
.ttt .mt-l span:nth-child(2) { text-align: center; } .ttt .mt-l span:last-child { text-align: right; }
.ttt .meter p { font-size: .875rem; margin-top: 8px; color: var(--text2); min-height: 3.3em; } /* room for the rules note, so the card never grows */
.ttt .xh-flat { border-bottom: 0; margin-bottom: 4px; padding-bottom: 0; }
.ttt .cx { display: grid; grid-template-columns: repeat(var(--cols, 5), auto); gap: 10px; justify-content: center; } /* two rows; spare room goes to the sides */
.ttt .cx-m { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 8px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); position: relative; }
.ttt .cx-m .mb { width: 64px; }
.ttt .cx-m b { font-family: var(--font-mono); font-size: .875rem; }
.ttt .cx-m small { font-size: .68rem; color: var(--text3); }
.ttt .cx-m.pick { border-color: var(--purple); box-shadow: inset 0 0 0 1px var(--purple); }
.ttt .cx-m.pick small { color: var(--purple); font-weight: 600; }
.ttt .cx-m.sel { outline: 2px dashed var(--text3); outline-offset: 3px; }
.ttt .cell.perfect::after { content: '✓'; position: absolute; top: 6%; right: 10%; font-size: .8rem; font-weight: 700; color: var(--purple); pointer-events: none; }
.ttt .cx-m.perfect::after { content: '✓'; position: absolute; top: 3px; right: 6px; font-size: .75rem; color: var(--purple); font-weight: 700; }
.ttt .cx-note { font-size: .875rem; color: var(--text2); margin-top: 12px; min-height: 4.95em; } /* three lines, the longest verdict */
@media (max-width: 560px) {
  .ttt .xh { flex-direction: row; }
  .ttt .wb { grid-template-columns: repeat(3, 38px); grid-auto-rows: 34px; }
  .ttt .wb-plus { display: none; }
  .ttt .nx { gap: 8px; }
  .ttt .l2 { grid-template-columns: auto auto auto auto auto auto; font-size: .68rem; gap: 5px 6px; }
  .ttt .l2 .bar { display: none; }
  .ttt .l2-h span:last-child { display: none; }
  .ttt canvas.tile { width: 40px; height: 20px; }
  .ttt .vx { grid-template-columns: 1fr; gap: 4px; }
  .ttt .vx-r.total .vx-l, .ttt .vx-l { margin-top: 4px; }
}

/* ---------- the panel: the one board, always on screen ---------- */
/* narrow screens: a bar at the bottom, board on the left */
.ttt .panel { position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: 20; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.16); padding: 8px 12px 8px 8px; font-size: .8125rem; color: var(--text2); }
.ttt.has-panel .ttt-main { padding-bottom: 150px; }
.ttt .panel .bw-board.pn-board { width: 112px; margin: 0; }
.ttt .pn-board .cell { border-radius: 8px; }
.ttt .pn-board .cell .val { font-size: .58rem; bottom: 4%; }
.ttt .pn-board .cell.best .val { left: 50%; right: auto; transform: translateX(-50%); padding: 0 3px; border-radius: 4px; background: var(--card); } /* the ring must not cover the number */
.ttt .pn-board .pc { stroke-width: 10; }
.ttt .pn-board .cell.perfect::after { font-size: .55rem; right: 6%; }
.ttt .pn-side { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ttt .pn-msg { font-weight: 500; color: var(--text); line-height: 1.35; min-height: 2.7em; } /* room for two lines, always */
.ttt .pn-side .pn-new { padding: .3rem .9rem; font-size: .8125rem; }
.ttt .pn-age { font-size: .7rem; color: var(--text3); }
.ttt .ok { color: var(--purple); } .ttt .bad { color: var(--neg); }

/* wide screens: a side panel next to the text */
@media (min-width: 1180px) {
  .ttt.has-panel .ttt-main { padding-right: calc(280px + 40px); padding-bottom: 6rem; }
  .ttt .panel { left: auto; right: 20px; bottom: auto; top: 50%; transform: translateY(-50%); width: 280px;
    display: flex; flex-direction: column; gap: 12px; border-radius: 18px; box-shadow: var(--shadow); padding: 18px; }
  .ttt .panel .bw-board.pn-board { width: 100%; max-width: 240px; margin: 0 auto; }
  .ttt .pn-board .cell { border-radius: 12px; }
  .ttt .pn-board .cell .val { font-size: .7rem; bottom: 9%; }
  .ttt .pn-board .cell.perfect::after { font-size: .7rem; right: 9%; }
  .ttt .pn-side { align-items: center; text-align: center; min-height: 4.6em; }
  .ttt .pn-msg { font-size: .875rem; }
}

/* the lab's board tools */
.ttt .lab-game { margin-bottom: 1.25rem; }
.ttt .lab-game h3 { margin: 0 0 .5rem; }
.ttt .lg { display: flex; flex-direction: column; gap: 10px; }
.ttt .lg-ctl { display: flex; flex-wrap: wrap; gap: 6px; }
.ttt .lg-ctl button:disabled { opacity: .4; cursor: default; }
.ttt .lg-try { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.ttt .lg-try > span { font-weight: 600; color: var(--text); font-size: .875rem; }
.ttt .pn-pick { font-size: .8125rem; min-height: 1.3em; margin: 0; }
.ttt .pn-time canvas { width: 100%; max-width: 560px; height: 110px; display: block; cursor: crosshair; }
.ttt .pn-cap { font-size: .75rem; color: var(--text3); line-height: 1.4; display: block; }
.ttt .pn-cap .pf { color: var(--purple); }

/* the inputs widget mirrors the board */
.ttt .iw-mb .mb { width: 120px; }
/* buttons in the text that act on the board */
.ttt button.show { padding: .15rem .7rem .15rem .55rem; font-size: .8125rem; background: color-mix(in srgb, var(--purple) 10%, var(--card)); border: 1px solid var(--purple); color: var(--purple); font-weight: 600; vertical-align: baseline; border-radius: 999px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.08); transition: background .15s, color .15s; }
.ttt button.show::before { content: '▸'; margin-right: .35em; }
.ttt button.show:hover { background: var(--purple); color: #fff; }
.ttt .w-only { display: none; }
@media (min-width: 1180px) { .ttt .w-only { display: inline; } .ttt .n-only { display: none; } }
.ttt .pn-side .pn-new[hidden] { display: inline-block; visibility: hidden; } /* keeps its space: nothing moves when a game ends */

/* ---------- opening: hero network, chapter strip ---------- */
.ttt .intro { padding: 3rem 0 1rem; }
.ttt .byline { margin-top: 1rem; font-size: .875rem; color: var(--text3); font-weight: 500; }
.ttt .widget.hero { margin-top: .5rem; margin-bottom: 1rem; padding: 14px 18px 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--purple) 6%, var(--card)), var(--card) 55%); }
.ttt .nw-hero .nw-cap { order: 2; margin: 8px auto 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; max-width: 32rem; min-height: 0; }
.ttt .nw-hero .nw-cap span { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.ttt .nw-hero .nw-cap small { font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); font-weight: 600; }
.ttt .nw-hero .nw-cap b { font-family: var(--font-mono); font-weight: 400; font-size: .8125rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ttt .nw-hero .nw-cap b.pos { color: var(--pos); } .ttt .nw-hero .nw-cap b.neg { color: var(--neg); }
.ttt .nw-hero { display: flex; flex-direction: column; }
.ttt .nw-hero .legend { display: none; }
.ttt .prose .lead { font-size: 1.1875rem; line-height: 1.6; }
.ttt .prose h2[id] { scroll-margin-top: 1.5rem; }
.ttt ul.map { list-style: none; padding: 0; }
.ttt ul.map li { padding: .55rem 0 .55rem 1rem; border-left: 3px solid color-mix(in srgb, var(--purple) 35%, transparent); margin: .5rem 0; }
.ttt .draft-note { border: 1.5px dashed var(--accent); border-radius: 10px; padding: .7rem 1rem; color: var(--accent); font-size: .9375rem; }
.ttt .reading li { font-size: .9375rem; margin: .45rem 0; }
@media (max-width: 560px) { .ttt .widget.hero { padding: 10px 10px 8px; } }

/* ---------- outline: the page's sections in the left margin, desktop only ---------- */
.ttt .outline { display: none; }
@media (min-width: 1180px) {
  .ttt.has-panel .ttt-main { padding-left: 210px; }
  .ttt .outline { display: block; position: fixed; left: 24px; top: 50%; transform: translateY(-50%); width: 170px; max-height: calc(100vh - 48px); overflow-y: auto;
    font-size: .8125rem; line-height: 1.3; scrollbar-width: none; }
  .ttt .outline a.ol-part { display: block; border-left: 0; padding-left: 0; color: var(--text3); }
  .ttt .outline .ol-part { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--text3); font-weight: 600; margin: 1rem 0 .35rem; }
  .ttt .outline .ol-part:first-child { margin-top: 0; }
  .ttt .outline a { display: flex; gap: 7px; padding: .28rem 0 .28rem 10px; border-left: 2px solid var(--line); color: var(--text3); text-decoration: none; transition: color .15s, border-color .15s; }
  .ttt .outline a i { font-style: normal; font-variant-numeric: tabular-nums; min-width: .8rem; color: inherit; opacity: .7; }
  .ttt .outline a:hover { color: var(--text); }
  .ttt .outline a.on { color: var(--purple); border-left-color: var(--purple); font-weight: 600; }
  .ttt .outline a.past { color: var(--text2); }
}

/* ---------- Step 3: the neuron's weights as boards, like its tile ---------- */
.ttt .nx { display: flex; align-items: flex-start; justify-content: center; gap: 14px; flex-wrap: wrap; }
.ttt .wbx { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ttt .wb-lab { font-size: .8125rem; } .ttt .wb-lab small { color: var(--text3); font-size: .72rem; }
.ttt .wb { display: grid; grid-template-columns: repeat(3, 46px); grid-auto-rows: 40px; gap: 3px; font-family: var(--font-mono); }
.ttt .wb span { position: relative; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: .72rem; }
.ttt .wb span.dim { opacity: .28; }
.ttt .wb span.lit { box-shadow: inset 0 0 0 2px var(--text); font-weight: 600; }
.ttt .wb span.dim { opacity: .22; }
.ttt .wb .pm { position: absolute; top: 2px; left: 3px; width: 13px; height: 13px; display: block; }
.ttt .wb .pm svg { width: 100%; height: 100%; display: block; }
.ttt .wb-sum { font-size: .75rem; color: var(--text3); } .ttt .wb-sum b { font-family: var(--font-mono); }
.ttt .wb-plus { align-self: center; margin-top: 1.4rem; }
.ttt .nx-note { flex-basis: 100%; text-align: center; font-size: .72rem; color: var(--text3); }
.ttt .xsum { display: flex; align-items: flex-end; gap: 18px; }
.ttt .xsum .term { display: flex; flex-direction: column; align-items: center; line-height: 1.25; min-width: 3.4rem; }
.ttt .xsum .term:has(> small:empty), .ttt .xsum .term.eq { min-width: 0; }
.ttt .xsum .term small { font-family: var(--font-body); font-size: .66rem; color: var(--text3); }
.ttt .xsum .op { padding-bottom: 1px; color: var(--text3); }
.ttt .xhint { color: var(--text3); font-size: .72rem; align-self: center; }

/* ---------- network hover card: a second-layer neuron, visually ---------- */
.ttt .tl2 { display: grid; grid-template-columns: 44px auto 78px auto; gap: 3px 6px; align-items: center; margin: 7px 0 4px; font-family: var(--font-mono); font-size: .72rem; }
.ttt canvas.tipt { width: 44px; height: 21px; display: block; }
.ttt .tbar { position: relative; height: 8px; background: var(--bg2); border-radius: 3px; }
.ttt .tbar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.ttt .tbar i.pos { background: var(--pos); } .ttt .tbar i.neg { background: var(--neg); }
.ttt .tl2-eq { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: .75rem; margin: 2px 0 6px; }
.ttt .tl2-eq svg { display: block; }

/* ---------- links in the text: quiet, purple underline ---------- */
.ttt .prose a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--purple) 55%, transparent); text-decoration-thickness: 1.5px; text-underline-offset: 2px; transition: color .15s, text-decoration-color .15s; }
.ttt .prose a:hover { color: var(--purple); text-decoration-color: var(--purple); }

/* ---------- part labels in the text: the page's three parts ---------- */
.ttt .prose .part { font-size: .8125rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--purple); margin: 4.5rem 0 .75rem; padding-top: 1.25rem; border-top: 1px solid var(--line); scroll-margin-top: 1.5rem; }
.ttt .prose .part:first-child { margin-top: 1rem; }

.ttt h1 .h1-sub { display: block; font-size: .5em; font-weight: 500; line-height: 1.25; color: var(--text2); margin-top: .35em; letter-spacing: 0; }
.ttt .prose .part + h2 { margin-top: .25rem; }
.ttt .prose .signoff { margin-top: 2.25rem; }
.ttt .prose .signoff::before { content: ''; display: block; width: 3rem; margin: 0 auto 2.25rem; border-top: 2px solid var(--purple); }

/* ---------- the outline and the board panel slide up to clear a host footer (set by ClearFooter) ---------- */
.ttt .outline, .ttt .panel { translate: 0 calc(-1 * var(--lift, 0px)); }

/* ---------- "What the neurons learn": three real neurons ---------- */
.ttt .learned .ln-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.ttt .learned .ln { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.ttt .learned .ln svg { max-width: 100%; height: auto; }
.ttt .learned .ln .lt { font: 10px var(--font-body); fill: var(--text3); }
.ttt .learned .ln p { font-size: .8125rem; line-height: 1.35; display: flex; flex-direction: column; gap: 3px; }
.ttt .learned .ln small { color: var(--text3); font-size: .75rem; }
.ttt .learned figcaption { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: .75rem; color: var(--text3); text-align: center; }
@media (max-width: 560px) { .ttt .learned .ln-row { grid-template-columns: 1fr; } }
