:root{--bg: #f7f2e8;--bg-deep: #efe7d9;--surface: #fbf7ef;--surface-strong: #fffdf8;--ink: #252726;--muted: #72736f;--line: #ded6c8;--line-strong: #cfc5b5;--green: #15935b;--red: #df3b2f;--blue: #1588d3;--orange: #df8a25;--warning: #d97919;--danger: #c94032;--shadow: 0 14px 36px rgba(54, 47, 35, .08);font-family:JetBrains Mono,IBM Plex Mono,SFMono-Regular,Consolas,monospace;color:var(--ink);background:var(--bg)}*{box-sizing:border-box}html,body,#root{min-height:100%;margin:0}@media(min-width:1181px){html:has(.level-screen),body:has(.level-screen),#root:has(.level-screen){height:100%;overflow:hidden}.level-screen{position:fixed;inset:0;width:100%}}body{background:radial-gradient(circle at 20% 0%,rgba(255,255,255,.7),transparent 34%),linear-gradient(120deg,#fbf7ef,var(--bg))}button{font:inherit;color:inherit}button,[role=button],[role=switch]{outline:none}button:focus-visible,[role=button]:focus-visible,[role=switch]:focus-visible,.port:focus-visible,.wire:focus-visible{outline:3px solid rgba(21,147,91,.36);outline-offset:4px}.map-background{position:fixed;inset:0;z-index:0;pointer-events:none;opacity:.72}.river{fill:none;stroke:#b9d2de6b;stroke-width:72;stroke-linecap:round}.map-lines path,.map-stations circle{fill:none;stroke:#a8a49a47;stroke-width:2}.map-stations circle{fill:var(--bg)}.map-icons{fill:#a8a49a2b}.title-screen,.level-select-screen,.level-screen{position:relative;z-index:1;min-height:100vh}.title-screen{display:grid;place-items:center;overflow:hidden;padding:32px}.title-circuit{position:absolute;width:min(76vw,960px);opacity:.55;transform:translateY(-80px)}.title-content{position:relative;max-width:760px;text-align:center;padding:48px 24px}.eyebrow{color:var(--green);text-transform:uppercase;letter-spacing:0;font-size:.94rem;margin:0 0 16px}.title-content h1{margin:0;font-size:clamp(3rem,9vw,7rem);line-height:.95;letter-spacing:0}.title-content p:not(.eyebrow){margin:24px auto 34px;max-width:610px;color:var(--muted);line-height:1.7}.play-button,.success-actions button,.choice-card button,.level-card,.gate-tray-item{border:1px solid var(--line);background:#fffcf6d1;cursor:pointer}.play-button{display:inline-flex;align-items:center;gap:12px;padding:18px 44px;border-radius:999px;color:var(--green);border-color:var(--green);font-size:1.35rem;font-weight:700;box-shadow:var(--shadow)}.play-button svg{fill:currentColor}.level-select-screen{padding:28px}.level-select-header{display:grid;grid-template-columns:minmax(280px,1fr) auto;gap:24px;align-items:start;margin-bottom:20px}.level-select-header h1{margin:0 0 14px;font-size:clamp(2rem,4vw,3.4rem);text-transform:uppercase;letter-spacing:0}.level-select-header p{margin:0;color:var(--muted)}.legend-card,.select-footer,.loading-panel,.load-error,.level-card,.circuit-panel,.truth-panel,.gate-tray,.level-badge,.goal-card,.top-controls,.success-card,.choice-card{border:1px solid var(--line);background:#fffcf6b8;border-radius:8px;box-shadow:0 1px #ffffffb8 inset;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}.legend-card{display:grid;grid-template-columns:repeat(6,minmax(62px,1fr));gap:16px;min-width:610px;padding:16px 22px}.legend-card span{display:grid;grid-template-columns:54px auto;gap:8px;align-items:center;font-weight:700;font-size:.85rem;color:var(--muted)}.level-grid{display:grid;grid-template-columns:repeat(4,minmax(250px,1fr));gap:14px}.level-card{min-height:250px;padding:16px;text-align:left;display:grid;grid-template-rows:auto auto 1fr auto;gap:10px;transition:transform .16s ease,border-color .16s ease,background .16s ease}.level-card:hover{transform:translateY(-2px);border-color:var(--line-strong);background:#fffdf9eb}.card-heading{display:grid;grid-template-columns:auto 1fr auto;gap:10px;align-items:center;text-transform:uppercase}.level-number{display:grid;place-items:center;width:30px;height:30px;border:1px solid var(--line);border-radius:50%;background:var(--surface-strong);font-weight:800}.card-complete{width:20px;color:var(--green)}.level-card p{margin:0;color:#555852;line-height:1.45;font-size:.88rem}.level-difficulty{text-transform:uppercase;font-weight:800;color:var(--muted)}.card-preview{width:100%;min-height:104px;overflow:visible}.preview-board{fill:#fffcf694;stroke:#cfc5b5b8;stroke-width:1}.preview-grid{fill:none;stroke:#bfb7aa61;stroke-width:.7}.preview-wire-bed,.preview-wire{fill:none;stroke-linecap:round;stroke-linejoin:round}.preview-wire-bed{stroke:#fffcf6e6;stroke-width:7}.preview-wire{stroke-width:3.2}.preview-wire.red{color:color-mix(in srgb,var(--red) 82%,#5f5149);stroke:currentColor}.preview-input.red{color:color-mix(in srgb,var(--red) 82%,#5f5149);stroke:currentColor;fill:currentColor}.preview-wire.blue{color:color-mix(in srgb,var(--blue) 82%,#4d5d67);stroke:currentColor}.preview-input.blue{color:color-mix(in srgb,var(--blue) 82%,#4d5d67);stroke:currentColor;fill:currentColor}.preview-wire.green{color:color-mix(in srgb,var(--green) 86%,#465a4f);stroke:currentColor}.preview-input.green{color:color-mix(in srgb,var(--green) 86%,#465a4f);stroke:currentColor;fill:currentColor}.preview-input text{font-size:12px;font-weight:900}.preview-input circle{fill:currentColor;stroke:#fffcf6f2;stroke-width:1.4}.preview-output circle{fill:#f8f4eb;stroke:var(--green);stroke-width:3.2}.preview-output path{fill:none;stroke:var(--ink);stroke-width:2.2;stroke-linecap:round;opacity:.72}.preview-slot{fill:#fffcf69e;stroke:#aaa399;stroke-width:1.6;stroke-dasharray:7 6}.preview-slot-label,.preview-zone-label{fill:var(--muted);font-size:12px;font-weight:800;text-transform:uppercase}.preview-build-zone,.preview-gate rect{fill:#fffdf8d6;stroke:#484b48bd;stroke-width:1.4}.preview-gate .gate-glyph{width:100%;height:100%;color:#2f3331}.preview-gate-strip .gate-glyph{color:#424744;opacity:.74}.session-stats{display:flex;justify-content:space-between;gap:10px;color:var(--muted);font-size:.78rem}.session-stats span{display:inline-flex;align-items:center;gap:4px}.session-stats svg{width:14px}.score-stat.earned svg{color:#d9a323;fill:currentColor}.select-footer{margin-top:20px;padding:18px 24px;display:grid;grid-template-columns:repeat(3,1fr);gap:18px;text-transform:uppercase}.level-screen{height:100vh;overflow:hidden;display:grid;grid-template-columns:210px minmax(560px,1fr) 250px;grid-template-rows:minmax(0,1fr) auto;gap:18px;padding:96px 24px 18px}.level-screen.no-bottom-tray{grid-template-rows:minmax(0,1fr)}.round-back{position:fixed;top:22px;left:24px;z-index:5;width:60px;height:60px;border-radius:50%;border:1px solid var(--line);background:#fffcf6d6;display:grid;place-items:center;box-shadow:var(--shadow)}.round-back svg{width:34px;height:34px}.top-controls{position:fixed;top:22px;right:24px;z-index:5;display:grid;grid-template-columns:repeat(3,68px);padding:8px}.icon-control{border:0;background:transparent;min-height:60px;display:grid;place-items:center;gap:4px;color:var(--ink);cursor:pointer}.icon-control svg{width:28px;height:28px}.icon-control span{font-size:.75rem}.icon-control.active{color:var(--green)}.icon-control:disabled{opacity:.35;cursor:not-allowed}.left-rail,.right-rail{display:grid;gap:14px;align-content:start;min-height:0}.left-rail,.right-rail{overflow-y:auto}.level-badge,.goal-card{padding:16px}.level-badge{min-height:84px}.level-badge strong{display:block;font-size:2rem}.level-badge span{color:var(--muted)}.goal-card h2,.gate-tray h2{margin:0 0 14px;font-size:.95rem;text-transform:uppercase}.goal-card svg{float:right;color:var(--muted)}.goal-card p{margin:28px 0 12px;font-weight:800;color:var(--green);line-height:1.5}.goal-card span,.truth-help{color:var(--muted);line-height:1.55;font-size:.84rem}.right-rail{padding-top:66px}.main-stage{min-width:0;min-height:0;position:relative;display:grid;grid-template-rows:auto minmax(0,1fr);gap:12px}.level-title-row{display:flex;justify-content:space-between;align-items:end;gap:20px;min-height:54px}.level-title-row h1{margin:0;text-transform:uppercase;font-size:1.35rem}.level-title-row p{margin:5px 0 0;color:var(--muted);line-height:1.45;max-width:820px}.stage-stats{display:flex;gap:10px;color:var(--muted);font-size:.78rem;white-space:nowrap}.circuit-panel{min-height:0;position:relative;overflow:hidden;background:#faf6ed94}.circuit-panel.canvas-over{border-color:var(--green)}.circuit-svg{width:100%;height:100%;min-height:340px;display:block;touch-action:none;-webkit-user-select:none;user-select:none}.canvas-river{fill:none;stroke:#b9d2de52;stroke-width:54;stroke-linecap:round}.canvas-map-lines path{fill:none;stroke:#a09d952e;stroke-width:1.4}.wire{fill:none;stroke:var(--wire-color, #a6a19a);stroke-width:5;stroke-linecap:round;cursor:pointer;pointer-events:stroke;transition:stroke-width .14s ease,opacity .14s ease}.signal-one{filter:url(#soft-glow);animation:signalPulse 1.1s linear infinite}.signal-zero{stroke:#8d8f8a;stroke-width:2.5;opacity:.48}.signal-unknown{stroke:#a8a39b;stroke-width:3;stroke-dasharray:9 12;opacity:.58}.selected-wire{stroke-width:8;stroke:var(--orange)}.wire-preview{pointer-events:none;stroke:var(--orange);opacity:.9}.wire-preview-dot{fill:var(--orange);opacity:.92;pointer-events:none}@keyframes signalPulse{0%{stroke-dasharray:1 18;stroke-dashoffset:30}to{stroke-dasharray:1 18;stroke-dashoffset:0}}.input-letter{font-size:25px;font-weight:900}.input-ring{fill:var(--surface);stroke:var(--ink);stroke-width:3}.input-node.node-active .input-ring{stroke:currentColor}.input-node{cursor:pointer}.input-core{stroke:var(--line-strong);stroke-width:2;transition:r .16s ease,fill .16s ease}.port{fill:var(--surface);stroke:var(--green);stroke-width:3;cursor:crosshair;touch-action:none}.port-input{stroke:#7e8582}.gate-node{cursor:pointer;touch-action:none}.gate-node.movable-gate,.gate-node.movable-gate .gate-glyph{cursor:grab}.gate-node.movable-gate:active,.gate-node.movable-gate:active .gate-glyph{cursor:grabbing}.selected-node .slot-box,.selected-node .input-ring,.selected-node .output-terminal{stroke:var(--orange);stroke-width:5}.selected-node .gate-glyph{filter:drop-shadow(0 0 8px rgba(223,138,37,.45))}.replaceable-gate-marker{fill:#df8a250f;stroke:var(--orange);stroke-width:3;stroke-dasharray:10 7}.replaceable-gate-label{fill:var(--orange);font-size:14px;font-weight:900;text-transform:uppercase}.replaceable-gate .gate-glyph{filter:drop-shadow(0 0 8px rgba(223,138,37,.28))}.slot-box{fill:#fffcf694;stroke:#777a77;stroke-width:2;stroke-dasharray:8 7}.black-box{fill:#fffdf8e6;stroke:#555a56;stroke-width:3}.slot-question{font-size:36px;fill:#333635}.black-box-question{fill:var(--ink);font-size:38px;font-weight:900}.node-label,.node-type{fill:#3b3d3b;font-size:16px}.node-type{font-size:17px;font-weight:900}.output-lead,.output-end-cap{fill:none;stroke:#4b504d;stroke-width:4;stroke-linecap:round;stroke-linejoin:round}.output-terminal{fill:#fffdf8eb;stroke:#4b504d;stroke-width:3}.output-node.node-active .output-terminal,.output-node.node-active .output-end-cap,.output-node.node-active .output-lead{stroke:var(--green)}.output-node.node-low .output-terminal,.output-node.node-low .output-end-cap,.output-node.node-low .output-lead{stroke:#7e8582}.output-label{fill:var(--muted);font-size:14px;font-weight:900;letter-spacing:0}.output-value{fill:var(--ink);font-size:32px;font-weight:900}.output-node.node-active .output-value{fill:var(--green)}.output-node.node-low .output-value{fill:#5f6460}.gate-glyph{color:#242827;display:block}.gate-glyph-active{color:var(--gate-color, currentColor)}.gate-glow{filter:url(#soft-glow)}.gate-glyph-label{font-size:13px;font-weight:900}.truth-panel{padding:20px 14px}.truth-panel table{width:100%;border-collapse:collapse;table-layout:fixed}.truth-panel th{padding:10px 6px 14px;border-bottom:1px solid var(--line);font-size:1rem}.truth-panel-compact{padding:16px 12px}.truth-panel-compact th{padding:8px 4px 10px}.truth-panel-compact td{padding:4px}.truth-panel-compact .truth-cell{min-height:32px}.out-heading{color:var(--green)}.state-heading{color:var(--muted)}.truth-panel td{padding:6px;text-align:center}.truth-cell{border:0;background:transparent;width:100%;min-height:36px;border-radius:6px;cursor:pointer;font-size:1.05rem}.active-row .input-cell{color:var(--green);font-weight:800}.out-cell{border:1px solid transparent;font-weight:900}.state-cell{color:var(--muted);background:#78787814;font-weight:900}.prediction-heading{font-size:.86rem}.prediction-cell{border:1px dashed #8f918b;background:#fffdf8a3;color:#3e423f;box-shadow:0 0 0 2px #8f918b14 inset}.prediction-cell:hover,.prediction-cell:focus-visible{border-color:var(--ink);background:#fffdf8eb}.prediction-filled{border-style:solid;background:#fffdf8db}.status-match{color:var(--green);background:#15935b1a}.status-mismatch{color:var(--warning);background:#d979191f;animation:badPulse .7s ease}.status-incomplete{color:#777a77;background:#78787814}.status-invalid{color:var(--danger);background:#c940321f}.target-output-cell{color:var(--green);background:#15935b1a}@keyframes badPulse{0%,to{transform:translate(0)}28%{transform:translate(-3px)}60%{transform:translate(3px)}}.target-line{display:grid;grid-template-columns:auto 1fr;align-items:center;gap:12px;margin:16px 8px 0;text-transform:uppercase;color:var(--muted)}.target-line i{height:5px;border-radius:5px;background:var(--green)}.prediction-target-line i{background:#8f918b}.truth-help{margin:14px 8px 0}.prediction-help{color:var(--ink);font-weight:800}.choice-card{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;padding:8px}.choice-card h2{grid-column:1 / -1;margin:0 0 6px;font-size:.95rem;text-transform:uppercase}.choice-card button{display:grid;justify-items:center;gap:2px;border-radius:8px;padding:5px 3px;min-height:72px;font-size:.78rem}.choice-card button.selected{border-color:var(--green);color:var(--green)}.bottom-tray{grid-column:1 / -1;display:grid;grid-template-columns:1fr}.gate-tray{min-height:0;padding:12px 22px}.gate-tray-list{display:grid;grid-template-columns:repeat(7,minmax(92px,1fr));gap:10px}.gate-tray-item{border-radius:8px;min-height:86px;display:grid;place-items:center;gap:2px;padding:6px;background:transparent;cursor:grab;touch-action:none}.gate-tray-item:active{cursor:grabbing}.gate-tray-item.selected,.gate-tray-item:hover{border-color:var(--gate-color);background:color-mix(in srgb,var(--gate-color) 12%,transparent)}.gate-tray-item.dragging{opacity:.56}.gate-disc{width:54px;height:54px;border-radius:50%;display:grid;place-items:center;background:color-mix(in srgb,var(--gate-color) 16%,white)}.gate-name{color:var(--gate-color);font-weight:900}.gate-dots{color:#a8a39b;letter-spacing:2px;font-size:.68rem}.error-toast{position:absolute;left:50%;bottom:18px;transform:translate(-50%);z-index:4;display:flex;align-items:center;gap:10px;padding:12px 18px;border-radius:999px;color:var(--warning);background:#fff8edf0;border:1px solid rgba(217,121,25,.4);box-shadow:var(--shadow)}.selection-toolbar{position:absolute;right:18px;bottom:18px;z-index:4;display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--line);border-radius:999px;background:#fffcf6f0;box-shadow:var(--shadow);color:var(--muted)}.selection-toolbar button{border:1px solid rgba(201,64,50,.42);background:#c9403214;color:var(--danger);border-radius:999px;padding:7px 12px;cursor:pointer}.tray-drag-ghost{position:fixed;z-index:30;transform:translate(-50%,-50%);pointer-events:none;padding:10px 14px;border-radius:999px;border:1px solid var(--green);background:#fffcf6f0;color:var(--green);font-weight:900;box-shadow:var(--shadow)}.success-overlay{position:fixed;inset:0;z-index:20;display:grid;place-items:center;background:#24231f2e;-webkit-backdrop-filter:blur(6px);backdrop-filter:blur(6px)}.success-card{position:relative;width:min(92vw,520px);padding:34px;text-align:center;overflow:hidden}.success-icon{width:64px;height:64px;color:var(--green)}.success-card h2{margin:8px 0;font-size:2.2rem}.success-card p{color:var(--muted);margin:0 0 20px}.score-strip{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin:22px 0}.score-strip div{border:1px solid var(--line);border-radius:8px;padding:14px 8px;background:#ffffff7a}.score-strip strong{display:block;font-size:1.5rem;color:var(--green)}.score-strip span{color:var(--muted);font-size:.75rem}.success-actions{display:flex;justify-content:center;flex-wrap:wrap;gap:12px}.success-actions button{display:inline-flex;align-items:center;gap:8px;border-radius:999px;padding:13px 24px}.success-actions .primary{border-color:var(--green);color:var(--green);font-weight:900}.spark-field span{position:absolute;width:8px;height:8px;border-radius:50%;background:var(--green);left:calc(20% + (var(--spark-index) * 4%));top:calc(12% + (var(--spark-index) % 5) * 16%);animation:spark .9s ease-out infinite alternate;opacity:.35}@keyframes spark{to{transform:translateY(-12px) scale(1.4);opacity:.05}}.level-loading{min-height:100vh;display:grid;place-items:center}.loading-panel,.load-error{padding:24px}.load-error{color:var(--danger)}@media(max-width:1180px){.level-grid{grid-template-columns:repeat(2,minmax(260px,1fr))}.legend-card{min-width:0;grid-template-columns:repeat(3,1fr)}.level-screen{grid-template-columns:180px minmax(480px,1fr);height:auto;min-height:100vh;position:relative;inset:auto;overflow-x:hidden;overflow-y:auto}.right-rail{grid-column:1 / -1;grid-template-columns:minmax(260px,360px) minmax(190px,1fr);padding-top:0}.bottom-tray{grid-template-columns:1fr}}@media(max-width:820px){.level-select-screen{padding:18px}.level-select-header{grid-template-columns:1fr}.legend-card{grid-template-columns:repeat(2,1fr)}.level-grid,.select-footer{grid-template-columns:1fr}.level-screen{padding:112px 14px 158px;grid-template-columns:1fr;grid-template-rows:auto;height:auto;overflow-x:hidden;overflow-y:auto}.level-screen.no-bottom-tray{padding-bottom:18px}.main-stage{order:1}.left-rail,.right-rail{grid-template-columns:1fr}.left-rail{order:2}.right-rail{order:3}.top-controls{right:12px;top:14px;grid-template-columns:repeat(3,58px)}.round-back{left:12px;top:14px;width:54px;height:54px}.level-title-row,.stage-stats{display:grid}.circuit-panel{min-height:430px}.gate-tray-list{grid-template-columns:repeat(3,1fr)}.bottom-tray{position:fixed;left:14px;right:14px;bottom:0;z-index:4;margin:0;padding:8px 6px;border-radius:12px 12px 0 0;background:#fffcf6f0;box-shadow:0 -12px 24px #32302b14}.gate-tray{padding:10px 12px}.gate-tray-item{min-height:74px}}
