/* Longhorn Pathfinder — minimal pixel-art theme */
:root {
  --orange: #bf5700;
  --orange-hi: #ff9a3c;
  --ink: #0e1020;
  --panel: #232a4d;
  --panel-2: #2d3560;
  --panel-hi: #3d4780;
  --text: #f1e3c8;
  --muted: #9aa0c4;
  --unvisited: #8d93a8;
  --identified: #f5c542;
  --visited: #5b8fd6;
  --current: #ff7a1a;
  --good: #7be05a;
  --bad: #ff5050;
  --pixel: "Silkscreen", "Courier New", monospace;
  --body: "VT323", "Courier New", monospace;
  font-family: var(--body);
  font-size: 20px;
}
* { box-sizing: border-box; }
html, body { margin: 0; color: var(--text); min-height: 100vh; image-rendering: pixelated; }
body {
  /* stepped sky — hard color bands, no smooth gradient */
  background:
    linear-gradient(#1a2456 0 18%, #213070 18% 36%, #2a3d8a 36% 54%, #3550a3 54% 100%) fixed;
}
button, select, input { font: inherit; color: inherit; }
code, .mono { font-family: var(--body); }
h1, h2, h3, h4, .pixel { font-family: var(--pixel); font-weight: 400; }

/* the panel look: hard 3px ink border, inner bevel, offset pixel shadow */
.card, .level, .overlay .box, nav.tabs, header .brand .logo {
  background: var(--panel);
  border: 3px solid var(--ink);
  box-shadow: inset 3px 3px 0 var(--panel-hi), inset -3px -3px 0 #1a1f3a, 4px 4px 0 rgba(0,0,0,.35);
}

/* ---------- header ---------- */
header { display: flex; align-items: center; gap: 16px; padding: 14px 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo { width: 52px; height: 52px; display: grid; place-items: center; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: 1px; text-shadow: 3px 3px 0 var(--ink); }
.brand small { color: var(--muted); display: block; font-size: 18px; }
nav.tabs { display: flex; gap: 4px; margin-left: auto; padding: 4px; }
nav.tabs button { background: none; border: 0; padding: 6px 14px; cursor: pointer; color: var(--muted); font-family: var(--pixel); font-size: 13px; }
nav.tabs button.active { background: var(--orange); color: #fff; box-shadow: inset 0 -3px 0 #7a3800; }
nav.tabs button:hover:not(.active) { color: var(--text); background: var(--panel-2); }

main { padding: 6px 24px 30px; max-width: 1500px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
.card { padding: 12px 14px; }
.card + .card { margin-top: 12px; }
.card h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 1px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.side { display: flex; flex-direction: column; gap: 12px; }
.side .card + .card { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 8px; }
.lbl { font-size: 18px; color: var(--muted); }
select, input[type=text] { background: var(--ink); border: 2px solid var(--panel-hi); padding: 2px 6px; border-radius: 0; font-size: 18px; max-width: 100%; }
select:focus, input:focus { outline: 2px solid var(--orange-hi); outline-offset: 0; }

.btn { background: var(--panel-2); border: 2px solid var(--ink); padding: 3px 10px; cursor: pointer; font-size: 18px; box-shadow: inset 0 -3px 0 #1a1f3a, inset 0 2px 0 var(--panel-hi); border-radius: 0; }
.btn:hover { background: var(--panel-hi); }
.btn:active { box-shadow: inset 0 3px 0 #1a1f3a; transform: translateY(1px); }
.btn.primary { background: var(--orange); color: #fff; box-shadow: inset 0 -3px 0 #7a3800, inset 0 2px 0 var(--orange-hi); }
.btn.primary:hover { background: #d66300; }
.btn.sel { background: var(--orange); color: #fff; box-shadow: inset 0 3px 0 #7a3800; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
input[type=range] { accent-color: var(--orange); width: 110px; }
kbd { font-family: var(--body); background: var(--ink); padding: 0 5px; border: 1px solid var(--panel-hi); }

/* ---------- map ---------- */
.map-card { padding: 0; overflow: hidden; position: relative; }
.map-card .map-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; gap: 10px; flex-wrap: wrap; border-bottom: 3px solid var(--ink); }
.map-card .map-head .title { font-family: var(--pixel); font-size: 13px; }
.legend { display: flex; gap: 12px; font-size: 17px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; vertical-align: -1px; border: 2px solid var(--ink); }
svg.graph { width: 100%; height: auto; display: block; aspect-ratio: 1000 / 700; user-select: none; border-bottom: 3px solid var(--ink); }
.msg-bar { padding: 6px 14px; min-height: 40px; font-size: 20px; display: flex; align-items: center; gap: 10px; }
.msg-bar .step-no { color: var(--muted); font-size: 17px; white-space: nowrap; }

/* svg pieces */
svg text { font-family: var(--pixel); }
.bg-street-label { fill: #c9c9d6; opacity: .55; font-size: 11px; }
.edge { stroke: #d8c49a; stroke-width: 4; opacity: .55; transition: stroke .2s steps(2), opacity .2s steps(2); }
svg:not(:has(.bg-road)) .edge { stroke: #7a7295; opacity: .9; }
.edge.tree { stroke: var(--orange-hi); stroke-width: 6; opacity: 1; }
.edge-w rect { fill: var(--ink); }
.edge-w text { fill: var(--text); font-size: 11px; text-anchor: middle; dominant-baseline: central; }
.explore { stroke: #fff; stroke-width: 6; stroke-dasharray: 8 8; animation: march .4s steps(4) infinite; }
@keyframes march { to { stroke-dashoffset: -16; } }
.final-path { fill: none; stroke: #ffe066; stroke-width: 10; stroke-linejoin: miter; animation: drawpath 1s steps(14) forwards; }
@keyframes drawpath { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }

.node { cursor: pointer; }
.node rect.body { stroke: var(--ink); stroke-width: 3; transition: fill .2s steps(2); }
.node rect.hi { fill: rgba(255,255,255,.28); pointer-events: none; }
.node rect.lo { fill: rgba(0,0,0,.25); pointer-events: none; }
.node .halo { fill: none; stroke: transparent; stroke-width: 4; }
.node text.id { font-size: 15px; text-anchor: middle; dominant-baseline: central; fill: var(--ink); pointer-events: none; }
.node text.name { font-size: 10px; text-anchor: middle; fill: var(--text); pointer-events: none; paint-order: stroke; stroke: var(--ink); stroke-width: 4px; opacity: 0; }
.node:hover text.name, .node.current text.name, .node.pin-start text.name, .node.pin-goal text.name { opacity: 1; }
svg:has(.bg-road) .node text.id { font-size: 10px; }
.node.unvisited rect.body { fill: var(--unvisited); }
.node.identified rect.body { fill: var(--identified); }
.node.visited rect.body { fill: var(--visited); }
.node.visited text.id { fill: #fff; }
.node.current rect.body { fill: var(--current); }
.node.current .halo { stroke: #fff; animation: blink .5s steps(1) infinite; }
@keyframes blink { 50% { stroke: transparent; } }
.node.on-path rect.body { stroke: #ffe066; }
.node:hover rect.body { stroke: #fff; }
.node .badge rect { fill: var(--ink); }
.node .badge text { fill: var(--orange-hi); font-size: 10px; text-anchor: middle; dominant-baseline: central; }
.node .dist rect { fill: var(--ink); }
.node .dist text { fill: #8fd0ff; font-size: 10px; text-anchor: middle; dominant-baseline: central; }
.node.pin-start .halo { stroke: var(--good); stroke-dasharray: 6 6; }
.node.pin-goal .halo { stroke: var(--bad); stroke-dasharray: 6 6; }
.node.current.pin-start .halo, .node.current.pin-goal .halo { stroke: #fff; stroke-dasharray: none; }
.node.shake { animation: shake .4s steps(4); }
@keyframes shake { 0%,100% { transform: translate(var(--tx), var(--ty)); } 25% { transform: translate(calc(var(--tx) - 6px), var(--ty)); } 50% { transform: translate(calc(var(--tx) + 6px), var(--ty)); } 75% { transform: translate(calc(var(--tx) - 3px), var(--ty)); } }
.node.hint .halo { stroke: var(--good); stroke-dasharray: none; animation: blink .3s steps(1) infinite; }
.node.correct rect.body { stroke: var(--good); }
.ripple { fill: none; stroke: #fff; stroke-width: 4; transform-box: fill-box; transform-origin: center; animation: ripple .6s steps(5) forwards; pointer-events: none; }
@keyframes ripple { from { transform: scale(1); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }
.pop-text { font-size: 18px; text-anchor: middle; paint-order: stroke; stroke: var(--ink); stroke-width: 5px; animation: floatup .9s steps(6) forwards; pointer-events: none; }
@keyframes floatup { to { transform: translateY(-36px); opacity: 0; } }
.token { transition: transform .3s steps(3); pointer-events: none; }
.token .bob { animation: bob .6s steps(1) infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }

/* ---------- data structure panel ---------- */
.ds { display: flex; gap: 4px; flex-wrap: wrap; min-height: 40px; align-items: center; padding: 4px; background: var(--ink); }
.ds.stack { flex-direction: column-reverse; align-items: stretch; }
.ds .empty { color: var(--muted); font-size: 18px; padding: 2px 6px; }
.chip { min-width: 36px; padding: 1px 8px; background: var(--identified); color: var(--ink); text-align: center; font-size: 20px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.chip small { opacity: .7; margin-left: 4px; font-size: 16px; }
.chip.enter { animation: chipin .25s steps(3); }
.ds.stack .chip.enter { animation: chipdrop .25s steps(3); }
.chip.front { outline: 3px solid #fff; outline-offset: -3px; }
@keyframes chipin { from { transform: translateX(24px); opacity: 0; } }
@keyframes chipdrop { from { transform: translateY(-18px); opacity: 0; } }
.chip.frame { background: var(--panel-hi); color: var(--text); }
.ds-label { display: flex; justify-content: space-between; font-size: 16px; color: var(--muted); margin: 0 2px 2px; }
.seq { display: flex; flex-wrap: wrap; gap: 4px; min-height: 26px; }
.seq .chip { background: var(--visited); color: #fff; padding: 0 6px; min-width: 28px; }
.seq .chip.finish { background: #6b5aa8; }
.seq .chip.new { animation: chipin .25s steps(3); background: var(--current); }
.removed-slot { font-size: 18px; color: var(--muted); margin-top: 6px; min-height: 20px; }
.removed-slot b { color: var(--orange-hi); font-weight: 400; }

details.code summary { cursor: pointer; font-family: var(--pixel); font-size: 11px; color: var(--muted); list-style: none; display: flex; justify-content: space-between; }
details.code summary::-webkit-details-marker { display: none; }
details.code summary::after { content: "+"; }
details.code[open] summary::after { content: "−"; }
.pseudo { font-family: var(--body); font-size: 18px; line-height: 1.15; margin: 8px 0 0; padding: 0; list-style: none; }
.pseudo li { white-space: pre-wrap; padding: 1px 6px; color: var(--muted); }
.pseudo li.hl { background: var(--orange); color: #fff; }

.result { box-shadow: inset 3px 3px 0 var(--orange-hi), inset -3px -3px 0 #7a3800, 4px 4px 0 rgba(0,0,0,.35); background: #4a2a12; }
.result .big { font-family: var(--pixel); font-size: 13px; margin-bottom: 6px; }
.result .path-str { font-size: 19px; color: #ffd29a; word-break: break-word; }
.note { margin: 8px 0 0; font-size: 18px; line-height: 1.1; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.stat { background: rgba(0,0,0,.3); padding: 4px; text-align: center; }
.stat b { display: block; font-family: var(--pixel); font-size: 18px; font-weight: 400; }
.stat span { font-size: 16px; color: var(--muted); }

/* ---------- pixel icons ---------- */
.px-icon { display: inline-block; vertical-align: middle; image-rendering: pixelated; }
.hearts .px-icon { margin-right: 3px; }

/* ---------- predict mode ---------- */
.intro { color: var(--muted); font-size: 19px; margin-top: 2px; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.level { position: relative; padding: 12px; cursor: pointer; }
.level:hover:not(.locked) { transform: translate(-2px, -2px); box-shadow: inset 3px 3px 0 var(--panel-hi), inset -3px -3px 0 #1a1f3a, 6px 6px 0 rgba(0,0,0,.35); }
.level .num { position: absolute; right: 10px; top: 8px; font-family: var(--pixel); font-size: 26px; color: rgba(255,255,255,.08); }
.level h4 { margin: 0 0 4px; font-size: 12px; line-height: 1.4; }
.level .algo-tag { display: inline-block; font-size: 16px; padding: 0 6px; background: var(--ink); color: var(--orange-hi); margin-bottom: 6px; }
.level .stars { margin-top: 8px; display: flex; gap: 3px; }
.level .best { font-size: 16px; color: var(--muted); }
.level.locked { opacity: .45; cursor: not-allowed; }
.hud { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.hud .pill { background: var(--ink); padding: 2px 10px; font-size: 19px; display: inline-flex; align-items: center; gap: 2px; }
.hud .pill.combo { color: var(--identified); }
.hud .pill.combo.hot { animation: hot .3s steps(2); }
@keyframes hot { 50% { transform: scale(1.2); } }
.prompt { font-size: 20px; color: var(--identified); }
.prompt.bad { color: #ff8a8a; }
.prompt.good { color: var(--good); }
.hidden { display: none !important; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 18px; color: var(--muted); cursor: pointer; }
.toggle input { accent-color: var(--orange); }

/* overlay */
.overlay { position: fixed; inset: 0; background: rgba(8,10,24,.75); display: grid; place-items: center; z-index: 50; }
.overlay .box { padding: 22px 26px; max-width: 480px; width: 92%; text-align: center; animation: popin .25s steps(3); }
@keyframes popin { from { transform: scale(.7); } }
.overlay h2 { margin: 0 0 8px; font-size: 18px; text-shadow: 3px 3px 0 var(--ink); }
.overlay p { font-size: 19px; }
.overlay .stars-big { display: flex; justify-content: center; gap: 10px; margin: 10px 0; }
.overlay .stars-big .px-icon { animation: popin .3s steps(3) backwards; }
.overlay .stars-big .px-icon:nth-child(2) { animation-delay: .15s; } .overlay .stars-big .px-icon:nth-child(3) { animation-delay: .3s; }
.overlay .answer { background: var(--ink); padding: 8px; margin: 10px 0; color: #ffd29a; font-size: 19px; word-break: break-word; }
.overlay .row { justify-content: center; margin-top: 12px; }

/* ---------- race ---------- */
.race-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.race-grid .card + .card { margin-top: 0; }
@media (max-width: 900px) { .race-grid { grid-template-columns: 1fr; } }
.lane .map-head .counter { color: var(--identified); font-size: 18px; }
.lane.winner { box-shadow: inset 3px 3px 0 var(--good), inset -3px -3px 0 #2f6b20, 4px 4px 0 rgba(0,0,0,.35); }
.lane .flag { position: absolute; top: 46px; right: 12px; font-family: var(--pixel); font-size: 11px; background: var(--good); color: var(--ink); padding: 4px 8px; animation: popin .25s steps(3); }
.verdict { margin-top: 14px; }
.verdict table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.verdict td, .verdict th { padding: 4px 8px; border-bottom: 2px solid var(--ink); text-align: left; font-weight: 400; }
.verdict th { color: var(--muted); font-size: 16px; }
.verdict td.win { color: var(--good); }
.verdict p { font-size: 19px; line-height: 1.15; }

/* ---------- cheat sheet ---------- */
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sheet-grid .card + .card { margin-top: 0; }
@media (max-width: 1000px) { .sheet-grid { grid-template-columns: 1fr; } }
table.cx { width: 100%; border-collapse: collapse; font-size: 19px; }
table.cx th, table.cx td { padding: 3px 8px; border-bottom: 2px solid var(--ink); text-align: left; font-weight: 400; }
table.cx th { color: var(--muted); font-size: 16px; }
table.cx td code { color: #ffd29a; }
.adj-list { font-size: 19px; line-height: 1.2; }
.adj-list b { color: var(--orange-hi); display: inline-block; min-width: 42px; font-weight: 400; }
.matrix-wrap { overflow: auto; max-height: 420px; }
table.matrix { border-collapse: collapse; font-size: 17px; }
table.matrix td, table.matrix th { width: 30px; height: 24px; text-align: center; border: 2px solid var(--ink); font-weight: 400; }
table.matrix th { color: var(--orange-hi); background: var(--panel); position: sticky; top: 0; }
table.matrix tbody th { position: sticky; left: 0; }
table.matrix td.on { background: var(--orange); color: #fff; }
table.matrix td.off { color: #555c85; }
.tips { padding-left: 18px; margin: 10px 0 0; }
.tips li { margin-bottom: 6px; line-height: 1.1; font-size: 19px; }
.tips b { color: var(--orange-hi); font-weight: 400; }
.small { font-size: 17px; color: var(--muted); }

/* ground strip at the very bottom of the page */
footer { text-align: center; color: var(--text); font-size: 17px; padding: 26px 20px 18px; margin-top: 10px;
  background:
    linear-gradient(#5aa83a 0 12px, #3f7a2a 12px 18px, transparent 18px),
    repeating-linear-gradient(90deg, #6b4a2e 0 24px, #5e4027 24px 48px);
  border-top: 3px solid var(--ink); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

/* ===================== topics + sub-tabs ===================== */
.topic { display: none; }
.topic.active { display: block; }
.subtabs { display: flex; gap: 4px; margin: 0 0 12px; overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs button { background: rgba(14,16,32,.55); border: 2px solid var(--ink); color: var(--muted); padding: 4px 12px; cursor: pointer; font-family: var(--pixel); font-size: 11px; white-space: nowrap; }
.subtabs button.active { background: var(--panel-hi); color: var(--text); box-shadow: inset 0 -3px 0 var(--orange); }
.narrow { max-width: 760px; margin: 0 auto; }
.scene { width: 100%; height: auto; display: block; border-bottom: 3px solid var(--ink); background: #1b2140; }
.map-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll { overflow-x: auto; }
.good-text { color: var(--good); } .bad-text { color: #ff8a8a; } .warn-text { color: var(--identified); }
.ok { color: var(--good); font-weight: 400; } .no { color: #ff8a8a; font-weight: 400; }
.note-card { background: #2c2a1a; box-shadow: inset 3px 3px 0 #5c5530, inset -3px -3px 0 #1a1910, 4px 4px 0 rgba(0,0,0,.35); font-size: 19px; line-height: 1.1; }

/* ===================== code viewer ===================== */
.code-box { max-height: 420px; overflow: auto; background: #12152b; }
.code-box.small-code { max-height: 260px; }
.code-box.small-code .java { font-size: 17px; }
.java { list-style: none; margin: 0; padding: 6px 0; font-family: var(--body); font-size: 20px; line-height: 1.12; }
.java li { display: flex; gap: 10px; padding: 0 10px 0 0; white-space: pre; border-left: 4px solid transparent; }
.java .ln { color: #4c5380; min-width: 26px; text-align: right; flex: none; }
.java code { font-family: inherit; color: #d9d4ff; }
.java .k { color: #ff9a3c; } .java .s { color: #9be07a; } .java .c { color: #6f78a8; }
.java li.hl { background: rgba(191,87,0,.38); border-left-color: var(--orange-hi); }
.java li.hl code { color: #fff; }
.java li.skip code { color: #4c5380; text-decoration: line-through; }
.java li.match { background: rgba(123,224,90,.25); border-left-color: var(--good); }
.java li.nomatch { background: rgba(255,80,80,.18); border-left-color: var(--bad); }
.java li.boom { background: rgba(255,80,80,.35); border-left-color: var(--bad); animation: shakeX .3s steps(3); }
@keyframes shakeX { 33% { transform: translateX(-4px); } 66% { transform: translateX(4px); } }

/* ===================== consoles, stacks, trees ===================== */
.console { background: #07080f; color: #c9f5b0; font-size: 19px; line-height: 1.1; padding: 6px 8px; min-height: 60px; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.console.tall { max-height: 320px; }
.console .err { color: #ff8a8a; } .console .ok { color: var(--good); } .console .warn { color: var(--identified); }
.console .empty { color: #4c5380; }
.exc-card { background: var(--bad); color: #fff; padding: 4px 10px; margin-bottom: 6px; display: flex; flex-direction: column; box-shadow: inset 0 -3px 0 rgba(0,0,0,.3); }
.exc-card b { font-family: var(--pixel); font-size: 11px; font-weight: 400; }
.exc-card span { font-size: 17px; opacity: .9; }
.exc-card.drop { animation: chipdrop .3s steps(3); }
.tree { font-size: 17px; line-height: 1.15; max-height: 260px; overflow: auto; }
.tree-row { color: var(--muted); white-space: nowrap; }
.tree-row.on { color: #fff; background: rgba(255,80,80,.3); }
.tag { font-size: 14px; padding: 0 4px; background: var(--ink); color: var(--muted); }
.tag.chk { color: var(--identified); }
.kvs { font-size: 19px; }
.kv { display: flex; justify-content: space-between; gap: 10px; border-bottom: 2px solid var(--ink); padding: 2px 0; }
.kv b { font-weight: 400; color: var(--muted); }
.kv span { text-align: right; word-break: break-all; }
.http-text { margin: 6px 0 0; background: #07080f; color: #ffd29a; padding: 6px 8px; font-family: var(--body); font-size: 18px; white-space: pre-wrap; }
.reassembled { display: flex; gap: 4px; }

/* ===================== catch it ===================== */
.cg-thrown { margin: 12px 0 8px; max-width: 360px; }
.cg-code .java li.pick { cursor: pointer; }
.cg-code .java li.pick:hover { background: rgba(255,255,255,.08); }
.cg-code .java li.right, .pick-none.right { background: rgba(123,224,90,.3); border-left-color: var(--good); }
.cg-code .java li.wrong, .pick-none.wrong { background: rgba(255,80,80,.3); border-left-color: var(--bad); }
.cg-code .java { background: #12152b; }
.pick-none { margin-top: 6px; width: 100%; text-align: left; }
#cg-why { min-height: 44px; margin: 8px 0; font-size: 19px; }

/* ===================== networking scene ===================== */
.nw-link { stroke: #4c5380; stroke-width: 4; }
.nw-link.lit { stroke: #d8c49a; }
.nw-node rect.body { stroke: var(--ink); stroke-width: 3; }
.nw-node rect.laptop { fill: var(--current); } .nw-node rect.server { fill: var(--visited); }
.nw-node rect.dns { fill: #6b5aa8; } .nw-node rect.router { fill: var(--unvisited); }
.nw-node rect.hi { fill: rgba(255,255,255,.28); }
.nw-label { font-size: 11px; text-anchor: middle; fill: var(--text); paint-order: stroke; stroke: var(--ink); stroke-width: 4px; }
.nw-sub { font-size: 10px; text-anchor: middle; fill: var(--identified); paint-order: stroke; stroke: var(--ink); stroke-width: 4px; }
.packet rect { fill: var(--identified); stroke: var(--ink); stroke-width: 2; }
.packet text { font-size: 11px; text-anchor: middle; dominant-baseline: central; fill: var(--ink); }
.packet.dns rect { fill: #8fb5ff; } .packet.tcp rect { fill: var(--good); } .packet.http rect { fill: var(--orange-hi); }
.packet.err rect, .packet.lost rect { fill: var(--bad); } .packet.lost text, .packet.err text { fill: #fff; }
.packet.lost { animation: blink .3s steps(1) 3; }

/* ===================== bank sockets ===================== */
.bank-grid { display: grid; grid-template-columns: 1fr 110px 1fr; gap: 12px; margin-top: 12px; align-items: stretch; }
.bank-grid .card + .card { margin-top: 0; }
.bank-grid .console { margin-top: 8px; }
.wire { position: relative; display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(90deg, #4c5380 0 8px, transparent 8px 14px) center / 100% 4px no-repeat; }
.wire .small { position: absolute; top: 6px; }
.wire-pkt { position: absolute; top: 50%; background: var(--identified); color: var(--ink); padding: 0 6px; font-size: 17px; white-space: nowrap; transform: translateY(-50%); border: 2px solid var(--ink); }
.wire-pkt.right { animation: toRight .7s steps(7) forwards; }
.wire-pkt.left { animation: toLeft .7s steps(7) forwards; background: var(--good); }
@keyframes toRight { from { left: -10%; } to { left: 70%; } }
@keyframes toLeft { from { left: 70%; } to { left: -10%; } }
input[type=text] { min-width: 0; }
#bk-input { flex: 1 1 160px; }

/* ===================== threads ===================== */
.sm-edge { stroke: #6b7096; stroke-width: 3; }
.sm-edge.lit { stroke: var(--orange-hi); stroke-width: 5; }
.sm-node rect.body { stroke: var(--ink); stroke-width: 3; opacity: .55; }
.sm-node rect.hi { fill: rgba(255,255,255,.25); opacity: .55; }
.sm-node text { font-size: 12px; text-anchor: middle; dominant-baseline: central; fill: #fff; paint-order: stroke; stroke: var(--ink); stroke-width: 4px; }
.sm-node.on rect.body, .sm-node.on rect.hi { opacity: 1; }
.sm-node.on rect.body { stroke: #fff; }
.sm-token { transition: transform .35s steps(4); }
#th-actions .btn:disabled { opacity: .3; }
.cpu { display: flex; gap: 2px; min-height: 26px; background: #07080f; padding: 4px; flex-wrap: wrap; }
.cpu i { width: 18px; height: 18px; display: block; animation: chipin .2s steps(2); }
.cpu .cpu-A { background: var(--current); } .cpu .cpu-B { background: var(--visited); }
.console .out-A { color: #ffbf8a; } .console .out-B { color: #9cc2ff; }
.console .flip { background: rgba(245,197,66,.15); }
.console .ts { color: #4c5380; }
.toggle.big { font-size: 24px; background: var(--ink); padding: 2px 10px; }

/* ===================== quiz ===================== */
.quiz-top { display: flex; justify-content: space-between; }
.quiz-bar { height: 8px; background: var(--ink); margin: 6px 0 12px; }
.quiz-bar i { display: block; height: 100%; background: var(--orange); }
.quiz-q { font-size: 23px; line-height: 1.15; margin-bottom: 12px; }
.quiz-opts { display: grid; gap: 6px; }
.quiz-opt { text-align: left; font-size: 20px; padding: 6px 12px; }
.quiz-opt.right { background: #2f6b20; box-shadow: inset 0 -3px 0 #1d4514; color: #fff; }
.quiz-opt.wrong { background: #7a2626; box-shadow: inset 0 -3px 0 #4a1515; color: #fff; }
.quiz-opt:disabled { cursor: default; }
.quiz-why { min-height: 30px; margin: 10px 0; font-size: 19px; line-height: 1.15; }
.quiz-end { text-align: center; padding: 10px 0; }
.quiz-end h2 { font-size: 20px; margin: 6px 0; }
.quiz-end .stars-big { display: flex; justify-content: center; gap: 10px; }

/* ===================== touch + mobile ===================== */
button, .btn, .node, .level, label { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media (hover: none) { .node text.name { opacity: 0; } .node.current text.name, .node.pin-start text.name, .node.pin-goal text.name { opacity: 1; } }
@media (max-width: 760px) {
  :root { font-size: 19px; }
  header { padding: 10px 12px 6px; gap: 10px; }
  .brand .logo { width: 42px; height: 42px; }
  .brand h1 { font-size: 16px; }
  .brand small { font-size: 16px; }
  nav.tabs { margin-left: 0; width: 100%; overflow-x: auto; scrollbar-width: none; }
  nav.tabs::-webkit-scrollbar { display: none; }
  nav.tabs button { flex: 1 0 auto; padding: 8px 10px; font-size: 11px; }
  main { padding: 4px 10px 24px; }
  .layout { gap: 12px; }
  .card { padding: 10px; }
  .btn { min-height: 38px; padding: 4px 10px; }
  .transport .btn { flex: 1; }
  .map-scroll > svg.graph { min-width: 640px; }
  .map-scroll > svg.scene { min-width: 620px; }
  .map-card .map-head { padding: 8px 10px; }
  .legend { font-size: 15px; gap: 8px; }
  .kbd-hint { display: none; }
  .side select, .side .row > select { width: 100%; }
  .race-grid .map-scroll > svg.graph { min-width: 520px; }
  .bank-grid { grid-template-columns: 1fr; }
  .wire { height: 44px; }
  @keyframes toRight { from { left: 0; } to { left: 75%; } }
  .levels { grid-template-columns: 1fr 1fr; gap: 8px; }
  .level { padding: 10px; }
  .level h4 { font-size: 10px; }
  .msg-bar { font-size: 19px; }
  .java { font-size: 17px; }
  .code-box { max-height: 340px; }
  .quiz-q { font-size: 21px; }
  .stats .stat b { font-size: 15px; }
  .overlay .box { padding: 16px; }
  footer { font-size: 15px; }
}
@media (max-width: 420px) {
  .levels { grid-template-columns: 1fr; }
  .hud .pill { font-size: 17px; padding: 2px 6px; }
}

/* keep wide maps inside their own scroll pane instead of widening the page */
.layout > *, .race-grid > *, .sheet-grid > *, .bank-grid > *, .side > * { min-width: 0; }
@media (max-width: 1100px) { .layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1000px) { .sheet-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .race-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .bank-grid { grid-template-columns: minmax(0, 1fr); }
  .map-scroll { position: relative; }
  .map-card .map-scroll::after { content: "swipe ↔"; position: sticky; left: 8px; bottom: 8px; display: inline-block; margin-top: -30px; font-size: 15px; background: rgba(14,16,32,.8); color: var(--muted); padding: 0 6px; pointer-events: none; }
  .map-card .legend { width: 100%; }
}
.sheet-grid .card { overflow-x: auto; }
@media (max-width: 760px) { .card h3 select { max-width: 60%; } table.cx { font-size: 17px; } }
