:root{--ink:#293729;--muted:#62705e;--line:#c9d2bf;--paper:#f4f6ef;--surface:#fff;--soft:#e8eddd;--on:#d5ef55;--blue:#9ee4ff}
:root[data-theme=dark]{--ink:#edf2e6;--muted:#afbba4;--line:#46513d;--paper:#161c18;--surface:#20291f;--soft:#303c28;color-scheme:dark}
*{box-sizing:border-box}body{margin:0;font:14px 'DM Sans',system-ui,sans-serif;background:var(--paper);color:var(--ink);-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}button,select{font:inherit;color:inherit}button{cursor:pointer;border:0;background:none;touch-action:manipulation;-webkit-tap-highlight-color:transparent}button:disabled{cursor:default;opacity:.45}[hidden]{display:none!important}
button:focus-visible,a:focus-visible,select:focus-visible,.board-viewport:focus-visible{outline:3px solid #3981e4;outline-offset:2px}
.circuit-shell{padding:0 16px 16px;margin:auto;width:100%}
.circuit-shell header{width:min(100%,760px);min-height:58px;margin:0 auto 5px;display:flex;align-items:center;justify-content:space-between;gap:12px;border:0}
.circuit-brand{display:flex;align-items:center;gap:8px;font:800 23px Manrope,system-ui,sans-serif;letter-spacing:-.7px}
.circuit-brand .brand-mark{display:block;width:30px;height:30px;flex-shrink:0}
#settings-toggle{display:flex;align-items:center;gap:12px;min-height:38px;padding:8px 11px;border:1px solid transparent;border-radius:7px;font-size:12px;color:var(--muted)}
#settings-toggle:hover{background:var(--soft);border-color:var(--line)}
.circuit-shell main{width:min(100%,calc(100dvh - 204px),760px);max-width:none;margin:0 auto}
.circuit-shell section.game{border:0;border-radius:0;background:transparent;box-shadow:none;overflow:visible}
.circuit-shell .game-body{padding:0;display:block}
.play-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:38px;margin-bottom:5px}
#goal{margin:0;font-size:12px;line-height:1.5;font-weight:500;color:var(--muted)}
.circuit-shell .metrics{display:flex;align-items:center;gap:15px;padding:0;flex-shrink:0}
.circuit-shell .metrics>div{display:flex;gap:4px;align-items:baseline;white-space:nowrap}
.circuit-shell .metrics strong{font:650 12px 'DM Sans',system-ui,sans-serif;letter-spacing:0;color:var(--ink)}
.circuit-shell .metrics small{font:inherit;color:var(--muted)}
.circuit-shell .metrics span{font-size:10px;color:var(--muted);letter-spacing:0;font-weight:400}
.board-area{min-width:0;width:100%}
.board-viewport{overflow:auto;overscroll-behavior:contain;max-height:calc(100dvh - 158px);border-radius:8px;scrollbar-width:thin}
.board{--size:5;display:grid;grid-template-columns:repeat(var(--size),minmax(0,1fr));gap:4px;padding:5px;background:#d2dac8;border:1px solid #9eae90;border-radius:8px;isolation:isolate}
.tile{position:relative;aspect-ratio:1;min-width:0;padding:0;border:1px solid #0f1a28;border-radius:5px;background:#293729;color:#acbba4;overflow:hidden;transition:background .13s,border-color .13s;display:block;opacity:1}
.wires{height:100%;width:100%;display:block;transition:transform .15s ease;pointer-events:none}
.wire{fill:none;stroke:currentColor;stroke-width:6;stroke-linecap:round}
.junction{fill:#293729;stroke:currentColor;stroke-width:4}
.tile.powered{background:#e1eda4;border-color:#8d9e45;color:#293729}
.tile.powered .junction{fill:#293729;stroke:#293729;stroke-width:3}
.tile.source{background:#d5ef55;color:#293729;border-color:#718831}
.tile.source .junction{fill:#d5ef55}
.source-node{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:25%;aspect-ratio:1;border-radius:50%;border:3px solid currentColor;background:#d5ef55;pointer-events:none}
.tile.powered.network-1{background:#b8eaff;border-color:#397891;color:#084761}
.tile.network-1.source,.tile.network-1.source .source-node{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:25%;aspect-ratio:1;border-radius:50%;border:3px solid currentColor;background:#d5ef55;pointer-events:none}
.tile.network-1.source .junction{fill:#78d2fa}
.tile:hover:not([aria-disabled=true]){outline:2px solid #3974d4;outline-offset:-3px}
.tile[aria-disabled=true]{cursor:default}
.tile:focus-visible{outline:3px solid #3981e4;outline-offset:-3px;z-index:3}
.fixed-mark{position:absolute;right:3px;top:3px;background:#fff;color:#233952;border:1px solid #7b91a9;border-radius:3px;width:clamp(10px,22%,20px);aspect-ratio:1;display:grid;place-items:center}
.lock-icon{height:13px;width:13px;stroke:currentColor;stroke-width:2;fill:none;display:block}
.fixed-mark .lock-icon{width:80%;height:80%}
.tile.fixed{box-shadow:inset 0 0 0 2px #e6edf5}
.network-tag{position:absolute;left:2px;top:2px;width:clamp(9px,22%,17px);aspect-ratio:1;display:grid;place-items:center;border-radius:2px;font-size:clamp(7px,1.6vw,10px);font-weight:800;background:#d5ef55;color:#293729;border:1px solid #718831}
.network-1 .network-tag{background:#9ee4ff;color:#073f56;border-color:#39809b}
.short-mark,.loose-mark{display:none;position:absolute;right:2px;bottom:2px;background:#a81932;color:#fff;font-size:clamp(9px,2vw,17px);font-weight:800;border-radius:50%;width:clamp(10px,23%,20px);aspect-ratio:1;place-items:center;line-height:1}
.tile.short-circuit{border-color:#d92841;box-shadow:inset 0 0 0 2px #d92841}
.short-circuit .short-mark,.loose .loose-mark{display:grid}
.loose-mark{left:2px;right:auto;background:#fff2d2;color:#704600;border:1px solid #ad6c12;font-size:clamp(9px,1.6vw,13px)}
.variant-wrap{border:2px solid #5661b4;padding:4px}
.edge-mark{position:absolute;z-index:2;color:#cdd7ff;background:#303b63;font:700 clamp(6px,1.4vw,9px) Arial,sans-serif;border-radius:2px;line-height:1.1;min-width:8px;pointer-events:none;text-align:center}
.edge-top{left:2px;top:1px}.edge-bottom{right:2px;bottom:1px}.edge-left{left:1px;bottom:2px}.edge-right{right:1px;top:2px}
.tile.powered .edge-mark{color:#253357;background:#e1e5ff}
.wall{position:absolute;z-index:2;background:repeating-linear-gradient(135deg,#f4c67a 0 3px,#573a27 3px 6px);pointer-events:none}
.wall-top,.wall-bottom{height:4px;left:0;right:0}.wall-top{top:0}.wall-bottom{bottom:0}
.wall-left,.wall-right{width:4px;top:0;bottom:0}.wall-left{left:0}.wall-right{right:0}
.wall-sample{width:17px;height:6px;background:repeating-linear-gradient(135deg,#f4c67a 0 3px,#573a27 3px 6px);border:1px solid #573a27}

#board-tip{font-size:11px;text-align:center;color:var(--muted);margin:8px 0 0;line-height:1.4}
.circuit-shell .tools{display:flex;justify-content:center;gap:10px;margin:12px 0 0}
html .circuit-shell .tools button{background:transparent;border:1px solid transparent;border-radius:7px;min-width:95px;min-height:42px;padding:8px 14px;font-size:12px;font-weight:550;color:var(--muted)}
html .circuit-shell .tools button:hover:enabled{background:var(--soft);border-color:var(--line);color:var(--ink)}
.live-state{text-align:center;font-size:11px;line-height:1.5;color:var(--muted);margin-top:6px}.live-state.warning{color:#ba3549}
#hint-message{font-size:12px;line-height:1.6;color:var(--ink);padding:10px;border:1px solid var(--line);border-radius:7px;background:var(--soft);margin:10px 0 0}
#result{text-align:center;padding:14px 0 0}#result h2{font-size:20px;font-weight:700;margin:0 0 6px}#result p{font-size:12px;color:var(--muted);line-height:1.7;margin:0 0 11px}
.result-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.primary,.secondary{min-height:42px;border-radius:7px;padding:10px;font-size:12px;font-weight:650;background:#18364d;color:#fff;border:1px solid #18364d}.secondary{background:var(--soft);color:var(--ink);border-color:var(--line)}
.play-foot{color:var(--muted);font-size:11px;text-align:center;line-height:1.6;margin:12px 0 0}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
dialog{width:min(440px,calc(100% - 24px));max-height:calc(100dvh - 24px);overflow:auto;border:1px solid var(--line);border-radius:14px;background:var(--surface);padding:22px;color:var(--ink);box-shadow:0 24px 90px #0005}
dialog::backdrop{background:#16263899;backdrop-filter:blur(3px)}
.modal-top{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:20px}.modal-top>strong{font:800 22px Manrope,system-ui,sans-serif}
.round-button{width:34px;height:34px;border:1px solid transparent;border-radius:7px;display:grid;place-items:center;font-size:21px;flex-shrink:0;color:var(--muted)}.round-button:hover{background:var(--soft)}
#settings-title{font:750 20px Manrope,system-ui,sans-serif;margin:0}#puzzle-label{font-size:11px;color:var(--muted);margin:4px 0 0}
.variant-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin-bottom:20px}
.variant-tabs button{min-height:45px;border:1px solid var(--line);background:var(--surface);border-radius:7px;font-size:12px;font-weight:600;display:flex;align-items:center;justify-content:center;gap:6px}
.variant-tabs button>span{font-size:17px;line-height:1}.variant-tabs button[data-variant=split]>span{font-size:10px;font-weight:800}
.variant-tabs button.active{background:var(--ink);color:var(--surface);border-color:var(--ink)}
.settings-row{display:flex;justify-content:space-between;align-items:center;gap:14px;margin-bottom:18px}.size-control{display:flex;align-items:center;gap:9px}.size-control label{font-size:12px;color:var(--muted)}
.size-control select{background:var(--soft);border:1px solid var(--line);border-radius:6px;padding:8px 6px;min-height:36px;font-size:12px;cursor:pointer}
.zoom-controls{display:flex;gap:4px}.zoom-controls button{min-height:36px;min-width:30px;padding:5px 7px;border:1px solid var(--line);background:var(--soft);border-radius:5px;font-size:12px}#fit{min-width:44px;font-variant-numeric:tabular-nums}
.state-key{display:flex;justify-content:center;gap:12px;align-items:center;flex-wrap:wrap;margin:0 0 20px}.key-chip{display:flex;align-items:center;gap:5px;font-size:10px;color:var(--muted)}
.sample{display:inline-block;width:13px;height:13px;border-radius:3px;border:1px solid #26374a;position:relative}.sample.off{background:#293729}.sample.off:after{content:'';position:absolute;inset:3px;border:1px solid #b4c3d6;border-radius:50%}.sample.on{background:#d5ef55;border-color:#886400}.sample.on:after{content:'';position:absolute;inset:3px;border-radius:50%;background:#775000}.sample.blue{background:#9ee4ff;border-color:#306779}.short-key{color:#b3243a;font-size:18px;line-height:10px}
.new-button{width:100%;min-height:42px;padding:9px;border:1px solid var(--line);background:var(--soft);border-radius:7px;font-size:12px;font-weight:650}
.settings-actions{display:flex;justify-content:center;gap:18px;margin:10px 0}.settings-actions button,.settings-actions a{font-size:11px;color:var(--muted);min-height:36px;display:flex;align-items:center}
.settings-note{font-size:11px;color:var(--muted);line-height:1.7;text-align:center;margin:12px 0}.continue-button{width:100%;margin-top:6px}
#modal-content h2{font-size:18px;margin:0 0 15px}#modal-content p,#modal-content li{font-size:13px;line-height:1.7;color:var(--muted)}#modal-content ul{padding-left:20px}#modal-content li{margin-bottom:9px}
.share-text{width:100%;min-height:150px;border:1px solid var(--line);padding:12px;border-radius:5px;font:13px/1.7 'DM Sans',system-ui,sans-serif;background:var(--paper);color:var(--ink)}
#toast{position:fixed;left:50%;bottom:18px;transform:translate(-50%,10px);background:#162b3e;color:#fff;border:1px solid #627f93;border-radius:7px;padding:10px 17px;font-size:13px;opacity:0;pointer-events:none;transition:.15s;z-index:10;max-width:calc(100% - 24px);text-align:center}#toast.visible{transform:translate(-50%,0);opacity:1}
.hint-flash{animation:flashHint .6s ease 2}.board.won{border-color:#507b24;background:#9ebf74}@keyframes flashHint{50%{box-shadow:inset 0 0 0 4px #3981e4}}
@media(max-width:1100px){.embedded .circuit-shell header{padding-left:96px}}
@media(max-width:540px){.circuit-shell{padding:0 10px 14px}.circuit-shell header{min-height:52px;margin-bottom:0;gap:6px}.circuit-brand{font-size:21px}.circuit-brand .brand-mark{display:block;width:30px;height:30px;flex-shrink:0}#settings-toggle{font-size:11px;padding:6px;gap:6px}.play-heading{align-items:center;gap:8px;min-height:44px;margin-bottom:2px}#goal{font-size:11px;max-width:50%}.circuit-shell .metrics{gap:10px}.circuit-shell .metrics span{font-size:9px}.board{gap:2px;padding:3px}.tile{border-radius:3px}.circuit-shell .tools{gap:7px;margin-top:8px}html .circuit-shell .tools button{min-width:82px;padding:8px}.fixed-mark{right:1px;top:1px}.network-tag{left:1px;top:1px}.wall-top,.wall-bottom{height:3px}.wall-left,.wall-right{width:3px}dialog{padding:18px}.settings-row{gap:8px}.size-control{gap:6px}.size-control label{font-size:11px}}
@media(orientation:landscape) and (max-height:550px){
 .circuit-shell{padding-bottom:8px}.circuit-shell header{min-height:42px;margin-bottom:0}.circuit-shell main{width:100%;max-width:900px}
 .circuit-shell .game-body{display:grid;grid-template-columns:minmax(0,calc(100dvh - 76px)) 170px;grid-template-rows:auto auto auto auto;gap:8px 22px;justify-content:center;align-items:start;padding-top:6px}
 .board-area{grid-column:1;grid-row:1/span 5;width:100%;margin:0}.board-viewport{max-height:calc(100dvh - 76px)}
 .play-heading{grid-column:2;grid-row:1;display:block;margin:0;min-height:0}#goal{max-width:none;font-size:12px}.circuit-shell .metrics{margin-top:9px;gap:12px}
 .circuit-shell .tools{grid-column:2;grid-row:2;display:grid;grid-template-columns:repeat(2,1fr);gap:6px;margin:0}html .circuit-shell .tools button{min-width:0;padding:6px 2px;min-height:38px;font-size:11px}
 #hint-message{grid-column:2;grid-row:3;margin:0;padding:6px;font-size:11px}#status{grid-column:2;grid-row:4;margin:0}#result{grid-column:2;grid-row:2/span 4;padding:0}#result h2{font-size:16px}.result-actions{grid-template-columns:1fr;gap:5px}
 #board-tip{font-size:10px;margin-top:4px}.circuit-brand{font-size:21px}dialog{padding:16px}.modal-top{margin-bottom:12px}.variant-tabs{margin-bottom:12px}.variant-tabs button{min-height:36px}.settings-note{margin:6px 0}
}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}
