* { -webkit-touch-callout:none; box-sizing:border-box; -webkit-tap-highlight-color:transparent; user-select:none; -webkit-user-select:none; touch-action:manipulation; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--g); font:15px "HudMono","Courier New", monospace; overflow:hidden; }
#tint { position:fixed; inset:0; pointer-events:none; z-index:20; opacity:0; transition:opacity .3s;
  background:radial-gradient(circle at 50% 50%, rgba(255,30,50,0) 35%, rgba(255,30,50,.85) 100%); }
body[data-err="1"] #tint { opacity:.35; }
body[data-err="2"] #tint { opacity:.85; animation:pulse .7s infinite alternate; }
@keyframes pulse { to { opacity:.5; } }
#app { max-width:480px; height:100%; margin:0 auto; padding:10px; display:flex; flex-direction:column; gap:10px; position:relative; }
#app.s1 { animation:shake1 .4s; } #app.s2 { animation:shake2 .6s; }
@keyframes shake1 { 20%{transform:translate(-4px,2px)} 40%{transform:translate(4px,-2px)} 60%{transform:translate(-3px,-1px)} 80%{transform:translate(3px,1px)} }
@keyframes shake2 { 10%{transform:translate(-9px,4px)} 30%{transform:translate(9px,-5px)} 50%{transform:translate(-8px,-3px)} 70%{transform:translate(8px,4px)} 90%{transform:translate(-4px,2px)} }
#app.blink { animation:blink .5s; }
@keyframes blink { 0%,100%{filter:none} 25%,75%{filter:brightness(3) saturate(0)} 50%{filter:brightness(.2)} }
#top { border:1px solid var(--d); padding:8px 10px; }
#top.alert { border-color:var(--r); animation:alarm .25s infinite alternate; }
#top.alert #stg::after { content:"  ⚠ СБОЙ"; color:var(--r); }
@keyframes alarm { to { background:rgba(255,40,60,.15); } }
.row { display:flex; justify-content:space-between; align-items:baseline; font-size:13px; }
#barwrap { position:relative; height:16px; border:1px solid var(--g); margin:6px 0; }
#bar { height:100%; width:0; background:var(--g); transition:width .25s; }
#bar.bad { background:var(--r); }
#barwrap i { position:absolute; top:-3px; bottom:-3px; width:2px; background:#fff; opacity:.7; }
#pct { font-size:22px; }
#ecg { width:100%; height:56px; display:block; }
#lower { flex:1; position:relative; min-height:0; display:flex; flex-direction:column; gap:10px; }
#cmds { min-height:176px; display:flex; flex-direction:column; gap:6px; }
.cmd { border:1px solid var(--g); padding:6px 8px; }
.cmd .tx { font-size:17px; margin-bottom:5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tb { height:6px; background:var(--d); } .tb > div { height:100%; width:100%; background:var(--g); }
.tb.low > div { background:var(--r); }
#panel { display:grid; grid-template-columns:1fr 1fr; grid-auto-flow:dense; grid-auto-rows:minmax(auto,1fr); gap:8px; align-content:stretch; flex:1; min-height:0; }
.ctl { border:1px solid var(--g); padding:8px; min-height:60px; position:relative; overflow:hidden; background:rgba(82,255,138,.04); display:flex; flex-direction:column; justify-content:space-between; }
.ctl.slot, .ctl.connect, .ctl.calibrate { grid-column:span 2; min-height:88px; }
.ctl.hold, .ctl.hatch, .ctl.lever, .ctl.knob, .ctl.slot, .ctl.connect, .ctl.vector, .ctl.calibrate, .cover, .chip { touch-action:none; }
.trk { position:absolute; right:10px; top:8px; bottom:8px; width:16px; border:1px solid var(--g); }
.hd { position:absolute; left:0; right:0; top:50%; height:12px; margin-top:-6px; background:var(--g); }
.dial { position:absolute; right:10px; top:50%; margin-top:-28px; width:56px; height:56px; border:2px solid var(--g); border-radius:50%; }
.dial i { position:absolute; left:50%; top:2px; width:3px; height:12px; margin-left:-1px; background:var(--g); }
.sel { display:flex; gap:4px; margin-top:6px; }
.sel span { flex:1; text-align:center; border:1px solid var(--g); padding:6px 0; }
.sel span.on { background:rgba(82,255,138,.35); }
.cover { position:absolute; inset:0; background:#0d3a1f; display:flex; flex-direction:column; align-items:center; justify-content:center; transition:transform .2s; z-index:2; }
.arrow-up { width:0; height:0; border-left:10px solid transparent; border-right:10px solid transparent; border-bottom:15px solid var(--g); margin-bottom:5px; animation:up-bounce .8s infinite; }
@keyframes up-bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.scr { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
.sync-track, .cal-track { position:absolute; left:12px; right:12px; bottom:15px; height:18px; border:1px solid var(--g); background:rgba(82,255,138,.06); }
.sync-target { position:absolute; left:47%; width:6%; top:0; bottom:0; background:rgba(82,255,138,.25); border-left:1px solid var(--g); border-right:1px solid var(--g); }
.sync-marker, .cal-marker { position:absolute; top:-5px; bottom:-5px; width:3px; background:#fff; box-shadow:0 0 7px var(--g); left:0; }
.cal-target { position:absolute; top:0; bottom:0; background:rgba(82,255,138,.3); border-left:1px solid var(--g); border-right:1px solid var(--g); }
.connect-cv { position:absolute; inset:0; width:100%; height:100%; touch-action:none; }
.vector-seq { position:absolute; left:8px; right:8px; bottom:10px; display:flex; justify-content:center; gap:10px; font-size:20px; letter-spacing:3px; }
.vector-seq span { border:1px solid var(--d); padding:2px 7px; opacity:.45; }
.vector-seq span.done { opacity:1; background:rgba(82,255,138,.25); border-color:var(--g); }
.ctl.sync, .ctl.calibrate { cursor:pointer; }
.ctl.ok { animation:okf .35s; } .ctl.no { animation:nof .25s; }
@keyframes okf { 0% { box-shadow:inset 0 0 0 60px rgba(82,255,138,.6); } }
@keyframes nof { 25% { transform:translateX(-5px); border-color:var(--r); } 75% { transform:translateX(5px); border-color:var(--r); } }
.tx b { color:#fff; }
.cover.up { transform:translateY(-105%); pointer-events:none; }
.chip { position:absolute; left:12px; bottom:8px; width:44px; height:30px; border:1px solid var(--g); display:flex; align-items:center; justify-content:center; background:#0d3a1f; z-index:2; }
.hole { position:absolute; right:12px; bottom:8px; width:56px; height:30px; border:1px dashed var(--g); display:flex; align-items:center; justify-content:center; }
.dirt { position:absolute; inset:0; pointer-events:none; background:repeating-linear-gradient(45deg,rgba(82,255,138,.22) 0 3px,transparent 3px 8px); }
.ctl .nm { font-size:15px; font-weight:bold; }
.ctl .ty { font-size:10px; opacity:.55; margin-top:2px; }
.ctl .vl { position:absolute; right:8px; top:8px; font-size:18px; }
.ctl input[type=range] { width:100%; margin:8px 0 0; accent-color:var(--g); touch-action:none; }
#event, #msg { position:absolute; inset:0; background:rgba(2,8,5,.94); border:1px solid var(--r); padding:14px; display:flex; flex-direction:column; gap:12px; z-index:3; }
#msg { border-color:var(--g); align-items:center; justify-content:center; text-align:center; }
#msg b { font-size:34px; } #msg small { opacity:.7; }
#event[hidden], #msg[hidden], #end[hidden] { display:none; }
.evh { color:var(--r); font-size:18px; } .evt { font-size:16px; }
#event .tb > div { background:var(--r); }
.evb { flex:1; display:grid; gap:8px; grid-template-columns:1fr 1fr; }
.evb button { font:inherit; font-size:30px; color:var(--g); background:none; border:1px solid var(--r); }
.evb button.done { opacity:.25; }
.evb .big { grid-column:span 2; font-size:26px; }
#end { position:absolute; inset:0; background:rgba(2,8,5,.97); z-index:30; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; text-align:center; padding:20px; }
#end h1 { margin:0; font-size:26px; } #end.lose h1 { color:var(--r); } #end pre { font:inherit; margin:0; line-height:1.6; }
button.go { font:inherit; font-size:18px; color:var(--g); background:none; border:1px solid var(--g); padding:10px 22px; }
#ev-count { font-size: 40px; text-align: center; margin: 20px; font-weight: bold; }
#menu, #calib { position:fixed; inset:0; z-index:50; background:var(--bg); display:flex; flex-direction:column; align-items:center; padding:20px 16px; overflow-y:auto; }
#menu[hidden], #calib[hidden], #tbar[hidden], #tback[hidden] { display:none; }
#menu { justify-content:center; gap:16px; }
#menu h1 { font-size:26px; margin:0 0 18px; letter-spacing:.12em; text-align:center; }
.mbtn { font:inherit; font-size:20px; color:var(--g); background:rgba(82,255,138,.06); border:1px solid var(--g); padding:14px 20px; width:100%; max-width:380px; letter-spacing:.1em; }
.mbtn:active { background:rgba(82,255,138,.25); }
#clist { width:100%; max-width:380px; }
#clist h2 { font-size:14px; margin:18px 0 8px; opacity:.7; letter-spacing:.1em; }
.citem { display:flex; justify-content:space-between; align-items:center; font-size:15px; padding:10px 12px; margin-bottom:6px; text-align:left; letter-spacing:.04em; }
.citem small { opacity:.55; font-size:10px; margin-left:10px; text-align:right; }
#tbar { position:fixed; top:0; left:0; right:0; z-index:45; padding:10px 14px; background:var(--bg); border-bottom:1px solid var(--d); }
#ttitle { font-size:16px; font-weight:bold; } #thint { font-size:11px; opacity:.7; margin:3px 0; } #tstat { font-size:12px; }
#tback { position:fixed; left:0; right:0; bottom:0; z-index:45; padding:24px 14px 14px; background:linear-gradient(rgba(2,8,5,0),var(--bg) 40%); display:flex; justify-content:center; }
body.testing #top { display:none; }
body.testing #app { padding:98px 10px 84px; }
.ctl.slot { min-height:92px; justify-content:flex-start; }
.chip { width:64px; height:44px; font-size:26px; }
.hole { width:80px; height:48px; font-size:26px; color:rgba(82,255,138,.45); }
.hole.hot { background:rgba(82,255,138,.3); border-style:solid; color:var(--g); }
.chip.pulse { animation:chipp .7s infinite alternate; }
@keyframes chipp { to { box-shadow:0 0 10px var(--g), 0 2px 2px rgba(0,0,0,.6); } }
/* этап 1.1: вёрстка */
.ctl.vector .ty { display:none; }
.ctl.vector .vector-seq { top:0 !important; bottom:0 !important; align-items:center; font-size:10px; letter-spacing:1px; text-align:center; }
#connCanvas { display:block; align-self:center; width:min(100%, calc(100dvh - 320px)); aspect-ratio:1/1; touch-action:none; }
